diff --git a/das-dn/cmg/ry.cpp b/das-dn/cmg/ry.cpp index 2cc7d1b4..49da4ad6 100644 --- a/das-dn/cmg/ry.cpp +++ b/das-dn/cmg/ry.cpp @@ -5,6 +5,8 @@ CRYDevice::CRYDevice() { ctx = NULL; conn = NULL; + + msg_count = 0; } CRYDevice::~CRYDevice() @@ -1788,7 +1790,7 @@ BOOLEAN CRYDevice::processSubModbusPointParam(const Json::Value jsonRoot, int ui { if (uid < 0 || uid >= UNIT_NUM) return FALSE; if (point < 0) return FALSE; - vLog(LOG_DEBUG, "%s", jsonRoot.toStyledString().c_str()); + //vLog(LOG_DEBUG, "%s", jsonRoot.toStyledString().c_str()); switch (type) { case POINT_TYPE_YX: @@ -1849,16 +1851,38 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot) int count = links.size(); int uartId = 0; - //m_gLinkIDs.clear(); + int uid = 0; uid2pid_map.clear(); + + long yxorder = 0, ycorder = 0, ymorder = 0, ykorder = 0, ytorder = 0; + string2intmap map_yxorders, map_ycorders, map_ymorders, map_ykorders, map_ytorders; + + pid2attrvectormap map_pid2attrserice; + + char dbyxname[512]; + snprintf(dbyxname, sizeof(dbyxname), "%s/%s", configpath, FILE_DATABASE_YX_STATIC); + FILE *pfdbyxname = fopen(dbyxname, "wb+"); + char dbycname[512]; + snprintf(dbycname, sizeof(dbycname), "%s/%s", configpath, FILE_DATABASE_YC_STATIC); + FILE *pfdbycname = fopen(dbycname, "wb+"); + char dbymname[512]; + snprintf(dbymname, sizeof(dbymname), "%s/%s", configpath, FILE_DATABASE_YM_STATIC); + FILE *pfdbymname = fopen(dbymname, "wb+"); + char dbykname[512]; + snprintf(dbykname, sizeof(dbykname), "%s/%s", configpath, FILE_DATABASE_YK_STATIC); + FILE *pfdbykname = fopen(dbykname, "wb+"); + char dbytname[512]; + snprintf(dbytname, sizeof(dbytname), "%s/%s", configpath, FILE_DATABASE_YT_STATIC); + FILE *pfdbytname = fopen(dbytname, "wb+"); + + map_yxorders.clear(); map_ycorders.clear(); map_ymorders.clear(); map_ykorders.clear(); map_ytorders.clear(); + for (int i = 0; i < count; i++) { const Json::Value link = links[i]; - + config_config.processes[i].state = TRUE; - config_config.processes[i].type = MASTER_UNIT; config_config.processes[i].time_gap = 300; //默认参数 config_config.processes[i].poll_gap = 5; - config_config.processes[i].mode = PROCESS_MODE_MASTER; if (link["linkName"].isString()) { snprintf(config_config.processes[i].name, sizeof(config_config.processes[i].name), "%s", link["linkName"].asCString()); @@ -1869,32 +1893,49 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot) if (link["protocol"].isInt()) { config_config.processes[i].proto = link["protocol"].asInt(); } - //处理链路参数,根据协议参数的不同来处理 + BYTE addrType = ADDR_TYPE_NORMAL; //根据协议设定单元地址类型 const Json::Value params = link["params"]; if (!params.isNull()) { switch (config_config.processes[i].proto) { case PROTOCOL_HOST_MODBUS_RTU: processUartParam(params, uartId); config_config.processes[i].order = uartId++; + config_config.processes[i].type = 1; + config_config.processes[i].mode = PROCESS_MODE_MASTER; break; case PROTOCOL_HOST_MODBUS_TCP: processHostModbustcpParam(params, i); + config_config.processes[i].type = 3; + config_config.processes[i].mode = PROCESS_MODE_MASTER; + addrType = ADDR_TYPE_IPV4; break; case PROTOCOL_HOST_BF_MODBUSTCP: processRymodbustcpParam(params, i); + config_config.processes[i].type = 3; + config_config.processes[i].mode = PROCESS_MODE_MASTER; + addrType = ADDR_TYPE_IPV4; break; case PROTOCOL_FTP2MINIO: processRyFTP2MinioParam(params, i); break; case PROTOCOL_HOST_IEC104: processHostIEC104ProcessParam(params, i); + config_config.processes[i].type = 3; + config_config.processes[i].mode = PROCESS_MODE_MASTER; + addrType = ADDR_TYPE_IPV4_FACNO; break; case PROTOCOL_SUB_IEC104: processSubIEC104ProcessParam(params, i); + config_config.processes[i].type = 3; + config_config.processes[i].mode = PROCESS_MODE_SLAVE; + addrType = ADDR_TYPE_IPV4_FACNO; break; case PROTOCOL_SUB_MODBUS_TCP: processSubModbustcpParam(params, i); + config_config.processes[i].type = 3; + config_config.processes[i].mode = PROCESS_MODE_SLAVE; + addrType = ADDR_TYPE_IPV4; break; default: break; @@ -1904,15 +1945,557 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot) const Json::Value devices = link["devices"]; if (devices.isArray()) { int size = devices.size(); - for (int j = 0; j < size; j++) { - std::string id = devices[j].asCString(); - if (uid2pid_map.find(id) == uid2pid_map.end()) { - uid2pid_map.insert(uid2pidmap::value_type(id, i)); + if (config_config.processes[i].mode == PROCESS_MODE_SLAVE) + { + attrvectorGroup attrsItem; + for (int j = 0; j < size; j++) { + const Json::Value device = devices[j]; + std::string id = ""; + std::string address = ""; + if (device["id"].isString()) { + id = device["id"].asString(); + } + if (device["addr"].isString()) { + address = device["addr"].asString(); + } + //此处先将数据缓存。然后在处理 + const Json::Value attrs = device["attrs"]; + if (!attrs.isNull()) { + int size = attrs.size(); + for (int k = 0; k < size; k++) { + const Json::Value attr = attrs[k]; + std::string type = ""; + if (attr["type"].isString()) type = attr["type"].asString(); + struct_attr name_param; + name_param.name = ""; + name_param.highSpeed = 0; + name_param.order = -1; + if (attr["name"].isString()) name_param.name = id + attr["name"].asString(); + if (attr["order"].isInt()) name_param.order = attr["order"].asInt(); + if (attr["params"].isObject()) name_param.params = attr["params"]; + if (type == "yc") attrsItem.ycs.push_back(name_param); + else if (type == "yx") attrsItem.yxs.push_back(name_param); + else if (type == "ym") attrsItem.yms.push_back(name_param); + } + } + const Json::Value services = device["services"]; + if (!services.isNull()) { + int size = services.size(); + for (int k = 0; k < size; k++) { + const Json::Value service = services[k]; + std::string type = ""; + if (service["type"].isString()) type = service["type"].asString(); + struct_attr name_param; + name_param.name = ""; + name_param.order = -1; + if (service["name"].isString()) name_param.name = id + service["name"].asString(); + if (service["order"].isInt()) name_param.order = service["order"].asInt(); + if (service["params"].isObject()) name_param.params = service["params"]; + if (type == "yk") attrsItem.yks.push_back(name_param); + else if (type == "yt") attrsItem.yts.push_back(name_param); + } + } + } + if (map_pid2attrserice.find(i) == map_pid2attrserice.end()) { + map_pid2attrserice.insert(pid2attrvectormap::value_type(i, attrsItem)); + } + } + else if (config_config.processes[i].mode == PROCESS_MODE_MASTER) + { + for (int j = 0; j < size; j++) { + const Json::Value device = devices[j]; + std::string id = ""; + std::string address = ""; + if (device["id"].isString()) { + id = device["id"].asString(); + } + if (device["addr"].isString()) { + address = device["addr"].asString(); + } + snprintf(config_static_units[uid].name, sizeof(config_static_units[uid].name), "device_%d", uid); + snprintf(config_static_units[uid].model, sizeof(config_static_units[uid].model), "model_%d", uid); + snprintf(config_static_units[uid].manufacturerId, sizeof(config_static_units[uid].manufacturerId), "%s", "iss"); + if (id != "") { + snprintf(config_static_units[uid].deviceId, sizeof(config_static_units[uid].deviceId), "%s", id.c_str()); + } else { + snprintf(config_static_units[uid].deviceId, sizeof(config_static_units[uid].deviceId), "iss_%d", uid); + } + + config_config.processes[i].units[j] = uid; + //根据协议修改地址 + if (address != "") { + if (addrType == ADDR_TYPE_HEX) { + StringToHex(address.c_str(), config_config.units[uid].addr); + } else if (addrType == ADDR_TYPE_IPV4) { + DWORD addr; + inet_pton(AF_INET, address.c_str(), (struct in_addr*)&addr); + memcpy(config_config.units[uid].addr, &addr, sizeof(addr)); + } else if (addrType == ADDR_TYPE_IPV4_FACNO) { + std::vector tokens = split(address, ':'); + if (tokens.size() >= 2) { + DWORD addr; + inet_pton(AF_INET, tokens.at(0).c_str(), (struct in_addr*)&addr); + memcpy(config_config.units[uid].addr, &addr, sizeof(addr)); + addr = (DWORD)atoi(tokens.at(1).c_str()); + memcpy(&config_config.units[uid].addr[4], &addr, sizeof(addr)); + } else { + DWORD addr; + inet_pton(AF_INET, tokens.at(0).c_str(), (struct in_addr*)&addr); + memcpy(config_config.units[uid].addr, &addr, sizeof(addr)); + addr = 1; + memcpy(&config_config.units[uid].addr[4], &addr, sizeof(addr)); + } + } else { + DWORD addr = (DWORD)atoi(address.c_str()); + memcpy(config_config.units[uid].addr, &addr, sizeof(addr)); + } + } + attrvector yxs, ycs, yms, yks, yts; + const Json::Value attrs = device["attrs"]; + if (!attrs.isNull()) { + int size = attrs.size(); + for (int k = 0; k < size; k++) { + const Json::Value attr = attrs[k]; + std::string type = ""; + if (attr["type"].isString()) type = attr["type"].asString(); + struct_attr name_param; + name_param.name = ""; + name_param.highSpeed = 0; + name_param.order = -1; + if (attr["name"].isString()) name_param.name = attr["name"].asString(); + if (attr["highSpeed"].isInt()) name_param.highSpeed = attr["highSpeed"].asInt(); + if (attr["order"].isInt()) name_param.order = attr["order"].asInt(); + if (attr["params"].isObject()) name_param.params = attr["params"]; + if (type == "yc") ycs.push_back(name_param); + else if (type == "yx") yxs.push_back(name_param); + else if (type == "ym") yms.push_back(name_param); + } + } + const Json::Value services = device["services"]; + if (!services.isNull()) { + int size = services.size(); + for (int k = 0; k < size; k++) { + const Json::Value service = services[k]; + std::string type = ""; + if (service["type"].isString()) type = service["type"].asString(); + struct_attr name_param; + name_param.name = ""; + name_param.order = -1; + if (service["name"].isString()) name_param.name = service["name"].asString(); + if (service["order"].isInt()) name_param.order = service["order"].asInt(); + if (service["params"].isObject()) name_param.params = service["params"]; + if (type == "yk") yks.push_back(name_param); + else if (type == "yt") yts.push_back(name_param); + } + } + + config_config.units[uid].value = SPI_ON; + config_config.units[uid].softdog = UNIT_WATCHDOG_TIME; + config_config.units[uid].state = TRUE; + config_config.units[uid].type = MASTER_UNIT; + config_config.units[uid].yxcount = yxs.size(); + config_config.units[uid].yccount = ycs.size(); + config_config.units[uid].ymcount = yms.size(); + config_config.units[uid].ykcount = yks.size(); + config_config.units[uid].ytcount = yts.size(); + if (config_config.units[uid].yccount > 0) { + config_config.units[uid].ycs = new struUnitYC[config_config.units[uid].yccount]; + 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++) { + 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++; + std::string idattrname = id + ycs[k].name; + if (map_ycorders.find(idattrname) == map_ycorders.end()) { + map_ycorders.insert(string2intmap::value_type(idattrname, config_config.units[uid].ycs[k].order)); + } + config_config.units[uid].ycs[k].value = 0; + config_config.units[uid].ycs[k].qds = 0x80; //默认为无效 + config_config.units[uid].ycs[k].factor = 1; + config_config.units[uid].ycs[k].change_pos = 2; + config_config.units[uid].ycs[k].coef = 1.0f; + config_config.units[uid].ycs[k].base = 0; + config_config.units[uid].ycs[k].upBound = 9999999.999f; + config_config.units[uid].ycs[k].lowBound = -9999999.999f; + config_config.units[uid].ycs[k].limit1Enable = FALSE; + config_config.units[uid].ycs[k].limit1Low = 0; + config_config.units[uid].ycs[k].limit1High = 0.0f; + config_config.units[uid].ycs[k].limit2Enable = FALSE; + config_config.units[uid].ycs[k].limit2Low = 0; + config_config.units[uid].ycs[k].limit2High = 0.0f; + config_config.units[uid].ycs[k].highSpeed = ycs[k].highSpeed; + Json::Value param = ycs[k].params; + if (!param.isNull()) { + if (param["coef"].isDouble()) config_config.units[uid].ycs[k].coef = param["coef"].asFloat(); + if (param["base"].isDouble()) config_config.units[uid].ycs[k].base = param["base"].asFloat(); + if (param["base"].isDouble()) config_config.units[uid].ycs[k].base = param["base"].asFloat(); + if (param["upBound"].isDouble()) config_config.units[uid].ycs[k].upBound = param["upBound"].asFloat(); + if (param["lowBound"].isDouble()) config_config.units[uid].ycs[k].lowBound = param["lowBound"].asFloat(); + if (param["limit1Enable"].isInt()) config_config.units[uid].ycs[k].limit1Enable = param["limit1Enable"].asInt(); + if (param["limit2Enable"].isInt()) config_config.units[uid].ycs[k].limit2Enable = param["limit2Enable"].asInt(); + if (param["limit1Low"].isDouble()) config_config.units[uid].ycs[k].limit1Low = param["limit1Low"].asFloat(); + if (param["limit2Low"].isDouble()) config_config.units[uid].ycs[k].limit2Low = param["limit2Low"].asFloat(); + if (param["limit1High"].isDouble()) config_config.units[uid].ycs[k].limit1High = param["limit1High"].asFloat(); + if (param["limit2High"].isDouble()) config_config.units[uid].ycs[k].limit2High = param["limit2High"].asFloat(); + + //vLog(LOG_DEBUG, "config_config.units[%d].ycs[%d].coef is: %f\n", uid, k, config_config.units[uid].ycs[k].coef); + switch (config_config.processes[i].proto) { + case PROTOCOL_HOST_MODBUS_RTU: + case PROTOCOL_HOST_MODBUS_TCP: + case PROTOCOL_HOST_MODBUS_RTU_TCP: + case PROTOCOL_HOST_BF_MODBUSTCP: + processHostModbusPointParam(param, uid, k, POINT_TYPE_YC); + break; + case PROTOCOL_HOST_IEC104: + break; + case PROTOCOL_SUB_MODBUS_TCP: + processSubModbusPointParam(param, uid, k, POINT_TYPE_YC); + break; + } + } + if (config_config.units[uid].type == MASTER_UNIT) { + config_database.ycs[config_config.units[uid].ycs[k].order].coef = config_config.units[uid].ycs[k].coef; + config_database.ycs[config_config.units[uid].ycs[k].order].base = config_config.units[uid].ycs[k].base; + } + if (pfdbycname) { + 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 (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) { + 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++) { + snprintf(config_config.units[uid].yms[k].name, sizeof(config_config.units[uid].yms[k].name), "%s", yms[k].name.c_str()); + config_config.units[uid].yms[k].order = ymorder++; + std::string idattrname = id + yms[k].name; + if (map_ymorders.find(idattrname) == map_ymorders.end()) { + map_ymorders.insert(string2intmap::value_type(idattrname, config_config.units[uid].yms[k].order)); + } + config_config.units[uid].yms[k].value = 0; + config_config.units[uid].yms[k].coef = 1.0f; + config_config.units[uid].yms[k].base = 0; + + Json::Value param = yms[k].params; + if (!param.isNull()) { + switch (config_config.processes[i].proto) { + case PROTOCOL_HOST_MODBUS_RTU: + case PROTOCOL_HOST_MODBUS_TCP: + case PROTOCOL_HOST_MODBUS_RTU_TCP: + case PROTOCOL_HOST_BF_MODBUSTCP: + processHostModbusPointParam(param, uid, k, POINT_TYPE_YM); + break; + case PROTOCOL_HOST_IEC104: + break; + } + } + if (config_config.units[uid].type == MASTER_UNIT) { + config_database.yms[config_config.units[uid].yms[k].order].coef = config_config.units[uid].yms[k].coef; + config_database.yms[config_config.units[uid].yms[k].order].base = config_config.units[uid].yms[k].base; + } + + if (pfdbymname) { + 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 (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) { + 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++) { + snprintf(config_config.units[uid].yks[k].name, sizeof(config_config.units[uid].yks[k].name), "%s", yks[k].name.c_str()); + config_config.units[uid].yks[k].order = ykorder++; + std::string idserverrname = id + yks[k].name; + if (map_ykorders.find(idserverrname) == map_ykorders.end()) { + map_ykorders.insert(string2intmap::value_type(idserverrname, config_config.units[uid].yks[k].order)); + } + + Json::Value param = yks[k].params; + if (!param.isNull()) { + switch (config_config.processes[i].proto) { + case PROTOCOL_HOST_MODBUS_RTU: + case PROTOCOL_HOST_MODBUS_TCP: + case PROTOCOL_HOST_MODBUS_RTU_TCP: + case PROTOCOL_HOST_BF_MODBUSTCP: + processHostModbusPointParam(param, uid, k, POINT_TYPE_YK); + break; + case PROTOCOL_HOST_IEC104: + break; + } + } + if (pfdbykname) { + 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 (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) { + 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++) { + snprintf(config_config.units[uid].yts[k].name, sizeof(config_config.units[uid].yts[k].name), "%s", yts[k].name.c_str()); + config_config.units[uid].yts[k].order = ytorder++; + std::string idserverrname = id + yts[k].name; + if (map_ytorders.find(idserverrname) == map_ytorders.end()) { + map_ytorders.insert(string2intmap::value_type(idserverrname, config_config.units[uid].yts[k].order)); + } + + Json::Value param = yts[k].params; + if (!param.isNull()) { + switch (config_config.processes[i].proto) { + case PROTOCOL_HOST_MODBUS_RTU: + case PROTOCOL_HOST_MODBUS_TCP: + case PROTOCOL_HOST_MODBUS_RTU_TCP: + case PROTOCOL_HOST_BF_MODBUSTCP: + processHostModbusPointParam(param, uid, k, POINT_TYPE_YT); + break; + case PROTOCOL_HOST_IEC104: + break; + } + } + if (pfdbytname) { + 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 (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) { + 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++) { + snprintf(config_config.units[uid].yxs[k].name, sizeof(config_config.units[uid].yxs[k].name), "%s", yxs[k].name.c_str()); + config_config.units[uid].yxs[k].order = yxorder++; + std::string idattrname = id + yxs[k].name; + if (map_yxorders.find(idattrname) == map_yxorders.end()) { + map_yxorders.insert(string2intmap::value_type(idattrname, config_config.units[uid].yxs[k].order)); + } + config_config.units[uid].yxs[k].value = 0; + config_config.units[uid].yxs[k].qds = 0x80; //默认为无效 + config_config.units[uid].yxs[k].invert = 0; + config_database.yxs[config_config.units[uid].yxs[k].order].auto_reset = 0; + + Json::Value param = yxs[k].params; + if (!param.isNull()) { + if (param["invert"].asInt()) config_config.units[uid].yxs[k].invert = param["invert"].asInt(); + switch (config_config.processes[i].proto) { + case PROTOCOL_HOST_MODBUS_RTU: + case PROTOCOL_HOST_MODBUS_TCP: + case PROTOCOL_HOST_MODBUS_RTU_TCP: + case PROTOCOL_HOST_BF_MODBUSTCP: + processHostModbusPointParam(param, uid, k, POINT_TYPE_YX); + break; + case PROTOCOL_HOST_IEC104: + break; + } + } + if (pfdbyxname) { + fseek(pfdbyxname, sizeof(struYKStatic) * config_config.units[uid].yxs[k].order, SEEK_SET); + fwrite(yxs[k].name.c_str(), (MAX_NAME_SIZE << 2), 1, pfdbyxname); + } + } + } + } + uid++; } } } } +#if 1 + //判断从设备列表 + int sub_uid = uid; + for (pid2attrvectormap::iterator it = map_pid2attrserice.begin(); it != map_pid2attrserice.end(); it++) + { + int pid = it->first; + attrvectorGroup attrs = it->second; + switch (config_config.processes[pid].proto) + { + case PROTOCOL_SUB_MODBUS_TCP: + config_config.units[sub_uid].addr[4] = 1; + config_config.processes[pid].option.smodbus.defaultYCType = 1; + break; + case PROTOCOL_SUB_IEC104: + config_config.units[sub_uid].addr[4] = 1; + break; + } + config_config.units[sub_uid].value = SPI_ON; + config_config.units[sub_uid].softdog = UNIT_WATCHDOG_TIME; + config_config.units[sub_uid].state = TRUE; + config_config.units[sub_uid].type = SLAVER_UNIT; + config_config.units[sub_uid].yxcount = attrs.yxs.size(); + config_config.units[sub_uid].yccount = attrs.ycs.size(); + config_config.units[sub_uid].ymcount = attrs.yms.size(); + config_config.units[sub_uid].ykcount = attrs.yks.size(); + config_config.units[sub_uid].ytcount = attrs.yts.size(); + + config_config.processes[pid].units[0] = sub_uid; + if (config_config.units[sub_uid].yccount > 0) + { + config_config.units[sub_uid].ycs = new struUnitYC[config_config.units[sub_uid].yccount]; + if (NULL != config_config.units[sub_uid].ycs) { + memset(config_config.units[sub_uid].ycs, 0, sizeof(struUnitYC) * config_config.units[sub_uid].yccount); + } + for (int i = 0; i < config_config.units[sub_uid].yccount; i++) { + std::string key = attrs.ycs[i].name; + int order = -1; + int point = i; + if (map_ycorders.find(key) != map_ycorders.end()) + { + order = map_ycorders[key]; + } + Json::Value param = attrs.ycs[i].params; + if (!param["order"].isNull()) + { + if (param["order"].isInt()) point = param["order"].asInt(); + if (param["order"].isString()) point = atoi(param["order"].asCString()); + } + 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].value = 0; + config_config.units[sub_uid].ycs[point].qds = 0x80; //默认为无效 + config_config.units[sub_uid].ycs[point].factor = 1; + config_config.units[sub_uid].ycs[point].change_pos = 2; + if (order >= 0) { + config_config.units[sub_uid].ycs[point].coef = config_database.ycs[order].coef; + config_config.units[sub_uid].ycs[point].base = config_database.ycs[order].base; + } else { + config_config.units[sub_uid].ycs[point].coef = 1.0f; + config_config.units[sub_uid].ycs[point].base = 0.0f; + } + config_config.units[sub_uid].ycs[point].upBound = 9999999.999f; + config_config.units[sub_uid].ycs[point].lowBound = -9999999.999f; + config_config.units[sub_uid].ycs[point].limit1Enable = FALSE; + config_config.units[sub_uid].ycs[point].limit1Low = 0; + config_config.units[sub_uid].ycs[point].limit1High = 0.0f; + config_config.units[sub_uid].ycs[point].limit2Enable = FALSE; + config_config.units[sub_uid].ycs[point].limit2Low = 0; + config_config.units[sub_uid].ycs[point].limit2High = 0.0f; + config_config.units[sub_uid].ycs[point].highSpeed = FALSE; + } + } + if (config_config.units[sub_uid].ymcount > 0) + { + config_config.units[sub_uid].yms = new struUnitYM[config_config.units[sub_uid].ymcount]; + if (NULL != config_config.units[sub_uid].yms) { + memset(config_config.units[sub_uid].yms, 0, sizeof(struUnitYM) * config_config.units[sub_uid].ymcount); + } + for (int i = 0; i < config_config.units[sub_uid].ymcount; i++) { + std::string key = attrs.yms[i].name; + int order = -1; + int point = i; + if (map_ymorders.find(key) != map_ymorders.end()) + { + order = map_ymorders[key]; + } + Json::Value param = attrs.yms[i].params; + if (!param["order"].isNull()) + { + if (param["order"].isInt()) point = param["order"].asInt(); + if (param["order"].isString()) point = atoi(param["order"].asCString()); + } + 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].value = 0; + if (order >= 0) { + config_config.units[sub_uid].yms[point].coef = config_database.yms[order].coef; + config_config.units[sub_uid].yms[point].base = config_database.yms[order].base; + } else { + config_config.units[sub_uid].yms[point].coef = 1.0f; + config_config.units[sub_uid].yms[point].base = 0.0f; + } + } + } + if (config_config.units[sub_uid].ykcount > 0) + { + config_config.units[sub_uid].yks = new struUnitYK[config_config.units[sub_uid].ykcount]; + if (NULL != config_config.units[sub_uid].yks) { + memset(config_config.units[sub_uid].yks, 0, sizeof(struUnitYK) * config_config.units[sub_uid].ykcount); + } + for (int i = 0; i < config_config.units[sub_uid].ykcount; i++) { + std::string key = attrs.yks[i].name; + int order = -1; + int point = i; + if (map_ykorders.find(key) != map_ykorders.end()) + { + order = map_ykorders[key]; + } + Json::Value param = attrs.yks[i].params; + if (!param["order"].isNull()) + { + if (param["order"].isInt()) point = param["order"].asInt(); + if (param["order"].isString()) point = atoi(param["order"].asCString()); + } + 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; + } + } + if (config_config.units[sub_uid].ytcount > 0) + { + config_config.units[sub_uid].yts = new struUnitYT[config_config.units[sub_uid].ytcount]; + if (NULL != config_config.units[sub_uid].yts) { + memset(config_config.units[sub_uid].yts, 0, sizeof(struUnitYT) * config_config.units[sub_uid].ytcount); + } + for (int i = 0; i < config_config.units[sub_uid].ytcount; i++) { + std::string key = attrs.yts[i].name; + int order = -1; + int point = i; + if (map_ytorders.find(key) != map_ytorders.end()) + { + order = map_ytorders[key]; + } + Json::Value param = attrs.yts[i].params; + if (!param["order"].isNull()) + { + if (param["order"].isInt()) point = param["order"].asInt(); + if (param["order"].isString()) point = atoi(param["order"].asCString()); + } + 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; + } + } + if (config_config.units[sub_uid].yxcount > 0) + { + config_config.units[sub_uid].yxs = new struUnitYX[config_config.units[sub_uid].yxcount]; + if (NULL != config_config.units[sub_uid].yxs) { + memset(config_config.units[sub_uid].yxs, 0, sizeof(struUnitYX) * config_config.units[sub_uid].yxcount); + } + for (int i = 0; i < config_config.units[sub_uid].yxcount; i++) { + std::string key = attrs.yxs[i].name; + int order = -1; + int point = i; + if (map_yxorders.find(key) != map_yxorders.end()) + { + order = map_yxorders[key]; + } + Json::Value param = attrs.yxs[i].params; + if (!param["order"].isNull()) + { + if (param["order"].isInt()) point = param["order"].asInt(); + if (param["order"].isString()) point = atoi(param["order"].asCString()); + } + 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].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].invert = 0; + + } + } + sub_uid++; + } +#endif +#if 0 //更新设备列表 const Json::Value equipments = jsonRoot["equipments"]; { @@ -2020,7 +2603,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot) name_param.highSpeed = 0; if (attr["name"].isString()) name_param.name = attr["name"].asString(); if (attr["highSpeed"].isInt()) name_param.highSpeed = attr["highSpeed"].asInt(); - if (attr["params"].isObject()) name_param.value = attr["params"]; + if (attr["params"].isObject()) name_param.params = attr["params"]; if (type == "yc") ycs.push_back(name_param); else if (type == "yx") yxs.push_back(name_param); else if (type == "ym") yms.push_back(name_param); @@ -2036,7 +2619,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot) struct_attr name_param; name_param.name = ""; if (service["name"].isString()) name_param.name = service["name"].asString(); - if (service["params"].isObject()) name_param.value = service["params"]; + if (service["params"].isObject()) name_param.params = service["params"]; if (type == "yk") yks.push_back(name_param); else if (type == "yt") yts.push_back(name_param); } @@ -2074,7 +2657,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot) config_config.units[uid].ycs[k].limit2Low = 0; config_config.units[uid].ycs[k].limit2High = 0.0f; config_config.units[uid].ycs[k].highSpeed = ycs[k].highSpeed; - Json::Value param = ycs[k].value; + Json::Value param = ycs[k].params; if (!param.isNull()) { if (param["coef"].isDouble()) config_config.units[uid].ycs[k].coef = param["coef"].asFloat(); if (param["base"].isDouble()) config_config.units[uid].ycs[k].base = param["base"].asFloat(); @@ -2124,7 +2707,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot) config_config.units[uid].yms[k].coef = 1.0f; config_config.units[uid].yms[k].base = 0; - Json::Value param = yms[k].value; + Json::Value param = yms[k].params; if (!param.isNull()) { switch (config_config.processes[pid].proto) { case PROTOCOL_HOST_MODBUS_RTU: @@ -2157,7 +2740,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot) snprintf(config_config.units[uid].yks[k].name, sizeof(config_config.units[uid].yks[k].name), "%s", yks[k].name.c_str()); config_config.units[uid].yks[k].order = ykorder++; - Json::Value param = yks[k].value; + Json::Value param = yks[k].params; if (!param.isNull()) { switch (config_config.processes[pid].proto) { case PROTOCOL_HOST_MODBUS_RTU: @@ -2185,7 +2768,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot) snprintf(config_config.units[uid].yts[k].name, sizeof(config_config.units[uid].yts[k].name), "%s", yts[k].name.c_str()); config_config.units[uid].yts[k].order = ytorder++; - Json::Value param = yts[k].value; + Json::Value param = yts[k].params; if (!param.isNull()) { switch (config_config.processes[pid].proto) { case PROTOCOL_HOST_MODBUS_RTU: @@ -2217,7 +2800,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot) config_config.units[uid].yxs[k].invert = 0; config_database.yxs[config_config.units[uid].yxs[k].order].auto_reset = 0; - Json::Value param = yxs[k].value; + Json::Value param = yxs[k].params; if (!param.isNull()) { if (param["invert"].asInt()) config_config.units[uid].yxs[k].invert = param["invert"].asInt(); switch (config_config.processes[pid].proto) { @@ -2245,6 +2828,13 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot) if (pfdbykname) fclose(pfdbykname); if (pfdbytname) fclose(pfdbytname); } +#endif + //保存数据库静态数据 + if (pfdbyxname) fclose(pfdbyxname); + if (pfdbycname) fclose(pfdbycname); + if (pfdbymname) fclose(pfdbymname); + if (pfdbykname) fclose(pfdbykname); + if (pfdbytname) fclose(pfdbytname); //保存数据 configWriteNodeCFG(); configWriteSystemCFG(); @@ -2296,11 +2886,11 @@ void CRYDevice::on_message(const char *msg, const int size) Json::CharReaderBuilder builder; Json::CharReader* reader(builder.newCharReader()); - vLog(LOG_DEBUG, "Received: %s.\n", msg); + //vLog(LOG_DEBUG, "Received: %s.\n", msg); do { if (!reader->parse(msg, msg + size, &jsonRoot, &err)) { - vLog(LOG_ERROR, "reader->parse(msg, msg + size, &jsonRoot, &err) error<%d,%s>。\n", errno, err.c_str()); + vLog(LOG_ERROR, "on_message reader->parse(msg, msg + size, &jsonRoot, &err) error<%d,%s>。\n", errno, err.c_str()); break; } if (jsonRoot["cmd"].isNull()) { @@ -2522,6 +3112,7 @@ BOOLEAN CRYDevice::ry_init(const char *host, const int port, const char *nodeId, unitname2service_map.clear(); for (int i = 0; i < UNIT_NUM; i++) { if (config.units[i].state != TRUE) continue; + if ((config.units[i].type & 0x0f) == SLAVER_UNIT) continue; std::string unit_id = static_units[i].deviceId; name2servicemap name2service_map; for (int j = 0; j < config.units[i].ykcount; j++) { @@ -2581,22 +3172,14 @@ bool CRYDevice::ry_run(void) while ((msg[msg_count] = nopoll_conn_get_msg(conn)) != NULL) { #if 1 - vLog(LOG_DEBUG, "recv %d length = %d, %d\n", msg_count, nopoll_msg_get_payload_size(msg[msg_count]), nopoll_msg_is_final(msg[msg_count])); -#endif -#if 0 - char pathN[256]; - snprintf(pathN, sizeof(pathN), "0/_%d.txt", msg_count); - FILE* pf = fopen(pathN, "w+"); - if (pf) { - fwrite(nopoll_msg_get_payload(msg[msg_count]), nopoll_msg_get_payload_size(msg[msg_count]), 1, pf); - fclose(pf); - } + vLog(LOG_DEBUG, "recv %d length = %d, final is: %d, fragment is: %d\n", msg_count, nopoll_msg_get_payload_size(msg[msg_count]), nopoll_msg_is_final(msg[msg_count]), nopoll_msg_is_fragment(msg[msg_count])); #endif if (nopoll_msg_is_final(msg[msg_count])) { msg_count++; if (msg_count > 0) { int buffer_len; BYTE *buffer = NULL; + vLog(LOG_DEBUG, "here... msg count is: %d\n", msg_count); if (websocket_msg_join(msg, msg_count, buffer, buffer_len)) { if (buffer) { on_message((const char *)buffer, buffer_len); diff --git a/das-dn/cmg/ry.h b/das-dn/cmg/ry.h index 9e0b9950..a35d94bb 100644 --- a/das-dn/cmg/ry.h +++ b/das-dn/cmg/ry.h @@ -46,11 +46,26 @@ typedef std::unordered_map unitserviceName2cmdIdmap; typedef struct { std::string name; - Json::Value value; - int highSpeed; + Json::Value params; + int highSpeed; + int order; } struct_attr; typedef std::vector attrvector; +//设备id和attrs/services名称对应的测点序号 +typedef std::unordered_map string2intmap; + +//设备unit和attrvector对应的关系 +typedef struct { + attrvector yxs; + attrvector ycs; + attrvector yms; + attrvector yks; + attrvector yts; +} attrvectorGroup; +typedef std::unordered_map pid2attrvectormap; + + class CRYDevice { public: diff --git a/das-dn/inc/public.h b/das-dn/inc/public.h index f5acc4f7..36e50592 100644 --- a/das-dn/inc/public.h +++ b/das-dn/inc/public.h @@ -642,6 +642,12 @@ typedef struct struModbusOption modbus; } struUnitModbusOption; +typedef struct +{ + struNetWorkOption net; + BYTE defaultYCType; +} struSubModbusTCPOption; + typedef struct { BYTE addressLength; @@ -858,6 +864,7 @@ typedef union struIEC104Option iec104; struIEC103Option iec103; struIEC101Option iec101; + struSubModbusTCPOption smodbus; struRYModbusOption rymodbus; struRYFTP2MINIOOption ftp2minio; } unionProcOption; diff --git a/das-dn/submodbustcp/sub_modbus_tcp.cpp b/das-dn/submodbustcp/sub_modbus_tcp.cpp index 86d9a3db..cf671502 100644 --- a/das-dn/submodbustcp/sub_modbus_tcp.cpp +++ b/das-dn/submodbustcp/sub_modbus_tcp.cpp @@ -123,30 +123,30 @@ BOOLEAN CSubModbusTcpProcess::OnPreCreate(int id) m_DiscreteTable.clear(); m_HoldingRegTable.clear(); m_InputRegTable.clear(); +#if 1 //获取遥信数量 int yxcount = GetUnitYXCount(uid); - //获取coil和discrete寄存器 for (j = 0; j < yxcount; j++) { - BYTE* param = GetUnitYXParamByPoint(uid, j); - if (param) { - if (param[0] == 0 || param[0] == 1) { - m_DiscreteTable.push_back(j); - } else { - m_CoilRegTable.push_back(j); - } - } + m_DiscreteTable.push_back(j); + } + + int ykcount = GetUnitYKCount(uid); + for (j = 0; j < ykcount; j++) { + m_CoilRegTable.push_back(j); } int yccount = GetUnitYCCount(uid); for (j = 0; j < yccount; j++) { - BYTE* param = GetUnitYCParamByPoint(uid, j); - if (param) { - if (param[0] == 0 || param[0] == 1) { - m_InputRegTable.push_back(j); - } else { - m_HoldingRegTable.push_back(j); - } - } + m_InputRegTable.push_back(j); + } + int ymcount = GetUnitYMCount(uid); + for (j = 0; j < ymcount; j++) { + m_InputRegTable.push_back(j); + } + + int ytcount = GetUnitYTCount(uid); + for (j = 0; j < ytcount; j++) { + m_HoldingRegTable.push_back(j); } if (m_CoilRegTable.size() > 0) @@ -154,6 +154,7 @@ BOOLEAN CSubModbusTcpProcess::OnPreCreate(int id) pItem->m_CoilRegCount = m_CoilRegTable.size(); pItem->m_pCoilRegTable = new BYTE[pItem->m_CoilRegCount]; memset(pItem->m_pCoilRegTable, 0, sizeof(BYTE) * pItem->m_CoilRegCount); + pItem->m_ykcount = ykcount; } if (m_DiscreteTable.size() > 0) { @@ -165,25 +166,51 @@ BOOLEAN CSubModbusTcpProcess::OnPreCreate(int id) { int count = 0; if (m_YC_Type == M_ME_NC) count = (m_InputRegTable.size() << 1); - else count = m_InputRegTable.size(); + else { + count = yccount + (ymcount << 1); + } pItem->m_InputregCount = count; pItem->m_pInputRegTable = new WORD[count]; memset(pItem->m_pInputRegTable, 0, sizeof(WORD) * count); + pItem->m_yccount = yccount; + pItem->m_ymcount = ymcount; } - int ymcount = GetUnitYMCount(uid); - if (m_HoldingRegTable.size() > 0 || ymcount > 0) + if (m_HoldingRegTable.size() > 0) { int count = m_HoldingRegTable.size(); - if (m_YC_Type == M_ME_NC) count = (count << 1); - count += (ymcount << 1); pItem->m_HoldingRegCount = count; pItem->m_pHoldingRegTable = new WORD[count]; memset(pItem->m_pHoldingRegTable, 0, sizeof(WORD) * count); + pItem->m_ytcount = ytcount; } +#else + pItem->m_yxcount = GetUnitYXCount(uid); + pItem->m_yccount = GetUnitYCCount(uid); + pItem->m_ymcount = GetUnitYMCount(uid); + pItem->m_ykcount = GetUnitYKCount(uid); + pItem->m_ytcount = GetUnitYTCount(uid); + + pItem->m_CoilRegCount = UNIT_YK_MAX; + pItem->m_pCoilRegTable = new BYTE[pItem->m_CoilRegCount]; + memset(pItem->m_pCoilRegTable, 0, sizeof(BYTE) * pItem->m_CoilRegCount); + + pItem->m_DiscreteRegCount = UNIT_YX_MAX; + pItem->m_pDiscreteRegTable = new BYTE[pItem->m_DiscreteRegCount]; + memset(pItem->m_pDiscreteRegTable, 0, sizeof(BYTE) * pItem->m_DiscreteRegCount); + + pItem->m_HoldingRegCount = UNIT_YT_MAX; + pItem->m_pHoldingRegTable = new WORD[pItem->m_HoldingRegCount]; + memset(pItem->m_pHoldingRegTable, 0, sizeof(WORD) * pItem->m_HoldingRegCount); + + pItem->m_InputregCount = 0x5700; + pItem->m_pHoldingRegTable = new WORD[pItem->m_InputregCount]; + memset(pItem->m_pHoldingRegTable, 0, sizeof(WORD) * pItem->m_InputregCount); +#endif } return TRUE; } + BOOLEAN CSubModbusTcpProcess::Run(void) { if (!CNetProcess::Run()) return FALSE; @@ -198,72 +225,55 @@ BOOLEAN CSubModbusTcpProcess::Run(void) uid = pItem->GetUnitID(); if (uid < 0) continue; //刷新寄存器 - WORD *wd_input = NULL; - WORD *wd_hold = NULL; - BYTE *bt_coil = NULL; - BYTE *bt_discrete = NULL; + WORD *wd_input = NULL; + BYTE *bt_discrete = NULL; - if (pItem->m_pInputRegTable) { + if (pItem->m_pInputRegTable) + { wd_input = (WORD *)pItem->m_pInputRegTable; - } - if (pItem->m_pHoldingRegTable) { - wd_hold = (WORD *)pItem->m_pHoldingRegTable; - } - for (j = 0; j < m_InputRegTable.size(); j++) - { - if (m_YC_Type == M_ME_NC) + for (j = 0; j < pItem->m_yccount; j++) { - union + if (m_YC_Type == M_ME_NC) { - float fv; - DWORD dv; - } val; - - val.fv = GetUnitYCReal(uid, m_InputRegTable[j]); - *wd_input = ((val.dv >> 16) & 0xffff); wd_input++; - *wd_input = (val.dv & 0xffff); wd_input++; - } - else - { - *wd_input = (WORD)GetUnitYC(uid, m_InputRegTable[j]); wd_input++; - } - } - for (j = 0; j < m_HoldingRegTable.size(); j++) - { - if (m_YC_Type == M_ME_NC) - { - union + union + { + float fv; + DWORD dv; + } val; + val.fv = GetUnitYCReal(uid, j); + *wd_input = ((val.dv >> 16) & 0xffff); wd_input++; + *wd_input = (val.dv & 0xffff); wd_input++; + } + else { - float fv; - DWORD dv; - } val; - - val.fv = GetUnitYCReal(uid, m_HoldingRegTable[j]); - *wd_hold = ((val.dv >> 16) & 0xffff); wd_hold++; - *wd_hold = (val.dv & 0xffff); wd_hold++; + *wd_input = (WORD)GetUnitYC(uid, j); wd_input++; + } } - else + for (j = 0; j < pItem->m_ymcount; j++) { - *wd_hold = (WORD)GetUnitYC(uid, m_HoldingRegTable[j]); wd_hold++; + if (m_YC_Type == M_ME_NC) + { + union + { + float fv; + DWORD dv; + } val; + val.fv = GetUnitYMReal(uid, j); + *wd_input = ((val.dv >> 16) & 0xffff); wd_input++; + *wd_input = (val.dv & 0xffff); wd_input++; + } + else + { + DWORD value = GetUnitYM(uid, j); + *wd_input = ((value >> 16) & 0xffff); wd_input++; + *wd_input = (value & 0xffff); wd_input++; + } } } - for (j = 0; j < GetUnitYMCount(uid); j++) - { - DWORD val = (DWORD)GetUnitYM(uid, j); - *wd_hold = ((val >> 16) & 0xffff); wd_hold++; - *wd_hold = (val & 0xffff); wd_hold++; - } - if (pItem->m_pCoilRegTable) { - bt_coil = (BYTE *)pItem->m_pCoilRegTable; - for (j = 0; j < m_CoilRegTable.size(); j++) - { - *bt_coil = (BYTE)GetUnitYX(uid, m_CoilRegTable[j]); bt_coil++; - } - } if (pItem->m_pDiscreteRegTable) { bt_discrete = (BYTE *)pItem->m_pDiscreteRegTable; - for (j = 0; j < m_DiscreteTable.size(); j++) + for (j = 0; j < pItem->m_yxcount; j++) { *bt_discrete = (BYTE)GetUnitYX(uid, m_DiscreteTable[j]); bt_discrete++; } @@ -382,11 +392,13 @@ int CSubModbusTcpProcess::OnPackageReceived(BYTE* pBuf, int count, int ord) BYTE *ppucFrame = &pBuf[MB_TCP_FUNC]; BYTE ucRcvAddress = pBuf[MB_TCP_UID]; +#if 0 if (ucRcvAddress != pItem->ied_addr && ucRcvAddress != MB_ADDRESS_BROADCAST) { vLog(LOG_DEBUG, "数据不是发送给我的.\n"); return count; } +#endif BYTE ucFunctionCode = ppucFrame[MB_PDU_FUNC_OFF]; eMBException eException; eMBErrorCode eStatus = MB_ENOERR; @@ -422,7 +434,6 @@ int CSubModbusTcpProcess::OnPackageReceived(BYTE* pBuf, int count, int ord) break; default: break; - } if (ucRcvAddress != MB_ADDRESS_BROADCAST) { @@ -433,7 +444,7 @@ int CSubModbusTcpProcess::OnPackageReceived(BYTE* pBuf, int count, int ord) ppucFrame[usLength++] = eException; } - eStatus = eMBTCPSend(ucRcvAddress, ppucFrame, usLength); + eStatus = eMBTCPSend(ucRcvAddress, ppucFrame, usLength, ord); if (eStatus != MB_ENOERR) { vLog(LOG_ERROR, "modbus tcp send error(%d)\n", eStatus); @@ -443,7 +454,7 @@ int CSubModbusTcpProcess::OnPackageReceived(BYTE* pBuf, int count, int ord) return (count); } -eMBErrorCode CSubModbusTcpProcess::eMBTCPSend(BYTE ucSlaveAddress, const BYTE *pucFrame, WORD usLength) +eMBErrorCode CSubModbusTcpProcess::eMBTCPSend(BYTE ucSlaveAddress, const BYTE *pucFrame, WORD usLength, int ord) { eMBErrorCode eStatus = MB_ENOERR; BYTE *pucMBTCPFrame = (BYTE *) pucFrame - MB_TCP_FUNC; @@ -451,7 +462,7 @@ eMBErrorCode CSubModbusTcpProcess::eMBTCPSend(BYTE ucSlaveAddress, const BYTE *p pucMBTCPFrame[MB_TCP_LEN] = (usLength + 1) >> 8U; pucMBTCPFrame[MB_TCP_LEN + 1] = (usLength + 1) & 0xFF; - if (WriteData(pucMBTCPFrame, usTCPLength, GetCurOrder())) + if (WriteData(pucMBTCPFrame, usTCPLength, ord)) { DisplayTxData(pucMBTCPFrame, usTCPLength, TRUE); } diff --git a/das-dn/submodbustcp/sub_modbus_tcp.h b/das-dn/submodbustcp/sub_modbus_tcp.h index 294c8cf6..911774a6 100644 --- a/das-dn/submodbustcp/sub_modbus_tcp.h +++ b/das-dn/submodbustcp/sub_modbus_tcp.h @@ -5,14 +5,6 @@ #include "modbus_def.h" #include -#pragma pack(1) -typedef struct -{ - struNetWorkOption net; - BYTE defaultYCType; -} struSubModbusTCPOption; -#pragma pack() - typedef std::vector vecInt; class CSubModbusTcpProcessItem : public CNetProcessItem @@ -30,6 +22,12 @@ public: BYTE *m_pDiscreteRegTable; WORD *m_pHoldingRegTable; WORD *m_pInputRegTable; + + int m_yccount; + int m_ymcount; + int m_yxcount; + int m_ykcount; + int m_ytcount; public: CSubModbusTcpProcessItem(); @@ -68,11 +66,11 @@ private: private: int OnPackageReceived(BYTE* pBuf, int count, int ord /* = -1 */); - BOOLEAN OnReceiveData(CSubModbusTcpProcessItem *pItem, BYTE* pData, int count, int uid); + BOOLEAN OnReceiveData(CSubModbusTcpProcessItem*, BYTE*, int, int); - eMBErrorCode eMBTCPSend(BYTE ucSlaveAddress, const BYTE *pucFrame, WORD usLength); + eMBErrorCode eMBTCPSend(BYTE, const BYTE*, WORD, int); - eMBException prveMBError2Exception(eMBErrorCode eErrorCode); + eMBException prveMBError2Exception(eMBErrorCode); eMBException eMBFuncReadInputRegister(CSubModbusTcpProcessItem *pItem, BYTE* pucFrame, WORD* usLen); eMBException eMBFuncReadHoldingRegister(CSubModbusTcpProcessItem *pItem, BYTE* pucFrame, WORD* usLen); eMBException eMBFuncWriteHoldingRegister(CSubModbusTcpProcessItem *pItem, BYTE* pucFrame, WORD* usLen); diff --git a/das-dn/third_party/nopoll/nopoll_conn.c b/das-dn/third_party/nopoll/nopoll_conn.c index 48254c3b..4873cd62 100644 --- a/das-dn/third_party/nopoll/nopoll_conn.c +++ b/das-dn/third_party/nopoll/nopoll_conn.c @@ -3244,8 +3244,7 @@ noPollMsg * nopoll_conn_get_msg (noPollConn * conn) /* update remaining bytes */ msg->payload_size = msg->remain_bytes; nopoll_free (msg->payload); - nopoll_log (conn->ctx, NOPOLL_LEVEL_DEBUG, "reusing noPollMsg reference (%p) since last payload read was 0, remaining: %d", msg, - msg->payload_size); + nopoll_log (conn->ctx, NOPOLL_LEVEL_DEBUG, "reusing noPollMsg reference (%p) since last payload read was 0, remaining: %d", msg, msg->payload_size); } /* nullify references */ @@ -3384,6 +3383,7 @@ noPollMsg * nopoll_conn_get_msg (noPollConn * conn) msg->payload_size = nopoll_get_16bit (buffer + 2); nopoll_log (conn->ctx, NOPOLL_LEVEL_DEBUG, "Received (%d) bytes in header (size %d) for payload size indication, which finally is: %d", bytes, header_size,(int) msg->payload_size); + fprintf(stderr, "Received (%d) bytes in header (size %d) for payload size indication, which finally is: %d\n", bytes, header_size,(int) msg->payload_size); } else if (msg->payload_size == 127) { /* read more content (next 8 bytes) */ @@ -3395,7 +3395,7 @@ noPollMsg * nopoll_conn_get_msg (noPollConn * conn) return NULL; } /* end if */ - len = (unsigned char*)buffer; + len = (unsigned char*)buffer; msg->payload_size = 0; #if defined(NOPOLL_64BIT_PLATFORM) msg->payload_size |= ((long)(len[0]) << 56); @@ -3479,6 +3479,8 @@ noPollMsg * nopoll_conn_get_msg (noPollConn * conn) nopoll_log (conn->ctx, NOPOLL_LEVEL_DEBUG, "Detected incoming websocket frame: fin(%d), op_code(%d), is_masked(%d), payload size(%ld), mask=%d", msg->has_fin, msg->op_code, msg->is_masked, msg->payload_size, nopoll_get_32bit (msg->mask)); + fprintf(stderr, "Detected incoming websocket frame: fin(%d), op_code(%d), is_masked(%d), payload size(%ld), mask=%d\n", + msg->has_fin, msg->op_code, msg->is_masked, msg->payload_size, nopoll_get_32bit (msg->mask)); /* check payload size */ if (msg->payload_size == 0) { diff --git a/das-dn/zjd3100proc/zjd3100pro.cpp b/das-dn/zjd3100proc/zjd3100pro.cpp index 4ca67650..69ac50a1 100644 --- a/das-dn/zjd3100proc/zjd3100pro.cpp +++ b/das-dn/zjd3100proc/zjd3100pro.cpp @@ -809,7 +809,7 @@ BOOLEAN CZJD3100Process::OnSyntaxUnitYC(char *pData, int uid, int ord) } else { - value = (float)config.units[uid].ycs[i].value * database.ycs[udb].coef + database.ycs[udb].base; + value = (float)config.units[uid].ycs[i].value * config.units[uid].ycs[i].coef + config.units[uid].ycs[i].base; } sprintf(buffer, "%4d %5.3f %-2s\t", i, value, ((config.units[uid].ycs[i].qds & 0x80) ? "IV" : " ")); diff --git a/das/src/main/java/com/das/modules/equipment/service/impl/SysEquipmentServiceImpl.java b/das/src/main/java/com/das/modules/equipment/service/impl/SysEquipmentServiceImpl.java index 7d9bb92d..f0213747 100644 --- a/das/src/main/java/com/das/modules/equipment/service/impl/SysEquipmentServiceImpl.java +++ b/das/src/main/java/com/das/modules/equipment/service/impl/SysEquipmentServiceImpl.java @@ -96,6 +96,7 @@ public class SysEquipmentServiceImpl implements SysEquipmentService { SysEquipment sysEquipment = new SysEquipment(); BeanCopyUtils.copy(sysEquipmentDto, sysEquipment); SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY); + SysEquipment oldModelSysEquipInfo = sysEquipmentMapper.selectById(sysEquipmentDto.getId()); SysEquipmentVo oldSysEquipment = sysEquipmentMapper.queryEquipmentInfoByCode(sysEquipmentDto.getCode()); // 判断设备编码是否存在 if (sysEquipmentMapper.queryEquipmentByCode(sysEquipment.getCode()) > 0) { @@ -106,7 +107,8 @@ public class SysEquipmentServiceImpl implements SysEquipmentService { sysEquipment.setUpdatedTime(new Date()); sysEquipment.setUpdatedBy(sysUserVo.getAccount()); sysEquipmentMapper.updateById(sysEquipment); - if (oldSysEquipment.getIotModelId() == null && sysEquipment.getIotModelId() != null){ + + if (oldModelSysEquipInfo.getIotModelId() == null && sysEquipment.getIotModelId() != null){ dataService.deviceModelMap.put(sysEquipment.getId().toString(),dataService.iotModelMap.get(sysEquipment.getIotModelId().toString())); } SysEquipmentVo sysEquipmentVo = new SysEquipmentVo(); diff --git a/das/src/main/java/com/das/modules/node/domain/vo/ConfigUpdateVo.java b/das/src/main/java/com/das/modules/node/domain/vo/ConfigUpdateVo.java index d387260e..3689c9cc 100644 --- a/das/src/main/java/com/das/modules/node/domain/vo/ConfigUpdateVo.java +++ b/das/src/main/java/com/das/modules/node/domain/vo/ConfigUpdateVo.java @@ -20,8 +20,6 @@ public class ConfigUpdateVo { private List links; - private List equipments; - public ConfigUpdateVo() { } diff --git a/das/src/main/java/com/das/modules/node/domain/vo/LinkVo.java b/das/src/main/java/com/das/modules/node/domain/vo/LinkVo.java index 84a5180f..ef853682 100644 --- a/das/src/main/java/com/das/modules/node/domain/vo/LinkVo.java +++ b/das/src/main/java/com/das/modules/node/domain/vo/LinkVo.java @@ -4,6 +4,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Data; +import java.util.List; + @Data public class LinkVo { /** @@ -26,5 +28,5 @@ public class LinkVo { /** * 关联的设备列表,设备id字符串列表 */ - private String[] devices; + private List devices; } diff --git a/das/src/main/java/com/das/modules/node/domain/vo/SysTabMappingVo.java b/das/src/main/java/com/das/modules/node/domain/vo/SysTabMappingVo.java index fbb218e0..66374182 100644 --- a/das/src/main/java/com/das/modules/node/domain/vo/SysTabMappingVo.java +++ b/das/src/main/java/com/das/modules/node/domain/vo/SysTabMappingVo.java @@ -63,4 +63,9 @@ public class SysTabMappingVo { * 参数 */ private String params; + + /** + * 协议号 + */ + private Integer protocol; } diff --git a/das/src/main/java/com/das/modules/node/service/impl/NodeMessageServiceImpl.java b/das/src/main/java/com/das/modules/node/service/impl/NodeMessageServiceImpl.java index 27c05c08..25990ec8 100644 --- a/das/src/main/java/com/das/modules/node/service/impl/NodeMessageServiceImpl.java +++ b/das/src/main/java/com/das/modules/node/service/impl/NodeMessageServiceImpl.java @@ -1,6 +1,8 @@ package com.das.modules.node.service.impl; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.das.common.constant.MeasType; import com.das.common.utils.AdminRedisTemplate; @@ -44,6 +46,7 @@ import org.springframework.web.socket.handler.TextWebSocketHandler; import java.io.IOException; import java.util.*; import java.util.concurrent.*; +import java.util.stream.Collectors; @Slf4j @Service @@ -131,7 +134,6 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node public JsonNode sendTerminalConfig(Long nodeId) { ConfigUpdateVo configUpdateVo = new ConfigUpdateVo(); List links = new ArrayList<>(); - List equipments = new ArrayList<>(); try { // 获取所有的链路信息 List sysCommunicationLinkVoList = sysCommunicationLinkMapper.querySysCommunicationLink(nodeId); @@ -142,14 +144,10 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node linkVo.setLinkName(sysCommunicationLinkVo.getLinkName()); linkVo.setParams(jsonNode); linkVo.setProtocol(sysCommunicationLinkVo.getProtocol()); - List stringList = new ArrayList<>(); - // 获取关联的设备Id + // 获取关联的设备所有属性 List equipmentList = sysImptabmappingMapper.getBindDeviceByLink(sysCommunicationLinkVo.getId()); - for (EquipmentVo dev : equipmentList) { - stringList.add(String.valueOf(dev.getId())); - } - String[] stringArray = stringList.toArray(new String[0]); - linkVo.setDevices(stringArray); + + List equipmentAndMappingVoList = new ArrayList<>(); links.add(linkVo); for (EquipmentVo dev : equipmentList) { @@ -162,6 +160,11 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node List tabMappingVoList = sysImptabmappingMapper.getMappingInfoListByLinkIdAndDeviceId(sysCommunicationLinkVo.getId(), dev.getId()); + if (sysCommunicationLinkVo.getProtocol() == 17 || sysCommunicationLinkVo.getProtocol() == 9){ + List orderMappingVoList = tabMappingVoList.stream().filter(item -> ObjectUtil.isNotEmpty(JSONObject.parseObject(item.getParams()).get("order"))).collect(Collectors.toList()); + tabMappingVoList.clear(); + tabMappingVoList.addAll(orderMappingVoList); + } if (!CollectionUtils.isEmpty(tabMappingVoList)) { for (SysTabMappingVo info : tabMappingVoList) { @@ -202,8 +205,10 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node equipment.setId(dev.getId()); equipment.setAttrs(attrs); equipment.setServices(services); - equipments.add(equipment); + equipmentAndMappingVoList.add(equipment); } + //改成list + linkVo.setDevices(equipmentAndMappingVoList); } } catch (Exception e) { log.error("获取设备配置信息失败", e); @@ -212,7 +217,6 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node configUpdateVo.setNodeId(nodeId); configUpdateVo.setVersion(1); configUpdateVo.setLinks(links); - configUpdateVo.setEquipments(equipments); log.info("下发配置为{}", configUpdateVo); JsonNode jsonNode = JSON_MAPPER.valueToTree(configUpdateVo); @@ -225,7 +229,9 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node .data(jsonNode) .build(); sendActionMessage(nodeId, configUpdate); + System.out.println(jsonNode); return jsonNode; + } @Override @@ -363,18 +369,18 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node deviceEventInfo.setConfirmed(0); if (!StringUtils.isEmpty(eventType) && eventType.equals("遥信变位")) { if (item.getAttrValue().equals(0)) { - deviceEventInfo.setEventText(fieldName + " 复归"); + deviceEventInfo.setEventText(item.getAttrCode()+fieldName + " 复归"); deviceEventInfo.setEventLevel(0); } else { - deviceEventInfo.setEventText(fieldName + " 动作"); + deviceEventInfo.setEventText(item.getAttrCode()+fieldName + " 动作"); Integer level = dataService.eventLevelMap.get(model).get(item.getAttrCode()); log.info("level:{}",level); log.info("fieldname{}",fieldName); deviceEventInfo.setEventLevel( level == null ? 0 : level); } } else { - deviceEventInfo.setEventText(fieldName + eventType + ",属性值为:" + item.getAttrValue() + ",越限值为:" + item.getLimitValue()); + deviceEventInfo.setEventText(item.getAttrCode()+fieldName + eventType + ",属性值为:" + item.getAttrValue() + ",越限值为:" + item.getLimitValue()); deviceEventInfo.setEventLevel(1); } valueList.add(deviceEventInfo); diff --git a/das/src/main/java/com/das/modules/node/service/impl/SysNodeServiceImpl.java b/das/src/main/java/com/das/modules/node/service/impl/SysNodeServiceImpl.java index 6be4c0fa..aca2938d 100644 --- a/das/src/main/java/com/das/modules/node/service/impl/SysNodeServiceImpl.java +++ b/das/src/main/java/com/das/modules/node/service/impl/SysNodeServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.io.IoUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.das.common.config.SessionUtil; import com.das.common.constant.MeasType; +import com.das.common.exceptions.ServiceException; import com.das.common.utils.BeanCopyUtils; import com.das.common.utils.PageDataInfo; import com.das.common.utils.PageQuery; @@ -14,6 +15,7 @@ import com.das.modules.auth.entity.SysOrg; import com.das.modules.auth.mapper.SysOrgMapper; import com.das.modules.equipment.domain.vo.SysIotModelFieldVo; import com.das.modules.equipment.domain.vo.SysIotModelServiceVo; +import com.das.modules.equipment.entity.SysIotModelField; import com.das.modules.equipment.mapper.SysEquipmentMapper; import com.das.modules.equipment.mapper.SysIotModelFieldMapper; import com.das.modules.equipment.mapper.SysIotModelServiceMapper; @@ -32,6 +34,7 @@ import com.das.modules.node.mapper.SysCommunicationLinkMapper; import com.das.modules.node.mapper.SysImpTabMappingMapper; import com.das.modules.node.mapper.SysNodeMapper; import com.das.modules.node.service.SysNodeService; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -48,6 +51,7 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.util.*; +import java.util.stream.Collectors; @Transactional(rollbackFor = Exception.class) @Service @@ -352,8 +356,21 @@ public class SysNodeServiceImpl implements SysNodeService { if (!CollectionUtils.isEmpty(impList)) { List list = new ArrayList<>(); + if (impList.get(0).getProtocol() == 9 || impList.get(0).getProtocol() == 17){ + Map collect = sysImptabmappingMapper.getMappingInfoListByLinkId(impList.get(0).getLinkId()).stream().collect(Collectors.toMap(SysTabMappingVo::getId, SysTabMappingVo::getMeasPointType, (value1, value2) -> value1)); + List analogList = impList.stream().filter(item -> collect.get(item.getId()) == 138).collect(Collectors.toList()); + List accumulator = impList.stream().filter(item -> collect.get(item.getId()) == 139).collect(Collectors.toList()); + List discrete = impList.stream().filter(item -> collect.get(item.getId()) == 140).collect(Collectors.toList()); + List setPoint = impList.stream().filter(item -> collect.get(item.getId()) == 146).collect(Collectors.toList()); + List control = impList.stream().filter(item -> collect.get(item.getId()) == 147).collect(Collectors.toList()); + if (checkOrderRepeated(analogList) || checkOrderRepeated(accumulator) || checkOrderRepeated(discrete) || checkOrderRepeated(setPoint) || checkOrderRepeated(control)){ + throw new ServiceException("检查顺序,排序不能重复"); + } + } SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY); for (SysTabMappingVo imp : impList) { + //校验param里面order不重复 + SysTabMapping rec = sysImptabmappingMapper.selectById(imp.getId()); rec.setUpdatedTime(new Date()); rec.setUpdatedBy(sysUserVo.getAccount()); @@ -466,4 +483,29 @@ public class SysNodeServiceImpl implements SysNodeService { return flag; } + + private Boolean checkOrderRepeated(List mappings) { + ObjectMapper objectMapper = new ObjectMapper(); + + Boolean orderRepeated = false; + try { + // 提取所有的 order 字段,转换为 Set + Set orderSet = new HashSet<>(); + orderRepeated = mappings.stream() + .map(SysTabMappingVo::getParams) // 提取 param 字段 + .map(param -> { + try { + // 解析 JSON 并提取 order + JsonNode jsonNode = objectMapper.readTree(param); + return jsonNode.get("order").asText(); + } catch (Exception e) { + throw new RuntimeException("JSON 解析失败: " + param, e); + } + }) + .anyMatch(order -> !orderSet.add(order)); + }catch (Exception e){ + log.error("校验order不重复失败:{}",e); + } + return orderRepeated; + } } diff --git a/das/src/main/java/com/das/modules/page/domian/WindTurbinesPageVo.java b/das/src/main/java/com/das/modules/page/domian/WindTurbinesPageVo.java index 76b83e08..5a441f23 100644 --- a/das/src/main/java/com/das/modules/page/domian/WindTurbinesPageVo.java +++ b/das/src/main/java/com/das/modules/page/domian/WindTurbinesPageVo.java @@ -14,6 +14,8 @@ public class WindTurbinesPageVo { private String name; + private String deviceCode; + @JsonSerialize(using = ToStringSerializer.class) private Long modelId; diff --git a/das/src/main/java/com/das/modules/page/service/impl/WindTurbinesPageServiceImpl.java b/das/src/main/java/com/das/modules/page/service/impl/WindTurbinesPageServiceImpl.java index cf133802..d422958d 100644 --- a/das/src/main/java/com/das/modules/page/service/impl/WindTurbinesPageServiceImpl.java +++ b/das/src/main/java/com/das/modules/page/service/impl/WindTurbinesPageServiceImpl.java @@ -104,6 +104,7 @@ public class WindTurbinesPageServiceImpl implements WindTurbinesPageService { windTurbinesPageVo.setIrn(item.getId()); windTurbinesPageVo.setName(item.getName()); windTurbinesPageVo.setModel(item.getModel()); + windTurbinesPageVo.setDeviceCode(item.getCode()); windTurbinesPageVo.setMadeinfactory(item.getMadeinFactory()); windTurbinesPageVo.setModelId(item.getIotModelId()); windTurbinesPageVo.setBelongLine(item.getBelongLine()); diff --git a/ui/dasadmin/src/api/backend/statAnalysis/request.ts b/ui/dasadmin/src/api/backend/statAnalysis/request.ts index c615dfd7..42abf4c3 100644 --- a/ui/dasadmin/src/api/backend/statAnalysis/request.ts +++ b/ui/dasadmin/src/api/backend/statAnalysis/request.ts @@ -7,14 +7,7 @@ export const queryWindTurbinesPages = () => { }) } -export const historyReq = (data: { - devices: { - deviceId: string - attributes: string - } - startTime: string - endTime: string -}) => { +export const historyReq = (data: any) => { return createAxios({ url: '/api/data/history', method: 'post', diff --git a/ui/dasadmin/src/assets/dashboard/bg2.png b/ui/dasadmin/src/assets/dashboard/bg2.png new file mode 100644 index 00000000..db9db3fe Binary files /dev/null and b/ui/dasadmin/src/assets/dashboard/bg2.png differ diff --git a/ui/dasadmin/src/utils/axios.ts b/ui/dasadmin/src/utils/axios.ts index 4e8c7cfa..42bca667 100644 --- a/ui/dasadmin/src/utils/axios.ts +++ b/ui/dasadmin/src/utils/axios.ts @@ -184,12 +184,16 @@ function createAxios>(axiosConfig: AxiosRequest error.config && removePending(error.config) options.loading && closeLoading(options) // 关闭loading options.showErrorMessage && httpErrorStatusHandle(error) // 处理错误状态码 - if (error.response.status == 401) { - let routerPath = adminBaseRoute.path - adminInfo.removeToken() - routerPath += '/login' - router.push({ path: routerPath }) + + if (error.response){ + if (error.response.status == 401) { + let routerPath = adminBaseRoute.path + adminInfo.removeToken() + routerPath += '/login' + router.push({ path: routerPath }) + } } + return Promise.reject(error) // 错误继续返回给到具体页面 } ) diff --git a/ui/dasadmin/src/views/backend/alarms/index.vue b/ui/dasadmin/src/views/backend/alarms/index.vue index 8c46d056..82c73284 100644 --- a/ui/dasadmin/src/views/backend/alarms/index.vue +++ b/ui/dasadmin/src/views/backend/alarms/index.vue @@ -17,12 +17,17 @@ />
{{ t('airBlower.airBlowerNumber') }}
- +
{{ t('alarm.type') }}
- +
@@ -153,7 +158,7 @@ const searchalarms = (): GetAlarmsTableParam => { const start = timeRange.value[0] const end = timeRange.value[1] const deviceCode: any = [] - if (airBlowerNumberValue.value.length) { + if (airBlowerNumberValue.value && airBlowerNumberValue.value.length) { deviceCode.push(airBlowerNumberValue.value) } else { airBlowerList.value.forEach((item: any) => { diff --git a/ui/dasadmin/src/views/backend/dashboard.vue b/ui/dasadmin/src/views/backend/dashboard.vue index fb1368cf..2e8187aa 100644 --- a/ui/dasadmin/src/views/backend/dashboard.vue +++ b/ui/dasadmin/src/views/backend/dashboard.vue @@ -3,11 +3,11 @@ - +
-
全厂平均风速
+
全场平均风速
{{realData.attributeMap.windfarmavgwindspeed}} m/s @@ -15,24 +15,24 @@
- +
-
全厂实时有功
+
全场实时有功
{{realData.attributeMap.windfarmactivepower}} - MW + kW
- +
-
全厂实时无功
+
全场实时无功
{{realData.attributeMap.windfarmreactivepower}} kvar @@ -41,7 +41,7 @@
- +
@@ -54,7 +54,7 @@
- +
@@ -66,7 +66,7 @@
- +
@@ -349,7 +349,7 @@ const getTableData = (deviceCode) => { limit: 100, eventLevel:2 } - console.log(JSON.stringify(data)) + // console.log(JSON.stringify(data)) getAlarmListReq(data).then((res) => { if (res.code == 200) { //tableData.value = res.rows @@ -431,11 +431,7 @@ const createScroll = () => { -const activeName = ref('first') -//let autoUpdateTimer: any = null let autoUpdateForSecondTimer: any = null -let autoUpdateTimerForMinuteTimer: any = null -let autoUpdateTimerForHourTimer: any = null const autoUpdate = () => { if (!autoUpdateForSecondTimer) { autoUpdateForSecondTimer = setInterval(() => { @@ -474,7 +470,7 @@ onMounted(() => { equipList({ objectType: 10002 }).then((res) => { res.data.map((item: any) => { - deviceCode.value.push(item.name) + deviceCode.value.push(item.code) }) getTableData(deviceCode.value) @@ -485,10 +481,6 @@ onUnmounted(() => { window.removeEventListener('resize', sizeChange) clearInterval(timer) autoUpdateForSecondTimer && clearInterval(autoUpdateForSecondTimer) - /*const chartKeys = Object.keys(state.charts) as Array - chartKeys.forEach((key) => { - state.charts[key].dispose() - })*/ }) @@ -552,8 +544,8 @@ $labelHeight: 30px; align-items: center; color: #4E5969; .small-panel-pic{ - width: 100px; - height: 100px; + width: 80px; + height: 80px; } } @@ -585,6 +577,9 @@ $labelHeight: 30px; p{ padding-right: 30px; display: inline-block; + span{ + padding-right: 10px; + } } } } @@ -602,7 +597,7 @@ $labelHeight: 30px; .matrix { @include cardlabel; - background: url('/@/assets/dashboard/bg1.png') no-repeat #ffffff; + background: url('/@/assets/dashboard/bg2.png') no-repeat #ffffff; background-size: 100% 100%; /* min-height: 900px;*/ width: 100%; @@ -622,59 +617,18 @@ $labelHeight: 30px; } } -@media screen and (max-width: 1920px) { - .default-main { - .trend { - height: 315px !important; - } - } -} -@media screen and (max-width: 1280px) { - .default-main { - /*height: auto !important;*/ - .windtitle { - margin-bottom: 10px; - } - .summarize { - .summarize-panel { - margin: 2px !important; - .summarize-panel-base { - white-space: normal !important; - } - } - } - } -} + + @media screen and (max-width: 1360px) { .default-main { font-size: 11px !important; - .summarize { - word-break: break-all !important; - } - .overview { - .small-panel { - .small-base { - margin-left: 0px !important; - font-size: 11px !important; - } - } - } } } @media screen and (max-width: 1480px) { .default-main { font-size: 12px !important; - .overview { - .small-panel { - padding: 13px 0px !important; - } - } - .status { - .status-panel { - .status-base-main { - margin-left: 5px !important; - } - } + .content-number { + font-size: 16px !important; } } } @@ -682,7 +636,7 @@ $labelHeight: 30px; .default-main { /*font-size: 12px !important;*/ .content-number { - font-size: 16px !important; + font-size: 18px !important; } .homelabel { @@ -697,26 +651,6 @@ $labelHeight: 30px; /* padding: 10px !important;*/ margin-bottom: 10px !important; } - .summarize { - margin-bottom: 10px !important; - } - } - .toal-panel { - padding: 0 !important; - padding-bottom: 10px !important; - } - // .matrix { - // height: 900px !important; - // } - :deep(.el-tabs__header) { - margin-top: -33px !important; - } - .overview { - .small-panel { - .small-base { - margin-left: 5px !important; - } - } } } } diff --git a/ui/dasadmin/src/views/backend/home/windMatrix.vue b/ui/dasadmin/src/views/backend/home/windMatrix.vue index 8d74cc3f..6319d46c 100644 --- a/ui/dasadmin/src/views/backend/home/windMatrix.vue +++ b/ui/dasadmin/src/views/backend/home/windMatrix.vue @@ -1,7 +1,7 @@