You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
3.9 KiB
C++
112 lines
3.9 KiB
C++
// RunComm.h: interface for the CRunComm class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#pragma once
|
|
|
|
#include <vector>
|
|
|
|
#include "RUN.H"
|
|
|
|
#include "DllDefines.h"
|
|
|
|
//
|
|
typedef struct _stNetAddress
|
|
{
|
|
std::string strIpAddress{ "127.0.0.1" };
|
|
int nPort{ 400 };
|
|
|
|
} stNetAddress;
|
|
|
|
//
|
|
typedef struct _stComSetting
|
|
{
|
|
std::string strCommPort{ "COM1" };
|
|
long lBaudRate{ 9600 };
|
|
std::string strParity{ "None" };
|
|
int nDataBits{ 8 };
|
|
double dStopBits{ 1.0 };
|
|
} stComSetting;
|
|
|
|
class MCCTRDLLCLASS CRunComm : public CRun
|
|
{
|
|
public:
|
|
int GetPortNo(bool bMaint = false, int nWhichOne = 0);
|
|
std::string GetIpAddress(bool bMaint = false, int nWhichOne = 0);
|
|
CRunComm(int nID, std::string strName, std::vector<struct stModule>& modules, std::vector<int>& iSequenceModuleNo);
|
|
virtual ~CRunComm();
|
|
|
|
enum
|
|
{
|
|
MAINT_OPEN_COM = 0x1,
|
|
MAINT_CLOSE_COM = 0x2,
|
|
MAINT_SEND_COM = 0x4,
|
|
MAINT_CONNECT_PORT = 0x8,
|
|
MAINT_DISCONNECT_PORT = 0x10,
|
|
MAINT_SEND_PACKET = 0x20,
|
|
};
|
|
|
|
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(std::string csIniFile, std::string csSectionName, int nWhichOne = 0);
|
|
bool GetNetworkPortSetting(std::string csIniFile, std::string csSectionName, int nWhichOne = 0);
|
|
// 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);
|
|
|
|
// send open com to modules in maintenance mode
|
|
virtual void OnMaintenanceOpenCom(LPCTSTR lpcComPort, int iBaudRate, int iDataBits,
|
|
LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl);
|
|
|
|
// send close com to modules in maintenance mode
|
|
virtual void OnMaintenanceCloseCom(LPCTSTR lpcComPort, int iBaudRate, int iDataBits,
|
|
LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl);
|
|
|
|
// send packet to modules in maintenance mode
|
|
virtual void OnMaintenanceSendPacket(LPCTSTR IpAddress, int iPortNo, LPCTSTR lpcSendMsg);
|
|
|
|
// send connect port to modules in maintenance mode
|
|
virtual void OnMaintenanceConnectPort(LPCTSTR IpAddress, int iPortNo);
|
|
|
|
// send connect port to modules in maintenance mode
|
|
virtual void OnMaintenanceDisconnectPort(LPCTSTR IpAddress, int iPortNo);
|
|
|
|
// write acknowledge message to text file
|
|
void WriteAckToTextFile(std::string strAckMsg);
|
|
|
|
virtual void SendPacket(std::string strAckMsg = "");
|
|
virtual void DisconnectPort(std::string strAckMsg = "");
|
|
virtual void ConnectPort(std::string strAckMsg = "");
|
|
virtual void SendComm(std::string strAckMsg = "");
|
|
virtual void CloseCommPort(std::string strAckMsg = "");
|
|
virtual void OpenCommPort(std::string strAckMsg = "");
|
|
void InitCommSettings(LPCTSTR lpcComPort, long lBaudRate, int iDataBits, LPCTSTR lpcParity, float fStopBits, LPCTSTR lpcFlowCtrl);
|
|
|
|
private:
|
|
// Maintenance use
|
|
char m_cComCommand;
|
|
std::string m_strMaintSendMsg;
|
|
|
|
// TCP/IP Maintenance variables
|
|
stNetAddress m_maintNetAddress;
|
|
// Serial Comm Settings for maintenance use
|
|
|
|
stComSetting m_maintComSetting;
|
|
|
|
// TCP/IP variables for auto run
|
|
std::vector<stNetAddress> m_vecNetAddress;
|
|
// Serial Comm Settings for auto run use
|
|
std::vector<stComSetting> m_vecComSetting;
|
|
};
|