// pch.h: 这是预编译标头文件。 // 下方列出的文件仅编译一次,提高了将来生成的生成性能。 // 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 // 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 // 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 #ifndef PCH_H #define PCH_H enum HDTcpStatus { Success = 1, Fail = 0, Error = -1 }; enum HDTcpType { ModbusTCP = 1, OMRON_FinsTCP = 2, Siemens_Snap7 = 3, MC_Binary = 4, MC_ASCII = 5, MC_A1E = 6, PanasonicCom_MewToCol = 7 }; enum StopBits { Zero = 0, One = 1, Two = 2, OnePointFive = 3 }; enum Parity { None = 0, Even = 1, Odd = 2, Mark = 3, Space = 4 }; // 添加要在此处预编译的标头 //1.功能放错处理(short类型判端,字符串判断为空等) // 2.断线重连 // 3.错误类别返回枚举 //Hsl /HDTcp #define CLASS_DECLSPEC __declspec(dllexport) class CLASS_DECLSPEC HDTcpBase { public: HDTcpBase() {} virtual ~HDTcpBase() {} public: virtual HDTcpStatus Connect(const char* Ip, int Port) = 0;//三菱MC[Binary],三菱MC[ASCII],三菱A-1E[Binary] virtual HDTcpStatus Connect(const char* Ip, int Port, unsigned char Station) = 0;//ModbusTCP virtual HDTcpStatus Connect(const char* Ip, int Port, unsigned char sA1, unsigned char dA1, unsigned char dA2) = 0;//欧姆龙FinsTCP virtual HDTcpStatus Connect(const char* Ip, int Rack, int Slot, int SiemensPLCS) = 0;//西门子S7[S1200,S300,S400,S1500,S200smart,S200] S1200=1,S300 = 2,以下类推 virtual HDTcpStatus Connect(unsigned char Station, const char* PortName,int BaudRate,int DataBits,int StopBits,int Parity) = 0;//串口通讯[包含松下MewToCol协议] virtual HDTcpStatus Disconnect() = 0; public: virtual HDTcpStatus read_Bool(const char* Address, unsigned short Length, bool* Value) = 0; virtual HDTcpStatus read_Short(const char* Address, unsigned short Length, short* Value) = 0; virtual HDTcpStatus read_Byte(const char* Address, unsigned short Length, unsigned char* Value) = 0; virtual HDTcpStatus read_Int(const char* Address, unsigned short Length, int* Value) = 0; virtual HDTcpStatus read_Long(const char* Address, unsigned short Length, long long* Value) = 0; virtual HDTcpStatus read_Float(const char* Address, unsigned short Length, float* Value) = 0; virtual HDTcpStatus read_Ushort(const char* Address, unsigned short Length, unsigned short* Value) = 0; virtual HDTcpStatus read_Uint(const char* Address, unsigned short Length, unsigned int* Value) = 0; virtual HDTcpStatus read_Ulong(const char* Address, unsigned short Length, unsigned long long* Value) = 0; virtual HDTcpStatus read_Double(const char* Address, unsigned short Length, double* Value) = 0; virtual HDTcpStatus read_String(const char* Address, unsigned short Length, char* Value) = 0; public: virtual HDTcpStatus write_Bool(const char* Address, unsigned short Length, bool* value) = 0; virtual HDTcpStatus write_Short(const char* Address, unsigned short Length, short* value) = 0; virtual HDTcpStatus write_Byte(const char* Address, unsigned short Length, unsigned char* value) = 0; virtual HDTcpStatus write_Int(const char* Address, unsigned short Length, int* value) = 0; virtual HDTcpStatus write_Long(const char* Address, unsigned short Length, long long* value) = 0; virtual HDTcpStatus write_Float(const char* Address, unsigned short Length, float* value) = 0; virtual HDTcpStatus write_Ushort(const char* Address, unsigned short Length, unsigned short* value) = 0; virtual HDTcpStatus write_UInt(const char* Address, unsigned short Length, unsigned int* value) = 0; virtual HDTcpStatus write_ULong(const char* Address, unsigned short Length, unsigned long long* value) = 0; virtual HDTcpStatus write_Double(const char* Address, unsigned short Length, double* value) = 0; virtual HDTcpStatus write_String(const char* Address, const char* value) = 0; }; extern "C" { CLASS_DECLSPEC bool isValidIp(const char* ip); CLASS_DECLSPEC HDTcpBase* CreatePtr(HDTcpType type); CLASS_DECLSPEC void DeletePtr(HDTcpBase* _bp); } #endif //PCH_H