diff --git a/Include/structure.h b/Include/structure.h index c0d20ce..39d776c 100644 --- a/Include/structure.h +++ b/Include/structure.h @@ -11,6 +11,23 @@ constexpr auto MAX_MODULE_INPUT = 11; constexpr auto MAX_MODULE_OUTPUT = 15; constexpr auto MAX_MODULE_MOTOR = 16; +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 }; + std::string strFlowCtrl{}; +}; + using stModule = struct _stModule { _stModule() diff --git a/commdll/lib/commdllD.lib b/commdll/lib/commdllD.lib index 451e0e9..48fb9ea 100644 Binary files a/commdll/lib/commdllD.lib and b/commdll/lib/commdllD.lib differ diff --git a/dll/commdllD.dll b/dll/commdllD.dll index 03406b3..ce6bdf1 100644 Binary files a/dll/commdllD.dll and b/dll/commdllD.dll differ diff --git a/dll/iodllD.dll b/dll/iodllD.dll index 467a7f4..2d738b1 100644 Binary files a/dll/iodllD.dll and b/dll/iodllD.dll differ diff --git a/dll/mcctrdllD.dll b/dll/mcctrdllD.dll index a6eab0d..16f2fdd 100644 Binary files a/dll/mcctrdllD.dll and b/dll/mcctrdllD.dll differ diff --git a/dll/utilityD.dll b/dll/utilityD.dll index 33802c4..7edc8ee 100644 Binary files a/dll/utilityD.dll and b/dll/utilityD.dll differ diff --git a/iodll/lib/iodllD.lib b/iodll/lib/iodllD.lib index c2b01f0..23ba424 100644 Binary files a/iodll/lib/iodllD.lib and b/iodll/lib/iodllD.lib differ diff --git a/mcctrdll/Include/RunComm.h b/mcctrdll/Include/RunComm.h index ffa4295..fa8f327 100644 --- a/mcctrdll/Include/RunComm.h +++ b/mcctrdll/Include/RunComm.h @@ -6,38 +6,19 @@ #include -#include "RUN.H" +#include "run.h" #include "structure.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 { public: CRunComm(int nID, const std::string& strName, const std::vector& modules, const std::vector& iSequenceModuleNo); virtual ~CRunComm(); - int GetPortNo(bool bMaint = false, int nWhichOne = 0); - std::string GetIpAddress(bool bMaint = false, int nWhichOne = 0); - enum { MAINT_OPEN_COM = 0x1, @@ -49,40 +30,37 @@ public: }; protected: - bool IsMaintenaceCloseCommPort(); - bool IsMaintenanceSendComm(); - bool IsMaintenaceOpenCommPort(); - std::string GetMaintMsg(); - bool IsMaintenanceDisconnectPort(); - bool IsMaintenanceConnectPort(); - bool IsMaintenanceSendPacket(); - double GetStopBits(bool bMaint = false, int nWhichOne = 0); - int GetDataBits(bool bMaint = false, int nWhichOne = 0); - long GetBaudRate(bool bMaint = false, int nWhichOne = 0); - std::string GetParity(bool bMaint = false, int nWhichOne = 0); - std::string GetCommPort(bool bMaint = false, int nWhichOne = 0); - bool GetCommPortSetting(const std::string& csIniFile, const std::string& csSectionName, int nWhichOne = 0); - bool GetNetworkPortSetting(const std::string& csIniFile, const std::string& csSectionName, int nWhichOne = 0); + bool IsMaintenaceCloseCommPort() const; + bool IsMaintenanceSendComm() const; + bool IsMaintenaceOpenCommPort() const; + std::string GetMaintMsg() const; + bool IsMaintenanceDisconnectPort() const; + bool IsMaintenanceConnectPort() const; + bool IsMaintenanceSendPacket() const; + + bool SetCommPortSetting(unsigned int nWhichOne, const stComSetting& _comSetting); + stComSetting GetCommPortSetting(unsigned int nWhichOne, bool bMaint = false); + + bool SetNetworkPortSetting(unsigned int nWhichOne, const stNetAddress& _netAddress); + stNetAddress GetNetworkPortSetting(unsigned int nWhichOne, bool bMaint = false); + // send com data to modules in maintenance mode - virtual void OnMaintenanceSendCom(LPCTSTR lpcComPort, int iBaudRate, int iDataBits, - LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl, LPCTSTR lpcSendMsg); + void OnMaintenanceSendCom(const stComSetting& _comSetting, const std::string& strSendMsg) override; // send open com to modules in maintenance mode - virtual void OnMaintenanceOpenCom(LPCTSTR lpcComPort, int iBaudRate, int iDataBits, - LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl); + void OnMaintenanceOpenCom(const stComSetting& _comSetting) override; // send close com to modules in maintenance mode - virtual void OnMaintenanceCloseCom(LPCTSTR lpcComPort, int iBaudRate, int iDataBits, - LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl); + void OnMaintenanceCloseCom(const stComSetting& _comSetting) override; // 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 - virtual void OnMaintenanceConnectPort(LPCTSTR IpAddress, int iPortNo); + void OnMaintenanceConnectPort(const stNetAddress& _netAddress) override; // 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 void WriteAckToTextFile(const std::string& strAckMsg); @@ -93,11 +71,12 @@ protected: virtual void SendComm(const std::string& strAckMsg = ""); virtual void CloseCommPort(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: // Maintenance use - char m_cComCommand; + char m_cComCommand{ 0 }; std::string m_strMaintSendMsg; // TCP/IP Maintenance variables diff --git a/mcctrdll/Include/run.h b/mcctrdll/Include/run.h index f60a22a..c45d01d 100644 --- a/mcctrdll/Include/run.h +++ b/mcctrdll/Include/run.h @@ -90,7 +90,7 @@ public: // new method to inform UI of OPE status/signal bool PostOPESignal(unsigned int uinSignal); - bool IsMaintenanceOperationCompleted(); + bool IsMaintenanceOperationCompleted() const; void StopMaintenanceOperation(); void StartMaintenanceOperation(); bool PostGeneralMessageToGUI(WPARAM wParam, LPARAM lParam); @@ -252,25 +252,22 @@ public: bool IsPowerUpRestart() const; // send com data to modules in maintenance mode - virtual void OnMaintenanceSendCom(LPCTSTR lpcComPort, int iBaudRate, int iDataBits, - LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl, LPCTSTR lpcSendMsg); + virtual void OnMaintenanceSendCom(const stComSetting& _comSetting, const std::string& strSendMsg); // send open com to modules in maintenance mode - virtual void OnMaintenanceOpenCom(LPCTSTR lpcComPort, int iBaudRate, int iDataBits, - LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl); + virtual void OnMaintenanceOpenCom(const stComSetting& _comSetting); // send close com to modules in maintenance mode - virtual void OnMaintenanceCloseCom(LPCTSTR lpcComPort, int iBaudRate, int iDataBits, - LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl); + virtual void OnMaintenanceCloseCom(const stComSetting& _comSetting); // send packet to modules in maintenance mode - virtual void OnMaintenanceSendPacket(LPCTSTR IpAddress, int iPortNo, LPCTSTR lpcSendMsg); + virtual void OnMaintenanceSendPacket(const stNetAddress& _netAddress, const std::string& strSendMsg); // send connect port to modules in maintenance mode - virtual void OnMaintenanceConnectPort(LPCTSTR IpAddress, int iPortNo); + virtual void OnMaintenanceConnectPort(const stNetAddress& _netAddress); // send connect port to modules in maintenance mode - virtual void OnMaintenanceDisconnectPort(LPCTSTR IpAddress, int iPortNo); + virtual void OnMaintenanceDisconnectPort(const stNetAddress& _netAddress); // get main application window handler void GetHwnd(HWND hwnd); diff --git a/mcctrdll/Include/runctrl.h b/mcctrdll/Include/runctrl.h index af65dc7..cc909da 100644 --- a/mcctrdll/Include/runctrl.h +++ b/mcctrdll/Include/runctrl.h @@ -433,25 +433,22 @@ public: HWND GetMainGuiWnd(); // send com data to all run modules in maintenance mode - void MaintenanceSendCom(LPCTSTR lpcComPort, int iBaudRate, int iDataBits, - LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl, LPCTSTR lpcSendMsg); + void MaintenanceSendCom(const stComSetting& _comSetting, const std::string& strSendMsg); // send open com to all run modules in maintenance mode - void MaintenanceOpenCom(LPCTSTR lpcComPort, int iBaudRate, int iDataBits, - LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl); + void MaintenanceOpenCom(const stComSetting& _comSetting); // send close com to all run modules in maintenance mode - void MaintenanceCloseCom(LPCTSTR lpcComPort, int iBaudRate, int iDataBits, - LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl); + void MaintenanceCloseCom(const stComSetting& _comSetting); // send packet in maintenance mode - void MaintenanceSendPacket(LPCTSTR IpAddress, int iPortNo, LPCTSTR lpcSendMsg); + void MaintenanceSendPacket(const stNetAddress& _netAddress, const std::string& strSendMsg); // connect port in maintenance mode - void MaintenanceConnectPort(LPCTSTR IpAddress, int iPortNo); + void MaintenanceConnectPort(const stNetAddress& _netAddress); // connect port in maintenance mode - void MaintenanceDisconnectPort(LPCTSTR IpAddress, int iPortNo); + void MaintenanceDisconnectPort(const stNetAddress& _netAddress); // setup SeqRun Module Mapping int GetSequenceModuleNo(int nModuleIndex); @@ -515,25 +512,22 @@ public: void CheckResetRunPuComplete(); // send com data to all run modules in maintenance mode - void OnMaintenanceSendCom(LPCTSTR lpcComPort, int iBaudRate, int iDataBits, LPCTSTR lpcParity, float fStopBits, - LPCTSTR lpcFlowCtrl, LPCTSTR lpcSendMsg); + void OnMaintenanceSendCom(const stComSetting& _comSetting, const std::string& strSendMsg); // send open com to all run modules in maintenance mode - void OnMaintenanceOpenCom(LPCTSTR lpcComPort, int iBaudRate, int iDataBits, - LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl); + void OnMaintenanceOpenCom(const stComSetting& _comSetting); // send close com to all run modules in maintenance mode - void OnMaintenanceCloseCom(LPCTSTR lpcComPort, int iBaudRate, int iDataBits, - LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl); + void OnMaintenanceCloseCom(const stComSetting& _comSetting); // send packet in maintenance mode - void OnMaintenanceSendPacket(LPCTSTR IpAddress, int iPortNo, LPCTSTR lpcSendMsg); + void OnMaintenanceSendPacket(const stNetAddress& _netAddress, const std::string& strSendMsg); // connect port in maintenance mode - void OnMaintenanceConnectPort(LPCTSTR IpAddress, int iPortNo); + void OnMaintenanceConnectPort(const stNetAddress& _netAddress); // disconnect port in maintenance mode - void OnMaintenanceDisconnectPort(LPCTSTR IpAddress, int iPortNo); + void OnMaintenanceDisconnectPort(const stNetAddress& _netAddress); void SetCustomizedTowerLight(int customLightId); void ClearCustomizedTowerLight(); @@ -750,7 +744,7 @@ private: double m_dJamStartTime; // jam Start time double m_dJamEndTime; // jam end time - enum + enum class eComCmd { NO_CMD = -1, SEND_COM, @@ -761,17 +755,12 @@ private: DISCONNECT_PORT, }; - int m_iComCmd{ NO_CMD }; - char m_lpcComPort[10]; - int m_iBaudRate; - int m_iDataBits; - char m_lpcParity[10]; - float m_fStopBits; - char m_lpcFlowCtrl[10]; - char m_lpcSendMsg[100]; - - char m_IpAddress[100]; - int m_iPortNo; + eComCmd m_eComCmd{ eComCmd::NO_CMD }; + + stComSetting m_comSetting; + stNetAddress m_netAddress; + + std::string m_strSendMsg; CEvt m_evtIpControllerStartUpdate{ "INPUT CONTROLLER START UPDATE" }; CEvt m_evtOpControllerStartUpdate{ "OUTPUT CONTROLLER START UPDATE" }; diff --git a/mcctrdll/lib/mcctrdllD.lib b/mcctrdll/lib/mcctrdllD.lib index a1b0619..992017e 100644 Binary files a/mcctrdll/lib/mcctrdllD.lib and b/mcctrdll/lib/mcctrdllD.lib differ diff --git a/utility/lib/utilityD.lib b/utility/lib/utilityD.lib index de87413..0d5620e 100644 Binary files a/utility/lib/utilityD.lib and b/utility/lib/utilityD.lib differ