|
@@ -4,6 +4,10 @@
|
|
|
#ifndef NNXX_TESTS_SNAP7_BUF_H
|
|
|
#define NNXX_TESTS_SNAP7_BUF_H
|
|
|
|
|
|
+#include <string>
|
|
|
+#include <map>
|
|
|
+#include <vector>
|
|
|
+
|
|
|
//Snap7协议的数据结构
|
|
|
class Snap7_buf
|
|
|
{
|
|
@@ -15,6 +19,16 @@ public:
|
|
|
ONCE_COMMUNICATION = 1, //一次通信
|
|
|
LOOP_COMMUNICATION = 2, //循环通信
|
|
|
};
|
|
|
+
|
|
|
+ //变量信息
|
|
|
+ struct Variable_information
|
|
|
+ {
|
|
|
+ std::string m_variable_name; //变量名称
|
|
|
+ char m_variable_type; //变量类型, 使用 typeid(a).name() 获取
|
|
|
+ int m_variable_index; //变量下标, 偏移量
|
|
|
+ int m_variable_size; //变量类型大小
|
|
|
+ int m_variable_count; //变量个数
|
|
|
+ };
|
|
|
public:
|
|
|
Snap7_buf();
|
|
|
Snap7_buf(const Snap7_buf& other);
|
|
@@ -23,6 +37,9 @@ public:
|
|
|
public://API functions
|
|
|
Snap7_buf(int id, int start_index, int size, Communication_mode communication_mode = NO_COMMUNICATION);
|
|
|
Snap7_buf(int id, int start_index, int size, void* p_buf_obverse, void* p_buf_reverse, Communication_mode communication_mode = NO_COMMUNICATION);
|
|
|
+
|
|
|
+ void obverse_to_reverse();
|
|
|
+ void reverse_to_obverse();
|
|
|
public://get or set member variable
|
|
|
int get_id();
|
|
|
int get_start_index();
|
|
@@ -42,6 +59,9 @@ public://member variable
|
|
|
void* mp_buf_reverse; //Snap7协议的倒序数据指针, 用作s7通信, 内存由本类管理
|
|
|
//注:s7的通信的数据必须要倒序之后才能进行通信,
|
|
|
|
|
|
+// std::map<std::string, Variable_information> m_variable_information_map;
|
|
|
+ std::vector<Variable_information> m_variable_information_vector;
|
|
|
+
|
|
|
Communication_mode m_communication_mode; //Snap7协议的通信模式
|
|
|
//注:s7协议传输很慢, 防止相同的数据重复发送...
|
|
|
|