parent
1468207cae
commit
3f6163defb
|
|
@ -200,6 +200,8 @@ typedef char L_STR[LONG_STR_LEN];
|
||||||
#define DATA_TYPE_C64 104
|
#define DATA_TYPE_C64 104
|
||||||
#define DATA_TYPE_C128 105
|
#define DATA_TYPE_C128 105
|
||||||
#define DATA_TYPE_C1 106
|
#define DATA_TYPE_C1 106
|
||||||
|
#define DATA_TYPE_STR 107
|
||||||
|
|
||||||
|
|
||||||
// typedef union
|
// typedef union
|
||||||
// {
|
// {
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,6 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef MY_SET_DATA_WITH_TYPE
|
|
||||||
#define MY_SET_DATA_WITH_TYPE(p, q, type) (*(type *)(p) = *(type *)(q))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@
|
||||||
|
|
||||||
#define TIMER_NUM 3 // 定时器个数
|
#define TIMER_NUM 3 // 定时器个数
|
||||||
// 通用定时器事件
|
// 通用定时器事件
|
||||||
#define EV_TIMER1 (0x01 << 0) // 定时器1
|
#define EV_TIMER1 (0x01 << 0) // 定时器1 10ms
|
||||||
#define EV_TIMER2 (0x01 << 1) // 定时器2
|
#define EV_TIMER2 (0x01 << 1) // 定时器2 100ms
|
||||||
#define EV_TIMER3 (0x01 << 2) // 定时器3
|
#define EV_TIMER3 (0x01 << 2) // 定时器3 1000ms
|
||||||
|
|
||||||
// 通讯线程事件
|
// 通讯线程事件
|
||||||
#define EV_COM_RX_IEC (0x01 << 3) // 收到IEC消息事件
|
#define EV_COM_RX_IEC (0x01 << 3) // 收到IEC消息事件
|
||||||
|
|
@ -253,6 +253,7 @@ typedef struct
|
||||||
{
|
{
|
||||||
stru_self_ptl_cfg_base base;
|
stru_self_ptl_cfg_base base;
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
|
uint8_t dc_type;
|
||||||
uint8_t num;
|
uint8_t num;
|
||||||
std::string unit;
|
std::string unit;
|
||||||
std::string min;
|
std::string min;
|
||||||
|
|
@ -330,6 +331,8 @@ typedef struct
|
||||||
// void *p_default; // 默认值
|
// void *p_default; // 默认值
|
||||||
}stru_signal_param;
|
}stru_signal_param;
|
||||||
|
|
||||||
|
|
||||||
|
typedef void (*out_signal_change_cb)(std::string saddr, uint8_t data_type, void *p_data, void *p_last_data);
|
||||||
typedef void (*signal_change_cb)(std::string saddr, SIGNAL_CTRL_STEP step, uint8_t data_type, uint8_t setting_zone, void *p_data);
|
typedef void (*signal_change_cb)(std::string saddr, SIGNAL_CTRL_STEP step, uint8_t data_type, uint8_t setting_zone, void *p_data);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -337,9 +340,13 @@ typedef void (*signal_change_cb)(std::string saddr, SIGNAL_CTRL_STEP step, uint8
|
||||||
// 数据中心out信号注册接口
|
// 数据中心out信号注册接口
|
||||||
int dc_signal_out(const std::string &saddr, const std::string &desc, uint8_t data_type, void *p_data);
|
int dc_signal_out(const std::string &saddr, const std::string &desc, uint8_t data_type, void *p_data);
|
||||||
|
|
||||||
|
int dc_signal_out_with_callback(const std::string &saddr, const std::string &desc, uint8_t data_type, void *p_data, out_signal_change_cb cb);
|
||||||
|
|
||||||
// 数据中心in信号注册并链接out信号接口
|
// 数据中心in信号注册并链接out信号接口
|
||||||
int dc_signal_in(const std::string &saddr, const std::string &desc, const std::string &link_saddr, uint8_t data_type, void **p_data);
|
int dc_signal_in(const std::string &saddr, const std::string &desc, const std::string &link_saddr, uint8_t data_type, void **p_data);
|
||||||
|
|
||||||
|
int dc_signal_in_with_callback(const std::string &saddr, const std::string &desc, const std::string &link_saddr, uint8_t data_type, void **p_data, out_signal_change_cb cb);
|
||||||
|
|
||||||
int dc_signal_ao(const std::string &saddr, const std::string &desc, uint8_t data_type, const stru_signal_param ¶m, uint8_t ctrl_type, void *p_data, void *p_default_data, signal_change_cb cb);
|
int dc_signal_ao(const std::string &saddr, const std::string &desc, uint8_t data_type, const stru_signal_param ¶m, uint8_t ctrl_type, void *p_data, void *p_default_data, signal_change_cb cb);
|
||||||
|
|
||||||
int dc_signal_ao_link_with_callback(const std::string &saddr, uint8_t data_type, void **p_data, signal_change_cb cb);
|
int dc_signal_ao_link_with_callback(const std::string &saddr, uint8_t data_type, void **p_data, signal_change_cb cb);
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ LOCAL const char *attr_saddr = "saddr";
|
||||||
LOCAL const char *attr_desc = "desc";
|
LOCAL const char *attr_desc = "desc";
|
||||||
LOCAL const char *attr_inf = "inf";
|
LOCAL const char *attr_inf = "inf";
|
||||||
LOCAL const char *attr_type = "type";
|
LOCAL const char *attr_type = "type";
|
||||||
|
LOCAL const char *attr_dc_type = "dc_type";
|
||||||
LOCAL const char *attr_unit = "unit";
|
LOCAL const char *attr_unit = "unit";
|
||||||
LOCAL const char *attr_min = "min";
|
LOCAL const char *attr_min = "min";
|
||||||
LOCAL const char *attr_max = "max";
|
LOCAL const char *attr_max = "max";
|
||||||
|
|
@ -181,6 +182,7 @@ int parse_ao(tinyxml2::XMLElement *root)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const char *type = signal_ele->Attribute(attr_type);
|
const char *type = signal_ele->Attribute(attr_type);
|
||||||
|
const char *dc_type = signal_ele->Attribute(attr_dc_type);
|
||||||
const char *unit = signal_ele->Attribute(attr_unit);
|
const char *unit = signal_ele->Attribute(attr_unit);
|
||||||
const char *min = signal_ele->Attribute(attr_min);
|
const char *min = signal_ele->Attribute(attr_min);
|
||||||
const char *max = signal_ele->Attribute(attr_max);
|
const char *max = signal_ele->Attribute(attr_max);
|
||||||
|
|
@ -192,6 +194,7 @@ int parse_ao(tinyxml2::XMLElement *root)
|
||||||
cfg_ao.base.desc = desc == nullptr ? "" : desc;
|
cfg_ao.base.desc = desc == nullptr ? "" : desc;
|
||||||
cfg_ao.base.inf = inf;
|
cfg_ao.base.inf = inf;
|
||||||
cfg_ao.type = dc_get_data_type_id_by_str(type == nullptr ? "" : type);
|
cfg_ao.type = dc_get_data_type_id_by_str(type == nullptr ? "" : type);
|
||||||
|
cfg_ao.dc_type = dc_get_data_type_id_by_str(dc_type == nullptr ? "" : dc_type);
|
||||||
cfg_ao.unit = unit == nullptr ? "" : unit;
|
cfg_ao.unit = unit == nullptr ? "" : unit;
|
||||||
cfg_ao.min = min == nullptr ? "" : min;
|
cfg_ao.min = min == nullptr ? "" : min;
|
||||||
cfg_ao.max = max == nullptr ? "" : max;
|
cfg_ao.max = max == nullptr ? "" : max;
|
||||||
|
|
@ -271,6 +274,7 @@ int parse_param(tinyxml2::XMLElement *root)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const char *type = signal_ele->Attribute(attr_type);
|
const char *type = signal_ele->Attribute(attr_type);
|
||||||
|
const char *dc_type = signal_ele->Attribute(attr_dc_type);
|
||||||
const char *unit = signal_ele->Attribute(attr_unit);
|
const char *unit = signal_ele->Attribute(attr_unit);
|
||||||
const char *min = signal_ele->Attribute(attr_min);
|
const char *min = signal_ele->Attribute(attr_min);
|
||||||
const char *max = signal_ele->Attribute(attr_max);
|
const char *max = signal_ele->Attribute(attr_max);
|
||||||
|
|
@ -281,6 +285,7 @@ int parse_param(tinyxml2::XMLElement *root)
|
||||||
cfg_param.base.desc = desc != nullptr ? desc : "";
|
cfg_param.base.desc = desc != nullptr ? desc : "";
|
||||||
cfg_param.base.inf = inf;
|
cfg_param.base.inf = inf;
|
||||||
cfg_param.type = dc_get_data_type_id_by_str(type != nullptr ? type : "");
|
cfg_param.type = dc_get_data_type_id_by_str(type != nullptr ? type : "");
|
||||||
|
cfg_param.dc_type = dc_get_data_type_id_by_str(dc_type != nullptr ? dc_type : "");
|
||||||
cfg_param.num = num != nullptr ? atoi(num) : 0;
|
cfg_param.num = num != nullptr ? atoi(num) : 0;
|
||||||
cfg_param.unit = unit != nullptr ? unit : "";
|
cfg_param.unit = unit != nullptr ? unit : "";
|
||||||
cfg_param.min = min != nullptr ? min : "";
|
cfg_param.min = min != nullptr ? min : "";
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,14 @@ typedef struct stru_signal
|
||||||
uint8_t data_type; // 数据类型
|
uint8_t data_type; // 数据类型
|
||||||
// void *p_data; // 数据指针
|
// void *p_data; // 数据指针
|
||||||
std::vector<void *> vec_p_data; // 数据指针列表(支持多条目)
|
std::vector<void *> vec_p_data; // 数据指针列表(支持多条目)
|
||||||
|
void *p_last_data; // 上一次数据指针
|
||||||
std::vector<void *> vec_p_default_data; // 默认值指针列表(支持多条目)
|
std::vector<void *> vec_p_default_data; // 默认值指针列表(支持多条目)
|
||||||
std::vector<std::string> link_saddrs;
|
std::vector<std::string> link_saddrs;
|
||||||
// stru_signal_ctrl ctrl; // 信号扩展信息
|
// stru_signal_ctrl ctrl; // 信号扩展信息
|
||||||
uint8_t ctrl_type; // 信号控制类型
|
uint8_t ctrl_type; // 信号控制类型
|
||||||
stru_signal_param param; // 信号参数信息
|
stru_signal_param param; // 信号参数信息
|
||||||
std::vector<signal_change_cb> change_cb_list; // 信号变化回调函数列表
|
std::vector<out_signal_change_cb> out_change_cb_list; // 输出类型信号变化回调函数列表
|
||||||
|
std::vector<signal_change_cb> change_cb_list; // 参数类型信号变化回调函数列表
|
||||||
}stru_signal;
|
}stru_signal;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -50,5 +52,5 @@ void dc_set_param_cfg_change(bool change);
|
||||||
|
|
||||||
void dc_param_cfg_check();
|
void dc_param_cfg_check();
|
||||||
|
|
||||||
|
void dc_signal_out_change_check();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ void *app_datacenter(void *arg)
|
||||||
|
|
||||||
if(event & EV_TIMER2)
|
if(event & EV_TIMER2)
|
||||||
{
|
{
|
||||||
;
|
dc_signal_out_change_check();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event & EV_TIMER3)
|
if(event & EV_TIMER3)
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,8 @@ LOCAL std::mutex g_param_cfg_change_mutex;
|
||||||
LOCAL std::vector<dc_param_group_info> g_param_groups;
|
LOCAL std::vector<dc_param_group_info> g_param_groups;
|
||||||
LOCAL std::mutex g_param_groups_mutex;
|
LOCAL std::mutex g_param_groups_mutex;
|
||||||
|
|
||||||
|
|
||||||
|
LOCAL int dc_data_compare(uint8_t data_type, void *p_data, void *p_data2);
|
||||||
LOCAL int dc_set_signal_val(void *p_data, uint8_t data_type, void *set_data);
|
LOCAL int dc_set_signal_val(void *p_data, uint8_t data_type, void *set_data);
|
||||||
LOCAL stru_signal* dc_find_signal(const XXH128_hash_t &hash, stru_signal_map &dc_signal_map);
|
LOCAL stru_signal* dc_find_signal(const XXH128_hash_t &hash, stru_signal_map &dc_signal_map);
|
||||||
LOCAL int dc_signal_add_to_map(stru_signal &signal, stru_signal_map &dc_signal_map);
|
LOCAL int dc_signal_add_to_map(stru_signal &signal, stru_signal_map &dc_signal_map);
|
||||||
|
|
@ -90,6 +92,8 @@ void dc_set_param_cfg_change(bool change)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int dc_get_out_signal_info(const std::string &saddr, std::string &desc, uint8_t &data_type, std::vector<void *> &vec_p_data)
|
int dc_get_out_signal_info(const std::string &saddr, std::string &desc, uint8_t &data_type, std::vector<void *> &vec_p_data)
|
||||||
{
|
{
|
||||||
stru_signal *p_signal = dc_find_out_signal(saddr);
|
stru_signal *p_signal = dc_find_out_signal(saddr);
|
||||||
|
|
@ -240,6 +244,26 @@ int dc_get_yk_signal_info(const std::string &saddr, std::string &desc, uint8_t &
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void dc_signal_out_change_check()
|
||||||
|
{
|
||||||
|
for(auto it = g_datacenter.signal_out.map_signals.begin(); it != g_datacenter.signal_out.map_signals.end(); it++)
|
||||||
|
{
|
||||||
|
stru_signal *p_signal = &it->second;
|
||||||
|
if(!p_signal->out_change_cb_list.empty() && nullptr != p_signal->vec_p_data[0] && nullptr != p_signal->p_last_data)
|
||||||
|
{
|
||||||
|
if(0 != dc_data_compare(p_signal->data_type, p_signal->vec_p_data[0], p_signal->p_last_data))
|
||||||
|
{
|
||||||
|
for(auto cb : p_signal->out_change_cb_list)
|
||||||
|
{
|
||||||
|
cb(p_signal->saddr, p_signal->data_type, p_signal->vec_p_data[0], p_signal->p_last_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
dc_set_signal_val(p_signal->p_last_data, p_signal->data_type, p_signal->vec_p_data[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LOCAL void dc_signal_ctrl_data_create(stru_signal_ctrl &ctrl)
|
LOCAL void dc_signal_ctrl_data_create(stru_signal_ctrl &ctrl)
|
||||||
{
|
{
|
||||||
switch(ctrl.data_type)
|
switch(ctrl.data_type)
|
||||||
|
|
@ -347,9 +371,13 @@ LOCAL int dc_data_compare(uint8_t data_type, void *p_data, void *p_data2)
|
||||||
case DATA_TYPE_UL64:
|
case DATA_TYPE_UL64:
|
||||||
return (*(uint64_t *)p_data == *(uint64_t *)p_data2) ? 0 : -1;
|
return (*(uint64_t *)p_data == *(uint64_t *)p_data2) ? 0 : -1;
|
||||||
case DATA_TYPE_F32:
|
case DATA_TYPE_F32:
|
||||||
return (*(float *)p_data == *(float *)p_data2) ? 0 : -1;
|
float f1 = *(float *)p_data;
|
||||||
|
float f2 = *(float *)p_data2;
|
||||||
|
return f1 == f2 ? 0 : -1;
|
||||||
case DATA_TYPE_D64:
|
case DATA_TYPE_D64:
|
||||||
return (*(double *)p_data == *(double *)p_data2) ? 0 : -1;
|
double d1 = *(double *)p_data;
|
||||||
|
double d2 = *(double *)p_data2;
|
||||||
|
return d1 == d2 ? 0 : -1;
|
||||||
case DATA_TYPE_C1:
|
case DATA_TYPE_C1:
|
||||||
return (*(char *)p_data == *(char *)p_data2) ? 0 : -1;
|
return (*(char *)p_data == *(char *)p_data2) ? 0 : -1;
|
||||||
case DATA_TYPE_IP:
|
case DATA_TYPE_IP:
|
||||||
|
|
@ -938,6 +966,13 @@ int dc_signal_out(const std::string &saddr, const std::string &desc, uint8_t dat
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stru_signal *p_signal = dc_find_out_signal(saddr);
|
||||||
|
if(nullptr != p_signal)
|
||||||
|
{
|
||||||
|
MY_LOG_E("saddr %s already registered", saddr.c_str());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
stru_signal signal;
|
stru_signal signal;
|
||||||
|
|
||||||
signal.hash = XXH3_128bits(saddr.c_str(), saddr.length());
|
signal.hash = XXH3_128bits(saddr.c_str(), saddr.length());
|
||||||
|
|
@ -945,12 +980,53 @@ int dc_signal_out(const std::string &saddr, const std::string &desc, uint8_t dat
|
||||||
signal.desc.assign(desc);
|
signal.desc.assign(desc);
|
||||||
signal.data_type = data_type;
|
signal.data_type = data_type;
|
||||||
signal.vec_p_data.push_back(p_data);
|
signal.vec_p_data.push_back(p_data);
|
||||||
|
void *p_last_data = dc_create_data_ptr_by_type(data_type);
|
||||||
|
if(p_last_data == nullptr)
|
||||||
|
{
|
||||||
|
MY_LOG_E("create p_last_data failed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
signal.p_last_data = p_last_data;
|
||||||
|
|
||||||
// MY_LOG_I("saddr %s, p_data %p", saddr.c_str(), p_data);
|
// MY_LOG_I("saddr %s, p_data %p", saddr.c_str(), p_data);
|
||||||
return dc_signal_add_to_map(signal, g_datacenter.signal_out);
|
return dc_signal_add_to_map(signal, g_datacenter.signal_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dc_signal_out_with_callback(const std::string &saddr, const std::string &desc, uint8_t data_type, void *p_data, out_signal_change_cb cb)
|
||||||
|
{
|
||||||
|
if(nullptr == p_data)
|
||||||
|
{
|
||||||
|
MY_LOG_E("p_data is nullptr");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
stru_signal *p_signal = dc_find_out_signal(saddr);
|
||||||
|
if(nullptr != p_signal)
|
||||||
|
{
|
||||||
|
MY_LOG_E("saddr %s already registered", saddr.c_str());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
stru_signal signal;
|
||||||
|
signal.hash = XXH3_128bits(saddr.c_str(), saddr.length());
|
||||||
|
signal.saddr.assign(saddr);
|
||||||
|
signal.desc.assign(desc);
|
||||||
|
signal.data_type = data_type;
|
||||||
|
signal.vec_p_data.push_back(p_data);
|
||||||
|
void *p_last_data = dc_create_data_ptr_by_type(data_type);
|
||||||
|
if(p_last_data == nullptr)
|
||||||
|
{
|
||||||
|
MY_LOG_E("create p_last_data failed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
signal.p_last_data = p_last_data;
|
||||||
|
if(nullptr != cb)
|
||||||
|
{
|
||||||
|
signal.out_change_cb_list.push_back(cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dc_signal_add_to_map(signal, g_datacenter.signal_out);
|
||||||
|
}
|
||||||
|
|
||||||
int dc_signal_in(const std::string &saddr, const std::string &desc, const std::string &link_saddr, uint8_t data_type, void **p_data)
|
int dc_signal_in(const std::string &saddr, const std::string &desc, const std::string &link_saddr, uint8_t data_type, void **p_data)
|
||||||
{
|
{
|
||||||
|
|
@ -960,6 +1036,13 @@ int dc_signal_in(const std::string &saddr, const std::string &desc, const std::s
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stru_signal *p_signal = dc_find_in_signal(saddr);
|
||||||
|
if(nullptr != p_signal)
|
||||||
|
{
|
||||||
|
MY_LOG_E("saddr %s already registered", saddr.c_str());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
stru_signal signal;
|
stru_signal signal;
|
||||||
|
|
||||||
signal.hash = XXH3_128bits(saddr.c_str(), saddr.length());
|
signal.hash = XXH3_128bits(saddr.c_str(), saddr.length());
|
||||||
|
|
@ -1005,6 +1088,55 @@ int dc_signal_in(const std::string &saddr, const std::string &desc, const std::s
|
||||||
return dc_signal_add_to_map(signal, g_datacenter.signal_in);
|
return dc_signal_add_to_map(signal, g_datacenter.signal_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dc_signal_in_with_callback(const std::string &saddr, const std::string &desc, const std::string &link_saddr, uint8_t data_type, void **p_data, out_signal_change_cb cb)
|
||||||
|
{
|
||||||
|
if(p_data == nullptr)
|
||||||
|
{
|
||||||
|
MY_LOG_E("p_data is nullptr");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
stru_signal *p_signal = dc_find_in_signal(saddr);
|
||||||
|
if(nullptr != p_signal)
|
||||||
|
{
|
||||||
|
MY_LOG_E("saddr %s already registered", saddr.c_str());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
stru_signal signal;
|
||||||
|
signal.hash = XXH3_128bits(saddr.c_str(), saddr.length());
|
||||||
|
signal.saddr.assign(saddr);
|
||||||
|
signal.desc.assign(desc);
|
||||||
|
signal.data_type = data_type;
|
||||||
|
|
||||||
|
if(link_saddr.empty())
|
||||||
|
{
|
||||||
|
MY_LOG_E("link_saddr is empty");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
stru_signal *p_signal_out = dc_find_out_signal(link_saddr);
|
||||||
|
if(p_signal_out == nullptr)
|
||||||
|
{
|
||||||
|
MY_LOG_E("link_saddr %s not found", link_saddr.c_str());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*p_data) = p_signal_out->vec_p_data[0];
|
||||||
|
signal.vec_p_data.push_back((*p_data));
|
||||||
|
|
||||||
|
if(nullptr != cb)
|
||||||
|
{
|
||||||
|
p_signal_out->out_change_cb_list.push_back(cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
p_signal_out->link_saddrs.push_back(saddr);
|
||||||
|
|
||||||
|
signal.link_saddrs.push_back(link_saddr);
|
||||||
|
|
||||||
|
return dc_signal_add_to_map(signal, g_datacenter.signal_in);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int dc_signal_ao(const std::string &saddr, const std::string &desc, uint8_t data_type, const stru_signal_param ¶m, uint8_t ctrl_type, void *p_data, void *p_default_data, signal_change_cb cb)
|
int dc_signal_ao(const std::string &saddr, const std::string &desc, uint8_t data_type, const stru_signal_param ¶m, uint8_t ctrl_type, void *p_data, void *p_default_data, signal_change_cb cb)
|
||||||
{
|
{
|
||||||
|
|
@ -1557,7 +1689,8 @@ LOCAL std::map<uint8_t, uint8_t> g_data_type_len = {
|
||||||
{DATA_TYPE_C32, 32},
|
{DATA_TYPE_C32, 32},
|
||||||
{DATA_TYPE_C64, 64},
|
{DATA_TYPE_C64, 64},
|
||||||
{DATA_TYPE_C128, 128},
|
{DATA_TYPE_C128, 128},
|
||||||
{DATA_TYPE_C1, 1}
|
{DATA_TYPE_C1, 1},
|
||||||
|
{DATA_TYPE_STR, 128}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string dc_get_data_type_str_by_id(uint8_t data_type)
|
std::string dc_get_data_type_str_by_id(uint8_t data_type)
|
||||||
|
|
@ -1664,6 +1797,11 @@ std::string dc_get_signal_val(void *p_data, uint8_t data_type)
|
||||||
break;
|
break;
|
||||||
case DATA_TYPE_C1:
|
case DATA_TYPE_C1:
|
||||||
str = std::string(1, *(char*)p_data);
|
str = std::string(1, *(char*)p_data);
|
||||||
|
break;
|
||||||
|
case DATA_TYPE_STR:
|
||||||
|
snprintf(temp, dc_get_data_type_len(data_type), "%s", (char *)p_data);
|
||||||
|
str = std::string(temp);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1723,7 +1861,7 @@ LOCAL int dc_set_signal_val(void *p_data, uint8_t data_type, void *set_data)
|
||||||
case DATA_TYPE_C8:
|
case DATA_TYPE_C8:
|
||||||
case DATA_TYPE_C32:
|
case DATA_TYPE_C32:
|
||||||
case DATA_TYPE_C64:
|
case DATA_TYPE_C64:
|
||||||
// case DATA_TYPE_C128:
|
case DATA_TYPE_C128:
|
||||||
strncpy((char *)p_data, (char *)set_data, dc_get_data_type_len(data_type));
|
strncpy((char *)p_data, (char *)set_data, dc_get_data_type_len(data_type));
|
||||||
break;
|
break;
|
||||||
case DATA_TYPE_C1:
|
case DATA_TYPE_C1:
|
||||||
|
|
@ -1912,6 +2050,10 @@ void *dc_create_data_ptr_by_type(uint8_t data_type)
|
||||||
p_char = new char[1];
|
p_char = new char[1];
|
||||||
memset(p_char, 0, 1);
|
memset(p_char, 0, 1);
|
||||||
return p_char;
|
return p_char;
|
||||||
|
case DATA_TYPE_STR:
|
||||||
|
p_char = new char[128];
|
||||||
|
memset(p_char, 0, 128);
|
||||||
|
return p_char;
|
||||||
default:
|
default:
|
||||||
LOG_E("unknown data_type: %d", data_type);
|
LOG_E("unknown data_type: %d", data_type);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -1964,6 +2106,7 @@ void dc_delete_signal_data(void *p_data, uint8_t data_type)
|
||||||
case DATA_TYPE_C64:
|
case DATA_TYPE_C64:
|
||||||
case DATA_TYPE_C128:
|
case DATA_TYPE_C128:
|
||||||
case DATA_TYPE_C1:
|
case DATA_TYPE_C1:
|
||||||
|
case DATA_TYPE_STR:
|
||||||
delete [] static_cast<char*>(p_data);
|
delete [] static_cast<char*>(p_data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "myBase.h"
|
||||||
|
#include "mySystem.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
std::string saddr;
|
||||||
|
std::string desc;
|
||||||
|
std::string link;
|
||||||
|
uint16_t inf;
|
||||||
|
uint8_t type;
|
||||||
|
std::vector<void *> vec_p_data;
|
||||||
|
std::vector<void *> vec_p_last_data;
|
||||||
|
std::vector<void *> vec_p_default_data;
|
||||||
|
}stru_cfg_base;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
std::vector<stru_cfg_base> vec_st; // 遥信
|
||||||
|
std::vector<stru_cfg_base> vec_mx; // 遥测
|
||||||
|
std::vector<stru_cfg_base> vec_co; // 遥控
|
||||||
|
std::vector<stru_cfg_base> vec_dd; // 电度
|
||||||
|
|
||||||
|
std::vector<stru_cfg_base> vec_ao; // 参数
|
||||||
|
std::vector<stru_cfg_base> vec_param; // 定值
|
||||||
|
}stru_iec_cfg;
|
||||||
|
|
||||||
|
|
||||||
|
stru_iec_cfg *iec_cfg_ptr_get(void);
|
||||||
|
|
||||||
|
int iec_cfg_parse(const std::string &path);
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include "myCmd.h"
|
#include "myCmd.h"
|
||||||
#include "iec.h"
|
#include "iec.h"
|
||||||
#include "iec_method.h"
|
#include "iec_method.h"
|
||||||
|
#include "iec_cfg_parse.h"
|
||||||
|
|
||||||
|
|
||||||
stru_iec_60870 g_iec60870[MAX_IEC_NUM];
|
stru_iec_60870 g_iec60870[MAX_IEC_NUM];
|
||||||
|
|
@ -296,6 +297,21 @@ LOCAL void iec60870_decode(uint8_t *data, uint16_t len, uint32_t interface)
|
||||||
CS10x_DoRecv(&p_iec->cs10x, (char *)data, len);
|
CS10x_DoRecv(&p_iec->cs10x, (char *)data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOCAL void iec_signal_link_change(std::string saddr, uint8_t data_type, void *p_data, void *p_last_data)
|
||||||
|
{
|
||||||
|
if(saddr.empty() || NULL == p_data || NULL == p_last_data)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
LOCAL void iec_signal_ctrl_change(std::string saddr, SIGNAL_CTRL_STEP step, uint8_t data_type, uint8_t setting_zone, void *p_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int iec_data_tx(uint8_t *p_tx, uint16_t tx_len, void *arg)
|
int iec_data_tx(uint8_t *p_tx, uint16_t tx_len, void *arg)
|
||||||
{
|
{
|
||||||
if(tx_len + sizeof(stru_msg_head) > MSG_SIZE)
|
if(tx_len + sizeof(stru_msg_head) > MSG_SIZE)
|
||||||
|
|
@ -399,6 +415,56 @@ int app_iec_init1(void *arg)
|
||||||
|
|
||||||
int app_iec_init2(void *arg)
|
int app_iec_init2(void *arg)
|
||||||
{
|
{
|
||||||
|
stru_iec_cfg *p_iec_cfg = iec_cfg_ptr_get();
|
||||||
|
if(NULL == p_iec_cfg)
|
||||||
|
{
|
||||||
|
LOG_E("iec_cfg_ptr_get return NULL");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
std::vector<stru_cfg_base> *p_vec = nullptr;
|
||||||
|
|
||||||
|
std::vector<std::vector<stru_cfg_base> *> vec_st_mx_dd = {&p_iec_cfg->vec_st, &p_iec_cfg->vec_mx, &p_iec_cfg->vec_dd};
|
||||||
|
std::vector<std::vector<stru_cfg_base> *> vec_co_ao_param = {&p_iec_cfg->vec_co, &p_iec_cfg->vec_ao, &p_iec_cfg->vec_param};
|
||||||
|
|
||||||
|
for(uint32_t i = 0; i < vec_st_mx_dd.size(); i++)
|
||||||
|
{
|
||||||
|
p_vec = vec_st_mx_dd[i];
|
||||||
|
for(uint32_t j = 0; j < p_vec->size(); j++)
|
||||||
|
{
|
||||||
|
void *p_data = nullptr;
|
||||||
|
ret = dc_signal_in_with_callback(p_vec->at(j).saddr, p_vec->at(j).desc, p_vec->at(j).link, p_vec->at(j).type, &p_data, iec_signal_link_change);
|
||||||
|
if(ret != 0)
|
||||||
|
{
|
||||||
|
LOG_E("dc_signal_in failed, saddr %s, desc %s, link %s, type %s",
|
||||||
|
p_vec->at(j).saddr, p_vec->at(j).desc, p_vec->at(j).link, dc_get_data_type_str_by_id(p_vec->at(j).type));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
p_vec->at(j).vec_p_data.push_back(p_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(uint32_t i = 0; i < vec_co_ao_param.size(); i++)
|
||||||
|
{
|
||||||
|
p_vec = vec_co_ao_param[i];
|
||||||
|
for(uint32_t j = 0; j < p_vec->size(); j++)
|
||||||
|
{
|
||||||
|
void *p_data = nullptr;
|
||||||
|
ret = dc_signal_yk_link_with_callback(p_vec->at(j).saddr, p_vec->at(j).type, &p_data, iec_signal_ctrl_change);
|
||||||
|
if(ret != 0)
|
||||||
|
{
|
||||||
|
LOG_E("dc_signal_yk_link failed, saddr %s, type %s",
|
||||||
|
p_vec->at(j).saddr, dc_get_data_type_str_by_id(p_vec->at(j).type));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
p_vec->at(j).vec_p_data.push_back(p_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,125 @@
|
||||||
|
#include "iec_cfg_parse.h"
|
||||||
|
#include <tinyxml2.h>
|
||||||
|
|
||||||
|
using namespace tinyxml2;
|
||||||
|
|
||||||
|
LOCAL const char *ele_Root = "Root";
|
||||||
|
LOCAL const char *ele_St = "St";
|
||||||
|
LOCAL const char *ele_Mx = "Mx";
|
||||||
|
LOCAL const char *ele_Co = "Co";
|
||||||
|
LOCAL const char *ele_Dd = "Dd";
|
||||||
|
LOCAL const char *ele_Ao = "Ao";
|
||||||
|
LOCAL const char *ele_Param = "Param";
|
||||||
|
LOCAL const char *ele_Signal = "Signal";
|
||||||
|
LOCAL const char *ele_Item = "Item";
|
||||||
|
|
||||||
|
LOCAL const char *attr_saddr = "saddr";
|
||||||
|
LOCAL const char *attr_desc = "desc";
|
||||||
|
LOCAL const char *attr_link = "link";
|
||||||
|
LOCAL const char *attr_inf = "inf";
|
||||||
|
LOCAL const char *attr_type = "type";
|
||||||
|
|
||||||
|
|
||||||
|
LOCAL stru_iec_cfg g_iec_cfg = {};
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
std::string ele_type;
|
||||||
|
std::vector<stru_cfg_base> *p_vec;
|
||||||
|
uint8_t data_type;
|
||||||
|
}stru_local_parse;
|
||||||
|
|
||||||
|
LOCAL std::vector<stru_local_parse> g_local_parse_vec =
|
||||||
|
{
|
||||||
|
{ele_St, &g_iec_cfg.vec_st, DATA_TYPE_U8},
|
||||||
|
{ele_Mx, &g_iec_cfg.vec_mx, DATA_TYPE_F32},
|
||||||
|
{ele_Co, &g_iec_cfg.vec_co, DATA_TYPE_U8},
|
||||||
|
{ele_Dd, &g_iec_cfg.vec_dd, DATA_TYPE_F32},
|
||||||
|
{ele_Ao, &g_iec_cfg.vec_ao, 0},
|
||||||
|
{ele_Param, &g_iec_cfg.vec_param, 0},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
LOCAL int parse_base(XMLElement *root)
|
||||||
|
{
|
||||||
|
if (root == nullptr)
|
||||||
|
{
|
||||||
|
MY_LOG_E("root is nullptr");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(uint32_t i = 0; i < g_local_parse_vec.size(); i++)
|
||||||
|
{
|
||||||
|
XMLElement *parent_ele = root->FirstChildElement(g_local_parse_vec[i].ele_type.c_str());
|
||||||
|
if (parent_ele == nullptr)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
XMLElement *signal_ele = parent_ele->FirstChildElement(ele_Signal);
|
||||||
|
while(signal_ele != nullptr)
|
||||||
|
{
|
||||||
|
stru_cfg_base cfg_base = {};
|
||||||
|
const char *saddr = signal_ele->Attribute(attr_saddr);
|
||||||
|
const char *desc = signal_ele->Attribute(attr_desc);
|
||||||
|
const char *link = signal_ele->Attribute(attr_link);
|
||||||
|
const char *inf = signal_ele->Attribute(attr_inf);
|
||||||
|
const char *type = signal_ele->Attribute(attr_type);
|
||||||
|
|
||||||
|
cfg_base.saddr = (saddr == nullptr ? "" : std::string(saddr));
|
||||||
|
cfg_base.desc = (desc == nullptr ? "" : std::string(desc));
|
||||||
|
cfg_base.link = (link == nullptr ? "" : std::string(link));
|
||||||
|
cfg_base.inf = (inf == nullptr ? 0 : atoi(inf));
|
||||||
|
cfg_base.type = (type == nullptr ? 0 : dc_get_data_type_id_by_str(type));
|
||||||
|
|
||||||
|
if(cfg_base.type == 0)
|
||||||
|
{
|
||||||
|
cfg_base.type = g_local_parse_vec[i].data_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_local_parse_vec[i].p_vec->push_back(cfg_base);
|
||||||
|
|
||||||
|
signal_ele = signal_ele->NextSiblingElement(ele_Signal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
stru_iec_cfg *iec_cfg_ptr_get(void)
|
||||||
|
{
|
||||||
|
return &g_iec_cfg;
|
||||||
|
}
|
||||||
|
|
||||||
|
int iec_cfg_parse(const std::string &path)
|
||||||
|
{
|
||||||
|
|
||||||
|
XMLDocument doc;
|
||||||
|
|
||||||
|
if (doc.LoadFile(path.c_str()) != XML_SUCCESS)
|
||||||
|
{
|
||||||
|
MY_LOG_E("LoadFile failed, path: %s", path.c_str());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
XMLElement *root = doc.RootElement();
|
||||||
|
if (root == nullptr)
|
||||||
|
{
|
||||||
|
MY_LOG_E("RootElement is nullptr");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(0 != parse_base(root))
|
||||||
|
{
|
||||||
|
MY_LOG_E("parse_base failed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -48,7 +48,7 @@ typedef struct
|
||||||
{
|
{
|
||||||
stru_self_ptl_cfg_base *p_base;
|
stru_self_ptl_cfg_base *p_base;
|
||||||
void *p_data;
|
void *p_data;
|
||||||
void *p_last_data;
|
// void *p_last_data;
|
||||||
stru_signal_ctrl *p_ctrl;
|
stru_signal_ctrl *p_ctrl;
|
||||||
}stru_self_ptl_cfg_base_data;
|
}stru_self_ptl_cfg_base_data;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -496,13 +496,13 @@ void mx_trans(stru_icp67 *p_icp67, uint16_t info_addr, float p_data)
|
||||||
{
|
{
|
||||||
*(float *)(p_app_cfg_data->mx_vec[info_addr].p_data) = p_data;
|
*(float *)(p_app_cfg_data->mx_vec[info_addr].p_data) = p_data;
|
||||||
|
|
||||||
float last = *(float *)(p_app_cfg_data->mx_vec[info_addr].p_last_data);
|
// float last = *(float *)(p_app_cfg_data->mx_vec[info_addr].p_last_data);
|
||||||
if(fabs(last - p_data) > 0.1)
|
// if(fabs(last - p_data) > 0.1)
|
||||||
{
|
// {
|
||||||
// UserWriteDisturbYc(info_addr, p_data);
|
// // UserWriteDisturbYc(info_addr, p_data);
|
||||||
// LOG_I("mx_trans: addr %d, data %f, old_data %f", info_addr, p_data, p_cfg->mx_info_vec[info_addr].old_data);
|
// // LOG_I("mx_trans: addr %d, data %f, old_data %f", info_addr, p_data, p_cfg->mx_info_vec[info_addr].old_data);
|
||||||
}
|
// }
|
||||||
*(float *)(p_app_cfg_data->mx_vec[info_addr].p_last_data) = p_data;
|
// *(float *)(p_app_cfg_data->mx_vec[info_addr].p_last_data) = p_data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -522,11 +522,11 @@ void st_trans(stru_icp67 *p_icp67, uint16_t info_addr, uint8_t p_data)
|
||||||
|
|
||||||
*(uint8_t *)(p_app_cfg_data->st_vec[info_addr].p_data) = p_data;
|
*(uint8_t *)(p_app_cfg_data->st_vec[info_addr].p_data) = p_data;
|
||||||
|
|
||||||
if(*(uint8_t *)(p_app_cfg_data->st_vec[info_addr].p_last_data) != p_data)
|
// if(*(uint8_t *)(p_app_cfg_data->st_vec[info_addr].p_last_data) != p_data)
|
||||||
{
|
// {
|
||||||
// UserWriteDisturbYx(info_addr, p_data);
|
// // UserWriteDisturbYx(info_addr, p_data);
|
||||||
*(uint8_t *)(p_app_cfg_data->st_vec[info_addr].p_last_data) = p_data;
|
// *(uint8_t *)(p_app_cfg_data->st_vec[info_addr].p_last_data) = p_data;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -481,31 +481,25 @@ LOCAL int self_ptl_cfg_init()
|
||||||
for(uint32_t i = 0; i < p_cfg->st_vec.size(); i++)
|
for(uint32_t i = 0; i < p_cfg->st_vec.size(); i++)
|
||||||
{
|
{
|
||||||
uint8_t *p_u8 = new uint8_t;
|
uint8_t *p_u8 = new uint8_t;
|
||||||
uint8_t *p_u8_last = new uint8_t;
|
|
||||||
(*p_u8) = 0;
|
(*p_u8) = 0;
|
||||||
(*p_u8_last) = 0;
|
|
||||||
|
|
||||||
|
p_cfg_data->st_vec.push_back({&p_cfg->st_vec[i], p_u8});
|
||||||
p_cfg_data->st_vec.push_back({&p_cfg->st_vec[i], p_u8, p_u8_last});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p_cfg_data->mx_vec.reserve(p_cfg->mx_vec.size() + 1);
|
p_cfg_data->mx_vec.reserve(p_cfg->mx_vec.size() + 1);
|
||||||
for(uint32_t i = 0; i < p_cfg->mx_vec.size(); i++)
|
for(uint32_t i = 0; i < p_cfg->mx_vec.size(); i++)
|
||||||
{
|
{
|
||||||
float *p_f = new float;
|
float *p_f = new float;
|
||||||
float *p_f_last = new float;
|
|
||||||
(*p_f) = 0.0;
|
(*p_f) = 0.0;
|
||||||
(*p_f_last) = 0.0;
|
|
||||||
p_cfg_data->mx_vec.push_back({&p_cfg->mx_vec[i], p_f, p_f_last});
|
p_cfg_data->mx_vec.push_back({&p_cfg->mx_vec[i], p_f});
|
||||||
}
|
}
|
||||||
|
|
||||||
p_cfg_data->co_vec.reserve(p_cfg->co_vec.size() + 1);
|
p_cfg_data->co_vec.reserve(p_cfg->co_vec.size() + 1);
|
||||||
for(uint32_t i = 0; i < p_cfg->co_vec.size(); i++)
|
for(uint32_t i = 0; i < p_cfg->co_vec.size(); i++)
|
||||||
{
|
{
|
||||||
uint8_t *p_u8 = new uint8_t;
|
uint8_t *p_u8 = new uint8_t;
|
||||||
uint8_t *p_u8_last = new uint8_t;
|
|
||||||
(*p_u8) = 0;
|
(*p_u8) = 0;
|
||||||
(*p_u8_last) = 0;
|
|
||||||
|
|
||||||
stru_signal_ctrl *p_ctrl = new stru_signal_ctrl;
|
stru_signal_ctrl *p_ctrl = new stru_signal_ctrl;
|
||||||
if(nullptr == p_ctrl)
|
if(nullptr == p_ctrl)
|
||||||
|
|
@ -524,20 +518,17 @@ LOCAL int self_ptl_cfg_init()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
p_cfg_data->co_vec.push_back({&p_cfg->co_vec[i], p_u8, p_u8_last, p_ctrl});
|
p_cfg_data->co_vec.push_back({&p_cfg->co_vec[i], p_u8, p_ctrl});
|
||||||
}
|
}
|
||||||
|
|
||||||
p_cfg_data->dd_vec.reserve(p_cfg->dd_vec.size() + 1);
|
p_cfg_data->dd_vec.reserve(p_cfg->dd_vec.size() + 1);
|
||||||
for(uint32_t i = 0; i < p_cfg->dd_vec.size(); i++)
|
for(uint32_t i = 0; i < p_cfg->dd_vec.size(); i++)
|
||||||
{
|
{
|
||||||
float *p_f = new float;
|
float *p_f = new float;
|
||||||
float *p_f_last = new float;
|
|
||||||
(*p_f) = 0.0;
|
(*p_f) = 0.0;
|
||||||
(*p_f_last) = 0.0;
|
|
||||||
p_cfg_data->dd_vec.push_back({&p_cfg->dd_vec[i], p_f, p_f_last});
|
|
||||||
}
|
|
||||||
|
|
||||||
MY_LOG_I("ao signals: %d", (int)p_cfg->ao_vec.size());
|
p_cfg_data->dd_vec.push_back({&p_cfg->dd_vec[i], p_f});
|
||||||
|
}
|
||||||
|
|
||||||
p_cfg_data->ao_vec.reserve(p_cfg->ao_vec.size() + 1);
|
p_cfg_data->ao_vec.reserve(p_cfg->ao_vec.size() + 1);
|
||||||
for(uint32_t i = 0; i < p_cfg->ao_vec.size(); i++)
|
for(uint32_t i = 0; i < p_cfg->ao_vec.size(); i++)
|
||||||
|
|
@ -553,28 +544,28 @@ LOCAL int self_ptl_cfg_init()
|
||||||
|
|
||||||
p_ctrl->type = SIGNAL_CTRL_TYPE::SBO_NORMAL;
|
p_ctrl->type = SIGNAL_CTRL_TYPE::SBO_NORMAL;
|
||||||
p_ctrl->step = SIGNAL_CTRL_STEP::READY;
|
p_ctrl->step = SIGNAL_CTRL_STEP::READY;
|
||||||
p_ctrl->data_type = p_ao->type;
|
p_ctrl->data_type = p_ao->dc_type;
|
||||||
p_ctrl->p_data = dc_create_data_ptr_by_type(p_ao->type);
|
p_ctrl->p_data = dc_create_data_ptr_by_type(p_ao->dc_type);
|
||||||
if(nullptr == p_ctrl->p_data)
|
if(nullptr == p_ctrl->p_data)
|
||||||
{
|
{
|
||||||
LOG_E("self_ptl_cfg_init dc_create_data_ptr_by_type failed, type:%d", p_ao->type);
|
LOG_E("self_ptl_cfg_init dc_create_data_ptr_by_type failed, type:%d", p_ao->dc_type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
p_cfg_data->ao_vec.push_back({p_ao, p_ctrl});
|
p_cfg_data->ao_vec.push_back({p_ao, p_ctrl});
|
||||||
|
|
||||||
void *p_data = dc_create_data_ptr_by_type(p_ao->type);
|
void *p_data = dc_create_data_ptr_by_type(p_ao->dc_type);
|
||||||
if(nullptr == p_data)
|
if(nullptr == p_data)
|
||||||
{
|
{
|
||||||
LOG_E("self_ptl_cfg_init dc_create_data_ptr_by_type failed, type:%d", p_ao->type);
|
LOG_E("self_ptl_cfg_init dc_create_data_ptr_by_type failed, type:%d", p_ao->dc_type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p_cfg_data->ao_vec.back().vec_p_data.push_back(p_data);
|
p_cfg_data->ao_vec.back().vec_p_data.push_back(p_data);
|
||||||
|
|
||||||
void *p_default_data = dc_create_data_ptr_by_type(p_ao->type);
|
void *p_default_data = dc_create_data_ptr_by_type(p_ao->dc_type);
|
||||||
if(nullptr == p_default_data)
|
if(nullptr == p_default_data)
|
||||||
{
|
{
|
||||||
LOG_E("self_ptl_cfg_init dc_create_data_ptr_by_type failed, type:%d", p_ao->type);
|
LOG_E("self_ptl_cfg_init dc_create_data_ptr_by_type failed, type:%d", p_ao->dc_type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p_cfg_data->ao_vec.back().vec_p_default_data.push_back(p_default_data);
|
p_cfg_data->ao_vec.back().vec_p_default_data.push_back(p_default_data);
|
||||||
|
|
@ -588,17 +579,17 @@ LOCAL int self_ptl_cfg_init()
|
||||||
stru_signal_ctrl *p_ctrl = new stru_signal_ctrl;
|
stru_signal_ctrl *p_ctrl = new stru_signal_ctrl;
|
||||||
if(nullptr == p_ctrl)
|
if(nullptr == p_ctrl)
|
||||||
{
|
{
|
||||||
LOG_E("self_ptl_cfg_init dc_create_data_ptr_by_type failed, type:%d", p_param->type);
|
LOG_E("self_ptl_cfg_init dc_create_data_ptr_by_type failed, type:%d", p_param->dc_type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
p_ctrl->type = SIGNAL_CTRL_TYPE::SBO_NORMAL;
|
p_ctrl->type = SIGNAL_CTRL_TYPE::SBO_NORMAL;
|
||||||
p_ctrl->step = SIGNAL_CTRL_STEP::READY;
|
p_ctrl->step = SIGNAL_CTRL_STEP::READY;
|
||||||
p_ctrl->data_type = p_param->type;
|
p_ctrl->data_type = p_param->dc_type;
|
||||||
p_ctrl->p_data = dc_create_data_ptr_by_type(p_param->type);
|
p_ctrl->p_data = dc_create_data_ptr_by_type(p_param->dc_type);
|
||||||
if(nullptr == p_ctrl->p_data)
|
if(nullptr == p_ctrl->p_data)
|
||||||
{
|
{
|
||||||
LOG_E("self_ptl_cfg_init dc_create_data_ptr_by_type failed, type:%d", p_param->type);
|
LOG_E("self_ptl_cfg_init dc_create_data_ptr_by_type failed, type:%d", p_param->dc_type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -606,18 +597,18 @@ LOCAL int self_ptl_cfg_init()
|
||||||
|
|
||||||
for(uint8_t i = 0; i < p_param->num; i++)
|
for(uint8_t i = 0; i < p_param->num; i++)
|
||||||
{
|
{
|
||||||
void *p_val_data = dc_create_data_ptr_by_type(p_param->type);
|
void *p_val_data = dc_create_data_ptr_by_type(p_param->dc_type);
|
||||||
if(nullptr == p_val_data)
|
if(nullptr == p_val_data)
|
||||||
{
|
{
|
||||||
LOG_E("self_ptl_cfg_init dc_create_data_ptr_by_type failed, type:%d", p_param->type);
|
LOG_E("self_ptl_cfg_init dc_create_data_ptr_by_type failed, type:%d", p_param->dc_type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p_cfg_data->param_vec.back().vec_p_data.push_back(p_val_data);
|
p_cfg_data->param_vec.back().vec_p_data.push_back(p_val_data);
|
||||||
|
|
||||||
void *p_default_val_data = dc_create_data_ptr_by_type(p_param->type);
|
void *p_default_val_data = dc_create_data_ptr_by_type(p_param->dc_type);
|
||||||
if(nullptr == p_default_val_data)
|
if(nullptr == p_default_val_data)
|
||||||
{
|
{
|
||||||
LOG_E("self_ptl_cfg_init dc_create_data_ptr_by_type failed, type:%d", p_param->type);
|
LOG_E("self_ptl_cfg_init dc_create_data_ptr_by_type failed, type:%d", p_param->dc_type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p_cfg_data->param_vec.back().vec_p_default_data.push_back(p_default_val_data);
|
p_cfg_data->param_vec.back().vec_p_default_data.push_back(p_default_val_data);
|
||||||
|
|
@ -905,7 +896,7 @@ int self_ptl_do_signal_out(stru_app *p_app)
|
||||||
param.step = safeStringToFloat(p_ao->p_param->step);
|
param.step = safeStringToFloat(p_ao->p_param->step);
|
||||||
param.unit = p_ao->p_param->unit;
|
param.unit = p_ao->p_param->unit;
|
||||||
|
|
||||||
ret |= dc_signal_ao(p_ao->p_param->base.saddr, p_ao->p_param->base.desc, p_ao->p_param->type, param, SIGNAL_CTRL_TYPE::SBO_NORMAL, p_ao->vec_p_data[0], p_ao->vec_p_default_data[0], self_ptl_signal_change_callback);
|
ret |= dc_signal_ao(p_ao->p_param->base.saddr, p_ao->p_param->base.desc, p_ao->p_param->dc_type, param, SIGNAL_CTRL_TYPE::SBO_NORMAL, p_ao->vec_p_data[0], p_ao->vec_p_default_data[0], self_ptl_signal_change_callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -927,7 +918,7 @@ int self_ptl_do_signal_out(stru_app *p_app)
|
||||||
|
|
||||||
|
|
||||||
// ret(saddr, p(saddr, p->name, p->type, p->p_data);
|
// ret(saddr, p(saddr, p->name, p->type, p->p_data);
|
||||||
ret |= dc_signal_param(p_param->p_param->base.saddr, p_param->p_param->base.desc, p_param->p_param->type, param, SIGNAL_CTRL_TYPE::SBO_NORMAL, p_param->vec_p_data, p_param->vec_p_default_data, self_ptl_signal_change_callback);
|
ret |= dc_signal_param(p_param->p_param->base.saddr, p_param->p_param->base.desc, p_param->p_param->dc_type, param, SIGNAL_CTRL_TYPE::SBO_NORMAL, p_param->vec_p_data, p_param->vec_p_default_data, self_ptl_signal_change_callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -555,10 +555,10 @@ void ws_recv(const char* p_rx, uint16_t rx_len)
|
||||||
|
|
||||||
void ws_task()
|
void ws_task()
|
||||||
{
|
{
|
||||||
// if(g_ws_out_signals.empty() && g_ws_in_signals.empty() && g_ws_yk_signals.empty() && g_ws_ao_signals.empty() && g_ws_param_signals.empty())
|
if(g_ws_out_signals.empty() && g_ws_in_signals.empty() && g_ws_yk_signals.empty() && g_ws_ao_signals.empty() && g_ws_param_signals.empty())
|
||||||
// {
|
{
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
const char ctrl_type_str[][16] = {"NONE", "DIRECT_NORMAL", "SBO_NORMAL"};
|
const char ctrl_type_str[][16] = {"NONE", "DIRECT_NORMAL", "SBO_NORMAL"};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,40 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Root>
|
<Root>
|
||||||
<St>
|
<St>
|
||||||
<Item saddr="iec1014.st.1" desc="远方遥信1-手分遥信" link="self_ptl.st.1" inf="1"/>
|
<Signal saddr="iec1014.st.1" desc="远方遥信1-手分遥信" link="self_ptl.st.1" inf="1"/>
|
||||||
<Item saddr="iec1014.st.2" desc="远方遥信2-手合遥信" link="self_ptl.st.2" inf="2"/>
|
<Signal saddr="iec1014.st.2" desc="远方遥信2-手合遥信" link="self_ptl.st.2" inf="2"/>
|
||||||
<Item saddr="iec1014.st.3" desc="远方遥信3-就地遥信" link="self_ptl.st.3" inf="3"/>
|
<Signal saddr="iec1014.st.3" desc="远方遥信3-就地遥信" link="self_ptl.st.3" inf="3"/>
|
||||||
<Item saddr="iec1014.st.4" desc="远方遥信4-远方遥信" link="self_ptl.st.4" inf="4"/>
|
<Signal saddr="iec1014.st.4" desc="远方遥信4-远方遥信" link="self_ptl.st.4" inf="4"/>
|
||||||
</St>
|
</St>
|
||||||
<Mx>
|
<Mx>
|
||||||
<Item saddr="iec1014.mx.1" desc="远方遥信1-经度" link="self_ptl.mx.1" inf="16385"/>
|
<Signal saddr="iec1014.mx.1" desc="远方遥信1-经度" link="self_ptl.mx.1" inf="16385"/>
|
||||||
<Item saddr="iec1014.mx.2" desc="远方遥信2-纬度" link="self_ptl.mx.5" inf="16386"/>
|
<Signal saddr="iec1014.mx.2" desc="远方遥信2-纬度" link="self_ptl.mx.5" inf="16386"/>
|
||||||
<Item saddr="iec1014.mx.3" desc="远方遥信3-海拔" link="self_ptl.mx.9" inf="16387"/>
|
<Signal saddr="iec1014.mx.3" desc="远方遥信3-海拔" link="self_ptl.mx.9" inf="16387"/>
|
||||||
<Item saddr="iec1014.mx.4" desc="计量-频率" link="self_ptl.mx.38" inf="16388"/>
|
<Signal saddr="iec1014.mx.4" desc="计量-频率" link="self_ptl.mx.38" inf="16388"/>
|
||||||
<Item saddr="iec1014.mx.5" desc="采集板温度" link="self_ptl.mx.64" inf="16390"/>
|
<Signal saddr="iec1014.mx.5" desc="采集板温度" link="self_ptl.mx.64" inf="16390"/>
|
||||||
</Mx>
|
</Mx>
|
||||||
<Co>
|
<Co>
|
||||||
<Item saddr="iec1014.co.1" desc="硬遥控11-交流录波" link="self_ptl.co.11" inf="24577"/>
|
<Signal saddr="iec1014.co.1" desc="硬遥控11-交流录波" link="self_ptl.co.11" inf="24577"/>
|
||||||
</Co>
|
</Co>
|
||||||
<Dd>
|
<Dd>
|
||||||
</Dd>
|
</Dd>
|
||||||
<Ao>
|
<Ao>
|
||||||
<Item saddr="iec1014.param.1" desc="终端类型" link="self_ptl.param.INFO_DEV_TYPE" inf="32769"/>
|
<Signal saddr="iec1014.param.1" desc="终端类型" link="self_ptl.param.INFO_DEV_TYPE" inf="32769" type="str"/>
|
||||||
<Item saddr="iec1014.param.2" desc="终端操作系统" link="self_ptl.param.INFO_PLATFORM" inf="32770"/>
|
<Signal saddr="iec1014.param.2" desc="终端操作系统" link="self_ptl.param.INFO_PLATFORM" inf="32770" type="str"/>
|
||||||
<Item saddr="iec1014.param.3" desc="生产厂商" link="self_ptl.param.HD_SERIAL" inf="32771"/>
|
<Signal saddr="iec1014.param.3" desc="生产厂商" link="self_ptl.param.HD_SERIAL" inf="32771" type="str"/>
|
||||||
<Item saddr="iec1014.param.4" desc="终端硬件版本" link="self_ptl.param.HD_SERIAL" inf="32772"/>
|
<Signal saddr="iec1014.param.4" desc="终端硬件版本" link="self_ptl.param.HD_SERIAL" inf="32772" type="str"/>
|
||||||
<Item saddr="iec1014.param.5" desc="终端软件版本" link="self_ptl.param.HD_SERIAL" inf="32773"/>
|
<Signal saddr="iec1014.param.5" desc="终端软件版本" link="self_ptl.param.HD_SERIAL" inf="32773" type="str"/>
|
||||||
<Item saddr="iec1014.param.6" desc="终端软件版本校验码" link="self_ptl.param.RES_C24_SYS1" inf="32774"/>
|
<Signal saddr="iec1014.param.6" desc="终端软件版本校验码" link="self_ptl.param.RES_C24_SYS1" inf="32774" type="str"/>
|
||||||
<Item saddr="iec1014.param.7" desc="终端通讯规约类型" link="self_ptl.param.INFO_PROTOCOL" inf="32775"/>
|
<Signal saddr="iec1014.param.7" desc="终端通讯规约类型" link="self_ptl.param.INFO_PROTOCOL" inf="32775" type="str"/>
|
||||||
<Item saddr="iec1014.param.8" desc="终端出厂型号" link="self_ptl.param.INFO_FACTORYMODEL" inf="32776"/>
|
<Signal saddr="iec1014.param.8" desc="终端出厂型号" link="self_ptl.param.INFO_FACTORYMODEL" inf="32776" type="str"/>
|
||||||
<Item saddr="iec1014.param.9" desc="终端ID号" link="self_ptl.param.TERM_ID" inf="32777"/>
|
<Signal saddr="iec1014.param.9" desc="终端ID号" link="self_ptl.param.TERM_ID" inf="32777" type="str"/>
|
||||||
<Item saddr="iec1014.param.10" desc="双MAC地址" link="self_ptl.param.DoubleMac" inf="32778"/>
|
<Signal saddr="iec1014.param.10" desc="双MAC地址" link="self_ptl.param.DoubleMac" inf="32778" type="str"/>
|
||||||
|
|
||||||
<Item saddr="iec1014.param.11" desc="遥测-交流电流死区" link="self_ptl.param.I_DEAD" inf="32800"/>
|
<Signal saddr="iec1014.param.11" desc="遥测-交流电流死区" link="self_ptl.param.I_DEAD" inf="32800" type="float"/>
|
||||||
<Item saddr="iec1014.param.12" desc="遥测-交流电压死区" link="self_ptl.param.UAC_DEAD" inf="32801"/>
|
<Signal saddr="iec1014.param.12" desc="遥测-交流电压死区" link="self_ptl.param.UAC_DEAD" inf="32801" type="float"/>
|
||||||
|
|
||||||
<Item saddr="iec1014.param.13" desc="保护-故障指示灯自动复归投退" link="self_ptl.param.ALARMLED_EN_MOD" inf="34848"/>
|
<Signal saddr="iec1014.param.13" desc="保护-故障指示灯自动复归投退" link="self_ptl.param.ALARMLED_EN_MOD" inf="34848" type="uint8_t"/>
|
||||||
<Item saddr="iec1014.param.14" desc="保护-故障指示灯复归时间" link="self_ptl.param.FaultLed_Reset_T" inf="34849"/>
|
<Signal saddr="iec1014.param.14" desc="保护-故障指示灯复归时间" link="self_ptl.param.FaultLed_Reset_T" inf="34849" type="uint32_t"/>
|
||||||
</Ao>
|
</Ao>
|
||||||
<Param>
|
<Param>
|
||||||
</Param>
|
</Param>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue