<修改> 1、将mms_m中的配置解析部分提取到APP处理,通过app调用mms_m库中的初始化接口传入解析后的配置信息;
2、调整数据中心参数相关的接口,改为C风格,后续优化各个模块对外接口,支持C调用; 3、配置文件调整,后续参数定值调整为手动配置进一个文件,最大最小值统一配置进这个文件,在各模块的配置文件中不配置这些,相应的数据中心的参数定值接口中,不传递最大最小缺省值
This commit is contained in:
parent
3743b69ef2
commit
c03832a31e
|
|
@ -42,8 +42,6 @@ typedef struct
|
||||||
float max; // 最大值
|
float max; // 最大值
|
||||||
float step; // 步长
|
float step; // 步长
|
||||||
std::string unit; // 单位
|
std::string unit; // 单位
|
||||||
// std::string default_value; // 默认值字符串
|
|
||||||
// void *p_default; // 默认值
|
|
||||||
}stru_signal_param;
|
}stru_signal_param;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -77,10 +75,10 @@ int dc_signal_ao_set_val(const std::string &saddr, SIGNAL_CTRL_STEP step, stru_s
|
||||||
int dc_signal_ao_set_val_without_check(const std::string &saddr, uint8_t data_type, void *p_data);
|
int dc_signal_ao_set_val_without_check(const std::string &saddr, uint8_t data_type, void *p_data);
|
||||||
|
|
||||||
// 数据中心参数信号注册接口
|
// 数据中心参数信号注册接口
|
||||||
int dc_signal_param(const std::string &saddr, const std::string &desc, uint8_t data_type, const stru_signal_param ¶m, uint8_t ctrl_type, std::vector<void *> &vec_p_data, std::vector<void *> &vec_p_default_data, signal_change_cb cb);
|
int dc_signal_param(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, int num, signal_change_cb cb);
|
||||||
|
|
||||||
// 数据中心参数链接信号接口
|
// 数据中心参数链接信号接口
|
||||||
int dc_signal_param_link_with_callback(const std::string &saddr, std::vector<void *> &vec_p_data, signal_change_cb cb);
|
int dc_signal_param_link_with_callback(const std::string &saddr, void **p_data, int num, signal_change_cb cb);
|
||||||
|
|
||||||
// 数据中心参数设置接口
|
// 数据中心参数设置接口
|
||||||
int dc_signal_param_set_val(const std::string &saddr, SIGNAL_CTRL_STEP step, stru_signal_ctrl &ctrl, uint8_t setting_zone, void *p_data);
|
int dc_signal_param_set_val(const std::string &saddr, SIGNAL_CTRL_STEP step, stru_signal_ctrl &ctrl, uint8_t setting_zone, void *p_data);
|
||||||
|
|
|
||||||
|
|
@ -39,74 +39,21 @@ enum
|
||||||
#define MMS_M_DEBUG_PRINT_OFF 0
|
#define MMS_M_DEBUG_PRINT_OFF 0
|
||||||
#define MMS_M_DEBUG_PRINT_ON 1
|
#define MMS_M_DEBUG_PRINT_ON 1
|
||||||
|
|
||||||
// typedef union
|
typedef char MMS_STR[MMS_M_STR_LEN];
|
||||||
// {
|
typedef char MMS_REF[MMS_M_REF_LEN];
|
||||||
// bool b;
|
|
||||||
// int8_t c;
|
|
||||||
// int16_t s;
|
|
||||||
// int32_t l;
|
|
||||||
// uint8_t cu;
|
|
||||||
// uint16_t su;
|
|
||||||
// uint32_t lu;
|
|
||||||
// float f;
|
|
||||||
// }un_value;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
char saddr[MMS_M_STR_LEN];
|
|
||||||
char desc[MMS_M_STR_LEN];
|
|
||||||
uint8_t data_type;
|
|
||||||
// void *p_data;
|
|
||||||
std::vector<void *> vec_p_data;
|
|
||||||
}stru_mms_m_gen_signal;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
stru_mms_m_gen_signal sig;
|
|
||||||
uint8_t ctrl_type;
|
|
||||||
}stru_mms_m_ctrl_signal;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
stru_mms_m_gen_signal sig;
|
|
||||||
uint8_t ctrl_type;
|
|
||||||
double min;
|
|
||||||
double max;
|
|
||||||
double step;
|
|
||||||
char unit[MMS_M_STR_LEN];
|
|
||||||
// void *p_default;
|
|
||||||
std::vector<void *> vec_p_default;
|
|
||||||
}stru_mms_m_param_signal;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint16_t st_num;
|
|
||||||
uint16_t mx_num;
|
|
||||||
uint16_t co_num;
|
|
||||||
uint16_t ao_num;
|
|
||||||
uint16_t param_num;
|
|
||||||
stru_mms_m_gen_signal *p_st_sig;
|
|
||||||
stru_mms_m_gen_signal *p_mx_sig;
|
|
||||||
stru_mms_m_ctrl_signal *p_co_sig;
|
|
||||||
stru_mms_m_param_signal *p_ao_sig;
|
|
||||||
stru_mms_m_param_signal *p_param_sig;
|
|
||||||
}stru_mms_m_config;
|
|
||||||
|
|
||||||
|
#define MMS_M_MAX_VAL_NUM 16
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int app_fd; // 61850客户端句柄
|
int app_fd; // 61850客户端句柄
|
||||||
char ied[MMS_M_STR_LEN]; // ied名称
|
MMS_STR ied; // ied名称
|
||||||
char saddr[MMS_M_STR_LEN]; // 信号短地址
|
MMS_STR saddr; // 信号短地址
|
||||||
uint8_t value_type; // 数据类型
|
uint8_t value_type; // 数据类型
|
||||||
// void *p_val; // 设置值
|
char val[MMS_M_DATA_STRING_LEN];
|
||||||
char val[128];
|
|
||||||
// char val_str[MMS_M_STR_LEN]; // 字符串类型的值
|
|
||||||
uint8_t ctrl_type; // 遥控类型
|
uint8_t ctrl_type; // 遥控类型
|
||||||
int set_zone; // 定值区
|
int set_zone; // 定值区
|
||||||
void (*p_func)(void *arg, int ret); // 设置回调函数
|
void (*p_func)(void *arg, int ret); // 设置回调函数
|
||||||
// void *arg; // 回调函数参数
|
|
||||||
}stru_mms_m_event;
|
}stru_mms_m_event;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -128,9 +75,9 @@ typedef struct
|
||||||
int reason;
|
int reason;
|
||||||
int type;
|
int type;
|
||||||
int quality;
|
int quality;
|
||||||
char name[MMS_M_STR_LEN];
|
MMS_STR name;
|
||||||
char desc[MMS_M_STR_LEN];
|
MMS_STR desc;
|
||||||
char reference[MMS_M_REF_LEN];
|
MMS_REF reference;
|
||||||
void *p_value;
|
void *p_value;
|
||||||
stru_mms_m_time time;
|
stru_mms_m_time time;
|
||||||
}stru_mms_m_out_value;
|
}stru_mms_m_out_value;
|
||||||
|
|
@ -140,9 +87,71 @@ typedef void (*mms_m_out_value_cb)(stru_mms_m_out_value *p_value);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int mms_m_out_init(const char *config_path, int debug_print_flag, uint32_t connectionTimeout);
|
|
||||||
|
|
||||||
int mms_m_out_get_signal_info(int app_fd, stru_mms_m_config *p_config);
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int quality;
|
||||||
|
int val_num;
|
||||||
|
void *p_val[MMS_M_MAX_VAL_NUM];
|
||||||
|
void *p_default[MMS_M_MAX_VAL_NUM];
|
||||||
|
stru_mms_m_time time;
|
||||||
|
}stru_point_value;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
MMS_STR desc;
|
||||||
|
MMS_STR host_ip;
|
||||||
|
uint16_t host_port;
|
||||||
|
MMS_STR ied;
|
||||||
|
}stru_para_page;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t no;
|
||||||
|
uint8_t type;
|
||||||
|
uint8_t fc;
|
||||||
|
uint8_t ctrl_model;
|
||||||
|
MMS_STR saddr;
|
||||||
|
MMS_STR desc;
|
||||||
|
MMS_STR ldev;
|
||||||
|
MMS_STR lnode;
|
||||||
|
MMS_STR doname;
|
||||||
|
MMS_REF reference;
|
||||||
|
stru_point_value value;
|
||||||
|
void *set_value;
|
||||||
|
void *control;
|
||||||
|
float min_value;
|
||||||
|
float max_value;
|
||||||
|
float step_value;
|
||||||
|
MMS_STR unit;
|
||||||
|
}stru_point_item;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
MMS_STR desc;
|
||||||
|
int st_num;
|
||||||
|
int mx_num;
|
||||||
|
int co_num;
|
||||||
|
int ao_num;
|
||||||
|
int param_num;
|
||||||
|
stru_point_item *p_st;
|
||||||
|
stru_point_item *p_mx;
|
||||||
|
stru_point_item *p_co;
|
||||||
|
stru_point_item *p_ao;
|
||||||
|
stru_point_item *p_param;
|
||||||
|
}stru_point_page;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
MMS_STR path;
|
||||||
|
stru_para_page para;
|
||||||
|
stru_point_page point;
|
||||||
|
}stru_cfg;
|
||||||
|
|
||||||
|
|
||||||
|
int mms_m_out_init(stru_cfg *p_cfg, int debug_print_flag, uint32_t connectionTimeout);
|
||||||
|
|
||||||
int mms_m_out_get_connect_status(int fd, mms_m_out_status_cb p_func);
|
int mms_m_out_get_connect_status(int fd, mms_m_out_status_cb p_func);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#include "iec61850_client.h"
|
#include "iec61850_client.h"
|
||||||
#include "mms_m_parse_cfg.h"
|
|
||||||
|
|
||||||
#define COLOR_RESET "\033[0m"
|
#define COLOR_RESET "\033[0m"
|
||||||
#define COLOR_RED "\033[31m"
|
#define COLOR_RED "\033[31m"
|
||||||
|
|
@ -113,7 +113,6 @@ typedef struct
|
||||||
{
|
{
|
||||||
std::string do_name; // 数据对象名称
|
std::string do_name; // 数据对象名称
|
||||||
std::vector<stru_point_item *> p_do_vec; // 指向DO的指针集合
|
std::vector<stru_point_item *> p_do_vec; // 指向DO的指针集合
|
||||||
// stru_point_item *p_do; // 指向DO的指针
|
|
||||||
}stru_dobj;
|
}stru_dobj;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
@ -133,7 +132,6 @@ typedef struct
|
||||||
{
|
{
|
||||||
std::string ref; // 描述
|
std::string ref; // 描述
|
||||||
int reason; // 原因
|
int reason; // 原因
|
||||||
// stru_point_item *p_do; // 指向DO的指针
|
|
||||||
std::vector<stru_point_item *> *p_do_vec; // 指向DO的指针集合
|
std::vector<stru_point_item *> *p_do_vec; // 指向DO的指针集合
|
||||||
}stru_member;
|
}stru_member;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include "iec61850_client.h"
|
|
||||||
#include "myMms_m.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int quality;
|
|
||||||
// void *p_val;
|
|
||||||
std::vector<void *> vec_p_val;
|
|
||||||
std::vector<void *> vec_p_default;
|
|
||||||
stru_mms_m_time time;
|
|
||||||
}stru_point_value;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
std::string desc;
|
|
||||||
std::string host_ip;
|
|
||||||
uint16_t host_port;
|
|
||||||
std::string ied;
|
|
||||||
}stru_para_page;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint16_t no;
|
|
||||||
uint8_t type;
|
|
||||||
uint8_t fc;
|
|
||||||
uint8_t ctrl_model;
|
|
||||||
std::string saddr;
|
|
||||||
std::string desc;
|
|
||||||
std::string ldev;
|
|
||||||
std::string lnode;
|
|
||||||
std::string doname;
|
|
||||||
std::string reference;
|
|
||||||
stru_point_value value;
|
|
||||||
MmsValue *set_value;
|
|
||||||
ControlObjectClient control;
|
|
||||||
float min_value;
|
|
||||||
float max_value;
|
|
||||||
float step_value;
|
|
||||||
std::string unit;
|
|
||||||
|
|
||||||
// std::vector<void *> vec_p_data;
|
|
||||||
// std::vector<void *> vec_p_default;
|
|
||||||
}stru_point_item;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
std::string desc;
|
|
||||||
std::vector<stru_point_item> st;
|
|
||||||
std::vector<stru_point_item> mx;
|
|
||||||
std::vector<stru_point_item> co;
|
|
||||||
std::vector<stru_point_item> ao;
|
|
||||||
std::vector<stru_point_item> param;
|
|
||||||
}stru_point_page;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
stru_para_page para;
|
|
||||||
stru_point_page point;
|
|
||||||
}stru_cfg;
|
|
||||||
|
|
||||||
|
|
||||||
stru_cfg *parse_cfg(const std::string &cfg_file);
|
|
||||||
void parse_show_cfg(stru_cfg* cfg);
|
|
||||||
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
#include "myMms_m.h"
|
#include "myMms_m.h"
|
||||||
#include "mms_m.h"
|
#include "mms_m.h"
|
||||||
#include "mms_m_errstr.h"
|
#include "mms_m_errstr.h"
|
||||||
#include "mms_m_parse_cfg.h"
|
|
||||||
#include "hal_thread.h"
|
#include "hal_thread.h"
|
||||||
|
|
||||||
// #include "conversions.h"
|
// #include "conversions.h"
|
||||||
|
|
@ -261,22 +260,22 @@ static int mms_m_param_value_sync(stru_point_item &item, stru_mms_m_event &event
|
||||||
{
|
{
|
||||||
case MMS_BOOLEAN:
|
case MMS_BOOLEAN:
|
||||||
val_b = atoi(event.val) > 0 ? true : false;
|
val_b = atoi(event.val) > 0 ? true : false;
|
||||||
MmsValue_setBoolean(item.set_value, val_b);
|
MmsValue_setBoolean((MmsValue *)item.set_value, val_b);
|
||||||
break;
|
break;
|
||||||
case MMS_INTEGER:
|
case MMS_INTEGER:
|
||||||
MmsValue_setInt32(item.set_value, atoi(event.val));
|
MmsValue_setInt32((MmsValue *)item.set_value, atoi(event.val));
|
||||||
break;
|
break;
|
||||||
case MMS_UNSIGNED:
|
case MMS_UNSIGNED:
|
||||||
MmsValue_setUint32(item.set_value, atoi(event.val));
|
MmsValue_setUint32((MmsValue *)item.set_value, atoi(event.val));
|
||||||
break;
|
break;
|
||||||
case MMS_FLOAT:
|
case MMS_FLOAT:
|
||||||
MmsValue_setFloat(item.set_value, atof(event.val));
|
MmsValue_setFloat((MmsValue *)item.set_value, atof(event.val));
|
||||||
break;
|
break;
|
||||||
case MMS_STRING:
|
case MMS_STRING:
|
||||||
MmsValue_setMmsString(item.set_value, (char *)event.val);
|
MmsValue_setMmsString((MmsValue *)item.set_value, (char *)event.val);
|
||||||
break;
|
break;
|
||||||
case MMS_VISIBLE_STRING:
|
case MMS_VISIBLE_STRING:
|
||||||
MmsValue_setVisibleString(item.set_value, (char *)event.val);
|
MmsValue_setVisibleString((MmsValue *)item.set_value, (char *)event.val);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_E("value type not support");
|
LOG_E("value type not support");
|
||||||
|
|
@ -289,41 +288,35 @@ static int mms_m_param_value_sync(stru_point_item &item, stru_mms_m_event &event
|
||||||
|
|
||||||
static int mms_m_send_ao_write(stru_mms_m_obj &obj, stru_mms_m_event &event)
|
static int mms_m_send_ao_write(stru_mms_m_obj &obj, stru_mms_m_event &event)
|
||||||
{
|
{
|
||||||
std::vector<stru_point_item>::iterator it;
|
|
||||||
stru_point_item *p_item = NULL;
|
stru_point_item *p_item = NULL;
|
||||||
IedClientError err;
|
IedClientError err;
|
||||||
|
|
||||||
for(it = obj.p_cfg->point.ao.begin(); it!= obj.p_cfg->point.ao.end(); it++)
|
for(int i = 0; obj.p_cfg->point.p_ao && i < obj.p_cfg->point.ao_num; i++)
|
||||||
{
|
{
|
||||||
if(it->saddr.compare(event.saddr) == 0)
|
if(0 == strcmp(obj.p_cfg->point.p_ao[i].saddr, event.saddr) && strlen(event.saddr) > 0)
|
||||||
{
|
{
|
||||||
p_item = &(*it);
|
p_item = &obj.p_cfg->point.p_ao[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL == p_item)
|
if(NULL == p_item)
|
||||||
{
|
{
|
||||||
LOG_E("%s: %s not found in cfg\n", obj.cfg_path.c_str(), event.saddr);
|
LOG_E("%s: %s not found in cfg\n", obj.cfg_path.c_str(), event.saddr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
size_t pos = p_item->reference.find("/");
|
|
||||||
if(pos == std::string::npos)
|
|
||||||
{
|
|
||||||
LOG_E("%s: %s reference is not correct\n", obj.cfg_path.c_str(), p_item->reference.c_str());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
MmsValue *p_value = IedConnection_readObject(obj.run.con, &err, p_item->reference.c_str(), (FunctionalConstraint)p_item->fc);
|
MmsValue *p_value = IedConnection_readObject(obj.run.con, &err, p_item->reference, (FunctionalConstraint)p_item->fc);
|
||||||
if(NULL != p_value)
|
if(NULL != p_value)
|
||||||
{
|
{
|
||||||
// if(MMS_M_DEBUG_PRINT_ON == obj.debug_print_flag)
|
if(MMS_M_DEBUG_PRINT_ON == obj.debug_print_flag)
|
||||||
{
|
{
|
||||||
mms_m_show_MmsValue(p_value, &p_item->type);
|
mms_m_show_MmsValue(p_value, &p_item->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_E("%s: %s read err:%s(%d)\n", obj.cfg_path.c_str(), p_item->reference.c_str(), mms_m_err_str(err), err);
|
LOG_E("%s: %s read err:%s(%d)\n", obj.cfg_path.c_str(), p_item->reference, mms_m_err_str(err), err);
|
||||||
}
|
}
|
||||||
MmsValue_delete(p_value);
|
MmsValue_delete(p_value);
|
||||||
|
|
||||||
|
|
@ -334,10 +327,10 @@ static int mms_m_send_ao_write(stru_mms_m_obj &obj, stru_mms_m_event &event)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
IedConnection_writeObject(obj.run.con, &err, p_item->reference.c_str(), (FunctionalConstraint)p_item->fc, p_item->set_value);
|
IedConnection_writeObject(obj.run.con, &err, p_item->reference, (FunctionalConstraint)p_item->fc, (MmsValue *)p_item->set_value);
|
||||||
if(err != IED_ERROR_OK)
|
if(err != IED_ERROR_OK)
|
||||||
{
|
{
|
||||||
LOG_E("%s: %s write err:%s(%d)\n", obj.cfg_path.c_str(), p_item->reference.c_str(), mms_m_err_str(err), err);
|
LOG_E("%s: %s write err:%s(%d)\n", obj.cfg_path.c_str(), p_item->reference, mms_m_err_str(err), err);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -345,35 +338,37 @@ static int mms_m_send_ao_write(stru_mms_m_obj &obj, stru_mms_m_event &event)
|
||||||
|
|
||||||
static int mms_m_send_param_write(stru_mms_m_obj &obj, stru_mms_m_event &event)
|
static int mms_m_send_param_write(stru_mms_m_obj &obj, stru_mms_m_event &event)
|
||||||
{
|
{
|
||||||
std::vector<stru_point_item>::iterator it;
|
|
||||||
stru_point_item *p_item = NULL;
|
stru_point_item *p_item = NULL;
|
||||||
IedClientError err;
|
IedClientError err;
|
||||||
|
|
||||||
for(it = obj.p_cfg->point.param.begin(); it!= obj.p_cfg->point.param.end(); it++)
|
for(int i = 0; obj.p_cfg->point.p_param && i < obj.p_cfg->point.param_num; i++)
|
||||||
{
|
{
|
||||||
if(it->saddr.compare(event.saddr) == 0)
|
if(0 == strcmp(obj.p_cfg->point.p_param[i].saddr, event.saddr) && strlen(event.saddr) > 0)
|
||||||
{
|
{
|
||||||
p_item = &(*it);
|
p_item = &obj.p_cfg->point.p_param[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL == p_item)
|
if(NULL == p_item)
|
||||||
{
|
{
|
||||||
LOG_E("%s: %s not found in cfg\n", obj.cfg_path.c_str(), event.saddr);
|
LOG_E("%s: %s not found in cfg\n", obj.cfg_path.c_str(), event.saddr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
size_t pos = p_item->reference.find("/");
|
|
||||||
|
std::string ref = p_item->reference;
|
||||||
|
size_t pos = ref.find("/");
|
||||||
if(pos == std::string::npos)
|
if(pos == std::string::npos)
|
||||||
{
|
{
|
||||||
LOG_E("%s: %s reference is not correct\n", obj.cfg_path.c_str(), p_item->reference.c_str());
|
LOG_E("%s: %s reference is not correct\n", obj.cfg_path.c_str(), ref.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string str_head = p_item->reference.substr(0, pos);
|
std::string str_head = ref.substr(0, pos);
|
||||||
std::string str_EditSG = str_head + "/" + g_sgcb_edit_sg;
|
std::string str_EditSG = str_head + "/" + g_sgcb_edit_sg;
|
||||||
std::string str_CnfEdit = str_head + "/" + g_sgcb_cnf_edit;
|
std::string str_CnfEdit = str_head + "/" + g_sgcb_cnf_edit;
|
||||||
|
|
||||||
MmsValue *p_value = IedConnection_readObject(obj.run.con, &err, p_item->reference.c_str(), (FunctionalConstraint)p_item->fc);
|
MmsValue *p_value = IedConnection_readObject(obj.run.con, &err, ref.c_str(), (FunctionalConstraint)p_item->fc);
|
||||||
if(NULL != p_value)
|
if(NULL != p_value)
|
||||||
{
|
{
|
||||||
if(MMS_M_DEBUG_PRINT_ON == obj.debug_print_flag)
|
if(MMS_M_DEBUG_PRINT_ON == obj.debug_print_flag)
|
||||||
|
|
@ -383,7 +378,7 @@ static int mms_m_send_param_write(stru_mms_m_obj &obj, stru_mms_m_event &event)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_E("%s: %s read err:%s(%d)\n", obj.cfg_path.c_str(), p_item->reference.c_str(), mms_m_err_str(err), err);
|
LOG_E("%s: %s read err:%s(%d)\n", obj.cfg_path.c_str(), ref.c_str(), mms_m_err_str(err), err);
|
||||||
}
|
}
|
||||||
MmsValue_delete(p_value);
|
MmsValue_delete(p_value);
|
||||||
|
|
||||||
|
|
@ -412,10 +407,10 @@ static int mms_m_send_param_write(stru_mms_m_obj &obj, stru_mms_m_event &event)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
IedConnection_writeObject(obj.run.con, &err, p_item->reference.c_str(), IEC61850_FC_SE, p_item->set_value);
|
IedConnection_writeObject(obj.run.con, &err, ref.c_str(), IEC61850_FC_SE, (MmsValue *)p_item->set_value);
|
||||||
if(err != IED_ERROR_OK)
|
if(err != IED_ERROR_OK)
|
||||||
{
|
{
|
||||||
LOG_E("%s: %s write err:%s(%d)\n", obj.cfg_path.c_str(), p_item->reference.c_str(), mms_m_err_str(err), err);
|
LOG_E("%s: %s write err:%s(%d)\n", obj.cfg_path.c_str(), ref.c_str(), mms_m_err_str(err), err);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -442,30 +437,23 @@ static void mms_m_send_read_ao(stru_mms_m_obj &obj, stru_mms_m_event &event)
|
||||||
MmsValue *p_value = NULL;
|
MmsValue *p_value = NULL;
|
||||||
|
|
||||||
stru_mms_m_out_value out_val;
|
stru_mms_m_out_value out_val;
|
||||||
|
|
||||||
std::vector<stru_point_item>::iterator it;
|
|
||||||
|
|
||||||
stru_point_item *p_item = NULL;
|
stru_point_item *p_item = NULL;
|
||||||
|
|
||||||
for(it = obj.p_cfg->point.ao.begin(); it!= obj.p_cfg->point.ao.end(); it++)
|
for(int i = 0; i < obj.p_cfg->point.ao_num; i++)
|
||||||
{
|
{
|
||||||
if(strlen(event.saddr) != 0 && it->saddr.compare(event.saddr) == 0)
|
if(obj.p_cfg->point.p_ao && 0 == strcmp(event.saddr, obj.p_cfg->point.p_ao[i].saddr))
|
||||||
{
|
{
|
||||||
p_item = &(*it);
|
p_item = &obj.p_cfg->point.p_ao[i];
|
||||||
}
|
|
||||||
else if(strlen(event.saddr) == 0)
|
|
||||||
{
|
|
||||||
p_item = &(*it);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL == (p_value = IedConnection_readObject(obj.run.con, &err, p_item->reference.c_str(), (FunctionalConstraint)p_item->fc)))
|
if(NULL == (p_value = IedConnection_readObject(obj.run.con, &err, p_item->reference, (FunctionalConstraint)p_item->fc)))
|
||||||
{
|
{
|
||||||
LOG_E("%s: saddr %s, ref %s read err:%s(%d)\n",
|
LOG_E("%s: saddr %s, ref %s read err:%s(%d)\n",
|
||||||
obj.cfg_path.c_str(), p_item->saddr.c_str(), p_item->reference.c_str(), mms_m_err_str(err), err);
|
obj.cfg_path.c_str(), p_item->saddr, p_item->reference, mms_m_err_str(err), err);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -474,9 +462,7 @@ static void mms_m_send_read_ao(stru_mms_m_obj &obj, stru_mms_m_event &event)
|
||||||
mms_m_show_MmsValue(p_value, &p_item->type);
|
mms_m_show_MmsValue(p_value, &p_item->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *p_val = event.set_zone >= p_item->value.vec_p_val.size() ? NULL : p_item->value.vec_p_val[event.set_zone];
|
if(0 != mms_m_get_mmsValue(p_value, p_item->type, p_item->value.p_val[0]))
|
||||||
|
|
||||||
if(0 != mms_m_get_mmsValue(p_value, p_item->type, p_val))
|
|
||||||
{
|
{
|
||||||
LOG_E("get mms value failed");
|
LOG_E("get mms value failed");
|
||||||
MmsValue_delete(p_value);
|
MmsValue_delete(p_value);
|
||||||
|
|
@ -484,13 +470,13 @@ static void mms_m_send_read_ao(stru_mms_m_obj &obj, stru_mms_m_event &event)
|
||||||
}
|
}
|
||||||
|
|
||||||
mms_m_get_local_time(out_val.time);
|
mms_m_get_local_time(out_val.time);
|
||||||
out_val.p_value = p_val;
|
out_val.p_value = p_item->value.p_val[0];
|
||||||
out_val.type = p_item->type;
|
out_val.type = p_item->type;
|
||||||
out_val.quality = 0;
|
out_val.quality = 0;
|
||||||
|
|
||||||
snprintf(out_val.name, sizeof(out_val.name) - 1, "%s", it->saddr.c_str());
|
snprintf(out_val.name, sizeof(out_val.name), "%s", p_item->saddr);
|
||||||
snprintf(out_val.desc, sizeof(out_val.desc) - 1, "%s", it->desc.c_str());
|
snprintf(out_val.desc, sizeof(out_val.desc), "%s", p_item->desc);
|
||||||
snprintf(out_val.reference, sizeof(out_val.reference) - 1, "%s", it->reference.c_str());
|
snprintf(out_val.reference, sizeof(out_val.reference), "%s", p_item->reference);
|
||||||
out_val.reason = MMS_M_REASON_READ_PARAM; // call param
|
out_val.reason = MMS_M_REASON_READ_PARAM; // call param
|
||||||
out_val.app_fd = obj.obj_fd;
|
out_val.app_fd = obj.obj_fd;
|
||||||
|
|
||||||
|
|
@ -519,21 +505,21 @@ static int mms_m_send_co_then_check_result(stru_mms_m_obj &obj, stru_point_item
|
||||||
IedClientError err;
|
IedClientError err;
|
||||||
MmsValue* stVal = NULL;
|
MmsValue* stVal = NULL;
|
||||||
|
|
||||||
if(NULL != (stVal = IedConnection_readObject(obj.run.con, &err, item.reference.c_str(), (FunctionalConstraint)item.fc)))
|
if(NULL != (stVal = IedConnection_readObject(obj.run.con, &err, item.reference, (FunctionalConstraint)item.fc)))
|
||||||
{
|
{
|
||||||
bool state = MmsValue_getBoolean(stVal);
|
bool state = MmsValue_getBoolean(stVal);
|
||||||
MmsValue_delete(stVal);
|
MmsValue_delete(stVal);
|
||||||
|
|
||||||
if(state == MmsValue_getBoolean(item.set_value))
|
if(state == MmsValue_getBoolean((MmsValue *)item.set_value))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_E("%s: %s direct then read stVal(%d) is not equal to set value(%d)\n", obj.cfg_path.c_str(), item.reference.c_str(), state, MmsValue_getBoolean(item.set_value));
|
LOG_E("%s: %s direct then read stVal(%d) is not equal to set value(%d)\n", obj.cfg_path.c_str(), item.reference, state, MmsValue_getBoolean((MmsValue *)item.set_value));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_E("%s: %s direct then read stVal err:%s(%d)\n", obj.cfg_path.c_str(), item.reference.c_str(), mms_m_err_str(err), err);
|
LOG_E("%s: %s direct then read stVal err:%s(%d)\n", obj.cfg_path.c_str(), item.reference, mms_m_err_str(err), err);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -545,47 +531,47 @@ static int mms_m_send_co_select(stru_mms_m_obj &obj, stru_point_item &item)
|
||||||
|
|
||||||
if(NULL == item.control)
|
if(NULL == item.control)
|
||||||
{
|
{
|
||||||
LOG_E("%s: %s control is not init\r\n", obj.cfg_path.c_str(), item.saddr.c_str());
|
LOG_E("%s: %s control is not init\r\n", obj.cfg_path.c_str(), item.saddr);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(CONTROL_MODEL_DIRECT_NORMAL == item.ctrl_model || CONTROL_MODEL_DIRECT_ENHANCED == item.ctrl_model)
|
if(CONTROL_MODEL_DIRECT_NORMAL == item.ctrl_model || CONTROL_MODEL_DIRECT_ENHANCED == item.ctrl_model)
|
||||||
{
|
{
|
||||||
LOG_E("%s: %s control model is %s(%d)\r\n", obj.cfg_path.c_str(), item.saddr.c_str(), mms_m_ctrl_model_str((ControlModel)item.ctrl_model), item.ctrl_model);
|
LOG_E("%s: %s control model is %s(%d)\r\n", obj.cfg_path.c_str(), item.saddr, mms_m_ctrl_model_str((ControlModel)item.ctrl_model), item.ctrl_model);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(CONTROL_MODEL_SBO_NORMAL == item.ctrl_model && ControlObjectClient_select(item.control))
|
if(CONTROL_MODEL_SBO_NORMAL == item.ctrl_model && ControlObjectClient_select((ControlObjectClient)item.control))
|
||||||
{
|
{
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
else if(CONTROL_MODEL_SBO_ENHANCED == item.ctrl_model)
|
else if(CONTROL_MODEL_SBO_ENHANCED == item.ctrl_model)
|
||||||
{
|
{
|
||||||
ControlObjectClient_setCommandTerminationHandler(item.control, mms_m_command_termination_handler, NULL);
|
ControlObjectClient_setCommandTerminationHandler((ControlObjectClient)item.control, mms_m_command_termination_handler, NULL);
|
||||||
|
|
||||||
if(MMS_M_DEBUG_PRINT_ON == obj.debug_print_flag)
|
if(MMS_M_DEBUG_PRINT_ON == obj.debug_print_flag)
|
||||||
{
|
{
|
||||||
mms_m_show_MmsValue(item.set_value, &item.type);
|
mms_m_show_MmsValue((MmsValue *)item.set_value, &item.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ControlObjectClient_selectWithValue(item.control, item.set_value))
|
if (ControlObjectClient_selectWithValue((ControlObjectClient)item.control, (MmsValue *)item.set_value))
|
||||||
{
|
{
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_E("%s: %s control model is %s(%d)\r\n", obj.cfg_path.c_str(), item.saddr.c_str(), mms_m_ctrl_model_str((ControlModel)item.ctrl_model), item.ctrl_model);
|
LOG_E("%s: %s control model is %s(%d)\r\n", obj.cfg_path.c_str(), item.saddr, mms_m_ctrl_model_str((ControlModel)item.ctrl_model), item.ctrl_model);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(0 == ret)
|
if(0 == ret)
|
||||||
{
|
{
|
||||||
LOG_I("%s: co saddr %s, desc %s, ref %s selected successfully, ctrl_model %s(%d)\n",
|
LOG_I("%s: co saddr %s, desc %s, ref %s selected successfully, ctrl_model %s(%d)\n",
|
||||||
obj.cfg_path.c_str(), item.saddr.c_str(), item.desc.c_str(), item.reference.c_str(), mms_m_ctrl_model_str((ControlModel)item.ctrl_model), item.ctrl_model);
|
obj.cfg_path.c_str(), item.saddr, item.desc, item.reference, mms_m_ctrl_model_str((ControlModel)item.ctrl_model), item.ctrl_model);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_E("%s: failed to select %s\n", obj.cfg_path.c_str(), item.reference.c_str());
|
LOG_E("%s: failed to select %s\n", obj.cfg_path.c_str(), item.reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -599,23 +585,23 @@ static int mms_m_send_co_direct(stru_mms_m_obj &obj, stru_point_item &item)
|
||||||
|
|
||||||
if(NULL == item.control)
|
if(NULL == item.control)
|
||||||
{
|
{
|
||||||
LOG_E("%s: %s control is not init\r\n", obj.cfg_path.c_str(), item.saddr.c_str());
|
LOG_E("%s: %s control is not init\r\n", obj.cfg_path.c_str(), item.saddr);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(CONTROL_MODEL_DIRECT_ENHANCED == item.ctrl_model || CONTROL_MODEL_SBO_ENHANCED == item.ctrl_model)
|
if(CONTROL_MODEL_DIRECT_ENHANCED == item.ctrl_model || CONTROL_MODEL_SBO_ENHANCED == item.ctrl_model)
|
||||||
{
|
{
|
||||||
ControlObjectClient_setCommandTerminationHandler(item.control, mms_m_command_termination_handler, NULL);
|
ControlObjectClient_setCommandTerminationHandler((ControlObjectClient)item.control, mms_m_command_termination_handler, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ControlObjectClient_operate(item.control, item.set_value, 0 /* operate now */))
|
if (ControlObjectClient_operate((ControlObjectClient)item.control, (MmsValue *)item.set_value, 0 /* operate now */))
|
||||||
{
|
{
|
||||||
LOG_I("%s: co saddr %s, desc %s, ref %s operated successfully\n", obj.cfg_path.c_str(), item.saddr.c_str(), item.desc.c_str(), item.reference.c_str());
|
LOG_I("%s: co saddr %s, desc %s, ref %s operated successfully\n", obj.cfg_path.c_str(), item.saddr, item.desc, item.reference);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_E("%s: failed to direct %s!\n", obj.cfg_path.c_str(), item.reference.c_str());
|
LOG_E("%s: failed to direct %s!\n", obj.cfg_path.c_str(), item.reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(item.ctrl_model)
|
switch(item.ctrl_model)
|
||||||
|
|
@ -633,7 +619,7 @@ static int mms_m_send_co_direct(stru_mms_m_obj &obj, stru_point_item &item)
|
||||||
Thread_sleep(1000);
|
Thread_sleep(1000);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_E("%s: %s control model is %s(%d)\r\n", obj.cfg_path.c_str(), item.saddr.c_str(), mms_m_ctrl_model_str((ControlModel)item.ctrl_model), item.ctrl_model);
|
LOG_E("%s: %s control model is %s(%d)\r\n", obj.cfg_path.c_str(), item.saddr, mms_m_ctrl_model_str((ControlModel)item.ctrl_model), item.ctrl_model);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -643,42 +629,45 @@ static int mms_m_send_co_direct(stru_mms_m_obj &obj, stru_point_item &item)
|
||||||
|
|
||||||
static int mms_m_send_co_cancel(stru_mms_m_obj &obj, stru_point_item &item)
|
static int mms_m_send_co_cancel(stru_mms_m_obj &obj, stru_point_item &item)
|
||||||
{
|
{
|
||||||
if(ControlObjectClient_cancel(item.control))
|
if(ControlObjectClient_cancel((ControlObjectClient)item.control))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_E("%s: failed to cancel %s\n", obj.cfg_path.c_str(), item.reference.c_str());
|
LOG_E("%s: failed to cancel %s\n", obj.cfg_path.c_str(), item.reference);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mms_m_send_co(stru_mms_m_obj &obj, stru_mms_m_event &event)
|
static int mms_m_send_co(stru_mms_m_obj &obj, stru_mms_m_event &event)
|
||||||
{
|
{
|
||||||
std::vector<stru_point_item>::iterator it;
|
int co_index = 0;
|
||||||
|
stru_point_item *p_point = NULL;
|
||||||
|
|
||||||
for(it = obj.p_cfg->point.co.begin(); it!= obj.p_cfg->point.co.end(); it++)
|
for(int co_index = 0; obj.p_cfg->point.p_co && co_index < obj.p_cfg->point.co_num; co_index++)
|
||||||
{
|
{
|
||||||
if(it->saddr.compare(event.saddr) == 0)
|
if(0 == strcmp(obj.p_cfg->point.p_co[co_index].saddr, event.saddr))
|
||||||
{
|
{
|
||||||
|
p_point = &obj.p_cfg->point.p_co[co_index];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(it == obj.p_cfg->point.co.end())
|
|
||||||
|
if(NULL == p_point)
|
||||||
{
|
{
|
||||||
LOG_E("%s:co saddr(%s) is not exist", obj.cfg_path.c_str(), event.saddr);
|
LOG_E("%s:co saddr(%s) is not exist", obj.cfg_path.c_str(), event.saddr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL == it->control )
|
if(NULL == p_point->control )
|
||||||
{
|
{
|
||||||
if(NULL != (it->control = ControlObjectClient_create(it->reference.c_str(), obj.run.con)))
|
if(NULL != (p_point->control = ControlObjectClient_create(p_point->reference, obj.run.con)))
|
||||||
{
|
{
|
||||||
ControlObjectClient_setOrigin(it->control, obj.cfg_path.c_str(), CONTROL_ORCAT_STATION_CONTROL);
|
ControlObjectClient_setOrigin((ControlObjectClient)p_point->control, obj.cfg_path.c_str(), CONTROL_ORCAT_STATION_CONTROL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_E("%s: create control object failed, ref(%s)", obj.cfg_path.c_str(), it->reference.c_str());
|
LOG_E("%s: create control object failed, ref(%s)", obj.cfg_path.c_str(), p_point->reference);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -686,25 +675,25 @@ static int mms_m_send_co(stru_mms_m_obj &obj, stru_mms_m_event &event)
|
||||||
// bool b = (MY_GET_DATA_WITH_TYPE(((void *)event.val), uint8_t) > 0) ? true : false;
|
// bool b = (MY_GET_DATA_WITH_TYPE(((void *)event.val), uint8_t) > 0) ? true : false;
|
||||||
bool b = atoi(event.val) > 0 ? true : false;
|
bool b = atoi(event.val) > 0 ? true : false;
|
||||||
|
|
||||||
if(it->set_value == NULL)
|
if(p_point->set_value == NULL)
|
||||||
{
|
{
|
||||||
it->set_value = MmsValue_newBoolean(b);
|
p_point->set_value = MmsValue_newBoolean(b);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MmsValue_setBoolean(it->set_value, b);
|
MmsValue_setBoolean((MmsValue *)p_point->set_value, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_I("mms_m_send_co b %d, set_value %d", b, MmsValue_getBoolean(it->set_value));
|
LOG_I("mms_m_send_co b %d, set_value %d", b, MmsValue_getBoolean((MmsValue *)p_point->set_value));
|
||||||
|
|
||||||
switch(event.ctrl_type)
|
switch(event.ctrl_type)
|
||||||
{
|
{
|
||||||
case _MMS_M_EVENT_CO_SELECT:
|
case _MMS_M_EVENT_CO_SELECT:
|
||||||
return mms_m_send_co_select(obj, (*it));
|
return mms_m_send_co_select(obj, *p_point);
|
||||||
case _MMS_M_EVENT_CO_DIRECT:
|
case _MMS_M_EVENT_CO_DIRECT:
|
||||||
return mms_m_send_co_direct(obj, (*it));
|
return mms_m_send_co_direct(obj, *p_point);
|
||||||
case _MMS_M_EVENT_CO_CANCEL:
|
case _MMS_M_EVENT_CO_CANCEL:
|
||||||
return mms_m_send_co_cancel(obj, (*it));
|
return mms_m_send_co_cancel(obj, *p_point);
|
||||||
default:
|
default:
|
||||||
LOG_E("%s: ctrl_type(%d) is not support", obj.cfg_path.c_str(), event.ctrl_type);
|
LOG_E("%s: ctrl_type(%d) is not support", obj.cfg_path.c_str(), event.ctrl_type);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -752,30 +741,45 @@ static void mms_m_send_set_gi(stru_mms_m_obj &obj)
|
||||||
|
|
||||||
static void mms_m_send_call_all(stru_mms_m_obj &obj)
|
static void mms_m_send_call_all(stru_mms_m_obj &obj)
|
||||||
{
|
{
|
||||||
std::vector<stru_point_item> temp_list[3] = {obj.p_cfg->point.st, obj.p_cfg->point.mx, obj.p_cfg->point.ao};
|
|
||||||
std::vector<stru_point_item>::iterator it;
|
typedef struct
|
||||||
|
{
|
||||||
|
int *p_num;
|
||||||
|
stru_point_item *p_item;
|
||||||
|
}stru_local;
|
||||||
|
|
||||||
|
std::vector<stru_local> temp_list =
|
||||||
|
{
|
||||||
|
{&obj.p_cfg->point.st_num, obj.p_cfg->point.p_st},
|
||||||
|
{&obj.p_cfg->point.mx_num, obj.p_cfg->point.p_mx},
|
||||||
|
{&obj.p_cfg->point.ao_num, obj.p_cfg->point.p_ao},
|
||||||
|
};
|
||||||
|
|
||||||
IedClientError err;
|
IedClientError err;
|
||||||
MmsValue *p_value = NULL;
|
MmsValue *p_value = NULL;
|
||||||
|
|
||||||
|
stru_point_item *p_point = NULL;
|
||||||
|
|
||||||
stru_mms_m_out_value out_val;
|
stru_mms_m_out_value out_val;
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++)
|
for(auto &item : temp_list)
|
||||||
{
|
{
|
||||||
for(it = temp_list[i].begin(); it!= temp_list[i].end(); it++)
|
for(int i = 0; i < (*item.p_num); i++)
|
||||||
{
|
{
|
||||||
if(NULL == (p_value = IedConnection_readObject(obj.run.con, &err, it->reference.c_str(), (FunctionalConstraint)it->fc)))
|
p_point = &item.p_item[i];
|
||||||
|
|
||||||
|
if(NULL == (p_value = IedConnection_readObject(obj.run.con, &err, p_point->reference, (FunctionalConstraint)p_point->fc)))
|
||||||
{
|
{
|
||||||
LOG_E("read object %s failed, err(%d:%s)", it->reference.c_str(), err, mms_m_err_str(err));
|
LOG_E("read object %s failed, err(%d:%s)", p_point->reference, err, mms_m_err_str(err));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(MMS_M_DEBUG_PRINT_ON == obj.debug_print_flag)
|
if(MMS_M_DEBUG_PRINT_ON == obj.debug_print_flag)
|
||||||
{
|
{
|
||||||
mms_m_show_MmsValue(p_value, &it->type);
|
mms_m_show_MmsValue(p_value, &p_point->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(0 != mms_m_get_mmsValue(p_value, it->type, it->value.vec_p_val[0]))
|
if(0 != mms_m_get_mmsValue(p_value, p_point->type, p_point->value.p_val[0]))
|
||||||
{
|
{
|
||||||
LOG_E("get mms value failed");
|
LOG_E("get mms value failed");
|
||||||
MmsValue_delete(p_value);
|
MmsValue_delete(p_value);
|
||||||
|
|
@ -783,13 +787,13 @@ static void mms_m_send_call_all(stru_mms_m_obj &obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
mms_m_get_local_time(out_val.time);
|
mms_m_get_local_time(out_val.time);
|
||||||
out_val.p_value = it->value.vec_p_val[0];
|
out_val.p_value = p_point->value.p_val[0];
|
||||||
out_val.type = it->type;
|
out_val.type = p_point->type;
|
||||||
out_val.quality = 0;
|
out_val.quality = 0;
|
||||||
|
|
||||||
snprintf(out_val.name, sizeof(out_val.name) - 1, "%s", it->saddr.c_str());
|
snprintf(out_val.name, sizeof(out_val.name), "%s", p_point->saddr);
|
||||||
snprintf(out_val.desc, sizeof(out_val.desc) - 1, "%s", it->desc.c_str());
|
snprintf(out_val.desc, sizeof(out_val.desc), "%s", p_point->desc);
|
||||||
snprintf(out_val.reference, sizeof(out_val.reference) - 1, "%s", it->reference.c_str());
|
snprintf(out_val.reference, sizeof(out_val.reference), "%s", p_point->reference);
|
||||||
out_val.reason = MMS_M_REASON_ALL_CALL; // call all
|
out_val.reason = MMS_M_REASON_ALL_CALL; // call all
|
||||||
out_val.app_fd = obj.obj_fd;
|
out_val.app_fd = obj.obj_fd;
|
||||||
|
|
||||||
|
|
@ -892,7 +896,7 @@ static int mms_m_get_MmsValue(stru_point_value &point_value, stru_mms_m_out_valu
|
||||||
}
|
}
|
||||||
std::string temp_str;
|
std::string temp_str;
|
||||||
|
|
||||||
void *p_val = point_value.vec_p_val[0];
|
void *p_val = point_value.p_val[0];
|
||||||
|
|
||||||
switch(MmsValue_getType(p_mms_values))
|
switch(MmsValue_getType(p_mms_values))
|
||||||
{
|
{
|
||||||
|
|
@ -1017,8 +1021,9 @@ static void mms_m_report_callback(void* parameter, ClientReport report)
|
||||||
memset(&out_value, 0, sizeof(out_value));
|
memset(&out_value, 0, sizeof(out_value));
|
||||||
memset(&point_value, 0, sizeof(point_value));
|
memset(&point_value, 0, sizeof(point_value));
|
||||||
char temp[256] = {0};
|
char temp[256] = {0};
|
||||||
// point_value.p_val = (void *)temp;
|
|
||||||
point_value.vec_p_val.push_back((void *)temp);
|
point_value.val_num = 1;
|
||||||
|
point_value.p_val[0] = (void *)temp;
|
||||||
|
|
||||||
mms_m_get_MmsValue(point_value, out_value, mms_value, tm_flag, p_obj->debug_print_flag);
|
mms_m_get_MmsValue(point_value, out_value, mms_value, tm_flag, p_obj->debug_print_flag);
|
||||||
|
|
||||||
|
|
@ -1028,7 +1033,7 @@ static void mms_m_report_callback(void* parameter, ClientReport report)
|
||||||
}
|
}
|
||||||
|
|
||||||
out_value.reason = reason;
|
out_value.reason = reason;
|
||||||
out_value.p_value = point_value.vec_p_val[0];
|
out_value.p_value = point_value.p_val[0];
|
||||||
out_value.app_fd = p_obj->obj_fd;
|
out_value.app_fd = p_obj->obj_fd;
|
||||||
out_value.time = point_value.time;
|
out_value.time = point_value.time;
|
||||||
|
|
||||||
|
|
@ -1036,9 +1041,9 @@ static void mms_m_report_callback(void* parameter, ClientReport report)
|
||||||
{
|
{
|
||||||
for(it = it_mb->p_do_vec->begin(); it!= it_mb->p_do_vec->end(); it++)
|
for(it = it_mb->p_do_vec->begin(); it!= it_mb->p_do_vec->end(); it++)
|
||||||
{
|
{
|
||||||
snprintf(out_value.name, MMS_M_STR_LEN - 1, "%s", (*it)->saddr.c_str());
|
snprintf(out_value.name, MMS_M_STR_LEN, "%s", (*it)->saddr);
|
||||||
snprintf(out_value.desc, MMS_M_STR_LEN - 1, "%s", (*it)->desc.c_str());
|
snprintf(out_value.desc, MMS_M_STR_LEN, "%s", (*it)->desc);
|
||||||
snprintf(out_value.reference, MMS_M_REF_LEN - 1, "%s", (*it)->reference.c_str());
|
snprintf(out_value.reference, MMS_M_REF_LEN, "%s", (*it)->reference);
|
||||||
|
|
||||||
mms_m_put_value((*p_obj), out_value);
|
mms_m_put_value((*p_obj), out_value);
|
||||||
}
|
}
|
||||||
|
|
@ -1415,28 +1420,27 @@ static void mms_m_run(stru_mms_m_obj &obj)
|
||||||
|
|
||||||
static void mms_m_control_init(stru_mms_m_obj &obj)
|
static void mms_m_control_init(stru_mms_m_obj &obj)
|
||||||
{
|
{
|
||||||
std::vector<stru_point_item>::iterator it;
|
for(int i = 0; i < obj.p_cfg->point.co_num; i++)
|
||||||
|
|
||||||
for(it = obj.p_cfg->point.co.begin(); it!= obj.p_cfg->point.co.end(); it++)
|
|
||||||
{
|
{
|
||||||
if(it->control)
|
stru_point_item &item = obj.p_cfg->point.p_co[i];
|
||||||
|
if(item.control)
|
||||||
{
|
{
|
||||||
ControlObjectClient_destroy(it->control);
|
ControlObjectClient_destroy((ControlObjectClient)item.control);
|
||||||
it->control = NULL;
|
item.control = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL != (it->control = ControlObjectClient_create(it->reference.c_str(), obj.run.con)))
|
if(NULL != (item.control = ControlObjectClient_create(item.reference, obj.run.con)))
|
||||||
{
|
{
|
||||||
ControlObjectClient_setOrigin(it->control, obj.cfg_path.c_str(), CONTROL_ORCAT_STATION_CONTROL);
|
ControlObjectClient_setOrigin((ControlObjectClient)item.control, obj.cfg_path.c_str(), CONTROL_ORCAT_STATION_CONTROL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_E("%s: ControlObjectClient_create failed, %s", obj.cfg_path.c_str(), it->reference.c_str());
|
LOG_E("%s: ControlObjectClient_create failed, %s", obj.cfg_path.c_str(), item.reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!it->set_value)
|
if(!item.set_value)
|
||||||
{
|
{
|
||||||
it->set_value = MmsValue_newBoolean(false);
|
item.set_value = MmsValue_newBoolean(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1677,7 +1681,7 @@ static void mms_m_show_ied(stru_mms_m_obj &obj)
|
||||||
{
|
{
|
||||||
stru_point_item *p_item = *it4;
|
stru_point_item *p_item = *it4;
|
||||||
printf(" signal saddr: %s, type: %d, fc: %d, ctrl_model: %d, desc: %s, reference: %s\n",
|
printf(" signal saddr: %s, type: %d, fc: %d, ctrl_model: %d, desc: %s, reference: %s\n",
|
||||||
p_item->saddr.c_str(), p_item->type, p_item->fc, p_item->ctrl_model, p_item->desc.c_str(), p_item->reference.c_str());
|
p_item->saddr, p_item->type, p_item->fc, p_item->ctrl_model, p_item->desc, p_item->reference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1754,7 +1758,7 @@ static void mms_m_add_point_to_ldevs(stru_mms_m_obj &obj, stru_point_item &point
|
||||||
|
|
||||||
static int mms_m_ied_init(stru_mms_m_obj &obj)
|
static int mms_m_ied_init(stru_mms_m_obj &obj)
|
||||||
{
|
{
|
||||||
if(obj.p_cfg && !obj.p_cfg->para.ied.empty())
|
if(obj.p_cfg && strlen(obj.p_cfg->para.ied) > 0)
|
||||||
{
|
{
|
||||||
obj.ied_name = obj.p_cfg->para.ied;
|
obj.ied_name = obj.p_cfg->para.ied;
|
||||||
}
|
}
|
||||||
|
|
@ -1771,24 +1775,27 @@ static int mms_m_ied_init(stru_mms_m_obj &obj)
|
||||||
|
|
||||||
std::vector<stru_point_item>::iterator it;
|
std::vector<stru_point_item>::iterator it;
|
||||||
|
|
||||||
for(it = obj.p_cfg->point.st.begin(); it!= obj.p_cfg->point.st.end(); it++)
|
typedef struct
|
||||||
{
|
{
|
||||||
mms_m_add_point_to_ldevs(obj, *it);
|
int *p_num;
|
||||||
}
|
stru_point_item *p_item;
|
||||||
|
}stru_add_point;
|
||||||
|
|
||||||
for(it = obj.p_cfg->point.mx.begin(); it!= obj.p_cfg->point.mx.end(); it++)
|
std::vector<stru_add_point> vec_add_point =
|
||||||
{
|
{
|
||||||
mms_m_add_point_to_ldevs(obj, *it);
|
{&obj.p_cfg->point.st_num, obj.p_cfg->point.p_st},
|
||||||
}
|
{&obj.p_cfg->point.mx_num, obj.p_cfg->point.p_mx},
|
||||||
|
{&obj.p_cfg->point.co_num, obj.p_cfg->point.p_co},
|
||||||
|
{&obj.p_cfg->point.ao_num, obj.p_cfg->point.p_ao},
|
||||||
|
{&obj.p_cfg->point.param_num, obj.p_cfg->point.p_param},
|
||||||
|
};
|
||||||
|
|
||||||
for(it = obj.p_cfg->point.co.begin(); it!= obj.p_cfg->point.co.end(); it++)
|
for(std::vector<stru_add_point>::iterator it = vec_add_point.begin(); it!= vec_add_point.end(); it++)
|
||||||
{
|
{
|
||||||
mms_m_add_point_to_ldevs(obj, *it);
|
for(int i = 0; i < *it->p_num; i++)
|
||||||
}
|
{
|
||||||
|
mms_m_add_point_to_ldevs(obj, it->p_item[i]);
|
||||||
for(it = obj.p_cfg->point.ao.begin(); it!= obj.p_cfg->point.ao.end(); it++)
|
}
|
||||||
{
|
|
||||||
mms_m_add_point_to_ldevs(obj, *it);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1796,9 +1803,9 @@ static int mms_m_ied_init(stru_mms_m_obj &obj)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int mms_m_out_init(const char *cfg_path, int debug_print_flag, uint32_t connectionTimeout)
|
int mms_m_out_init(stru_cfg *p_cfg, int debug_print_flag, uint32_t connectionTimeout)
|
||||||
{
|
{
|
||||||
if(NULL == cfg_path)
|
if(NULL == p_cfg)
|
||||||
{
|
{
|
||||||
LOG_E("Invalid config path\n");
|
LOG_E("Invalid config path\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -1806,9 +1813,9 @@ int mms_m_out_init(const char *cfg_path, int debug_print_flag, uint32_t connecti
|
||||||
|
|
||||||
for(std::map<int, stru_mms_m_obj *>::iterator it = g_mms_m_obj_map.begin(); it != g_mms_m_obj_map.end(); it++)
|
for(std::map<int, stru_mms_m_obj *>::iterator it = g_mms_m_obj_map.begin(); it != g_mms_m_obj_map.end(); it++)
|
||||||
{
|
{
|
||||||
if(0 == it->second->cfg_path.compare(cfg_path))
|
if(strlen(p_cfg->path) > 0 && 0 == it->second->cfg_path.compare(p_cfg->path))
|
||||||
{
|
{
|
||||||
LOG_E("IED with config file %s already exists\n", cfg_path);
|
LOG_E("IED with config file %s already exists\n", p_cfg->path);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1821,27 +1828,14 @@ int mms_m_out_init(const char *cfg_path, int debug_print_flag, uint32_t connecti
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(p_obj, 0, sizeof(stru_mms_m_obj));
|
memset(p_obj, 0, sizeof(stru_mms_m_obj));
|
||||||
p_obj->cfg_path = cfg_path;
|
p_obj->cfg_path = p_cfg->path;
|
||||||
p_obj->debug_print_flag = debug_print_flag;
|
p_obj->debug_print_flag = debug_print_flag;
|
||||||
p_obj->connectionTimeout = connectionTimeout;
|
p_obj->connectionTimeout = connectionTimeout;
|
||||||
p_obj->p_cfg = parse_cfg(cfg_path);
|
p_obj->p_cfg = p_cfg;
|
||||||
if(NULL == p_obj->p_cfg)
|
|
||||||
{
|
|
||||||
LOG_E("Failed to parse config file %s\n", cfg_path);
|
|
||||||
delete p_obj;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p_obj->debug_print_flag)
|
|
||||||
{
|
|
||||||
LOG_I("Config file %s parsed successfully\n", cfg_path);
|
|
||||||
parse_show_cfg(p_obj->p_cfg);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(0 != mms_m_ied_init(*p_obj))
|
if(0 != mms_m_ied_init(*p_obj))
|
||||||
{
|
{
|
||||||
LOG_E("Failed to initialize IED, config file %s\n", cfg_path);
|
LOG_E("Failed to initialize IED, config file %s\n", p_cfg->path);
|
||||||
delete p_obj->p_cfg;
|
|
||||||
delete p_obj;
|
delete p_obj;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -1853,16 +1847,14 @@ int mms_m_out_init(const char *cfg_path, int debug_print_flag, uint32_t connecti
|
||||||
|
|
||||||
if(0 != sem_init(&p_obj->run.sem, 0, 1))
|
if(0 != sem_init(&p_obj->run.sem, 0, 1))
|
||||||
{
|
{
|
||||||
LOG_E("Failed to initialize IED semaphore, config file %s\n", cfg_path);
|
LOG_E("Failed to initialize IED semaphore, config file %s\n", p_cfg->path);
|
||||||
delete p_obj->p_cfg;
|
|
||||||
delete p_obj;
|
delete p_obj;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(0 != pthread_create(&p_obj->run.pthread_task, NULL, mms_m_run_thread, p_obj))
|
if(0 != pthread_create(&p_obj->run.pthread_task, NULL, mms_m_run_thread, p_obj))
|
||||||
{
|
{
|
||||||
LOG_E("Failed to create IED thread, config file %s\n", cfg_path);
|
LOG_E("Failed to create IED thread, config file %s\n", p_cfg->path);
|
||||||
delete p_obj->p_cfg;
|
|
||||||
delete p_obj;
|
delete p_obj;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -1872,161 +1864,11 @@ int mms_m_out_init(const char *cfg_path, int debug_print_flag, uint32_t connecti
|
||||||
|
|
||||||
g_mms_m_obj_map[id]->obj_fd = id;
|
g_mms_m_obj_map[id]->obj_fd = id;
|
||||||
|
|
||||||
LOG_I("IED with config file %s added, id %d\n", cfg_path, id);
|
LOG_I("IED with config file %s added, id %d\n", p_cfg->path, id);
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int mms_m_out_get_signal_info(int app_fd, stru_mms_m_config *p_config)
|
|
||||||
{
|
|
||||||
if(NULL == p_config)
|
|
||||||
{
|
|
||||||
LOG_E("Invalid config\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(g_mms_m_obj_map.find(app_fd) == g_mms_m_obj_map.end())
|
|
||||||
{
|
|
||||||
LOG_E("IED with app_fd %d not found\n", app_fd);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
stru_mms_m_obj &obj = *g_mms_m_obj_map[app_fd];
|
|
||||||
|
|
||||||
if(NULL == obj.p_cfg)
|
|
||||||
{
|
|
||||||
LOG_E("IED with app_fd %d config is NULL\n", app_fd);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
p_config->st_num = obj.p_cfg->point.st.size();
|
|
||||||
|
|
||||||
p_config->p_st_sig = new stru_mms_m_gen_signal[p_config->st_num];
|
|
||||||
if(NULL == p_config->p_st_sig)
|
|
||||||
{
|
|
||||||
LOG_E("Failed to allocate memory for ST signal\n");
|
|
||||||
p_config->st_num = 0;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0; i < p_config->st_num; i++)
|
|
||||||
{
|
|
||||||
stru_point_item &point = obj.p_cfg->point.st[i];
|
|
||||||
stru_mms_m_gen_signal &sig = p_config->p_st_sig[i];
|
|
||||||
|
|
||||||
strncpy(sig.saddr, point.saddr.c_str(), sizeof(sig.saddr));
|
|
||||||
strncpy(sig.desc, point.desc.c_str(), sizeof(sig.desc));
|
|
||||||
sig.data_type = point.type;
|
|
||||||
sig.vec_p_data.push_back(point.value.vec_p_val[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
p_config->mx_num = obj.p_cfg->point.mx.size();
|
|
||||||
|
|
||||||
p_config->p_mx_sig = new stru_mms_m_gen_signal[p_config->mx_num];
|
|
||||||
if(NULL == p_config->p_mx_sig)
|
|
||||||
{
|
|
||||||
LOG_E("Failed to allocate memory for MX signal\n");
|
|
||||||
p_config->mx_num = 0;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0; i < p_config->mx_num; i++)
|
|
||||||
{
|
|
||||||
stru_point_item &point = obj.p_cfg->point.mx[i];
|
|
||||||
stru_mms_m_gen_signal &sig = p_config->p_mx_sig[i];
|
|
||||||
|
|
||||||
strncpy(sig.saddr, point.saddr.c_str(), sizeof(sig.saddr));
|
|
||||||
strncpy(sig.desc, point.desc.c_str(), sizeof(sig.desc));
|
|
||||||
sig.data_type = point.type;
|
|
||||||
sig.vec_p_data.push_back(point.value.vec_p_val[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
p_config->co_num = obj.p_cfg->point.co.size();
|
|
||||||
p_config->p_co_sig = new stru_mms_m_ctrl_signal[p_config->co_num];
|
|
||||||
if(NULL == p_config->p_co_sig)
|
|
||||||
{
|
|
||||||
LOG_E("Failed to allocate memory for CO signal\n");
|
|
||||||
p_config->co_num = 0;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0; i < p_config->co_num; i++)
|
|
||||||
{
|
|
||||||
stru_point_item &point = obj.p_cfg->point.co[i];
|
|
||||||
stru_mms_m_ctrl_signal &co_sig = p_config->p_co_sig[i];
|
|
||||||
|
|
||||||
strncpy(co_sig.sig.saddr, point.saddr.c_str(), sizeof(co_sig.sig.saddr));
|
|
||||||
strncpy(co_sig.sig.desc, point.desc.c_str(), sizeof(co_sig.sig.desc));
|
|
||||||
co_sig.sig.data_type = point.type;
|
|
||||||
co_sig.sig.vec_p_data.push_back(point.value.vec_p_val[0]);
|
|
||||||
co_sig.ctrl_type = point.ctrl_model;
|
|
||||||
}
|
|
||||||
|
|
||||||
p_config->ao_num = obj.p_cfg->point.ao.size();
|
|
||||||
p_config->p_ao_sig = new stru_mms_m_param_signal[p_config->ao_num];
|
|
||||||
if(NULL == p_config->p_ao_sig)
|
|
||||||
{
|
|
||||||
LOG_E("Failed to allocate memory for AO signal\n");
|
|
||||||
p_config->ao_num = 0;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0; i < p_config->ao_num; i++)
|
|
||||||
{
|
|
||||||
stru_point_item &point = obj.p_cfg->point.ao[i];
|
|
||||||
stru_mms_m_param_signal &ao_sig = p_config->p_ao_sig[i];
|
|
||||||
|
|
||||||
strncpy(ao_sig.sig.saddr, point.saddr.c_str(), sizeof(ao_sig.sig.saddr));
|
|
||||||
strncpy(ao_sig.sig.desc, point.desc.c_str(), sizeof(ao_sig.sig.desc));
|
|
||||||
ao_sig.sig.data_type = point.type;
|
|
||||||
ao_sig.sig.vec_p_data.push_back(point.value.vec_p_val[0]);
|
|
||||||
ao_sig.vec_p_default.push_back(point.value.vec_p_default[0]);
|
|
||||||
ao_sig.ctrl_type = point.ctrl_model;
|
|
||||||
|
|
||||||
ao_sig.min = point.min_value;
|
|
||||||
ao_sig.max = point.max_value;
|
|
||||||
ao_sig.step = point.step_value;
|
|
||||||
strncpy(ao_sig.unit, point.unit.c_str(), sizeof(ao_sig.unit));
|
|
||||||
}
|
|
||||||
|
|
||||||
p_config->param_num = obj.p_cfg->point.param.size();
|
|
||||||
p_config->p_param_sig = new stru_mms_m_param_signal[p_config->param_num];
|
|
||||||
if(NULL == p_config->p_param_sig)
|
|
||||||
{
|
|
||||||
LOG_E("Failed to allocate memory for PARAM signal\n");
|
|
||||||
p_config->param_num = 0;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0; i < p_config->param_num; i++)
|
|
||||||
{
|
|
||||||
stru_point_item &point = obj.p_cfg->point.param[i];
|
|
||||||
stru_mms_m_param_signal ¶m_sig = p_config->p_param_sig[i];
|
|
||||||
|
|
||||||
strncpy(param_sig.sig.saddr, point.saddr.c_str(), sizeof(param_sig.sig.saddr));
|
|
||||||
strncpy(param_sig.sig.desc, point.desc.c_str(), sizeof(param_sig.sig.desc));
|
|
||||||
param_sig.sig.data_type = point.type;
|
|
||||||
|
|
||||||
param_sig.ctrl_type = point.ctrl_model;
|
|
||||||
|
|
||||||
param_sig.min = point.min_value;
|
|
||||||
param_sig.max = point.max_value;
|
|
||||||
param_sig.step = point.step_value;
|
|
||||||
strncpy(param_sig.unit, point.unit.c_str(), sizeof(param_sig.unit));
|
|
||||||
|
|
||||||
for(size_t j = 0; j < point.value.vec_p_val.size(); j++)
|
|
||||||
{
|
|
||||||
param_sig.sig.vec_p_data.push_back(point.value.vec_p_val[j]);
|
|
||||||
param_sig.vec_p_default.push_back(point.value.vec_p_default[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int mms_m_out_get_connect_status(int app_fd, mms_m_out_status_cb p_func)
|
int mms_m_out_get_connect_status(int app_fd, mms_m_out_status_cb p_func)
|
||||||
{
|
{
|
||||||
if(g_mms_m_obj_map.find(app_fd) == g_mms_m_obj_map.end())
|
if(g_mms_m_obj_map.find(app_fd) == g_mms_m_obj_map.end())
|
||||||
|
|
|
||||||
|
|
@ -1,455 +0,0 @@
|
||||||
#include "mms_m_parse_cfg.h"
|
|
||||||
#include "mms_m.h"
|
|
||||||
#include "tinyxml2.h"
|
|
||||||
|
|
||||||
|
|
||||||
static const char *ELE_Root = "Root";
|
|
||||||
static const char *ELE_Para = "Para";
|
|
||||||
static const char *ELE_Point = "Point";
|
|
||||||
static const char *ELE_St = "St";
|
|
||||||
static const char *ELE_Mx = "Mx";
|
|
||||||
static const char *ELE_Co = "Co";
|
|
||||||
static const char *ELE_Ao = "Ao";
|
|
||||||
static const char *ELE_Param = "Param";
|
|
||||||
static const char *ELE_Item = "Item";
|
|
||||||
static const char *ELE_SubItem = "SubItem";
|
|
||||||
|
|
||||||
|
|
||||||
static const char *KEY_NO = "no";
|
|
||||||
static const char *KEY_SADDR = "saddr";
|
|
||||||
static const char *KEY_DESC = "desc";
|
|
||||||
static const char *KEY_HOST_IP = "host_ip";
|
|
||||||
static const char *KEY_HOST_PORT = "host_port";
|
|
||||||
static const char *KEY_IED = "ied";
|
|
||||||
static const char *KEY_TYPE = "type";
|
|
||||||
static const char *KEY_CTRL_MODEL = "ctlModel";
|
|
||||||
static const char *KEY_LDEV = "LDev";
|
|
||||||
static const char *KEY_LNODE = "LNode";
|
|
||||||
static const char *KEY_DONAME = "DoName";
|
|
||||||
static const char *KEY_FC = "fc";
|
|
||||||
static const char *KEY_MIN_VAL = "min";
|
|
||||||
static const char *KEY_MAX_VAL = "max";
|
|
||||||
static const char *KEY_STEP_VAL = "step";
|
|
||||||
static const char *KEY_UNIT = "unit";
|
|
||||||
|
|
||||||
static const char *KEY_VAL = "value";
|
|
||||||
static const char *KEY_DEFAULT_VAL = "default";
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int parse_cfg_item(tinyxml2::XMLElement *item, std::vector<stru_point_item> &item_list, const std::string &ied)
|
|
||||||
{
|
|
||||||
if(NULL == item)
|
|
||||||
{
|
|
||||||
LOG_E("item is NULL");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *str = NULL;
|
|
||||||
if(NULL != (str = item->Attribute(KEY_NO)))
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_E("no attribute %s in item", KEY_NO);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(std::vector<stru_point_item>::iterator it = item_list.begin(); it!= item_list.end(); ++it)
|
|
||||||
{
|
|
||||||
if(it->no == atoi(str))
|
|
||||||
{
|
|
||||||
LOG_E("item no %s already exists", str);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stru_point_item item_info;
|
|
||||||
item_info.no = atoi(str);
|
|
||||||
|
|
||||||
if(NULL != (str = item->Attribute(KEY_SADDR)))
|
|
||||||
{
|
|
||||||
item_info.saddr = str;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_E("no attribute %s in item", KEY_SADDR);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (str = item->Attribute(KEY_DESC)))
|
|
||||||
{
|
|
||||||
item_info.desc = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (str = item->Attribute(KEY_LDEV)))
|
|
||||||
{
|
|
||||||
item_info.ldev = str;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_E("no attribute %s in item", KEY_LDEV);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (str = item->Attribute(KEY_LNODE)))
|
|
||||||
{
|
|
||||||
item_info.lnode = str;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_E("no attribute %s in item", KEY_LNODE);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (str = item->Attribute(KEY_DONAME)))
|
|
||||||
{
|
|
||||||
item_info.doname = str;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_E("no attribute %s in item", KEY_DONAME);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (str = item->Attribute(KEY_FC)))
|
|
||||||
{
|
|
||||||
item_info.fc = atoi(str);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_E("no attribute %s in item", KEY_FC);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (str = item->Attribute(KEY_TYPE)))
|
|
||||||
{
|
|
||||||
item_info.type = atoi(str);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_E("no attribute %s in item", KEY_TYPE);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (str = item->Attribute(KEY_CTRL_MODEL)))
|
|
||||||
{
|
|
||||||
item_info.ctrl_model = atoi(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (str = item->Attribute(KEY_MIN_VAL)))
|
|
||||||
{
|
|
||||||
item_info.min_value = atof(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (str = item->Attribute(KEY_MAX_VAL)))
|
|
||||||
{
|
|
||||||
item_info.max_value = atof(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (str = item->Attribute(KEY_STEP_VAL)))
|
|
||||||
{
|
|
||||||
item_info.step_value = atof(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (str = item->Attribute(KEY_UNIT)))
|
|
||||||
{
|
|
||||||
item_info.unit = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
item_info.reference = ied + item_info.ldev + "/" + item_info.lnode + "." + item_info.doname;
|
|
||||||
|
|
||||||
item_list.push_back(item_info);
|
|
||||||
|
|
||||||
item_list.back().set_value = NULL;
|
|
||||||
item_list.back().control = NULL;
|
|
||||||
|
|
||||||
// stru_point_item *p_item = &item_list.back();
|
|
||||||
|
|
||||||
// p_item->value.p_val = mms_m_create_data_ptr(p_item->type);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int parse_cfg_para(tinyxml2::XMLElement *para, stru_para_page ¶_page, std::string &ied)
|
|
||||||
{
|
|
||||||
if (NULL == para)
|
|
||||||
{
|
|
||||||
LOG_E("para is NULL");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
const char *str = NULL;
|
|
||||||
|
|
||||||
if(NULL != (str = para->Attribute(KEY_DESC)))
|
|
||||||
{
|
|
||||||
para_page.desc = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (str = para->Attribute(KEY_HOST_IP)))
|
|
||||||
{
|
|
||||||
para_page.host_ip = str;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_E("no attribute %s in para", KEY_HOST_IP);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (str = para->Attribute(KEY_HOST_PORT)))
|
|
||||||
{
|
|
||||||
para_page.host_port = atoi(str);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_E("no attribute %s in para", KEY_HOST_PORT);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (str = para->Attribute(KEY_IED)))
|
|
||||||
{
|
|
||||||
para_page.ied = str;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_E("no attribute %s in para", KEY_IED);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ied = para_page.ied;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int parse_cfg_point(tinyxml2::XMLElement *point, stru_point_page &point_page, const std::string &ied)
|
|
||||||
{
|
|
||||||
if(NULL == point)
|
|
||||||
{
|
|
||||||
LOG_E("point is NULL");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
tinyxml2::XMLElement *st, *mx, *co, *ao, *param, *item = NULL, *sub_item = NULL;
|
|
||||||
|
|
||||||
if(NULL != (st = point->FirstChildElement(ELE_St)))
|
|
||||||
{
|
|
||||||
for(item = st->FirstChildElement(ELE_Item); item; item = item->NextSiblingElement(ELE_Item))
|
|
||||||
{
|
|
||||||
if(parse_cfg_item(item, point_page.st, ied) != 0)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
point_page.st.back().value.vec_p_val.push_back(mms_m_create_data_ptr(point_page.st.back().type));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (mx = point->FirstChildElement(ELE_Mx)))
|
|
||||||
{
|
|
||||||
for(item = mx->FirstChildElement(ELE_Item); item; item = item->NextSiblingElement(ELE_Item))
|
|
||||||
{
|
|
||||||
if(parse_cfg_item(item, point_page.mx, ied) != 0)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
point_page.mx.back().value.vec_p_val.push_back(mms_m_create_data_ptr(point_page.mx.back().type));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (co = point->FirstChildElement(ELE_Co)))
|
|
||||||
{
|
|
||||||
for(item = co->FirstChildElement(ELE_Item); item; item = item->NextSiblingElement(ELE_Item))
|
|
||||||
{
|
|
||||||
if(parse_cfg_item(item, point_page.co, ied) != 0)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
point_page.co.back().value.vec_p_val.push_back(mms_m_create_data_ptr(point_page.co.back().type));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (ao = point->FirstChildElement(ELE_Ao)))
|
|
||||||
{
|
|
||||||
for(item = ao->FirstChildElement(ELE_Item); item; item = item->NextSiblingElement(ELE_Item))
|
|
||||||
{
|
|
||||||
if(parse_cfg_item(item, point_page.ao, ied) != 0)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
point_page.ao.back().value.vec_p_val.push_back(mms_m_create_data_ptr(point_page.ao.back().type));
|
|
||||||
point_page.ao.back().value.vec_p_default.push_back(mms_m_create_data_ptr(point_page.ao.back().type));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != (param = point->FirstChildElement(ELE_Param)))
|
|
||||||
{
|
|
||||||
for(item = param->FirstChildElement(ELE_Item); item; item = item->NextSiblingElement(ELE_Item))
|
|
||||||
{
|
|
||||||
if(parse_cfg_item(item, point_page.param, ied) != 0)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(sub_item = item->FirstChildElement(ELE_SubItem); sub_item; sub_item = sub_item->NextSiblingElement(ELE_SubItem))
|
|
||||||
{
|
|
||||||
const char *val = sub_item->Attribute(KEY_VAL);
|
|
||||||
const char *def = sub_item->Attribute(KEY_DEFAULT_VAL);
|
|
||||||
|
|
||||||
void *p_val = mms_m_create_data_ptr(point_page.param.back().type);
|
|
||||||
void *p_def = mms_m_create_data_ptr(point_page.param.back().type);
|
|
||||||
|
|
||||||
if(NULL != val)
|
|
||||||
{
|
|
||||||
mms_m_set_data_by_str(p_val, point_page.param.back().type, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(NULL != def)
|
|
||||||
{
|
|
||||||
mms_m_set_data_by_str(p_def, point_page.param.back().type, def);
|
|
||||||
}
|
|
||||||
|
|
||||||
point_page.param.back().value.vec_p_default.push_back(p_def);
|
|
||||||
point_page.param.back().value.vec_p_val.push_back(p_val);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
stru_cfg *parse_cfg(const std::string &cfg_file)
|
|
||||||
{
|
|
||||||
if (cfg_file.empty())
|
|
||||||
{
|
|
||||||
LOG_E("cfg_file is empty");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
stru_cfg *p_cfg = new stru_cfg;
|
|
||||||
if (NULL == p_cfg)
|
|
||||||
{
|
|
||||||
LOG_E("create cfg struct failed");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(p_cfg, 0, sizeof(stru_cfg));
|
|
||||||
|
|
||||||
if(NULL == strstr(cfg_file.c_str(), ".xml"))
|
|
||||||
{
|
|
||||||
LOG_E("cfg_file is not an xml file");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ied = "";
|
|
||||||
tinyxml2::XMLDocument doc;
|
|
||||||
tinyxml2::XMLElement *root, *para, *point;
|
|
||||||
tinyxml2::XMLError err = doc.LoadFile(cfg_file.c_str());
|
|
||||||
if (err != tinyxml2::XML_SUCCESS)
|
|
||||||
{
|
|
||||||
LOG_E("load cfg file %s failed, error code: %d", cfg_file.c_str(), err);
|
|
||||||
goto EXIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
root = doc.FirstChildElement(ELE_Root);
|
|
||||||
if (NULL == root)
|
|
||||||
{
|
|
||||||
LOG_E("no Root element in cfg file");
|
|
||||||
goto EXIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
para = root->FirstChildElement(ELE_Para);
|
|
||||||
if (NULL == para)
|
|
||||||
{
|
|
||||||
LOG_E("no Para element in cfg file");
|
|
||||||
goto EXIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(0 != parse_cfg_para(para, p_cfg->para, ied))
|
|
||||||
{
|
|
||||||
LOG_E("parse Para element in cfg file failed");
|
|
||||||
goto EXIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
point = root->FirstChildElement(ELE_Point);
|
|
||||||
if (NULL == point)
|
|
||||||
{
|
|
||||||
LOG_E("no Point element in cfg file");
|
|
||||||
goto EXIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(0 != parse_cfg_point(point, p_cfg->point, ied))
|
|
||||||
{
|
|
||||||
LOG_E("parse Point element in cfg file failed");
|
|
||||||
goto EXIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
doc.Clear();
|
|
||||||
return p_cfg;
|
|
||||||
|
|
||||||
EXIT:
|
|
||||||
delete p_cfg;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void parse_show_cfg(stru_cfg *p_cfg)
|
|
||||||
{
|
|
||||||
if (NULL == p_cfg)
|
|
||||||
{
|
|
||||||
LOG_E("p_cfg is NULL");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Para-%s: ip %s, port %d, ied %s\n",
|
|
||||||
p_cfg->para.desc.c_str(), p_cfg->para.host_ip.c_str(), p_cfg->para.host_port, p_cfg->para.ied.c_str());
|
|
||||||
|
|
||||||
printf("Point-%s:\n", p_cfg->point.desc.c_str());
|
|
||||||
printf("St-num %ld:\n", p_cfg->point.st.size());
|
|
||||||
std::vector<stru_point_item>::iterator it;
|
|
||||||
for(it = p_cfg->point.st.begin(); it!= p_cfg->point.st.end(); ++it)
|
|
||||||
{
|
|
||||||
printf(" no %d, type %d, fc %d, saddr %s, desc %s, ldev %s, lnode %s, doname %s, reference %s\n",
|
|
||||||
it->no, it->type, it->fc, it->saddr.c_str(), it->desc.c_str(), it->ldev.c_str(), it->lnode.c_str(), it->doname.c_str(), it->reference.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Mx-num %ld:\n", p_cfg->point.mx.size());
|
|
||||||
for(it = p_cfg->point.mx.begin(); it!= p_cfg->point.mx.end(); ++it)
|
|
||||||
{
|
|
||||||
printf(" no %d, type %d, fc %d, saddr %s, desc %s, ldev %s, lnode %s, doname %s, reference %s\n",
|
|
||||||
it->no, it->type, it->fc, it->saddr.c_str(), it->desc.c_str(), it->ldev.c_str(), it->lnode.c_str(), it->doname.c_str(), it->reference.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Co-num %ld:\n", p_cfg->point.co.size());
|
|
||||||
for(it = p_cfg->point.co.begin(); it!= p_cfg->point.co.end(); ++it)
|
|
||||||
{
|
|
||||||
printf(" no %d, type %d, fc %d, ctrl_model %d, saddr %s, desc %s, ldev %s, lnode %s, doname %s, reference %s\n",
|
|
||||||
it->no, it->type, it->fc, it->ctrl_model, it->saddr.c_str(), it->desc.c_str(), it->ldev.c_str(), it->lnode.c_str(), it->doname.c_str(), it->reference.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Ao-num %ld:\n", p_cfg->point.ao.size());
|
|
||||||
for(it = p_cfg->point.ao.begin(); it != p_cfg->point.ao.end(); ++it)
|
|
||||||
{
|
|
||||||
printf(" no %d, type %d, fc %d, saddr %s, desc %s, ldev %s, lnode %s, doname %s, reference %s\n",
|
|
||||||
it->no, it->type, it->fc, it->saddr.c_str(), it->desc.c_str(), it->ldev.c_str(), it->lnode.c_str(), it->doname.c_str(), it->reference.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -157,7 +157,7 @@ void dc_param_cfg_parse()
|
||||||
|
|
||||||
dc_signal_param(saddr, desc, data_type, param,
|
dc_signal_param(saddr, desc, data_type, param,
|
||||||
SIGNAL_CTRL_TYPE::SBO_NORMAL,
|
SIGNAL_CTRL_TYPE::SBO_NORMAL,
|
||||||
vec_p_data, vec_p_default_data, nullptr);
|
vec_p_data.data(), vec_p_default_data.data(), num, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -413,7 +413,7 @@ LOCAL bool dc_signal_ao_add_check(stru_signal *p_signal, const std::string &desc
|
||||||
return change;
|
return change;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOCAL bool dc_signal_param_add_check(stru_signal *p_signal, const std::string &desc, uint8_t data_type, const stru_signal_param ¶m, uint8_t ctrl_type, std::vector<void *> &vec_p_default_data)
|
LOCAL bool dc_signal_param_add_check(stru_signal *p_signal, const std::string &desc, uint8_t data_type, const stru_signal_param ¶m, uint8_t ctrl_type, void **p_default_data, uint8_t num)
|
||||||
{
|
{
|
||||||
bool change = false;
|
bool change = false;
|
||||||
|
|
||||||
|
|
@ -441,9 +441,9 @@ LOCAL bool dc_signal_param_add_check(stru_signal *p_signal, const std::string &d
|
||||||
change = true;
|
change = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(size_t i = 0; i < vec_p_default_data.size(); i++)
|
for(size_t i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
if(0 != dc_data_compare(p_signal->data_type, vec_p_default_data[i], p_signal->vec_p_default_data[i]))
|
if(0 != dc_data_compare(p_signal->data_type, p_default_data[i], p_signal->vec_p_default_data[i]))
|
||||||
{
|
{
|
||||||
change = true;
|
change = true;
|
||||||
}
|
}
|
||||||
|
|
@ -1263,23 +1263,23 @@ int dc_signal_ao_set_val_without_check(const std::string &saddr, uint8_t data_ty
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dc_signal_param(const std::string &saddr, const std::string &desc, uint8_t data_type, const stru_signal_param ¶m, uint8_t ctrl_type, std::vector<void *> &vec_p_data, std::vector<void *> &vec_p_default_data, signal_change_cb cb)
|
int dc_signal_param(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, int data_num, signal_change_cb cb)
|
||||||
{
|
{
|
||||||
// 先从参数表里解析,调用参数注册
|
// 先从参数表里解析,调用参数注册
|
||||||
// 程序注册时,从参数表里去查找,同一个信息,使用参数表中的保存的数据值,在线程初始化时,通知所有链接此信号的信号
|
// 程序注册时,从参数表里去查找,同一个信息,使用参数表中的保存的数据值,在线程初始化时,通知所有链接此信号的信号
|
||||||
// 注册时不在参数表中的,新增到动态表里,并保存到参数表里,使用缺省值
|
// 注册时不在参数表中的,新增到动态表里,并保存到参数表里,使用缺省值
|
||||||
|
|
||||||
if(vec_p_data.size() != vec_p_default_data.size() || vec_p_data.empty())
|
if(0 == data_num)
|
||||||
{
|
{
|
||||||
MY_LOG_E("vec_p_data size %ld, vec_p_default_data size %ld", vec_p_data.size(), vec_p_default_data.size());
|
MY_LOG_E("data_num is 0");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(size_t i = 0; i < vec_p_data.size(); i++)
|
for(int i = 0; i < data_num; i++)
|
||||||
{
|
{
|
||||||
if(vec_p_data[i] == nullptr || vec_p_default_data[i] == nullptr)
|
if(p_data[i] == nullptr || p_default_data[i] == nullptr)
|
||||||
{
|
{
|
||||||
MY_LOG_E("vec_p_data[%ld] or vec_p_default_data[%ld] is nullptr", i, i);
|
MY_LOG_E("p_data[%d] or p_default_data[%d] is nullptr", i, i);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1289,19 +1289,19 @@ int dc_signal_param(const std::string &saddr, const std::string &desc, uint8_t d
|
||||||
if(p_signal != nullptr)
|
if(p_signal != nullptr)
|
||||||
{
|
{
|
||||||
// dc_set_signal_val(p_data, data_type, p_signal->p_data);
|
// dc_set_signal_val(p_data, data_type, p_signal->p_data);
|
||||||
if(true == dc_signal_param_add_check(p_signal, desc, data_type, param, ctrl_type, vec_p_default_data))
|
if(true == dc_signal_param_add_check(p_signal, desc, data_type, param, ctrl_type, p_default_data, data_num))
|
||||||
{
|
{
|
||||||
dc_set_param_cfg_change(true);
|
dc_set_param_cfg_change(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i < vec_p_data.size(); i++)
|
for(size_t i = 0; i < data_num; i++)
|
||||||
{
|
{
|
||||||
dc_set_signal_val(vec_p_data[i], data_type, p_signal->vec_p_data[i]);
|
dc_set_signal_val(p_data[i], data_type, p_signal->vec_p_data[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(size_t i = 0; i < vec_p_data.size(); i++)
|
for(size_t i = 0; i < data_num; i++)
|
||||||
{
|
{
|
||||||
// delete p_signal->vec_p_data[i];
|
// delete p_signal->vec_p_data[i];
|
||||||
dc_delete_signal_data(p_signal->vec_p_data[i], data_type);
|
dc_delete_signal_data(p_signal->vec_p_data[i], data_type);
|
||||||
|
|
@ -1312,10 +1312,10 @@ int dc_signal_param(const std::string &saddr, const std::string &desc, uint8_t d
|
||||||
p_signal->vec_p_data.clear();
|
p_signal->vec_p_data.clear();
|
||||||
p_signal->vec_p_default_data.clear();
|
p_signal->vec_p_default_data.clear();
|
||||||
|
|
||||||
for(size_t i = 0; i < vec_p_data.size(); i++)
|
for(size_t i = 0; i < data_num; i++)
|
||||||
{
|
{
|
||||||
p_signal->vec_p_data.push_back(vec_p_data[i]);
|
p_signal->vec_p_data.push_back(p_data[i]);
|
||||||
p_signal->vec_p_default_data.push_back(vec_p_default_data[i]);
|
p_signal->vec_p_default_data.push_back(p_default_data[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
p_signal->change_cb_list.push_back(cb);
|
p_signal->change_cb_list.push_back(cb);
|
||||||
|
|
@ -1337,10 +1337,10 @@ int dc_signal_param(const std::string &saddr, const std::string &desc, uint8_t d
|
||||||
p_signal = dc_find_signal(saddr, g_datacenter.signal_param);
|
p_signal = dc_find_signal(saddr, g_datacenter.signal_param);
|
||||||
if(p_signal != nullptr )
|
if(p_signal != nullptr )
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i < vec_p_data.size(); i++)
|
for(size_t i = 0; i < data_num; i++)
|
||||||
{
|
{
|
||||||
p_signal->vec_p_data.push_back(vec_p_data[i]);
|
p_signal->vec_p_data.push_back(p_data[i]);
|
||||||
p_signal->vec_p_default_data.push_back(vec_p_default_data[i]);
|
p_signal->vec_p_default_data.push_back(p_default_data[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cb)
|
if(cb)
|
||||||
|
|
@ -1353,27 +1353,20 @@ int dc_signal_param(const std::string &saddr, const std::string &desc, uint8_t d
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dc_signal_param_link_with_callback(const std::string &saddr, std::vector<void *> &vec_p_data, signal_change_cb cb)
|
int dc_signal_param_link_with_callback(const std::string &saddr, void **p_data, int data_num, signal_change_cb cb)
|
||||||
{
|
{
|
||||||
XXH128_hash_t hash = XXH3_128bits(saddr.c_str(), saddr.length());
|
XXH128_hash_t hash = XXH3_128bits(saddr.c_str(), saddr.length());
|
||||||
stru_signal *p_signal = dc_find_signal(saddr, g_datacenter.signal_param);
|
stru_signal *p_signal = dc_find_signal(saddr, g_datacenter.signal_param);
|
||||||
if(p_signal != nullptr)
|
if(p_signal != nullptr)
|
||||||
{
|
{
|
||||||
// if(p_signal->data_type != data_type)
|
|
||||||
// {
|
|
||||||
// LOG_E("saddr %s data type %s(%d) not match %s(%d)",
|
|
||||||
// saddr.c_str(), dc_get_data_type_str_by_id(p_signal->data_type), p_signal->data_type, dc_get_data_type_str_by_id(data_type), data_type);
|
|
||||||
// return -1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if(cb)
|
if(cb)
|
||||||
{
|
{
|
||||||
p_signal->change_cb_list.push_back(cb);
|
p_signal->change_cb_list.push_back(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(size_t i = 0; i < vec_p_data.size(); i++)
|
for(size_t i = 0; i < p_signal->vec_p_data.size() && i < data_num; i++)
|
||||||
{
|
{
|
||||||
vec_p_data.push_back(p_signal->vec_p_data[i]);
|
p_data[i] = p_signal->vec_p_data[i];
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
#include "myBase.h"
|
||||||
|
#include "myMms_m.h"
|
||||||
|
|
||||||
|
stru_cfg *parse_cfg(const std::string &cfg_file);
|
||||||
|
void show_cfg(stru_cfg &cfg);
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include "myCmd.h"
|
#include "myCmd.h"
|
||||||
#include "iec61850_client.h"
|
#include "iec61850_client.h"
|
||||||
#include "myDatacenter.h"
|
#include "myDatacenter.h"
|
||||||
|
#include "parse_xml.h"
|
||||||
|
|
||||||
|
|
||||||
LOCAL void mms_event_back(void *arg, int ret);
|
LOCAL void mms_event_back(void *arg, int ret);
|
||||||
|
|
@ -16,7 +17,7 @@ typedef struct
|
||||||
int debug;
|
int debug;
|
||||||
uint32_t connectionTimeout; // 61850库默认10000
|
uint32_t connectionTimeout; // 61850库默认10000
|
||||||
stru_mms_m_event mms_event;
|
stru_mms_m_event mms_event;
|
||||||
stru_mms_m_config mms_config;
|
stru_cfg *p_cfg;
|
||||||
}stru_iec61850m_info;;
|
}stru_iec61850m_info;;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -24,12 +25,13 @@ LOCAL std::vector<stru_iec61850m_info> g_vec_iec61850m_info =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
.fd = -1,
|
.fd = -1,
|
||||||
.prj_name = "prj.xml",
|
.prj_name = "mms_m.xml",
|
||||||
.debug = MMS_M_DEBUG_PRINT_OFF,
|
.debug = MMS_M_DEBUG_PRINT_OFF,
|
||||||
.connectionTimeout = 10000,
|
.connectionTimeout = 10000,
|
||||||
.mms_event = {
|
.mms_event = {
|
||||||
.p_func = mms_event_back,
|
.p_func = mms_event_back,
|
||||||
}
|
},
|
||||||
|
.p_cfg = NULL,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -134,25 +136,29 @@ LOCAL void mms_data_back(stru_mms_m_out_value *p)
|
||||||
|
|
||||||
for(uint32_t i = 0; i < g_vec_iec61850m_info.size(); i++)
|
for(uint32_t i = 0; i < g_vec_iec61850m_info.size(); i++)
|
||||||
{
|
{
|
||||||
if(g_vec_iec61850m_info[i].fd == p->app_fd)
|
if(g_vec_iec61850m_info[i].fd == p->app_fd && NULL != g_vec_iec61850m_info[i].p_cfg)
|
||||||
{
|
{
|
||||||
stru_mms_m_config *p_config = &g_vec_iec61850m_info[i].mms_config;
|
stru_cfg *p_cfg = g_vec_iec61850m_info[i].p_cfg;
|
||||||
for(uint32_t j = 0; j < p_config->st_num; j++)
|
for(uint32_t j = 0; j < p_cfg->point.st_num; j++)
|
||||||
{
|
{
|
||||||
if(strcmp(p_config->p_st_sig[j].saddr, p->name) == 0)
|
if(strcmp(p_cfg->point.p_st[j].saddr, p->name) == 0 && NULL != p_cfg->point.p_st[j].value.p_val[0])
|
||||||
{
|
{
|
||||||
*(uint8_t *)p_config->p_st_sig[j].vec_p_data[0] = MY_GET_DATA_WITH_TYPE(p->p_value, uint8_t);
|
// *(uint8_t *)p_cfg->point.p_st[j].value.p_val[0] = MY_GET_DATA_WITH_TYPE(p->p_value, uint8_t);
|
||||||
|
|
||||||
|
dc_set_out_signal_val(p_cfg->point.p_st[j].saddr, p->p_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uint32_t j = 0; j < p_config->mx_num; j++)
|
for(uint32_t j = 0; j < p_cfg->point.mx_num; j++)
|
||||||
{
|
{
|
||||||
if(strcmp(p_config->p_mx_sig[j].saddr, p->name) == 0)
|
if(strcmp(p_cfg->point.p_mx[j].saddr, p->name) == 0 && NULL != p_cfg->point.p_mx[j].value.p_val[0])
|
||||||
{
|
{
|
||||||
if(p->type == MMS_FLOAT)
|
// if(p->type == MMS_FLOAT)
|
||||||
*(float *)p_config->p_mx_sig[j].vec_p_data[0] = MY_GET_DATA_WITH_TYPE(p->p_value, float);
|
// *(float *)p_cfg->point.p_mx[j].value.p_val[0] = MY_GET_DATA_WITH_TYPE(p->p_value, float);
|
||||||
else if(p->type == MMS_INTEGER)
|
// else if(p->type == MMS_INTEGER)
|
||||||
*(int32_t *)p_config->p_mx_sig[j].vec_p_data[0] = MY_GET_DATA_WITH_TYPE(p->p_value, int32_t);
|
// *(int32_t *)p_cfg->point.p_mx[j].value.p_val[0] = MY_GET_DATA_WITH_TYPE(p->p_value, int32_t);
|
||||||
|
|
||||||
|
dc_set_out_signal_val(p_cfg->point.p_mx[j].saddr, p->p_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -180,25 +186,6 @@ LOCAL void iec61850m_connect_status(int fd, int status)
|
||||||
LOG_I("iec61850m_connect_status, fd %d, prj_name %s, status %s", fd, prj_name.c_str(), status == MMS_M_ON_LINE? "ON_LINE" : "OFF_LINE");
|
LOG_I("iec61850m_connect_status, fd %d, prj_name %s, status %s", fd, prj_name.c_str(), status == MMS_M_ON_LINE? "ON_LINE" : "OFF_LINE");
|
||||||
}
|
}
|
||||||
|
|
||||||
void iec61850m_init()
|
|
||||||
{
|
|
||||||
for(int i = 0; i < g_vec_iec61850m_info.size(); i++)
|
|
||||||
{
|
|
||||||
stru_iec61850m_info *p_info = &g_vec_iec61850m_info[i];
|
|
||||||
|
|
||||||
std::string cfg_path = g_61850m_prj_path + std::string(p_info->prj_name);
|
|
||||||
p_info->fd = mms_m_out_init(cfg_path.c_str(), p_info->debug, p_info->connectionTimeout);
|
|
||||||
if(p_info->fd < 0)
|
|
||||||
{
|
|
||||||
LOG_E("mms_m_out_init failed, fd %d, no %d, prj_name %s", p_info->fd, i, p_info->prj_name);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_I("mms_m_out_init success, fd %d, no %d, prj_name %s", p_info->fd, i, p_info->prj_name);
|
|
||||||
mms_m_out_get_value(p_info->fd, mms_data_back);
|
|
||||||
mms_m_out_get_connect_status(p_info->fd, iec61850m_connect_status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
LOCAL int iec61850m_signal_change_decode(std::string saddr, SIGNAL_CTRL_STEP step, uint8_t data_type, void *p_data, uint8_t &ctrl_type, uint8_t &mms_type, std::string signal_type)
|
LOCAL int iec61850m_signal_change_decode(std::string saddr, SIGNAL_CTRL_STEP step, uint8_t data_type, void *p_data, uint8_t &ctrl_type, uint8_t &mms_type, std::string signal_type)
|
||||||
|
|
@ -270,11 +257,11 @@ LOCAL void iec61850m_signal_co_change_callback(std::string saddr, SIGNAL_CTRL_ST
|
||||||
for(int i = 0; i < g_vec_iec61850m_info.size(); i++)
|
for(int i = 0; i < g_vec_iec61850m_info.size(); i++)
|
||||||
{
|
{
|
||||||
stru_iec61850m_info *p_info = &g_vec_iec61850m_info[i];
|
stru_iec61850m_info *p_info = &g_vec_iec61850m_info[i];
|
||||||
stru_mms_m_config *p_config = &p_info->mms_config;
|
stru_cfg *p_cfg = p_info->p_cfg;
|
||||||
|
|
||||||
for(uint16_t j = 0; j < p_config->co_num; j++)
|
for(uint16_t j = 0; NULL != p_cfg && p_cfg->point.p_co && j < p_cfg->point.co_num; j++)
|
||||||
{
|
{
|
||||||
if(p_config->p_co_sig[j].sig.saddr == saddr)
|
if(p_cfg->point.p_co[j].saddr == saddr && NULL != p_cfg->point.p_co[j].value.p_val[0])
|
||||||
{
|
{
|
||||||
std::string val = dc_get_signal_val(p_data, data_type);
|
std::string val = dc_get_signal_val(p_data, data_type);
|
||||||
MY_LOG_I("iec61850m_signal_change_callback val %s, ctrl_type %d", val.c_str(), ctrl_type);
|
MY_LOG_I("iec61850m_signal_change_callback val %s, ctrl_type %d", val.c_str(), ctrl_type);
|
||||||
|
|
@ -302,11 +289,11 @@ LOCAL void iec61850m_signal_ao_change_callback(std::string saddr, SIGNAL_CTRL_ST
|
||||||
for(int i = 0; i < g_vec_iec61850m_info.size(); i++)
|
for(int i = 0; i < g_vec_iec61850m_info.size(); i++)
|
||||||
{
|
{
|
||||||
stru_iec61850m_info *p_info = &g_vec_iec61850m_info[i];
|
stru_iec61850m_info *p_info = &g_vec_iec61850m_info[i];
|
||||||
stru_mms_m_config *p_config = &p_info->mms_config;
|
stru_cfg *p_cfg = p_info->p_cfg;
|
||||||
|
|
||||||
for(uint16_t j = 0; j < p_config->ao_num; j++)
|
for(uint16_t j = 0; NULL != p_cfg && p_cfg->point.p_ao && j < p_cfg->point.ao_num; j++)
|
||||||
{
|
{
|
||||||
if(p_config->p_ao_sig[j].sig.saddr == saddr)
|
if(p_cfg->point.p_ao[j].saddr == saddr && NULL != p_cfg->point.p_ao[j].value.p_val[0])
|
||||||
{
|
{
|
||||||
std::string val = dc_get_signal_val(p_data, data_type);
|
std::string val = dc_get_signal_val(p_data, data_type);
|
||||||
MY_LOG_I("iec61850m_signal_change_callback val %s, ctrl_type %d, mms_type %d", val.c_str(), ctrl_type, mms_type);
|
MY_LOG_I("iec61850m_signal_change_callback val %s, ctrl_type %d, mms_type %d", val.c_str(), ctrl_type, mms_type);
|
||||||
|
|
@ -334,11 +321,11 @@ LOCAL void iec61850m_signal_param_change_callback(std::string saddr, SIGNAL_CTRL
|
||||||
for(int i = 0; i < g_vec_iec61850m_info.size(); i++)
|
for(int i = 0; i < g_vec_iec61850m_info.size(); i++)
|
||||||
{
|
{
|
||||||
stru_iec61850m_info *p_info = &g_vec_iec61850m_info[i];
|
stru_iec61850m_info *p_info = &g_vec_iec61850m_info[i];
|
||||||
stru_mms_m_config *p_config = &p_info->mms_config;
|
stru_cfg *p_cfg = p_info->p_cfg;
|
||||||
|
|
||||||
for(uint16_t j = 0; j < p_config->param_num; j++)
|
for(uint16_t j = 0; NULL != p_cfg && p_cfg->point.p_param && j < p_cfg->point.param_num; j++)
|
||||||
{
|
{
|
||||||
if(p_config->p_param_sig[j].sig.saddr == saddr)
|
if(p_cfg->point.p_param[j].saddr == saddr && NULL != p_cfg->point.p_param[j].value.p_val[0])
|
||||||
{
|
{
|
||||||
std::string val = dc_get_signal_val(p_data, data_type);
|
std::string val = dc_get_signal_val(p_data, data_type);
|
||||||
MY_LOG_I("iec61850m_signal_change_callback val %s, ctrl_type %d", val.c_str(), ctrl_type);
|
MY_LOG_I("iec61850m_signal_change_callback val %s, ctrl_type %d", val.c_str(), ctrl_type);
|
||||||
|
|
@ -349,164 +336,246 @@ LOCAL void iec61850m_signal_param_change_callback(std::string saddr, SIGNAL_CTRL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LOCAL int iec61850m_st_mx_signal_init(int num, stru_point_item *p_item)
|
||||||
int iec61850m_signal_init(stru_mms_m_config &cfg)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
stru_point_item *p = nullptr;
|
||||||
|
|
||||||
for(uint16_t i = 0; i < cfg.st_num; i++)
|
for(int i = 0; p_item && i < num; i++)
|
||||||
{
|
{
|
||||||
uint8_t type_local = g_mms_m_type_to_local_type[cfg.p_st_sig[i].data_type];
|
p = &p_item[i];
|
||||||
|
if(g_mms_m_type_to_local_type.find(p->type) == g_mms_m_type_to_local_type.end())
|
||||||
std::string saddr = cfg.p_st_sig[i].saddr;
|
|
||||||
std::string desc = cfg.p_st_sig[i].desc;
|
|
||||||
void *p_data = cfg.p_st_sig[i].vec_p_data.empty() ? nullptr : cfg.p_st_sig[i].vec_p_data[0];
|
|
||||||
if(p_data == nullptr)
|
|
||||||
{
|
{
|
||||||
MY_LOG_E("st saddr %s, desc %s, p_data %p", saddr.c_str(), desc.c_str(), p_data);
|
MY_LOG_E("g_mms_m_type_to_local_type not found, type %d", p->type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret |= dc_signal_out(saddr, desc, type_local, p_data);
|
if(NULL == p->value.p_val[0])
|
||||||
}
|
|
||||||
|
|
||||||
if(ret != 0)
|
|
||||||
{
|
|
||||||
LOG_E("dc_signal_out failed, ret %d", ret);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(uint16_t i = 0; i < cfg.mx_num; i++)
|
|
||||||
{
|
|
||||||
uint8_t type_local = g_mms_m_type_to_local_type[cfg.p_mx_sig[i].data_type];
|
|
||||||
|
|
||||||
void *p_data = cfg.p_mx_sig[i].vec_p_data.empty() ? nullptr : cfg.p_mx_sig[i].vec_p_data[0];
|
|
||||||
if(p_data == nullptr)
|
|
||||||
{
|
{
|
||||||
MY_LOG_E("mx saddr %s, desc %s, p_data %p", cfg.p_mx_sig[i].saddr, cfg.p_mx_sig[i].desc, p_data);
|
MY_LOG_E("p->value.p_val[0] is null, type %d", p->type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret |= dc_signal_out(cfg.p_mx_sig[i].saddr, cfg.p_mx_sig[i].desc, type_local, p_data);
|
uint8_t local_type = g_mms_m_type_to_local_type[p->type];
|
||||||
}
|
if(0 != dc_signal_out(p->saddr, p->desc, local_type, p->value.p_val[0]))
|
||||||
|
|
||||||
if(ret != 0)
|
|
||||||
{
|
|
||||||
LOG_E("dc_signal_out failed, ret %d", ret);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(uint16_t i = 0; i < cfg.co_num; i++)
|
|
||||||
{
|
|
||||||
uint8_t type_local = g_mms_m_type_to_local_type[cfg.p_co_sig[i].sig.data_type];
|
|
||||||
uint8_t ctrl_type_local = g_mms_m_ctrl_type_to_local_ctrl_type[cfg.p_co_sig[i].ctrl_type];
|
|
||||||
|
|
||||||
void *p_data = cfg.p_co_sig[i].sig.vec_p_data.empty() ? nullptr : cfg.p_co_sig[i].sig.vec_p_data[0];
|
|
||||||
if(p_data == nullptr)
|
|
||||||
{
|
{
|
||||||
MY_LOG_E("co saddr %s, desc %s, p_data %p", cfg.p_co_sig[i].sig.saddr, cfg.p_co_sig[i].sig.desc, p_data);
|
MY_LOG_E("dc_signal_out failed, saddr %s, desc %s, type %d", p->saddr, p->desc, p->type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret |= dc_signal_yk(cfg.p_co_sig[i].sig.saddr, cfg.p_co_sig[i].sig.desc, type_local, ctrl_type_local, p_data, iec61850m_signal_co_change_callback);
|
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(ret != 0)
|
|
||||||
|
LOCAL int iec61850m_co_signal_init(int num, stru_point_item *p_item)
|
||||||
|
{
|
||||||
|
stru_point_item *p = nullptr;
|
||||||
|
for(int i = 0; p_item && i < num; i++)
|
||||||
{
|
{
|
||||||
LOG_E("dc_signal_yk failed, ret %d", ret);
|
p = &p_item[i];
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(uint16_t i = 0; i < cfg.ao_num; i++)
|
if(g_mms_m_type_to_local_type.find(p->type) == g_mms_m_type_to_local_type.end())
|
||||||
{
|
|
||||||
stru_signal_param param;
|
|
||||||
param.min = cfg.p_ao_sig[i].min;
|
|
||||||
param.max = cfg.p_ao_sig[i].max;
|
|
||||||
param.step = cfg.p_ao_sig[i].step;
|
|
||||||
param.unit = cfg.p_ao_sig[i].unit;
|
|
||||||
// param.default_value = cfg.p_ao_sig[i].p_default ? dc_get_signal_val(cfg.p_ao_sig[i].p_default, cfg.p_ao_sig[i].sig.data_type) : "";
|
|
||||||
|
|
||||||
uint8_t type_local = g_mms_m_type_to_local_type[cfg.p_ao_sig[i].sig.data_type];
|
|
||||||
uint8_t ctrl_type_local = g_mms_m_ctrl_type_to_local_ctrl_type[cfg.p_ao_sig[i].ctrl_type];
|
|
||||||
|
|
||||||
void *p_data = cfg.p_ao_sig[i].sig.vec_p_data.empty() ? nullptr : cfg.p_ao_sig[i].sig.vec_p_data[0];
|
|
||||||
void *p_def_data = cfg.p_ao_sig[i].vec_p_default.empty() ? nullptr : cfg.p_ao_sig[i].vec_p_default[0];
|
|
||||||
|
|
||||||
if(p_data == nullptr || p_def_data == nullptr)
|
|
||||||
{
|
{
|
||||||
MY_LOG_E("ao saddr %s, desc %s, p_data %p, p_def_data %p", cfg.p_ao_sig[i].sig.saddr, cfg.p_ao_sig[i].sig.desc, p_data, p_def_data);
|
MY_LOG_E("g_mms_m_type_to_local_type not found, type %d", p->type);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(NULL == p->value.p_val[0])
|
||||||
|
{
|
||||||
|
MY_LOG_E("p->value.p_val[0] is null, type %d", p->type);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
uint8_t local_type = g_mms_m_type_to_local_type[p->type];
|
||||||
|
uint8_t local_ctrl_type = g_mms_m_ctrl_type_to_local_ctrl_type[p->ctrl_model];
|
||||||
|
if(0 != dc_signal_yk(p->saddr, p->desc, local_type, local_ctrl_type, p->value.p_val[0], iec61850m_signal_co_change_callback))
|
||||||
|
{
|
||||||
|
MY_LOG_E("dc_signal_yk failed, saddr %s, desc %s, type %d", p->saddr, p->desc, p->type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret |= dc_signal_ao(cfg.p_ao_sig[i].sig.saddr, cfg.p_ao_sig[i].sig.desc, type_local, param, ctrl_type_local, p_data, p_def_data, iec61850m_signal_ao_change_callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ret != 0)
|
|
||||||
{
|
|
||||||
LOG_E("dc_signal_ao failed, ret %d", ret);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(uint16_t i = 0; i < cfg.param_num; i++)
|
|
||||||
{
|
|
||||||
stru_signal_param param;
|
|
||||||
param.min = cfg.p_param_sig[i].min;
|
|
||||||
param.max = cfg.p_param_sig[i].max;
|
|
||||||
param.step = cfg.p_param_sig[i].step;
|
|
||||||
param.unit = cfg.p_param_sig[i].unit;
|
|
||||||
|
|
||||||
uint8_t type_local = g_mms_m_type_to_local_type[cfg.p_param_sig[i].sig.data_type];
|
|
||||||
uint8_t ctrl_type_local = g_mms_m_ctrl_type_to_local_ctrl_type[cfg.p_param_sig[i].ctrl_type];
|
|
||||||
|
|
||||||
ret |= dc_signal_param(cfg.p_param_sig[i].sig.saddr, cfg.p_param_sig[i].sig.desc, type_local, param, ctrl_type_local, cfg.p_param_sig[i].sig.vec_p_data, cfg.p_param_sig[i].vec_p_default, iec61850m_signal_param_change_callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ret != 0)
|
|
||||||
{
|
|
||||||
LOG_E("dc_signal_param failed, ret %d", ret);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t *p_iec_run_cnt = NULL;
|
LOCAL int iec61850m_ao_signal_init(int num, stru_point_item *p_item)
|
||||||
|
|
||||||
int app_iec61850m_init1(void *arg)
|
|
||||||
{
|
{
|
||||||
iec61850m_init();
|
stru_point_item *p = nullptr;
|
||||||
stru_app *p_app = (stru_app *)arg;
|
|
||||||
|
|
||||||
dc_signal_out("iec61850m.run_cnt", "iec61850m.run_cnt", DATA_TYPE_U32, &p_app->run_cnt);
|
for(int i = 0; p_item && i < num; i++)
|
||||||
|
|
||||||
for(int i = 0; i < g_vec_iec61850m_info.size(); i++)
|
|
||||||
{
|
{
|
||||||
stru_iec61850m_info *p_info = &g_vec_iec61850m_info[i];
|
p = &p_item[i];
|
||||||
stru_mms_m_config *p_config = &p_info->mms_config;
|
|
||||||
|
|
||||||
if(0 != mms_m_out_get_signal_info(p_info->fd, p_config))
|
if(g_mms_m_type_to_local_type.find(p->type) == g_mms_m_type_to_local_type.end())
|
||||||
{
|
{
|
||||||
LOG_E("mms_m_out_get_signal_info failed, fd %d, no %d, prj_name %s", p_info->fd, i, p_info->prj_name);
|
MY_LOG_E("g_mms_m_type_to_local_type not found, type %d", p->type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(0 != iec61850m_signal_init(*p_config))
|
if(NULL == p->value.p_val[0] || NULL == p->value.p_default[0])
|
||||||
{
|
{
|
||||||
LOG_E("iec61850m_signal_init failed, fd %d, no %d, prj_name %s", p_info->fd, i, p_info->prj_name);
|
MY_LOG_E("p->value.p_val[0] or p->value.p_default[0] is null, p_val %p, p_default %p, type %d", p->value.p_val[0], p->value.p_default[0], p->type);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t local_type = g_mms_m_type_to_local_type[p->type];
|
||||||
|
uint8_t ctrl_type = SIGNAL_CTRL_TYPE::DIRECT_NORMAL;
|
||||||
|
stru_signal_param param = {0};
|
||||||
|
|
||||||
|
if(0 != dc_signal_ao(p->saddr, p->desc, local_type, param, ctrl_type, p->value.p_val[0], p->value.p_default[0], iec61850m_signal_ao_change_callback))
|
||||||
|
{
|
||||||
|
MY_LOG_E("dc_signal_ao failed, saddr %s, desc %s, type %d", p->saddr, p->desc, p->type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOCAL int iec61850m_param_signal_init(int num, stru_point_item *p_item)
|
||||||
|
{
|
||||||
|
stru_point_item *p = nullptr;
|
||||||
|
|
||||||
|
for(int i = 0; p_item && i < num; i++)
|
||||||
|
{
|
||||||
|
p = &p_item[i];
|
||||||
|
|
||||||
|
if(g_mms_m_type_to_local_type.find(p->type) == g_mms_m_type_to_local_type.end())
|
||||||
|
{
|
||||||
|
MY_LOG_E("g_mms_m_type_to_local_type not found, type %d", p->type);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t local_type = g_mms_m_type_to_local_type[p->type];
|
||||||
|
uint8_t ctrl_type = SIGNAL_CTRL_TYPE::DIRECT_NORMAL;
|
||||||
|
stru_signal_param param = {0};
|
||||||
|
|
||||||
|
if(0 != dc_signal_param(p->saddr, p->desc, local_type, param, ctrl_type, p->value.p_val, p->value.p_default, MMS_M_MAX_VAL_NUM, iec61850m_signal_param_change_callback))
|
||||||
|
{
|
||||||
|
MY_LOG_E("dc_signal_param failed, saddr %s, desc %s, type %d", p->saddr, p->desc, p->type);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOCAL int iec61850m_signal_init(stru_cfg &cfg)
|
||||||
|
{
|
||||||
|
stru_point_item *p = nullptr;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int num;
|
||||||
|
stru_point_item *p_item;
|
||||||
|
int (*signal_init)(int num, stru_point_item *p_item);
|
||||||
|
}stru_local_signal_item;
|
||||||
|
|
||||||
|
std::vector<stru_local_signal_item> signal_item =
|
||||||
|
{
|
||||||
|
{cfg.point.st_num, cfg.point.p_st, iec61850m_st_mx_signal_init},
|
||||||
|
{cfg.point.mx_num, cfg.point.p_mx, iec61850m_st_mx_signal_init},
|
||||||
|
{cfg.point.co_num, cfg.point.p_co, iec61850m_co_signal_init},
|
||||||
|
{cfg.point.ao_num, cfg.point.p_ao, iec61850m_ao_signal_init},
|
||||||
|
{cfg.point.param_num, cfg.point.p_param, iec61850m_param_signal_init},
|
||||||
|
};
|
||||||
|
|
||||||
|
for(auto &item : signal_item)
|
||||||
|
{
|
||||||
|
for(int i = 0; item.p_item && i < item.num; i++)
|
||||||
|
{
|
||||||
|
p = &item.p_item[i];
|
||||||
|
|
||||||
|
if(g_mms_m_type_to_local_type.find(p->type) == g_mms_m_type_to_local_type.end())
|
||||||
|
{
|
||||||
|
MY_LOG_E("g_mms_m_type_to_local_type not found, type %d", p->type);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
uint8_t local_type = g_mms_m_type_to_local_type[p->type];
|
||||||
|
p->value.p_val[0] = dc_create_data_ptr_by_type(local_type);
|
||||||
|
|
||||||
|
if(item.p_item == cfg.point.p_ao)
|
||||||
|
{
|
||||||
|
p->value.p_default[0] = dc_create_data_ptr_by_type(local_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(item.p_item == cfg.point.p_param)
|
||||||
|
{
|
||||||
|
p->value.p_default[0] = dc_create_data_ptr_by_type(local_type);
|
||||||
|
for(int j = 1; j < MMS_M_MAX_VAL_NUM; j++)
|
||||||
|
{
|
||||||
|
p->value.p_val[j] = dc_create_data_ptr_by_type(local_type);
|
||||||
|
p->value.p_default[j] = dc_create_data_ptr_by_type(local_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(0 != item.signal_init(item.num, item.p_item))
|
||||||
|
{
|
||||||
|
MY_LOG_E("iec61850m_signal_init failed, cfg %s", cfg.path);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int iec61850m_init()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < g_vec_iec61850m_info.size(); i++)
|
||||||
|
{
|
||||||
|
stru_iec61850m_info *p_info = &g_vec_iec61850m_info[i];
|
||||||
|
|
||||||
|
std::string cfg_path = g_61850m_prj_path + std::string(p_info->prj_name);
|
||||||
|
|
||||||
|
if(nullptr == (p_info->p_cfg = parse_cfg(cfg_path.c_str())))
|
||||||
|
{
|
||||||
|
MY_LOG_E("parse_cfg failed, cfg_path %s", cfg_path.c_str());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
show_cfg(*p_info->p_cfg);
|
||||||
|
|
||||||
|
if(0 != iec61850m_signal_init(*p_info->p_cfg))
|
||||||
|
{
|
||||||
|
MY_LOG_E("iec61850m_signal_init failed, prj_name %s", p_info->prj_name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
p_info->fd = mms_m_out_init(p_info->p_cfg, p_info->debug, p_info->connectionTimeout);
|
||||||
|
if(p_info->fd < 0)
|
||||||
|
{
|
||||||
|
MY_LOG_E("mms_m_out_init failed, fd %d, no %d, prj_name %s", p_info->fd, i, p_info->prj_name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
MY_LOG_I("mms_m_out_init success, fd %d, no %d, prj_name %s", p_info->fd, i, p_info->prj_name);
|
||||||
|
mms_m_out_get_value(p_info->fd, mms_data_back);
|
||||||
|
mms_m_out_get_connect_status(p_info->fd, iec61850m_connect_status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int app_iec61850m_init1(void *arg)
|
||||||
|
{
|
||||||
|
stru_app *p_app = (stru_app *)arg;
|
||||||
|
|
||||||
|
dc_signal_out("iec61850m.run_cnt", "iec61850m.run_cnt", DATA_TYPE_U32, &p_app->run_cnt);
|
||||||
|
|
||||||
|
if(0 != iec61850m_init())
|
||||||
|
{
|
||||||
|
LOG_E("iec61850m_init failed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int app_iec61850m_init2(void *arg)
|
int app_iec61850m_init2(void *arg)
|
||||||
{
|
{
|
||||||
|
static uint32_t *p_iec_run_cnt = NULL;
|
||||||
|
|
||||||
dc_signal_in("iec61850m.iec_run_cnt_in", "iec61850m.iec_run_cnt_in", "iec.run_cnt", (void **)&p_iec_run_cnt);
|
dc_signal_in("iec61850m.iec_run_cnt_in", "iec61850m.iec_run_cnt_in", "iec.run_cnt", (void **)&p_iec_run_cnt);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,320 @@
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "parse_xml.h"
|
||||||
|
#include "myLog.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "tinyxml2.h"
|
||||||
|
|
||||||
|
using namespace tinyxml2;
|
||||||
|
|
||||||
|
|
||||||
|
static const char *ELE_Root = "Root";
|
||||||
|
static const char *ELE_Para = "Para";
|
||||||
|
static const char *ELE_Point = "Point";
|
||||||
|
static const char *ELE_St = "St";
|
||||||
|
static const char *ELE_Mx = "Mx";
|
||||||
|
static const char *ELE_Co = "Co";
|
||||||
|
static const char *ELE_Ao = "Ao";
|
||||||
|
static const char *ELE_Param = "Param";
|
||||||
|
static const char *ELE_Item = "Item";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static const char *KEY_NO = "no";
|
||||||
|
static const char *KEY_SADDR = "saddr";
|
||||||
|
static const char *KEY_DESC = "desc";
|
||||||
|
static const char *KEY_HOST_IP = "host_ip";
|
||||||
|
static const char *KEY_HOST_PORT = "host_port";
|
||||||
|
static const char *KEY_IED = "ied";
|
||||||
|
static const char *KEY_TYPE = "type";
|
||||||
|
static const char *KEY_CTRL_MODEL = "ctlModel";
|
||||||
|
static const char *KEY_LDEV = "LDev";
|
||||||
|
static const char *KEY_LNODE = "LNode";
|
||||||
|
static const char *KEY_DONAME = "DoName";
|
||||||
|
static const char *KEY_FC = "fc";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
std::string type;
|
||||||
|
int *poing_num;
|
||||||
|
stru_point_item **point_item;
|
||||||
|
}stru_parse_point;
|
||||||
|
|
||||||
|
|
||||||
|
LOCAL int parse_item(XMLElement *p_item, stru_point_item &item, const std::string &ied)
|
||||||
|
{
|
||||||
|
if(NULL == p_item)
|
||||||
|
{
|
||||||
|
LOG_E("p_item is NULL");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
string saddr = p_item->Attribute(KEY_SADDR) ? p_item->Attribute(KEY_SADDR) : "";
|
||||||
|
string ldev = p_item->Attribute(KEY_LDEV) ? p_item->Attribute(KEY_LDEV) : "";
|
||||||
|
string lnode = p_item->Attribute(KEY_LNODE) ? p_item->Attribute(KEY_LNODE) : "";
|
||||||
|
string doname = p_item->Attribute(KEY_DONAME) ? p_item->Attribute(KEY_DONAME) : "";
|
||||||
|
string fc = p_item->Attribute(KEY_FC) ? p_item->Attribute(KEY_FC) : "";
|
||||||
|
string type = p_item->Attribute(KEY_TYPE) ? p_item->Attribute(KEY_TYPE) : "";
|
||||||
|
|
||||||
|
if(saddr.empty() || ldev.empty() || lnode.empty() || doname.empty() || fc.empty() || type.empty())
|
||||||
|
{
|
||||||
|
LOG_E("check item attribute error, saddr %s, ldev %s, lnode %s, doname %s, fc %s, type %s", saddr.c_str(), ldev.c_str(), lnode.c_str(), doname.c_str(), fc.c_str(), type.c_str());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
string desc = p_item->Attribute(KEY_DESC) ? p_item->Attribute(KEY_DESC) : "";
|
||||||
|
string ctrl_model = p_item->Attribute(KEY_CTRL_MODEL) ? p_item->Attribute(KEY_CTRL_MODEL) : "";
|
||||||
|
string reference = ied + ldev + "/" + lnode + "." + doname;
|
||||||
|
|
||||||
|
snprintf(item.saddr, MMS_M_STR_LEN-1, "%s", saddr.c_str());
|
||||||
|
snprintf(item.desc, MMS_M_STR_LEN-1, "%s", desc.c_str());
|
||||||
|
snprintf(item.ldev, MMS_M_STR_LEN-1, "%s", ldev.c_str());
|
||||||
|
snprintf(item.lnode, MMS_M_STR_LEN-1, "%s", lnode.c_str());
|
||||||
|
snprintf(item.doname, MMS_M_STR_LEN-1, "%s", doname.c_str());
|
||||||
|
item.fc = atoi(fc.c_str());
|
||||||
|
item.type = atoi(type.c_str());
|
||||||
|
item.ctrl_model = atoi(ctrl_model.c_str());
|
||||||
|
|
||||||
|
snprintf(item.reference, MMS_M_REF_LEN-1, "%s", reference.c_str());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOCAL int parse_para(XMLElement *p_para, stru_para_page ¶_page, std::string &out_ied)
|
||||||
|
{
|
||||||
|
if (NULL == p_para)
|
||||||
|
{
|
||||||
|
LOG_E("p_para is NULL");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
string desc = p_para->Attribute(KEY_DESC) ? p_para->Attribute(KEY_DESC) : "";
|
||||||
|
snprintf(para_page.desc, MMS_M_STR_LEN-1, "%s", desc.c_str());
|
||||||
|
|
||||||
|
string host_ip = p_para->Attribute(KEY_HOST_IP) ? p_para->Attribute(KEY_HOST_IP) : "";
|
||||||
|
if(host_ip.empty())
|
||||||
|
{
|
||||||
|
LOG_E("no attribute %s in para", KEY_HOST_IP);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
snprintf(para_page.host_ip, MMS_M_STR_LEN-1, "%s", host_ip.c_str());
|
||||||
|
|
||||||
|
string host_port = p_para->Attribute(KEY_HOST_PORT) ? p_para->Attribute(KEY_HOST_PORT) : "";
|
||||||
|
if(host_port.empty())
|
||||||
|
{
|
||||||
|
LOG_E("no attribute %s in para", KEY_HOST_PORT);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
para_page.host_port = atoi(host_port.c_str());
|
||||||
|
|
||||||
|
string ied = p_para->Attribute(KEY_IED) ? p_para->Attribute(KEY_IED) : "";
|
||||||
|
if(ied.empty())
|
||||||
|
{
|
||||||
|
LOG_E("no attribute %s in para", KEY_IED);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
snprintf(para_page.ied, MMS_M_STR_LEN-1, "%s", ied.c_str());
|
||||||
|
|
||||||
|
out_ied = para_page.ied;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOCAL int parse_point(XMLElement *p_point, stru_point_page &point_page, const std::string &ied)
|
||||||
|
{
|
||||||
|
if (NULL == p_point)
|
||||||
|
{
|
||||||
|
LOG_E("p_point is NULL");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
vector<stru_parse_point> vec_parse_point =
|
||||||
|
{
|
||||||
|
{ELE_St, &point_page.st_num, &point_page.p_st},
|
||||||
|
{ELE_Mx, &point_page.mx_num, &point_page.p_mx},
|
||||||
|
{ELE_Co, &point_page.co_num, &point_page.p_co},
|
||||||
|
{ELE_Ao, &point_page.ao_num, &point_page.p_ao},
|
||||||
|
{ELE_Param, &point_page.param_num, &point_page.p_param},
|
||||||
|
};
|
||||||
|
|
||||||
|
for(auto &parse_point : vec_parse_point)
|
||||||
|
{
|
||||||
|
XMLElement *Signal = p_point->FirstChildElement(parse_point.type.c_str());
|
||||||
|
if(nullptr == Signal)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int item_num = Signal->ChildElementCount(ELE_Item);
|
||||||
|
if(0 == item_num)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
stru_point_item *p_point_item = NULL;
|
||||||
|
|
||||||
|
p_point_item = new stru_point_item[item_num];
|
||||||
|
if(NULL == p_point_item)
|
||||||
|
{
|
||||||
|
LOG_E("create point_item struct failed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
memset(p_point_item, 0, sizeof(stru_point_item) * item_num);
|
||||||
|
(*parse_point.poing_num) = item_num;
|
||||||
|
*parse_point.point_item = p_point_item;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
XMLElement *Item = Signal->FirstChildElement(ELE_Item);
|
||||||
|
while(nullptr != Item)
|
||||||
|
{
|
||||||
|
stru_point_item &point_item = (*parse_point.point_item)[i];
|
||||||
|
|
||||||
|
if(0 != parse_item(Item, point_item, ied))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Item = Item->NextSiblingElement(ELE_Item);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
stru_cfg *parse_cfg(const std::string &cfg_file)
|
||||||
|
{
|
||||||
|
if (cfg_file.empty())
|
||||||
|
{
|
||||||
|
LOG_E("cfg_file is empty");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
stru_cfg *p_cfg = new stru_cfg;
|
||||||
|
if (NULL == p_cfg)
|
||||||
|
{
|
||||||
|
LOG_E("create cfg struct failed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(p_cfg, 0, sizeof(stru_cfg));
|
||||||
|
|
||||||
|
if(NULL == strstr(cfg_file.c_str(), ".xml"))
|
||||||
|
{
|
||||||
|
LOG_E("cfg_file is not an xml file");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(p_cfg->path, MMS_M_STR_LEN-1, "%s", cfg_file.c_str());
|
||||||
|
|
||||||
|
std::string ied = "";
|
||||||
|
XMLDocument doc;
|
||||||
|
XMLElement *root, *para, *point;
|
||||||
|
XMLError err = doc.LoadFile(cfg_file.c_str());
|
||||||
|
if (err != XML_SUCCESS)
|
||||||
|
{
|
||||||
|
LOG_E("load cfg file %s failed, error code: %d", cfg_file.c_str(), err);
|
||||||
|
goto EXIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
root = doc.FirstChildElement(ELE_Root);
|
||||||
|
if (NULL == root)
|
||||||
|
{
|
||||||
|
LOG_E("no Root element in cfg file");
|
||||||
|
goto EXIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
para = root->FirstChildElement(ELE_Para);
|
||||||
|
if (NULL == para)
|
||||||
|
{
|
||||||
|
LOG_E("no Para element in cfg file");
|
||||||
|
goto EXIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(0 != parse_para(para, p_cfg->para, ied))
|
||||||
|
{
|
||||||
|
LOG_E("parse Para element in cfg file failed");
|
||||||
|
goto EXIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
point = root->FirstChildElement(ELE_Point);
|
||||||
|
if (NULL == point)
|
||||||
|
{
|
||||||
|
LOG_E("no Point element in cfg file");
|
||||||
|
goto EXIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(0 != parse_point(point, p_cfg->point, ied))
|
||||||
|
{
|
||||||
|
LOG_E("parse Point element in cfg file failed");
|
||||||
|
goto EXIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
doc.Clear();
|
||||||
|
return p_cfg;
|
||||||
|
|
||||||
|
EXIT:
|
||||||
|
delete p_cfg;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void show_cfg(stru_cfg &cfg)
|
||||||
|
{
|
||||||
|
stru_point_item *p = NULL;
|
||||||
|
|
||||||
|
printf("Para-%s: ip %s, port %d, ied %s\n", cfg.para.desc, cfg.para.host_ip, cfg.para.host_port, cfg.para.ied);
|
||||||
|
printf("Point-%s:\n", cfg.point.desc);
|
||||||
|
|
||||||
|
printf("\tSt-%d\n", cfg.point.st_num);
|
||||||
|
for(int i = 0; i < cfg.point.st_num; i++)
|
||||||
|
{
|
||||||
|
p = &cfg.point.p_st[i];
|
||||||
|
printf("\t\tno %d, type %d, fc %d, saddr %s, desc %s, ld %s, ln %s, do %s, ref %s\n",
|
||||||
|
i, p->type, p->fc, p->saddr, p->desc, p->ldev, p->lnode, p->doname, p->reference);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\tMx-%d\n", cfg.point.mx_num);
|
||||||
|
for(int i = 0; i < cfg.point.mx_num; i++)
|
||||||
|
{
|
||||||
|
p = &cfg.point.p_mx[i];
|
||||||
|
printf("\t\tno %d, type %d, fc %d, saddr %s, desc %s, ld %s, ln %s, do %s, ref %s\n",
|
||||||
|
i, p->type, p->fc, p->saddr, p->desc, p->ldev, p->lnode, p->doname, p->reference);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\tCo-%d\n", cfg.point.co_num);
|
||||||
|
for(int i = 0; i < cfg.point.co_num; i++)
|
||||||
|
{
|
||||||
|
p = &cfg.point.p_co[i];
|
||||||
|
printf("\t\tno %d, type %d, fc %d, saddr %s, desc %s, ld %s, ln %s, do %s, ref %s, ctrl_model %d\n",
|
||||||
|
i, p->type, p->fc, p->saddr, p->desc, p->ldev, p->lnode, p->doname, p->reference, p->ctrl_model);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\tAo-%d\n", cfg.point.ao_num);
|
||||||
|
for(int i = 0; i < cfg.point.ao_num; i++)
|
||||||
|
{
|
||||||
|
p = &cfg.point.p_ao[i];
|
||||||
|
printf("\t\tno %d, type %d, fc %d, saddr %s, desc %s, ld %s, ln %s, do %s, ref %s\n",
|
||||||
|
i, p->type, p->fc, p->saddr, p->desc, p->ldev, p->lnode, p->doname, p->reference);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\tParam-%d\n", cfg.point.param_num);
|
||||||
|
for(int i = 0; i < cfg.point.param_num; i++)
|
||||||
|
{
|
||||||
|
p = &cfg.point.p_param[i];
|
||||||
|
printf("\t\tno %d, type %d, fc %d, saddr %s, desc %s, ld %s, ln %s, do %s, ref %s\n",
|
||||||
|
i, p->type, p->fc, p->saddr, p->desc, p->ldev, p->lnode, p->doname, p->reference);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -59,7 +59,7 @@ LOCAL int parse_base(XMLElement *root)
|
||||||
|
|
||||||
if(saddr.empty() || saddr.length() > MMS_S_STR_LEN - 1)
|
if(saddr.empty() || saddr.length() > MMS_S_STR_LEN - 1)
|
||||||
{
|
{
|
||||||
MY_LOG_E("saddr is empty or length is too long, saddr: %s, len: %d", saddr.c_str(), saddr.length());
|
MY_LOG_E("saddr is empty or length is too long, saddr: %s, len: %ld", saddr.c_str(), saddr.length());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,7 +114,7 @@ void show_mms_xml(stru_mms_cfg &cfg)
|
||||||
|
|
||||||
for(auto &it : vec_map)
|
for(auto &it : vec_map)
|
||||||
{
|
{
|
||||||
MY_LOG_I("ele: %s, size: %d", it.first.c_str(), it.second->size());
|
MY_LOG_I("ele: %s, size: %ld", it.first.c_str(), it.second->size());
|
||||||
|
|
||||||
for(int i = 0; i < it.second->size(); ++i)
|
for(int i = 0; i < it.second->size(); ++i)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -918,7 +918,8 @@ int self_ptl_do_signal_out(stru_app *p_app)
|
||||||
param.step = safeStringToFloat(p_param->p_param->step);
|
param.step = safeStringToFloat(p_param->p_param->step);
|
||||||
param.unit = p_param->p_param->unit;
|
param.unit = p_param->p_param->unit;
|
||||||
|
|
||||||
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->type, param,
|
||||||
|
SIGNAL_CTRL_TYPE::SBO_NORMAL, p_param->vec_p_data.data(), p_param->vec_p_default_data.data(), p_param->p_param->num, self_ptl_signal_change_callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
<Authentication none="true" />
|
<Authentication none="true" />
|
||||||
<LDevice inst="PROT">
|
<LDevice inst="PROT">
|
||||||
<LN0 lnType="NRR_LLN0_P9600" lnClass="LLN0" inst="">
|
<LN0 lnType="NRR_LLN0_P9600" lnClass="LLN0" inst="">
|
||||||
<!-- <DataSet name="dsRelayDin" desc="保护遥信数据集">
|
<DataSet name="dsRelayDin" desc="保护遥信数据集">
|
||||||
<FCDA ldInst="PROT" lnClass="GGIO" lnInst="7" doName="Ind1" fc="ST" />
|
<FCDA ldInst="PROT" lnClass="GGIO" lnInst="7" doName="Ind1" fc="ST" />
|
||||||
<FCDA ldInst="PROT" lnClass="GGIO" lnInst="7" doName="Ind2" fc="ST" />
|
<FCDA ldInst="PROT" lnClass="GGIO" lnInst="7" doName="Ind2" fc="ST" />
|
||||||
<FCDA ldInst="PROT" lnClass="GGIO" lnInst="7" doName="Ind3" fc="ST" />
|
<FCDA ldInst="PROT" lnClass="GGIO" lnInst="7" doName="Ind3" fc="ST" />
|
||||||
|
|
@ -160,11 +160,11 @@
|
||||||
<FCDA ldInst="PROT" lnClass="GGIO" lnInst="10" doName="Ind3" fc="ST" />
|
<FCDA ldInst="PROT" lnClass="GGIO" lnInst="10" doName="Ind3" fc="ST" />
|
||||||
<FCDA ldInst="PROT" lnClass="GGIO" lnInst="10" doName="Ind4" fc="ST" />
|
<FCDA ldInst="PROT" lnClass="GGIO" lnInst="10" doName="Ind4" fc="ST" />
|
||||||
<FCDA ldInst="PROT" lnClass="GGIO" lnInst="10" doName="Ind5" fc="ST" />
|
<FCDA ldInst="PROT" lnClass="GGIO" lnInst="10" doName="Ind5" fc="ST" />
|
||||||
</DataSet> -->
|
</DataSet>
|
||||||
<DataSet name="dsParameter" desc="设备参数定值">
|
<DataSet name="dsParameter" desc="设备参数定值">
|
||||||
<FCDA ldInst="PROT" lnClass="LPHD" lnInst="1" doName="SettingGrp" fc="SP" />
|
<FCDA ldInst="PROT" lnClass="LPHD" lnInst="1" doName="SettingGrp" fc="SP" />
|
||||||
<FCDA ldInst="PROT" lnClass="LPHD" lnInst="1" doName="DeviceName" fc="SP" />
|
<FCDA ldInst="PROT" lnClass="LPHD" lnInst="1" doName="DeviceName" fc="SP" />
|
||||||
<!-- <FCDA ldInst="PROT" lnClass="TCTR" lnInst="1" doName="ARtg" fc="SP" />
|
<FCDA ldInst="PROT" lnClass="TCTR" lnInst="1" doName="ARtg" fc="SP" />
|
||||||
<FCDA ldInst="PROT" lnClass="TCTR" lnInst="1" doName="ARtgSnd" fc="SP" />
|
<FCDA ldInst="PROT" lnClass="TCTR" lnInst="1" doName="ARtgSnd" fc="SP" />
|
||||||
<FCDA ldInst="PROT" lnClass="TCTR" lnInst="2" doName="ARtg" fc="SP" />
|
<FCDA ldInst="PROT" lnClass="TCTR" lnInst="2" doName="ARtg" fc="SP" />
|
||||||
<FCDA ldInst="PROT" lnClass="TCTR" lnInst="2" doName="ARtgSnd" fc="SP" />
|
<FCDA ldInst="PROT" lnClass="TCTR" lnInst="2" doName="ARtgSnd" fc="SP" />
|
||||||
|
|
@ -173,13 +173,13 @@
|
||||||
<FCDA ldInst="PROT" lnClass="TVTR" lnInst="2" doName="VRtg" fc="SP" />
|
<FCDA ldInst="PROT" lnClass="TVTR" lnInst="2" doName="VRtg" fc="SP" />
|
||||||
<FCDA ldInst="PROT" lnClass="TVTR" lnInst="2" doName="VRtgSnd" fc="SP" />
|
<FCDA ldInst="PROT" lnClass="TVTR" lnInst="2" doName="VRtgSnd" fc="SP" />
|
||||||
<FCDA ldInst="PROT" lnClass="PTOC" lnInst="6" doName="ZroASlfCalEna" fc="SG" />
|
<FCDA ldInst="PROT" lnClass="PTOC" lnInst="6" doName="ZroASlfCalEna" fc="SG" />
|
||||||
<FCDA ldInst="PROT" lnClass="TCTR" lnInst="1" doName="CTMod" fc="SP" /> -->
|
<FCDA ldInst="PROT" lnClass="TCTR" lnInst="1" doName="CTMod" fc="SP" />
|
||||||
</DataSet>
|
</DataSet>
|
||||||
<DataSet name="dsSetting" desc="保护定值数据集">
|
<DataSet name="dsSetting" desc="保护定值数据集">
|
||||||
<!-- <FCDA ldInst="PROT" lnClass="GGIO" lnInst="4" doName="BlkValVpp" fc="SG" /> -->
|
<FCDA ldInst="PROT" lnClass="GGIO" lnInst="4" doName="BlkValVpp" fc="SG" />
|
||||||
<FCDA ldInst="PROT" lnClass="PTOC" lnInst="1" doName="StrVal" fc="SG" />
|
<FCDA ldInst="PROT" lnClass="PTOC" lnInst="1" doName="StrVal" fc="SG" />
|
||||||
<FCDA ldInst="PROT" lnClass="PTOC" lnInst="1" doName="OpDlTmms" fc="SG" />
|
<FCDA ldInst="PROT" lnClass="PTOC" lnInst="1" doName="OpDlTmms" fc="SG" />
|
||||||
<!-- <FCDA ldInst="PROT" lnClass="PTOC" lnInst="2" doName="StrVal" fc="SG" />
|
<FCDA ldInst="PROT" lnClass="PTOC" lnInst="2" doName="StrVal" fc="SG" />
|
||||||
<FCDA ldInst="PROT" lnClass="PTOC" lnInst="2" doName="OpDlTmms" fc="SG" />
|
<FCDA ldInst="PROT" lnClass="PTOC" lnInst="2" doName="OpDlTmms" fc="SG" />
|
||||||
<FCDA ldInst="PROT" lnClass="PTOC" lnInst="3" doName="StrVal" fc="SG" />
|
<FCDA ldInst="PROT" lnClass="PTOC" lnInst="3" doName="StrVal" fc="SG" />
|
||||||
<FCDA ldInst="PROT" lnClass="PTOC" lnInst="3" doName="OpDlTmms" fc="SG" />
|
<FCDA ldInst="PROT" lnClass="PTOC" lnInst="3" doName="OpDlTmms" fc="SG" />
|
||||||
|
|
@ -232,9 +232,9 @@
|
||||||
<FCDA ldInst="PROT" lnClass="RREC" lnInst="1" doName="RecChkSyn" fc="SG" />
|
<FCDA ldInst="PROT" lnClass="RREC" lnInst="1" doName="RecChkSyn" fc="SG" />
|
||||||
<FCDA ldInst="PROT" lnClass="RSYN" lnInst="1" doName="LnDeaEna" fc="SG" />
|
<FCDA ldInst="PROT" lnClass="RSYN" lnInst="1" doName="LnDeaEna" fc="SG" />
|
||||||
<FCDA ldInst="PROT" lnClass="RSYN" lnInst="1" doName="BsDeaEna" fc="SG" />
|
<FCDA ldInst="PROT" lnClass="RSYN" lnInst="1" doName="BsDeaEna" fc="SG" />
|
||||||
<FCDA ldInst="PROT" lnClass="RSYN" lnInst="1" doName="LnBsDeaEna" fc="SG" /> -->
|
<FCDA ldInst="PROT" lnClass="RSYN" lnInst="1" doName="LnBsDeaEna" fc="SG" />
|
||||||
</DataSet>
|
</DataSet>
|
||||||
<!-- <ReportControl name="brcbRelayDin" datSet="dsRelayDin" intgPd="0" rptID="PROT/LLN0$BR$brcbRelayDin" confRev="1" buffered="true" bufTime="0">
|
<ReportControl name="brcbRelayDin" datSet="dsRelayDin" intgPd="0" rptID="PROT/LLN0$BR$brcbRelayDin" confRev="1" buffered="true" bufTime="0">
|
||||||
<TrgOps dchg="true" qchg="false" dupd="false" period="true" />
|
<TrgOps dchg="true" qchg="false" dupd="false" period="true" />
|
||||||
<OptFields seqNum="false" timeStamp="true" dataSet="true" reasonCode="true" dataRef="true" entryID="true" configRef="true" />
|
<OptFields seqNum="false" timeStamp="true" dataSet="true" reasonCode="true" dataRef="true" entryID="true" configRef="true" />
|
||||||
<RptEnabled max="16" />
|
<RptEnabled max="16" />
|
||||||
|
|
@ -268,7 +268,7 @@
|
||||||
<TrgOps dchg="true" qchg="false" dupd="false" period="true" />
|
<TrgOps dchg="true" qchg="false" dupd="false" period="true" />
|
||||||
<OptFields seqNum="false" timeStamp="true" dataSet="true" reasonCode="true" dataRef="true" entryID="false" configRef="false" />
|
<OptFields seqNum="false" timeStamp="true" dataSet="true" reasonCode="true" dataRef="true" entryID="false" configRef="false" />
|
||||||
<RptEnabled max="16" />
|
<RptEnabled max="16" />
|
||||||
</ReportControl> -->
|
</ReportControl>
|
||||||
<DOI name="Mod" desc="Mode">
|
<DOI name="Mod" desc="Mode">
|
||||||
<DAI name="ctlModel">
|
<DAI name="ctlModel">
|
||||||
<Val>0</Val>
|
<Val>0</Val>
|
||||||
|
|
@ -483,7 +483,7 @@
|
||||||
</DAI>
|
</DAI>
|
||||||
</DOI>
|
</DOI>
|
||||||
</LN>
|
</LN>
|
||||||
<!-- <LN desc="过流Ⅱ段" lnType="NRR_PTOC_V1.01" lnClass="PTOC" inst="2">
|
<LN desc="过流Ⅱ段" lnType="NRR_PTOC_V1.01" lnClass="PTOC" inst="2">
|
||||||
<DOI name="Mod" desc="Mode">
|
<DOI name="Mod" desc="Mode">
|
||||||
<DAI name="ctlModel">
|
<DAI name="ctlModel">
|
||||||
<Val>0</Val>
|
<Val>0</Val>
|
||||||
|
|
@ -3831,7 +3831,7 @@
|
||||||
<SDI name="Cancel">
|
<SDI name="Cancel">
|
||||||
<DAI name="ctlVal" sAddr="RYB:B01.GVBI1.swi_vebi1" />
|
<DAI name="ctlVal" sAddr="RYB:B01.GVBI1.swi_vebi1" />
|
||||||
</SDI>
|
</SDI>
|
||||||
<DAI name="stVal" sAddr="YX:B01.GVBI1.swi_vebi1" />
|
<DAI name="stVal" sAddr="iec61850m.prj.st.4" />
|
||||||
<DAI name="ctlModel">
|
<DAI name="ctlModel">
|
||||||
<Val>4</Val>
|
<Val>4</Val>
|
||||||
</DAI>
|
</DAI>
|
||||||
|
|
@ -4427,13 +4427,13 @@
|
||||||
</DAI>
|
</DAI>
|
||||||
</DOI>
|
</DOI>
|
||||||
<DOI name="Ind2" desc="低频减载投入">
|
<DOI name="Ind2" desc="低频减载投入">
|
||||||
<DAI name="stVal" sAddr="YX:B01.GVIO1.vio11" />
|
<DAI name="stVal" sAddr="iec61850m.prj.st.1" />
|
||||||
<DAI name="dU">
|
<DAI name="dU">
|
||||||
<Val>低频减载投入</Val>
|
<Val>低频减载投入</Val>
|
||||||
</DAI>
|
</DAI>
|
||||||
</DOI>
|
</DOI>
|
||||||
<DOI name="Ind3" desc="重合闸停用">
|
<DOI name="Ind3" desc="重合闸停用">
|
||||||
<DAI name="stVal" sAddr="YX:B01.GVIO1.vio12" />
|
<DAI name="stVal" sAddr="iec61850m.prj.st.2" />
|
||||||
<DAI name="dU">
|
<DAI name="dU">
|
||||||
<Val>重合闸停用</Val>
|
<Val>重合闸停用</Val>
|
||||||
</DAI>
|
</DAI>
|
||||||
|
|
@ -4445,7 +4445,7 @@
|
||||||
</DAI>
|
</DAI>
|
||||||
</DOI>
|
</DOI>
|
||||||
<DOI name="Ind5" desc="远方位置">
|
<DOI name="Ind5" desc="远方位置">
|
||||||
<DAI name="stVal" sAddr="YX:B01.GVIO1.vio14" />
|
<DAI name="stVal" sAddr="iec61850m.prj.st.0" />
|
||||||
<DAI name="dU">
|
<DAI name="dU">
|
||||||
<Val>远方位置</Val>
|
<Val>远方位置</Val>
|
||||||
</DAI>
|
</DAI>
|
||||||
|
|
@ -5437,7 +5437,7 @@
|
||||||
<Val>SGCC MODEL:2009</Val>
|
<Val>SGCC MODEL:2009</Val>
|
||||||
</DAI>
|
</DAI>
|
||||||
</DOI>
|
</DOI>
|
||||||
</LN> -->
|
</LN>
|
||||||
</LDevice>
|
</LDevice>
|
||||||
<LDevice inst="CTRL">
|
<LDevice inst="CTRL">
|
||||||
<LN0 lnType="NRR_LLN0_P9600" lnClass="LLN0" inst="">
|
<LN0 lnType="NRR_LLN0_P9600" lnClass="LLN0" inst="">
|
||||||
|
|
|
||||||
|
|
@ -25,14 +25,11 @@
|
||||||
<Item no="4" type="2" ctlModel="4" saddr="iec61850m.prj.co.4" desc="低频保护软压板" LDev="PROT" LNode="GGIO1" DoName="SPCSO1" fc="0"/>
|
<Item no="4" type="2" ctlModel="4" saddr="iec61850m.prj.co.4" desc="低频保护软压板" LDev="PROT" LNode="GGIO1" DoName="SPCSO1" fc="0"/>
|
||||||
</Co>
|
</Co>
|
||||||
<Ao desc="参数">
|
<Ao desc="参数">
|
||||||
<Item no="0" type="4" ctlModel="4" saddr="iec61850m.prj.ao.0" desc="参数01" LDev="PROT" LNode="LPHD1" DoName="SettingGrp.setVal" fc="2" min="1" max="30" step="1" unit="" value="1" default="1"/>
|
<Item no="0" type="4" ctlModel="4" saddr="iec61850m.prj.ao.0" desc="参数01" LDev="PROT" LNode="LPHD1" DoName="SettingGrp.setVal" fc="2" />
|
||||||
<Item no="1" type="13" ctlModel="4" saddr="iec61850m.prj.ao.1" desc="参数02" LDev="PROT" LNode="LPHD1" DoName="DeviceName.setVal" fc="2" min="" max="" step="" unit="" value="1" default="1"/>
|
<Item no="1" type="13" ctlModel="4" saddr="iec61850m.prj.ao.1" desc="参数02" LDev="PROT" LNode="LPHD1" DoName="DeviceName.setVal" fc="2" />
|
||||||
</Ao>
|
</Ao>
|
||||||
<Param desc="定值">
|
<Param desc="定值">
|
||||||
<Item no="0" type="6" ctlModel="4" saddr="iec61850m.prj.param.0" desc="定值01" LDev="PROT" LNode="PTOC1" DoName="StrVal.setMag.f" fc="2" min="0.05" max="150" step="0.001" unit="A" num="2">
|
<Item no="0" type="6" ctlModel="4" saddr="iec61850m.prj.param.0" desc="定值01" LDev="PROT" LNode="PTOC1" DoName="StrVal.setMag.f" fc="2" />
|
||||||
<SubItem value="15" default="15"/>
|
|
||||||
<SubItem value="27" default="27"/>
|
|
||||||
</Item>
|
|
||||||
</Param>
|
</Param>
|
||||||
</Point>
|
</Point>
|
||||||
</Root>
|
</Root>
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue