|
|
|
@ -6,38 +6,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
#include "RUN.H"
|
|
|
|
#include "run.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "structure.h"
|
|
|
|
#include "structure.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "DllDefines.h"
|
|
|
|
#include "DllDefines.h"
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
using stNetAddress = struct _stNetAddress
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::string strIpAddress{ "127.0.0.1" };
|
|
|
|
|
|
|
|
int nPort{ 400 };
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
using stComSetting = struct _stComSetting
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::string strCommPort{ "COM1" };
|
|
|
|
|
|
|
|
long lBaudRate{ 9600 };
|
|
|
|
|
|
|
|
std::string strParity{ "None" };
|
|
|
|
|
|
|
|
int nDataBits{ 8 };
|
|
|
|
|
|
|
|
double dStopBits{ 1.0 };
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MCCTRDLLCLASS CRunComm : public CRun
|
|
|
|
class MCCTRDLLCLASS CRunComm : public CRun
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
CRunComm(int nID, const std::string& strName, const std::vector<stModule>& modules, const std::vector<int>& iSequenceModuleNo);
|
|
|
|
CRunComm(int nID, const std::string& strName, const std::vector<stModule>& modules, const std::vector<int>& iSequenceModuleNo);
|
|
|
|
virtual ~CRunComm();
|
|
|
|
virtual ~CRunComm();
|
|
|
|
|
|
|
|
|
|
|
|
int GetPortNo(bool bMaint = false, int nWhichOne = 0);
|
|
|
|
|
|
|
|
std::string GetIpAddress(bool bMaint = false, int nWhichOne = 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MAINT_OPEN_COM = 0x1,
|
|
|
|
MAINT_OPEN_COM = 0x1,
|
|
|
|
@ -49,40 +30,37 @@ public:
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
bool IsMaintenaceCloseCommPort();
|
|
|
|
bool IsMaintenaceCloseCommPort() const;
|
|
|
|
bool IsMaintenanceSendComm();
|
|
|
|
bool IsMaintenanceSendComm() const;
|
|
|
|
bool IsMaintenaceOpenCommPort();
|
|
|
|
bool IsMaintenaceOpenCommPort() const;
|
|
|
|
std::string GetMaintMsg();
|
|
|
|
std::string GetMaintMsg() const;
|
|
|
|
bool IsMaintenanceDisconnectPort();
|
|
|
|
bool IsMaintenanceDisconnectPort() const;
|
|
|
|
bool IsMaintenanceConnectPort();
|
|
|
|
bool IsMaintenanceConnectPort() const;
|
|
|
|
bool IsMaintenanceSendPacket();
|
|
|
|
bool IsMaintenanceSendPacket() const;
|
|
|
|
double GetStopBits(bool bMaint = false, int nWhichOne = 0);
|
|
|
|
|
|
|
|
int GetDataBits(bool bMaint = false, int nWhichOne = 0);
|
|
|
|
bool SetCommPortSetting(unsigned int nWhichOne, const stComSetting& _comSetting);
|
|
|
|
long GetBaudRate(bool bMaint = false, int nWhichOne = 0);
|
|
|
|
stComSetting GetCommPortSetting(unsigned int nWhichOne, bool bMaint = false);
|
|
|
|
std::string GetParity(bool bMaint = false, int nWhichOne = 0);
|
|
|
|
|
|
|
|
std::string GetCommPort(bool bMaint = false, int nWhichOne = 0);
|
|
|
|
bool SetNetworkPortSetting(unsigned int nWhichOne, const stNetAddress& _netAddress);
|
|
|
|
bool GetCommPortSetting(const std::string& csIniFile, const std::string& csSectionName, int nWhichOne = 0);
|
|
|
|
stNetAddress GetNetworkPortSetting(unsigned int nWhichOne, bool bMaint = false);
|
|
|
|
bool GetNetworkPortSetting(const std::string& csIniFile, const std::string& csSectionName, int nWhichOne = 0);
|
|
|
|
|
|
|
|
// send com data to modules in maintenance mode
|
|
|
|
// send com data to modules in maintenance mode
|
|
|
|
virtual void OnMaintenanceSendCom(LPCTSTR lpcComPort, int iBaudRate, int iDataBits,
|
|
|
|
void OnMaintenanceSendCom(const stComSetting& _comSetting, const std::string& strSendMsg) override;
|
|
|
|
LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl, LPCTSTR lpcSendMsg);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// send open com to modules in maintenance mode
|
|
|
|
// send open com to modules in maintenance mode
|
|
|
|
virtual void OnMaintenanceOpenCom(LPCTSTR lpcComPort, int iBaudRate, int iDataBits,
|
|
|
|
void OnMaintenanceOpenCom(const stComSetting& _comSetting) override;
|
|
|
|
LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// send close com to modules in maintenance mode
|
|
|
|
// send close com to modules in maintenance mode
|
|
|
|
virtual void OnMaintenanceCloseCom(LPCTSTR lpcComPort, int iBaudRate, int iDataBits,
|
|
|
|
void OnMaintenanceCloseCom(const stComSetting& _comSetting) override;
|
|
|
|
LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// send packet to modules in maintenance mode
|
|
|
|
// send packet to modules in maintenance mode
|
|
|
|
virtual void OnMaintenanceSendPacket(LPCTSTR IpAddress, int iPortNo, LPCTSTR lpcSendMsg);
|
|
|
|
void OnMaintenanceSendPacket(const stNetAddress& _netAddress, const std::string& strSendMsg) override;
|
|
|
|
|
|
|
|
|
|
|
|
// send connect port to modules in maintenance mode
|
|
|
|
// send connect port to modules in maintenance mode
|
|
|
|
virtual void OnMaintenanceConnectPort(LPCTSTR IpAddress, int iPortNo);
|
|
|
|
void OnMaintenanceConnectPort(const stNetAddress& _netAddress) override;
|
|
|
|
|
|
|
|
|
|
|
|
// send connect port to modules in maintenance mode
|
|
|
|
// send connect port to modules in maintenance mode
|
|
|
|
virtual void OnMaintenanceDisconnectPort(LPCTSTR IpAddress, int iPortNo);
|
|
|
|
void OnMaintenanceDisconnectPort(const stNetAddress& _netAddress) override;
|
|
|
|
|
|
|
|
|
|
|
|
// write acknowledge message to text file
|
|
|
|
// write acknowledge message to text file
|
|
|
|
void WriteAckToTextFile(const std::string& strAckMsg);
|
|
|
|
void WriteAckToTextFile(const std::string& strAckMsg);
|
|
|
|
@ -93,11 +71,12 @@ protected:
|
|
|
|
virtual void SendComm(const std::string& strAckMsg = "");
|
|
|
|
virtual void SendComm(const std::string& strAckMsg = "");
|
|
|
|
virtual void CloseCommPort(const std::string& strAckMsg = "");
|
|
|
|
virtual void CloseCommPort(const std::string& strAckMsg = "");
|
|
|
|
virtual void OpenCommPort(const std::string& strAckMsg = "");
|
|
|
|
virtual void OpenCommPort(const std::string& strAckMsg = "");
|
|
|
|
void InitCommSettings(LPCTSTR lpcComPort, long lBaudRate, int iDataBits, LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl);
|
|
|
|
|
|
|
|
|
|
|
|
void SetMaintCommSettings(const stComSetting& _comSetting);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
// Maintenance use
|
|
|
|
// Maintenance use
|
|
|
|
char m_cComCommand;
|
|
|
|
char m_cComCommand{ 0 };
|
|
|
|
std::string m_strMaintSendMsg;
|
|
|
|
std::string m_strMaintSendMsg;
|
|
|
|
|
|
|
|
|
|
|
|
// TCP/IP Maintenance variables
|
|
|
|
// TCP/IP Maintenance variables
|
|
|
|
|