update
This commit is contained in:
parent
02c38651b9
commit
17d490f85d
@ -89,10 +89,20 @@ bool CRYDevice::configInitializeMemory(void)
|
|||||||
config_config.units[i].ftp_softdog = 0;
|
config_config.units[i].ftp_softdog = 0;
|
||||||
|
|
||||||
config_config.units[i].yxs = new struUnitYX[UNIT_YX_MAX];
|
config_config.units[i].yxs = new struUnitYX[UNIT_YX_MAX];
|
||||||
|
memset(config_config.units[i].yxs, 0, sizeof(struUnitYX) * UNIT_YX_MAX);
|
||||||
|
for (int k = 0; k < UNIT_YX_MAX; k++) config_config.units[i].yxs[k].order = -1;
|
||||||
config_config.units[i].ycs = new struUnitYC[UNIT_YC_MAX];
|
config_config.units[i].ycs = new struUnitYC[UNIT_YC_MAX];
|
||||||
|
memset(config_config.units[i].ycs, 0, sizeof(struUnitYC) * UNIT_YC_MAX);
|
||||||
|
for (int k = 0; k < UNIT_YC_MAX; k++) config_config.units[i].ycs[k].order = -1;
|
||||||
config_config.units[i].yms = new struUnitYM[UNIT_YM_MAX];
|
config_config.units[i].yms = new struUnitYM[UNIT_YM_MAX];
|
||||||
|
memset(config_config.units[i].yms, 0, sizeof(struUnitYM) * UNIT_YM_MAX);
|
||||||
|
for (int k = 0; k < UNIT_YM_MAX; k++) config_config.units[i].yms[k].order = -1;
|
||||||
config_config.units[i].yks = new struUnitYK[UNIT_YK_MAX];
|
config_config.units[i].yks = new struUnitYK[UNIT_YK_MAX];
|
||||||
|
memset(config_config.units[i].yks, 0, sizeof(struUnitYK) * UNIT_YK_MAX);
|
||||||
|
for (int k = 0; k < UNIT_YK_MAX; k++) config_config.units[i].yks[k].order = -1;
|
||||||
config_config.units[i].yts = new struUnitYT[UNIT_YT_MAX];
|
config_config.units[i].yts = new struUnitYT[UNIT_YT_MAX];
|
||||||
|
memset(config_config.units[i].yts, 0, sizeof(struUnitYT) * UNIT_YT_MAX);
|
||||||
|
for (int k = 0; k < UNIT_YT_MAX; k++) config_config.units[i].yts[k].order = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -2190,6 +2200,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
|||||||
name_param.name = "";
|
name_param.name = "";
|
||||||
name_param.highSpeed = 0;
|
name_param.highSpeed = 0;
|
||||||
name_param.order = -1;
|
name_param.order = -1;
|
||||||
|
name_param.deviceId = id;
|
||||||
if (attr["name"].isString()) name_param.name = id + attr["name"].asString();
|
if (attr["name"].isString()) name_param.name = id + attr["name"].asString();
|
||||||
if (attr["order"].isInt()) name_param.order = attr["order"].asInt();
|
if (attr["order"].isInt()) name_param.order = attr["order"].asInt();
|
||||||
if (attr["params"].isObject()) name_param.params = attr["params"];
|
if (attr["params"].isObject()) name_param.params = attr["params"];
|
||||||
@ -2208,6 +2219,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
|||||||
struct_attr name_param;
|
struct_attr name_param;
|
||||||
name_param.name = "";
|
name_param.name = "";
|
||||||
name_param.order = -1;
|
name_param.order = -1;
|
||||||
|
name_param.deviceId = id;
|
||||||
if (service["name"].isString()) name_param.name = id + service["name"].asString();
|
if (service["name"].isString()) name_param.name = id + service["name"].asString();
|
||||||
if (service["order"].isInt()) name_param.order = service["order"].asInt();
|
if (service["order"].isInt()) name_param.order = service["order"].asInt();
|
||||||
if (service["params"].isObject()) name_param.params = service["params"];
|
if (service["params"].isObject()) name_param.params = service["params"];
|
||||||
@ -2241,6 +2253,9 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
|||||||
snprintf(config_static_units[uid].deviceId, sizeof(config_static_units[uid].deviceId), "iss_%d", uid);
|
snprintf(config_static_units[uid].deviceId, sizeof(config_static_units[uid].deviceId), "iss_%d", uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (uid2pid_map.find(id) == uid2pid_map.end()) {
|
||||||
|
uid2pid_map.insert(string2intmap::value_type(id, i));
|
||||||
|
}
|
||||||
config_config.processes[i].units[j] = uid;
|
config_config.processes[i].units[j] = uid;
|
||||||
//根据协议修改地址
|
//根据协议修改地址
|
||||||
if (address != "") {
|
if (address != "") {
|
||||||
@ -2322,7 +2337,6 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
|||||||
if (config_config.units[uid].yccount > 0) {
|
if (config_config.units[uid].yccount > 0) {
|
||||||
//config_config.units[uid].ycs = new struUnitYC[config_config.units[uid].yccount];
|
//config_config.units[uid].ycs = new struUnitYC[config_config.units[uid].yccount];
|
||||||
if (NULL != config_config.units[uid].ycs) {
|
if (NULL != config_config.units[uid].ycs) {
|
||||||
memset(config_config.units[uid].ycs, 0, sizeof(struUnitYC) * config_config.units[uid].yccount);
|
|
||||||
for (int k = 0; k < config_config.units[uid].yccount; k++) {
|
for (int k = 0; k < config_config.units[uid].yccount; k++) {
|
||||||
snprintf(config_config.units[uid].ycs[k].name, sizeof(config_config.units[uid].ycs[k].name), "%s", ycs[k].name.c_str());
|
snprintf(config_config.units[uid].ycs[k].name, sizeof(config_config.units[uid].ycs[k].name), "%s", ycs[k].name.c_str());
|
||||||
config_config.units[uid].ycs[k].order = ycorder++;
|
config_config.units[uid].ycs[k].order = ycorder++;
|
||||||
@ -2382,13 +2396,18 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
|||||||
}
|
}
|
||||||
if (pfdbycname) {
|
if (pfdbycname) {
|
||||||
fseek(pfdbycname, sizeof(struYCStatic) * config_config.units[uid].ycs[k].order, SEEK_SET);
|
fseek(pfdbycname, sizeof(struYCStatic) * config_config.units[uid].ycs[k].order, SEEK_SET);
|
||||||
fwrite(ycs[k].name.c_str(), (MAX_NAME_SIZE << 2), 1, pfdbycname);
|
if (!ycs[k].params["measPointName"].isNull())
|
||||||
|
{
|
||||||
|
std::string measPointName = std::string(config_config.processes[i].name) + std::string("_");
|
||||||
|
if (ycs[k].params["measPointName"].isString()) measPointName += ycs[k].params["measPointName"].asString();
|
||||||
|
else measPointName += std::string("备用");
|
||||||
|
fwrite(measPointName.c_str(), (MAX_NAME_SIZE << 2), 1, pfdbycname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config_config.units[uid].ymcount > 0) {
|
if (config_config.units[uid].ymcount > 0) {
|
||||||
//config_config.units[uid].yms = new struUnitYM[config_config.units[uid].ymcount];
|
|
||||||
if (NULL != config_config.units[uid].yms) {
|
if (NULL != config_config.units[uid].yms) {
|
||||||
memset(config_config.units[uid].yms, 0, sizeof(struUnitYM) * config_config.units[uid].ymcount);
|
memset(config_config.units[uid].yms, 0, sizeof(struUnitYM) * config_config.units[uid].ymcount);
|
||||||
for (int k = 0; k < config_config.units[uid].ymcount; k++) {
|
for (int k = 0; k < config_config.units[uid].ymcount; k++) {
|
||||||
@ -2425,13 +2444,18 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
|||||||
|
|
||||||
if (pfdbymname) {
|
if (pfdbymname) {
|
||||||
fseek(pfdbymname, sizeof(struYMStatic) * config_config.units[uid].yms[k].order, SEEK_SET);
|
fseek(pfdbymname, sizeof(struYMStatic) * config_config.units[uid].yms[k].order, SEEK_SET);
|
||||||
fwrite(yms[k].name.c_str(), (MAX_NAME_SIZE << 2), 1, pfdbymname);
|
if (!yms[k].params["measPointName"].isNull())
|
||||||
|
{
|
||||||
|
std::string measPointName = std::string(config_config.processes[i].name) + std::string("_");
|
||||||
|
if (yms[k].params["measPointName"].isString()) measPointName += yms[k].params["measPointName"].asString();
|
||||||
|
else measPointName += std::string("备用");
|
||||||
|
fwrite(measPointName.c_str(), (MAX_NAME_SIZE << 2), 1, pfdbymname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config_config.units[uid].ykcount > 0) {
|
if (config_config.units[uid].ykcount > 0) {
|
||||||
//config_config.units[uid].yks = new struUnitYK[config_config.units[uid].ykcount];
|
|
||||||
if (NULL != config_config.units[uid].yks) {
|
if (NULL != config_config.units[uid].yks) {
|
||||||
memset(config_config.units[uid].yks, 0, sizeof(struUnitYK) * config_config.units[uid].ykcount);
|
memset(config_config.units[uid].yks, 0, sizeof(struUnitYK) * config_config.units[uid].ykcount);
|
||||||
for (int k = 0; k < config_config.units[uid].ykcount; k++) {
|
for (int k = 0; k < config_config.units[uid].ykcount; k++) {
|
||||||
@ -2460,13 +2484,18 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
|||||||
}
|
}
|
||||||
if (pfdbykname) {
|
if (pfdbykname) {
|
||||||
fseek(pfdbykname, sizeof(struYKStatic) * config_config.units[uid].yks[k].order, SEEK_SET);
|
fseek(pfdbykname, sizeof(struYKStatic) * config_config.units[uid].yks[k].order, SEEK_SET);
|
||||||
fwrite(yks[k].name.c_str(), (MAX_NAME_SIZE << 2), 1, pfdbykname);
|
if (!yks[k].params["measPointName"].isNull())
|
||||||
|
{
|
||||||
|
std::string measPointName = std::string(config_config.processes[i].name) + std::string("_");
|
||||||
|
if (yks[k].params["measPointName"].isString()) measPointName += yks[k].params["measPointName"].asString();
|
||||||
|
else measPointName += std::string("备用");
|
||||||
|
fwrite(measPointName.c_str(), (MAX_NAME_SIZE << 2), 1, pfdbykname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config_config.units[uid].ytcount > 0) {
|
if (config_config.units[uid].ytcount > 0) {
|
||||||
//config_config.units[uid].yts = new struUnitYT[config_config.units[uid].ytcount];
|
|
||||||
if (NULL != config_config.units[uid].yts) {
|
if (NULL != config_config.units[uid].yts) {
|
||||||
memset(config_config.units[uid].yts, 0, sizeof(struUnitYT) * config_config.units[uid].ytcount);
|
memset(config_config.units[uid].yts, 0, sizeof(struUnitYT) * config_config.units[uid].ytcount);
|
||||||
for (int k = 0; k < config_config.units[uid].ytcount; k++) {
|
for (int k = 0; k < config_config.units[uid].ytcount; k++) {
|
||||||
@ -2495,13 +2524,18 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
|||||||
}
|
}
|
||||||
if (pfdbytname) {
|
if (pfdbytname) {
|
||||||
fseek(pfdbytname, sizeof(struYTStatic) * config_config.units[uid].yts[k].order, SEEK_SET);
|
fseek(pfdbytname, sizeof(struYTStatic) * config_config.units[uid].yts[k].order, SEEK_SET);
|
||||||
fwrite(yts[k].name.c_str(), (MAX_NAME_SIZE << 2), 1, pfdbytname);
|
if (!yts[k].params["measPointName"].isNull())
|
||||||
|
{
|
||||||
|
std::string measPointName = std::string(config_config.processes[i].name) + std::string("_");
|
||||||
|
if (yts[k].params["measPointName"].isString()) measPointName += yts[k].params["measPointName"].asString();
|
||||||
|
else measPointName += std::string("备用");
|
||||||
|
fwrite(measPointName.c_str(), (MAX_NAME_SIZE << 2), 1, pfdbytname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config_config.units[uid].yxcount > 0) {
|
if (config_config.units[uid].yxcount > 0) {
|
||||||
//config_config.units[uid].yxs = new struUnitYX[config_config.units[uid].yxcount];
|
|
||||||
if (NULL != config_config.units[uid].yxs) {
|
if (NULL != config_config.units[uid].yxs) {
|
||||||
memset(config_config.units[uid].yxs, 0, sizeof(struUnitYX) * config_config.units[uid].yxcount);
|
memset(config_config.units[uid].yxs, 0, sizeof(struUnitYX) * config_config.units[uid].yxcount);
|
||||||
for (int k = 0; k < config_config.units[uid].yxcount; k++) {
|
for (int k = 0; k < config_config.units[uid].yxcount; k++) {
|
||||||
@ -2537,7 +2571,13 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
|||||||
}
|
}
|
||||||
if (pfdbyxname) {
|
if (pfdbyxname) {
|
||||||
fseek(pfdbyxname, sizeof(struYXStatic) * config_config.units[uid].yxs[k].order, SEEK_SET);
|
fseek(pfdbyxname, sizeof(struYXStatic) * config_config.units[uid].yxs[k].order, SEEK_SET);
|
||||||
fwrite(yxs[k].name.c_str(), (MAX_NAME_SIZE << 2), 1, pfdbyxname);
|
if (!yxs[k].params["measPointName"].isNull())
|
||||||
|
{
|
||||||
|
std::string measPointName = std::string(config_config.processes[i].name) + std::string("_");
|
||||||
|
if (yxs[k].params["measPointName"].isString()) measPointName += yxs[k].params["measPointName"].asString();
|
||||||
|
else measPointName += std::string("备用");
|
||||||
|
fwrite(measPointName.c_str(), (MAX_NAME_SIZE << 2), 1, pfdbyxname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2554,7 +2594,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
|||||||
{
|
{
|
||||||
int pid = it->first;
|
int pid = it->first;
|
||||||
attrvectorGroup attrs = it->second;
|
attrvectorGroup attrs = it->second;
|
||||||
fprintf(stderr, "pid is: %d, link uid is: %d\n", pid, sub_uid);
|
|
||||||
switch (config_config.processes[pid].proto)
|
switch (config_config.processes[pid].proto)
|
||||||
{
|
{
|
||||||
case PROTOCOL_SUB_MODBUS_TCP:
|
case PROTOCOL_SUB_MODBUS_TCP:
|
||||||
@ -2566,43 +2606,35 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int s_yxcount, s_yccount, s_ymcount, s_ykcount, s_ytcount;
|
|
||||||
config_config.units[sub_uid].value = SPI_ON;
|
config_config.units[sub_uid].value = SPI_ON;
|
||||||
config_config.units[sub_uid].real_softdog = UNIT_WATCHDOG_TIME;
|
config_config.units[sub_uid].real_softdog = UNIT_WATCHDOG_TIME;
|
||||||
config_config.units[sub_uid].state = TRUE;
|
config_config.units[sub_uid].state = TRUE;
|
||||||
config_config.units[sub_uid].type = SLAVER_UNIT;
|
config_config.units[sub_uid].type = SLAVER_UNIT;
|
||||||
s_yxcount = attrs.yxs.size();
|
config_config.units[sub_uid].yxcount = attrs.yxs.size();
|
||||||
s_yccount = attrs.ycs.size();
|
config_config.units[sub_uid].yccount = attrs.ycs.size();
|
||||||
s_ymcount = attrs.yms.size();
|
config_config.units[sub_uid].ymcount = attrs.yms.size();
|
||||||
s_ykcount = attrs.yks.size();
|
config_config.units[sub_uid].ykcount = attrs.yks.size();
|
||||||
s_ytcount = attrs.yts.size();
|
config_config.units[sub_uid].ytcount = attrs.yts.size();
|
||||||
config_config.units[sub_uid].yxcount = s_yxcount;
|
|
||||||
config_config.units[sub_uid].yccount = s_yccount;
|
|
||||||
config_config.units[sub_uid].ymcount = s_ymcount;
|
|
||||||
config_config.units[sub_uid].ykcount = s_ykcount;
|
|
||||||
config_config.units[sub_uid].ytcount = s_ytcount;
|
|
||||||
|
|
||||||
config_config.processes[pid].units[0] = sub_uid;
|
config_config.processes[pid].units[0] = sub_uid;
|
||||||
if (s_yccount > 0)
|
|
||||||
|
if (config_config.units[sub_uid].yccount > 0)
|
||||||
{
|
{
|
||||||
//config_config.units[sub_uid].ycs = new struUnitYC[s_yccount];
|
for (int i = 0; i < config_config.units[sub_uid].yccount; i++) {
|
||||||
if (NULL != config_config.units[sub_uid].ycs) {
|
std::string key;
|
||||||
memset(config_config.units[sub_uid].ycs, 0, sizeof(struUnitYC) * s_yccount);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < s_yccount; i++) {
|
|
||||||
std::string key = attrs.ycs[i].name;
|
|
||||||
int order = -1;
|
int order = -1;
|
||||||
int point = i;
|
int point = -1;
|
||||||
if (map_ycorders.find(key) != map_ycorders.end())
|
|
||||||
{
|
|
||||||
order = map_ycorders[key];
|
|
||||||
}
|
|
||||||
Json::Value param = attrs.ycs[i].params;
|
Json::Value param = attrs.ycs[i].params;
|
||||||
if (!param["order"].isNull())
|
if (!param["order"].isNull())
|
||||||
{
|
{
|
||||||
if (param["order"].isInt()) point = param["order"].asInt();
|
if (param["order"].isInt()) point = param["order"].asInt();
|
||||||
if (param["order"].isString()) point = atoi(param["order"].asCString());
|
if (param["order"].isString()) point = atoi(param["order"].asCString());
|
||||||
}
|
}
|
||||||
|
if (point < 0 || point >= config_config.units[sub_uid].yccount) continue;
|
||||||
|
key = attrs.ycs[i].name;
|
||||||
|
if (map_ycorders.find(key) != map_ycorders.end())
|
||||||
|
{
|
||||||
|
order = map_ycorders[key];
|
||||||
|
}
|
||||||
snprintf(config_config.units[sub_uid].ycs[point].name, sizeof(config_config.units[sub_uid].ycs[point].name), "%s", key.c_str());
|
snprintf(config_config.units[sub_uid].ycs[point].name, sizeof(config_config.units[sub_uid].ycs[point].name), "%s", key.c_str());
|
||||||
config_config.units[sub_uid].ycs[point].order = order;
|
config_config.units[sub_uid].ycs[point].order = order;
|
||||||
config_config.units[sub_uid].ycs[point].value = 0;
|
config_config.units[sub_uid].ycs[point].value = 0;
|
||||||
@ -2627,26 +2659,24 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
|||||||
config_config.units[sub_uid].ycs[point].highSpeed = FALSE;
|
config_config.units[sub_uid].ycs[point].highSpeed = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s_ymcount > 0)
|
if (config_config.units[sub_uid].ymcount > 0)
|
||||||
{
|
{
|
||||||
//config_config.units[sub_uid].yms = new struUnitYM[s_ymcount];
|
for (int i = 0; i < config_config.units[sub_uid].ymcount; i++) {
|
||||||
if (NULL != config_config.units[sub_uid].yms) {
|
std::string key;
|
||||||
memset(config_config.units[sub_uid].yms, 0, sizeof(struUnitYM) * s_ymcount);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < s_ymcount; i++) {
|
|
||||||
std::string key = attrs.yms[i].name;
|
|
||||||
int order = -1;
|
int order = -1;
|
||||||
int point = i;
|
int point = -1;
|
||||||
if (map_ymorders.find(key) != map_ymorders.end())
|
|
||||||
{
|
|
||||||
order = map_ymorders[key];
|
|
||||||
}
|
|
||||||
Json::Value param = attrs.yms[i].params;
|
Json::Value param = attrs.yms[i].params;
|
||||||
if (!param["order"].isNull())
|
if (!param["order"].isNull())
|
||||||
{
|
{
|
||||||
if (param["order"].isInt()) point = param["order"].asInt();
|
if (param["order"].isInt()) point = param["order"].asInt();
|
||||||
if (param["order"].isString()) point = atoi(param["order"].asCString());
|
if (param["order"].isString()) point = atoi(param["order"].asCString());
|
||||||
}
|
}
|
||||||
|
if (point < 0 || point >= config_config.units[sub_uid].ymcount) continue;
|
||||||
|
key = attrs.yms[i].name;
|
||||||
|
if (map_ymorders.find(key) != map_ymorders.end())
|
||||||
|
{
|
||||||
|
order = map_ymorders[key];
|
||||||
|
}
|
||||||
snprintf(config_config.units[sub_uid].yms[point].name, sizeof(config_config.units[sub_uid].yms[point].name), "%s", key.c_str());
|
snprintf(config_config.units[sub_uid].yms[point].name, sizeof(config_config.units[sub_uid].yms[point].name), "%s", key.c_str());
|
||||||
config_config.units[sub_uid].yms[point].order = order;
|
config_config.units[sub_uid].yms[point].order = order;
|
||||||
config_config.units[sub_uid].yms[point].value = 0;
|
config_config.units[sub_uid].yms[point].value = 0;
|
||||||
@ -2659,83 +2689,192 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s_ykcount > 0)
|
if (config_config.units[sub_uid].ykcount > 0)
|
||||||
{
|
{
|
||||||
//config_config.units[sub_uid].yks = new struUnitYK[s_ykcount];
|
for (int i = 0; i < config_config.units[sub_uid].ykcount; i++) {
|
||||||
if (NULL != config_config.units[sub_uid].yks) {
|
std::string key;
|
||||||
memset(config_config.units[sub_uid].yks, 0, sizeof(struUnitYK) * s_ykcount);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < s_ykcount; i++) {
|
|
||||||
std::string key = attrs.yks[i].name;
|
|
||||||
int order = -1;
|
int order = -1;
|
||||||
int point = i;
|
int point = -1;
|
||||||
if (map_ykorders.find(key) != map_ykorders.end())
|
|
||||||
{
|
|
||||||
order = map_ykorders[key];
|
|
||||||
}
|
|
||||||
Json::Value param = attrs.yks[i].params;
|
Json::Value param = attrs.yks[i].params;
|
||||||
if (!param["order"].isNull())
|
if (!param["order"].isNull())
|
||||||
{
|
{
|
||||||
if (param["order"].isInt()) point = param["order"].asInt();
|
if (param["order"].isInt()) point = param["order"].asInt();
|
||||||
if (param["order"].isString()) point = atoi(param["order"].asCString());
|
if (param["order"].isString()) point = atoi(param["order"].asCString());
|
||||||
}
|
}
|
||||||
|
if (point < 0 || point >= config_config.units[sub_uid].ykcount) continue;
|
||||||
|
key = attrs.yks[i].name;
|
||||||
|
if (map_ykorders.find(key) != map_ykorders.end())
|
||||||
|
{
|
||||||
|
order = map_ykorders[key];
|
||||||
|
}
|
||||||
|
if (map_ykorders.find(key) != map_ykorders.end())
|
||||||
|
{
|
||||||
|
order = map_ykorders[key];
|
||||||
|
}
|
||||||
snprintf(config_config.units[sub_uid].yks[point].name, sizeof(config_config.units[sub_uid].yks[point].name), "%s", key.c_str());
|
snprintf(config_config.units[sub_uid].yks[point].name, sizeof(config_config.units[sub_uid].yks[point].name), "%s", key.c_str());
|
||||||
config_config.units[sub_uid].yks[point].order = order;
|
config_config.units[sub_uid].yks[point].order = order;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s_ytcount > 0)
|
if (config_config.units[sub_uid].ytcount > 0)
|
||||||
{
|
{
|
||||||
//config_config.units[sub_uid].yts = new struUnitYT[s_ytcount];
|
for (int i = 0; i < config_config.units[sub_uid].ytcount; i++) {
|
||||||
if (NULL != config_config.units[sub_uid].yts) {
|
std::string key;
|
||||||
memset(config_config.units[sub_uid].yts, 0, sizeof(struUnitYT) * s_ytcount);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < s_ytcount; i++) {
|
|
||||||
std::string key = attrs.yts[i].name;
|
|
||||||
int order = -1;
|
int order = -1;
|
||||||
int point = i;
|
int point = -1;
|
||||||
if (map_ytorders.find(key) != map_ytorders.end())
|
|
||||||
{
|
|
||||||
order = map_ytorders[key];
|
|
||||||
}
|
|
||||||
Json::Value param = attrs.yts[i].params;
|
Json::Value param = attrs.yts[i].params;
|
||||||
if (!param["order"].isNull())
|
if (!param["order"].isNull())
|
||||||
{
|
{
|
||||||
if (param["order"].isInt()) point = param["order"].asInt();
|
if (param["order"].isInt()) point = param["order"].asInt();
|
||||||
if (param["order"].isString()) point = atoi(param["order"].asCString());
|
if (param["order"].isString()) point = atoi(param["order"].asCString());
|
||||||
}
|
}
|
||||||
|
if (point < 0 || point >= config_config.units[sub_uid].ytcount) continue;
|
||||||
|
key = attrs.yts[i].name;
|
||||||
|
if (map_ytorders.find(key) != map_ytorders.end())
|
||||||
|
{
|
||||||
|
order = map_ytorders[key];
|
||||||
|
}
|
||||||
snprintf(config_config.units[sub_uid].yts[point].name, sizeof(config_config.units[sub_uid].yts[point].name), "%s", key.c_str());
|
snprintf(config_config.units[sub_uid].yts[point].name, sizeof(config_config.units[sub_uid].yts[point].name), "%s", key.c_str());
|
||||||
config_config.units[sub_uid].yts[point].order = order;
|
config_config.units[sub_uid].yts[point].order = order;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s_yxcount > 0)
|
if (config_config.units[sub_uid].yxcount > 0)
|
||||||
{
|
{
|
||||||
//config_config.units[sub_uid].yxs = new struUnitYX[s_yxcount];
|
for (int i = 0; i < config_config.units[sub_uid].yxcount; i++) {
|
||||||
if (NULL != config_config.units[sub_uid].yxs) {
|
std::string key;
|
||||||
memset(config_config.units[sub_uid].yxs, 0, sizeof(struUnitYX) * s_yxcount);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < s_yxcount; i++) {
|
|
||||||
std::string key = attrs.yxs[i].name;
|
|
||||||
int order = -1;
|
int order = -1;
|
||||||
int point = i;
|
int point = -1;
|
||||||
if (map_yxorders.find(key) != map_yxorders.end())
|
|
||||||
{
|
|
||||||
order = map_yxorders[key];
|
|
||||||
}
|
|
||||||
Json::Value param = attrs.yxs[i].params;
|
Json::Value param = attrs.yxs[i].params;
|
||||||
if (!param["order"].isNull())
|
if (!param["order"].isNull())
|
||||||
{
|
{
|
||||||
if (param["order"].isInt()) point = param["order"].asInt();
|
if (param["order"].isInt()) point = param["order"].asInt();
|
||||||
if (param["order"].isString()) point = atoi(param["order"].asCString());
|
if (param["order"].isString()) point = atoi(param["order"].asCString());
|
||||||
}
|
}
|
||||||
|
if (point < 0 || point >= config_config.units[sub_uid].yxcount) continue;
|
||||||
|
key = attrs.yxs[i].name;
|
||||||
|
if (map_yxorders.find(key) != map_yxorders.end())
|
||||||
|
{
|
||||||
|
order = map_yxorders[key];
|
||||||
|
}
|
||||||
snprintf(config_config.units[sub_uid].yxs[point].name, sizeof(config_config.units[sub_uid].yxs[point].name), "%s", key.c_str());
|
snprintf(config_config.units[sub_uid].yxs[point].name, sizeof(config_config.units[sub_uid].yxs[point].name), "%s", key.c_str());
|
||||||
config_config.units[sub_uid].yxs[point].order = order;
|
config_config.units[sub_uid].yxs[point].order = order;
|
||||||
config_config.units[sub_uid].yxs[point].value = 0;
|
config_config.units[sub_uid].yxs[point].value = 0;
|
||||||
config_config.units[sub_uid].yxs[point].value = 0;
|
config_config.units[sub_uid].yxs[point].value = 0;
|
||||||
config_config.units[sub_uid].yxs[point].qds = 0x80; //默认为无效
|
config_config.units[sub_uid].yxs[point].qds = 0x80; //默认为无效
|
||||||
config_config.units[sub_uid].yxs[point].invert = 0;
|
config_config.units[sub_uid].yxs[point].invert = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
char csvFileName[260];
|
||||||
|
snprintf(csvFileName, sizeof(csvFileName), "%s/%s%d.csv", configpath, config_config.processes[pid].name, sub_uid);
|
||||||
|
FILE* csvFile = fopen(csvFileName, "wb+");
|
||||||
|
if (csvFile)
|
||||||
|
{
|
||||||
|
fprintf(csvFile, "[遥测量]\n");
|
||||||
|
for (int i = 0; i < config_config.units[sub_uid].yccount; i++)
|
||||||
|
{
|
||||||
|
struYCStatic yc;
|
||||||
|
memset(&yc, '\0', sizeof(yc));
|
||||||
|
if (pfdbycname && (config_config.units[sub_uid].ycs[i].order >= 0))
|
||||||
|
{
|
||||||
|
if (fseek(pfdbycname, sizeof(struYCStatic) * config_config.units[sub_uid].ycs[i].order, SEEK_SET) == 0)
|
||||||
|
{
|
||||||
|
fread(&yc, sizeof(yc), 1, pfdbycname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (yc.name[0] == '\0')
|
||||||
|
{
|
||||||
|
fprintf(csvFile, "%d=备用,1,0\n", i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(csvFile, "%d=%s,%f,%f\n", i, yc.name, config_config.units[sub_uid].ycs[i].coef, config_config.units[sub_uid].ycs[i].base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(csvFile, "[遥脉量]\n");
|
||||||
|
for (int i = 0; i < config_config.units[sub_uid].ymcount; i++)
|
||||||
|
{
|
||||||
|
struYMStatic ym;
|
||||||
|
memset(&ym, '\0', sizeof(ym));
|
||||||
|
if (pfdbymname && (config_config.units[sub_uid].yms[i].order >= 0))
|
||||||
|
{
|
||||||
|
if (fseek(pfdbymname, sizeof(struYMStatic) * config_config.units[sub_uid].yms[i].order, SEEK_SET) == 0)
|
||||||
|
{
|
||||||
|
fread(&ym, sizeof(ym), 1, pfdbymname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ym.name[0] == '\0')
|
||||||
|
{
|
||||||
|
fprintf(csvFile, "%d=备用\n", i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(csvFile, "%d=%s\n", i, ym.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(csvFile, "[遥控量]\n");
|
||||||
|
for (int i = 0; i < config_config.units[sub_uid].ykcount; i++)
|
||||||
|
{
|
||||||
|
struYKStatic yk;
|
||||||
|
memset(&yk, '\0', sizeof(yk));
|
||||||
|
if (pfdbykname && (config_config.units[sub_uid].yks[i].order >= 0))
|
||||||
|
{
|
||||||
|
if (fseek(pfdbykname, sizeof(struYKStatic) * config_config.units[sub_uid].yks[i].order, SEEK_SET) == 0)
|
||||||
|
{
|
||||||
|
fread(&yk, sizeof(yk), 1, pfdbykname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (yk.name[0] == '\0')
|
||||||
|
{
|
||||||
|
fprintf(csvFile, "%d=备用\n", i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(csvFile, "%d=%s\n", i, yk.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(csvFile, "[遥调量]\n");
|
||||||
|
for (int i = 0; i < config_config.units[sub_uid].ytcount; i++)
|
||||||
|
{
|
||||||
|
struYTStatic yt;
|
||||||
|
memset(&yt, '\0', sizeof(yt));
|
||||||
|
if (pfdbytname && (config_config.units[sub_uid].yts[i].order >= 0))
|
||||||
|
{
|
||||||
|
if (fseek(pfdbytname, sizeof(struYTStatic) * config_config.units[sub_uid].yts[i].order, SEEK_SET) == 0)
|
||||||
|
{
|
||||||
|
fread(&yt, sizeof(yt), 1, pfdbytname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (yt.name[0] == '\0')
|
||||||
|
{
|
||||||
|
fprintf(csvFile, "%d=备用\n", i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(csvFile, "%d=%s\n", i, yt.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(csvFile, "[遥信量]\n");
|
||||||
|
for (int i = 0; i < config_config.units[sub_uid].yxcount; i++)
|
||||||
|
{
|
||||||
|
struYXStatic yx;
|
||||||
|
if (pfdbyxname && (config_config.units[sub_uid].yxs[i].order >= 0))
|
||||||
|
{
|
||||||
|
if (fseek(pfdbyxname, sizeof(struYXStatic) * config_config.units[sub_uid].yxs[i].order, SEEK_SET) == 0)
|
||||||
|
{
|
||||||
|
fread(&yx, sizeof(yx), 1, pfdbyxname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (yx.name[0] == '\0')
|
||||||
|
{
|
||||||
|
fprintf(csvFile, "%d=备用,1,0\n", i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(csvFile, "%d=%s\n", i, yx.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(csvFile);
|
||||||
|
}
|
||||||
sub_uid++;
|
sub_uid++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2745,6 +2884,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
|||||||
if (pfdbymname) fclose(pfdbymname);
|
if (pfdbymname) fclose(pfdbymname);
|
||||||
if (pfdbykname) fclose(pfdbykname);
|
if (pfdbykname) fclose(pfdbykname);
|
||||||
if (pfdbytname) fclose(pfdbytname);
|
if (pfdbytname) fclose(pfdbytname);
|
||||||
|
|
||||||
//保存数据
|
//保存数据
|
||||||
configWriteNodeCFG();
|
configWriteNodeCFG();
|
||||||
configWriteSystemCFG();
|
configWriteSystemCFG();
|
||||||
|
@ -56,6 +56,7 @@ typedef std::unordered_map<std::string, std::string> unitserviceName2cmdIdmap;
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
std::string name;
|
std::string name;
|
||||||
|
std::string deviceId;
|
||||||
Json::Value params;
|
Json::Value params;
|
||||||
int highSpeed;
|
int highSpeed;
|
||||||
int order;
|
int order;
|
||||||
@ -89,7 +90,7 @@ public:
|
|||||||
|
|
||||||
void handle_message(const std::string & message);
|
void handle_message(const std::string & message);
|
||||||
private:
|
private:
|
||||||
uid2pidmap uid2pid_map;
|
string2intmap uid2pid_map;
|
||||||
unitname2servicemap unitname2service_map;
|
unitname2servicemap unitname2service_map;
|
||||||
unitserviceName2cmdIdmap unitserviceName2cmdId_map;
|
unitserviceName2cmdIdmap unitserviceName2cmdId_map;
|
||||||
std::string m_traceId;
|
std::string m_traceId;
|
||||||
|
Loading…
Reference in New Issue
Block a user