snap7_buf.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef NNXX_TESTS_SNAP7_BUF_H
  2. #define NNXX_TESTS_SNAP7_BUF_H
  3. //Snap7协议的数据结构
  4. class Snap7_buf
  5. {
  6. public:
  7. //通信模式
  8. enum Communication_mode
  9. {
  10. NO_COMMUNICATION = 0, //不通信
  11. ONCE_COMMUNICATION = 1, //一次通信
  12. LOOP_COMMUNICATION = 2, //循环通信
  13. };
  14. public:
  15. Snap7_buf();
  16. Snap7_buf(const Snap7_buf& other);
  17. Snap7_buf& operator =(const Snap7_buf& other);
  18. ~Snap7_buf();
  19. public://API functions
  20. Snap7_buf(int id, int start_index, int size, Communication_mode communication_mode = NO_COMMUNICATION);
  21. Snap7_buf(int id, int start_index, int size, void* p_buf_obverse, void* p_buf_reverse, Communication_mode communication_mode = NO_COMMUNICATION);
  22. public://get or set member variable
  23. int get_id();
  24. int get_start_index();
  25. int get_size();
  26. void* get_buf_obverse();
  27. void* get_buf_reverse();
  28. Communication_mode get_communication_mode();
  29. void set_communication_mode(Communication_mode communication_mode);
  30. protected://member functions
  31. public://member variable
  32. int m_id; //Snap7协议的数据块的编号
  33. int m_start_index; //Snap7协议的数据起始位下标
  34. int m_size; //Snap7协议的数据字节大小
  35. void* mp_buf_obverse; //Snap7协议的正序数据指针, 和数据结构体进行强转, 内存由本类管理
  36. void* mp_buf_reverse; //Snap7协议的倒序数据指针, 用作s7通信, 内存由本类管理
  37. //注:s7的通信的数据必须要倒序之后才能进行通信,
  38. Communication_mode m_communication_mode; //Snap7协议的通信模式
  39. //注:s7协议传输很慢, 防止相同的数据重复发送...
  40. private:
  41. };
  42. #endif //NNXX_TESTS_SNAP7_BUF_H