Device.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef __DEVICE_HEADER__
  2. #define __DEVICE_HEADER__
  3. #include "SynSerial.h"
  4. #pragma once
  5. class CDevice
  6. {
  7. CSynSerial m_obj;
  8. public:
  9. CDevice();
  10. ~CDevice();
  11. bool Open();
  12. void Close();
  13. bool IsOpen();
  14. std::string SendCommond(std::string cmd);
  15. public:
  16. int m_iID; // -- 设备的ID
  17. int m_iPort; // -- 设备串口号
  18. std::string m_strDeviceName; // -- 设备名称
  19. int m_iDeviceType; // -- 设备类型
  20. int m_iBaudrate; // -- 波特率
  21. int m_iDatabit; // -- 数据位
  22. int m_iStopbit; // -- 停止位
  23. int m_iParitybit; // -- 奇偶校验位
  24. int m_iRsmode; // -- 串口通信方式,0 - RS232;1 - RS422; 2 - RS485
  25. //////////////////////////////////////////////////////////////////////////
  26. std::string m_strIp; // -- ip地址号
  27. int m_iIpport; // -- ip端口号
  28. int m_iCommmode; // -- 通信的方式,有 0 - 串口方式;1 - tcp/ip...
  29. int m_iDevideaddr; // -- 设备地址
  30. int m_iTimeout; // -- 通讯超时
  31. int m_iIsuse; // -- 是否启用设备1:启用,0:禁用
  32. std::string m_strProtocoldllname; // -- 协议DLL名称
  33. int m_bySpecialdevice; // -- Modbus Rtu;Modbus Ascii;Modbus Tcp;Snmp;RS232;
  34. };
  35. extern std::map<int, CDevice*> g_dmap;
  36. #endif