Merge branch 'main' of https://git.jsspisoft.com/ry-das
This commit is contained in:
commit
288797beae
@ -89,10 +89,20 @@ bool CRYDevice::configInitializeMemory(void)
|
||||
config_config.units[i].ftp_softdog = 0;
|
||||
|
||||
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];
|
||||
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];
|
||||
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];
|
||||
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];
|
||||
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;
|
||||
@ -2190,6 +2200,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
name_param.name = "";
|
||||
name_param.highSpeed = 0;
|
||||
name_param.order = -1;
|
||||
name_param.deviceId = id;
|
||||
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"];
|
||||
@ -2208,6 +2219,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
struct_attr name_param;
|
||||
name_param.name = "";
|
||||
name_param.order = -1;
|
||||
name_param.deviceId = id;
|
||||
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"];
|
||||
@ -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);
|
||||
}
|
||||
|
||||
if (uid2pid_map.find(id) == uid2pid_map.end()) {
|
||||
uid2pid_map.insert(string2intmap::value_type(id, i));
|
||||
}
|
||||
config_config.processes[i].units[j] = uid;
|
||||
//根据协议修改地址
|
||||
if (address != "") {
|
||||
@ -2322,7 +2337,6 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
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++;
|
||||
@ -2382,13 +2396,18 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
}
|
||||
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 (!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) {
|
||||
//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++) {
|
||||
@ -2425,13 +2444,18 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
|
||||
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 (!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) {
|
||||
//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++) {
|
||||
@ -2460,13 +2484,18 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
}
|
||||
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 (!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) {
|
||||
//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++) {
|
||||
@ -2495,13 +2524,18 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
}
|
||||
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 (!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) {
|
||||
//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++) {
|
||||
@ -2537,7 +2571,13 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
}
|
||||
if (pfdbyxname) {
|
||||
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;
|
||||
attrvectorGroup attrs = it->second;
|
||||
fprintf(stderr, "pid is: %d, link uid is: %d\n", pid, sub_uid);
|
||||
|
||||
switch (config_config.processes[pid].proto)
|
||||
{
|
||||
case PROTOCOL_SUB_MODBUS_TCP:
|
||||
@ -2566,43 +2606,35 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
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].real_softdog = UNIT_WATCHDOG_TIME;
|
||||
config_config.units[sub_uid].state = TRUE;
|
||||
config_config.units[sub_uid].type = SLAVER_UNIT;
|
||||
s_yxcount = attrs.yxs.size();
|
||||
s_yccount = attrs.ycs.size();
|
||||
s_ymcount = attrs.yms.size();
|
||||
s_ykcount = attrs.yks.size();
|
||||
s_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.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 (s_yccount > 0)
|
||||
|
||||
if (config_config.units[sub_uid].yccount > 0)
|
||||
{
|
||||
//config_config.units[sub_uid].ycs = new struUnitYC[s_yccount];
|
||||
if (NULL != config_config.units[sub_uid].ycs) {
|
||||
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;
|
||||
for (int i = 0; i < config_config.units[sub_uid].yccount; i++) {
|
||||
std::string key;
|
||||
int order = -1;
|
||||
int point = i;
|
||||
if (map_ycorders.find(key) != map_ycorders.end())
|
||||
{
|
||||
order = map_ycorders[key];
|
||||
}
|
||||
int point = -1;
|
||||
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());
|
||||
}
|
||||
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());
|
||||
config_config.units[sub_uid].ycs[point].order = order;
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (s_ymcount > 0)
|
||||
if (config_config.units[sub_uid].ymcount > 0)
|
||||
{
|
||||
//config_config.units[sub_uid].yms = new struUnitYM[s_ymcount];
|
||||
if (NULL != config_config.units[sub_uid].yms) {
|
||||
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;
|
||||
for (int i = 0; i < config_config.units[sub_uid].ymcount; i++) {
|
||||
std::string key;
|
||||
int order = -1;
|
||||
int point = i;
|
||||
if (map_ymorders.find(key) != map_ymorders.end())
|
||||
{
|
||||
order = map_ymorders[key];
|
||||
}
|
||||
int point = -1;
|
||||
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());
|
||||
}
|
||||
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());
|
||||
config_config.units[sub_uid].yms[point].order = order;
|
||||
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];
|
||||
if (NULL != config_config.units[sub_uid].yks) {
|
||||
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;
|
||||
for (int i = 0; i < config_config.units[sub_uid].ykcount; i++) {
|
||||
std::string key;
|
||||
int order = -1;
|
||||
int point = i;
|
||||
if (map_ykorders.find(key) != map_ykorders.end())
|
||||
{
|
||||
order = map_ykorders[key];
|
||||
}
|
||||
int point = -1;
|
||||
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());
|
||||
}
|
||||
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());
|
||||
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];
|
||||
if (NULL != config_config.units[sub_uid].yts) {
|
||||
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;
|
||||
for (int i = 0; i < config_config.units[sub_uid].ytcount; i++) {
|
||||
std::string key;
|
||||
int order = -1;
|
||||
int point = i;
|
||||
if (map_ytorders.find(key) != map_ytorders.end())
|
||||
{
|
||||
order = map_ytorders[key];
|
||||
}
|
||||
int point = -1;
|
||||
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());
|
||||
}
|
||||
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());
|
||||
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];
|
||||
if (NULL != config_config.units[sub_uid].yxs) {
|
||||
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;
|
||||
for (int i = 0; i < config_config.units[sub_uid].yxcount; i++) {
|
||||
std::string key;
|
||||
int order = -1;
|
||||
int point = i;
|
||||
if (map_yxorders.find(key) != map_yxorders.end())
|
||||
{
|
||||
order = map_yxorders[key];
|
||||
}
|
||||
int point = -1;
|
||||
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());
|
||||
}
|
||||
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());
|
||||
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;
|
||||
|
||||
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++;
|
||||
}
|
||||
#endif
|
||||
@ -2745,6 +2884,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
if (pfdbymname) fclose(pfdbymname);
|
||||
if (pfdbykname) fclose(pfdbykname);
|
||||
if (pfdbytname) fclose(pfdbytname);
|
||||
|
||||
//保存数据
|
||||
configWriteNodeCFG();
|
||||
configWriteSystemCFG();
|
||||
|
@ -56,6 +56,7 @@ typedef std::unordered_map<std::string, std::string> unitserviceName2cmdIdmap;
|
||||
|
||||
typedef struct {
|
||||
std::string name;
|
||||
std::string deviceId;
|
||||
Json::Value params;
|
||||
int highSpeed;
|
||||
int order;
|
||||
@ -89,7 +90,7 @@ public:
|
||||
|
||||
void handle_message(const std::string & message);
|
||||
private:
|
||||
uid2pidmap uid2pid_map;
|
||||
string2intmap uid2pid_map;
|
||||
unitname2servicemap unitname2service_map;
|
||||
unitserviceName2cmdIdmap unitserviceName2cmdId_map;
|
||||
std::string m_traceId;
|
||||
|
@ -13,4 +13,9 @@ public interface EquipmentTypeIds {
|
||||
* Wind Turbine Generator
|
||||
*/
|
||||
Integer EQUIPMENT_TYPE_STATION_WTG = 10002;
|
||||
|
||||
/**
|
||||
* 能量管理设备
|
||||
*/
|
||||
Integer EQUIPMENT_TYPE_PM = 10003;
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ public class EquipmentController {
|
||||
List<EquipmentTypeVo> typeVoList= new ArrayList<>();
|
||||
typeVoList.add(new EquipmentTypeVo(EquipmentTypeIds.EQUIPMENT_TYPE_WIND_FARM,"风电场"));
|
||||
typeVoList.add(new EquipmentTypeVo(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG,"机组"));
|
||||
typeVoList.add(new EquipmentTypeVo(EquipmentTypeIds.EQUIPMENT_TYPE_PM,"能量管理设备"));
|
||||
|
||||
return R.success(typeVoList);
|
||||
}
|
||||
|
@ -275,6 +275,8 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
@Override
|
||||
public void bindDevices(List<BindEquipmentInfoDto> equipmentList, Long linkId) {
|
||||
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||
//记录整体排序
|
||||
Integer order = 1;
|
||||
|
||||
// 如果绑定设备列表为空,则清空映射表
|
||||
if (CollectionUtils.isEmpty(equipmentList)) {
|
||||
@ -329,7 +331,8 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
SysTabMapping mapping = sysImptabmappingMapper.selectById(item.getId());
|
||||
mapping.setMeasPointName(iotModelVo.getAttributeName());
|
||||
mapping.setHighSpeed(iotModelVo.getHighSpeed());
|
||||
mapping.setPorder(iotModelVo.getPorder());
|
||||
mapping.setPorder(order);
|
||||
order++;
|
||||
updateList.add(mapping);
|
||||
|
||||
}else{
|
||||
@ -341,7 +344,8 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
mapping.setMeasPointCode(iotModelVo.getAttributeCode());
|
||||
mapping.setMeasPointName(iotModelVo.getAttributeName());
|
||||
mapping.setHighSpeed(iotModelVo.getHighSpeed());
|
||||
mapping.setPorder(iotModelVo.getPorder());
|
||||
mapping.setPorder(order);
|
||||
order++;
|
||||
mapping.setCreatedBy(sysUserVo.getAccount());
|
||||
mapping.setCreatedTime(new Date());
|
||||
mapping.setRevision(1);
|
||||
@ -368,7 +372,8 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
|
||||
SysTabMapping mapping = sysImptabmappingMapper.selectById(item.getId());
|
||||
mapping.setMeasPointName(iotServiceVo.getServiceName());
|
||||
mapping.setPorder(iotServiceVo.getPorder());
|
||||
mapping.setPorder(order);
|
||||
order++;
|
||||
updateList.add(mapping);
|
||||
}else{
|
||||
SysTabMapping mapping = new SysTabMapping();
|
||||
@ -378,7 +383,8 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
mapping.setMeasPointType(measType);
|
||||
mapping.setMeasPointCode(iotServiceVo.getServiceCode());
|
||||
mapping.setMeasPointName(iotServiceVo.getServiceName());
|
||||
mapping.setPorder(iotServiceVo.getPorder());
|
||||
mapping.setPorder(order);
|
||||
order++;
|
||||
mapping.setCreatedBy(sysUserVo.getAccount());
|
||||
mapping.setCreatedTime(new Date());
|
||||
mapping.setRevision(1);
|
||||
|
@ -75,8 +75,6 @@
|
||||
where
|
||||
t1.link_id = #{linkId} and t1.meas_point_type = #{type}
|
||||
order by
|
||||
t1.equipment_id ,
|
||||
t1.meas_point_type,
|
||||
t1.porder
|
||||
</select>
|
||||
|
||||
|
@ -321,26 +321,25 @@ const currentColor = ref()
|
||||
const curveColors: any = ref([])
|
||||
const submitCurveColors = ref([])
|
||||
const initColor = [
|
||||
'#FF6666', // 浅红色
|
||||
'#66FF66', // 浅绿色
|
||||
'#6666FF', // 浅蓝色
|
||||
'#FFFF66', // 浅黄色
|
||||
'#FF66FF', // 浅品红
|
||||
'#66FFFF', // 浅青色
|
||||
'#FF9966', // 温和橙色
|
||||
'#9966FF', // 温和紫色
|
||||
'#FFFF99', // 浅米黄色
|
||||
'#FF9999', // 温和红色
|
||||
'#99FF99', // 温和绿色
|
||||
'#9999FF', // 温和蓝色
|
||||
'#FF66B2', // 浅红紫色
|
||||
'#9966B2', // 淡紫色
|
||||
'#FF8066', // 浅橙红色
|
||||
'#66FFB2', // 清新青绿色
|
||||
'#9966A6', // 深紫色调
|
||||
'#FFFF99', // 黄绿色
|
||||
'#FF6666', // 淡红色
|
||||
'#4D66FF', // 深蓝色
|
||||
'#3357FF',
|
||||
'#2ECC71',
|
||||
'#FF5733',
|
||||
'#FFBD33',
|
||||
'#FF33A6',
|
||||
'#33A6FF',
|
||||
'#FF8C00',
|
||||
'#00FFB3',
|
||||
'#B33FFF',
|
||||
'#F9E74F',
|
||||
'#FF9A8B',
|
||||
'#5DBA61',
|
||||
'#1E90FF',
|
||||
'#F15BB5',
|
||||
'#56CCF2',
|
||||
'#F8C8DC',
|
||||
'#B3FF57',
|
||||
'#FF6F61',
|
||||
'#33FF57',
|
||||
]
|
||||
|
||||
const EditCurvecolor = (data: any) => {
|
||||
|
@ -1,11 +1,20 @@
|
||||
<template>
|
||||
<div class="measurement">
|
||||
<div class="transferHeader">
|
||||
<span class="transferTitle">可添加的测点</span>
|
||||
<el-radio-group v-model="radioActiveName" @change="typeChange">
|
||||
<el-radio :value="138">模拟量</el-radio>
|
||||
<el-radio :value="199">计算量</el-radio>
|
||||
</el-radio-group>
|
||||
<div class="pointDialogColTitleInput">
|
||||
<span class="transferTitle">可添加的测点</span>
|
||||
<el-input v-model="inputValue" clearable @keyup.enter="typeChange"></el-input>
|
||||
<el-button type="primary" @click="typeChange">查询</el-button>
|
||||
</div>
|
||||
<div class="radios">
|
||||
<span style="margin-right: 10px">是否高频数据</span>
|
||||
<el-switch style="margin-right: 24px" v-model="highSpeed" @change="typeChange" />
|
||||
|
||||
<el-radio-group v-model="radioActiveName" @change="typeChange">
|
||||
<el-radio :value="138">模拟量</el-radio>
|
||||
<el-radio :value="199">计算量</el-radio>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
</div>
|
||||
<div class="main">
|
||||
<el-table :columns="tableColumn" :data="tableData" max-height="420">
|
||||
@ -70,6 +79,8 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
const radioActiveName = ref(138)
|
||||
const inputValue = ref('')
|
||||
const highSpeed = ref(false)
|
||||
const typeChange = () => {
|
||||
pageSetting.current == 1 ? getCompleteData() : (pageSetting.current = 1)
|
||||
}
|
||||
@ -120,6 +131,8 @@ const getAttributeList = () => {
|
||||
pageNum: pageSetting.current,
|
||||
pageSize: pageSetting.pageSize,
|
||||
attributeType: radioActiveName.value,
|
||||
highSpeed: highSpeed.value ? 1 : 0,
|
||||
attributeName: inputValue.value,
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
getModelAttributeListReq(requestData)
|
||||
@ -163,8 +176,10 @@ watch(
|
||||
() => props.show,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
pageSetting.current == 1 ? getCompleteData() : (pageSetting.current = 1)
|
||||
selectedIndex.value = props.irn
|
||||
inputValue.value = ''
|
||||
highSpeed.value = false
|
||||
pageSetting.current == 1 ? getCompleteData() : (pageSetting.current = 1)
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -187,6 +202,18 @@ watch(
|
||||
background: #f7f9fc;
|
||||
border-bottom: 1px solid #e1edf6;
|
||||
border-radius: 6px 6px 0 0;
|
||||
.pointDialogColTitleInput {
|
||||
.el-input {
|
||||
width: 180px;
|
||||
}
|
||||
.el-button {
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
.radios {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
.main {
|
||||
padding: 10px;
|
||||
|
@ -288,7 +288,7 @@ const getDateRange = (type: 'week' | 'month') => {
|
||||
return [startOfMonth, endOfMonth]
|
||||
}
|
||||
}
|
||||
|
||||
const theoryData = ref([])
|
||||
const isLoading = ref(false)
|
||||
const statAnalysisOperate = () => {
|
||||
const deviceId = statAnalysisDeviceId.value.split(':')[2]
|
||||
@ -359,9 +359,7 @@ const statAnalysisOperate = () => {
|
||||
const seriesData = iGenPower.map((item: any, index: number) => {
|
||||
return [getCutDecimalsValue(iWindSpeed[index], 2), getCutDecimalsValue(item, 2)]
|
||||
})
|
||||
// seriesData.sort((a: any, b: any) => {
|
||||
// return a[0] - b[0]
|
||||
// })
|
||||
|
||||
seriesDataInit.value = seriesData
|
||||
calculateData.value = calculateAverages(seriesDataInit.value)
|
||||
updateChart()
|
||||
@ -371,6 +369,7 @@ const statAnalysisOperate = () => {
|
||||
const seriesData = resData1.map((item: any) => {
|
||||
return [getCutDecimalsValue(item.speed, 2), getCutDecimalsValue(item.power, 2)]
|
||||
})
|
||||
theoryData.value = seriesData
|
||||
const series = {
|
||||
type: 'line',
|
||||
data: seriesData,
|
||||
@ -391,33 +390,49 @@ const statAnalysisOperate = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const statAnalysisExport = () => {
|
||||
const params = statAnalysisFatory.value ? statAnalysisFatory.value : statAnalysisDeviceId.value
|
||||
const windSource = statAnalysisSelectOptions.speedSource.filter((item: any) => item.value == statAnalysisSpeedSource.value)
|
||||
const requestData = {
|
||||
devices: [
|
||||
{
|
||||
deviceId: statAnalysisDeviceId.value.split(':')[2],
|
||||
attributes: [statAnalysisSpeedSource.value, 'AvgActivePower_10min'],
|
||||
},
|
||||
],
|
||||
startTime: new Date(statAnalysisTime.value[0]).getTime(),
|
||||
endTime: new Date(statAnalysisTime.value[1]).getTime(),
|
||||
madeinfactory: params.split(':')[0],
|
||||
model: params.split(':')[1],
|
||||
windSource: windSource[0]['label'],
|
||||
displayCurve: AvgWindSpeedSwitch.value ? 1 : 0,
|
||||
const escapeCsvValue = (value: any) => {
|
||||
if (typeof value === 'string') {
|
||||
// 如果值包含逗号、双引号或换行符,进行转义
|
||||
return `"${value.replace(/"/g, '""')}"`
|
||||
}
|
||||
powerCurveExport(requestData).then((res: any) => {
|
||||
const downloadUrl = window.URL.createObjectURL(res)
|
||||
const a = document.createElement('a')
|
||||
a.href = downloadUrl
|
||||
a.download = '功率曲线' + new Date().getTime()
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
window.URL.revokeObjectURL(downloadUrl)
|
||||
document.body.removeChild(a)
|
||||
return value
|
||||
}
|
||||
|
||||
const statAnalysisExport = () => {
|
||||
const windSource = statAnalysisSelectOptions.speedSource.filter((item: any) => item.value == statAnalysisSpeedSource.value)
|
||||
const csvHeaders = ['风机名称' + '\t', windSource[0]['label'] + '\t', '功率' + '\t', '理论风速' + '\t', '理论功率' + '\t'].join(',') + '\n'
|
||||
const deviceRow = statAnalysisSelectOptions.deviceId.filter((item: any) => item.value == statAnalysisDeviceId.value)
|
||||
let sortseriesDataInit = [...seriesDataInit.value]
|
||||
sortseriesDataInit.sort((a: any, b: any) => {
|
||||
return a[0] - b[0]
|
||||
})
|
||||
const exportExcelData1 = chartType.value === 'scatter' ? sortseriesDataInit : calculateData.value
|
||||
const exportExcelData: any = []
|
||||
exportExcelData1.forEach((item: any, index: number) => {
|
||||
let theoryItem0 = (theoryData.value[index] && theoryData.value[index][0]) || ''
|
||||
let theoryItem1 = (theoryData.value[index] && theoryData.value[index][1]) || ''
|
||||
const dataItem = [
|
||||
escapeCsvValue(deviceRow[0]['label']) + '\t',
|
||||
escapeCsvValue(item[0]) + '\t',
|
||||
escapeCsvValue(item[1]) + '\t',
|
||||
escapeCsvValue(theoryItem0) + '\t',
|
||||
escapeCsvValue(theoryItem1) + '\t',
|
||||
]
|
||||
exportExcelData.push(dataItem.join(','))
|
||||
})
|
||||
|
||||
const csvContent = csvHeaders + exportExcelData.join('\n')
|
||||
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' })
|
||||
const link = document.createElement('a')
|
||||
if (link.download !== undefined) {
|
||||
const url = URL.createObjectURL(blob)
|
||||
link.setAttribute('href', url)
|
||||
link.setAttribute('download', '功率曲线' + new Date().getTime() + '.csv')
|
||||
link.style.visibility = 'hidden'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
}
|
||||
}
|
||||
|
||||
const calculateAverages = (data: any) => {
|
||||
|
@ -637,7 +637,7 @@ const statAnalysisExport = () => {
|
||||
if (link.download !== undefined) {
|
||||
const url = URL.createObjectURL(blob)
|
||||
link.setAttribute('href', url)
|
||||
link.setAttribute('download', '趋势分析_' + new Date().getTime() + '.csv')
|
||||
link.setAttribute('download', '单机分析_' + new Date().getTime() + '.csv')
|
||||
link.style.visibility = 'hidden'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
|
@ -494,6 +494,8 @@ const intervalChange = (val: any) => {
|
||||
const tableDataLeftRef = ref()
|
||||
const openMeasure = () => {
|
||||
showMeasure.value = true
|
||||
highSpeed.value = false
|
||||
inputValue.value = ''
|
||||
pageSetting.current = 1
|
||||
getCompleteData()
|
||||
selectedLeft.value = JSON.parse(JSON.stringify(submitParams.selectedLeft))
|
||||
@ -629,8 +631,12 @@ const handleRes = (res: any, selectAllDevices: any) => {
|
||||
lowSpeedExoprtData.value.push(dataItem.join(','))
|
||||
})
|
||||
}
|
||||
highcsvContent.value = highSpeedExoprtHeader.value + '\n' + highSpeedExoprtData.value.join('\n')
|
||||
lowcsvContent.value = lowSpeedExoprtHeader.value + '\n' + lowSpeedExoprtData.value.join('\n')
|
||||
highcsvContent.value = highSpeedExoprtData.value.length
|
||||
? highSpeedExoprtHeader.value + '\n' + highSpeedExoprtData.value.join('\n')
|
||||
: []
|
||||
lowcsvContent.value = lowSpeedExoprtData.value.length
|
||||
? lowSpeedExoprtHeader.value + '\n' + lowSpeedExoprtData.value.join('\n')
|
||||
: []
|
||||
if (!yData.length) {
|
||||
ElMessage.info(`${deviceName + attName}数据为空`)
|
||||
return
|
||||
@ -689,26 +695,24 @@ const escapeCsvValue = (value: any) => {
|
||||
}
|
||||
const statAnalysisExport = () => {
|
||||
const tables = [
|
||||
{ data: highcsvContent.value, filename: '高频.csv' },
|
||||
{ data: lowcsvContent.value, filename: '低频.csv' },
|
||||
{ data: highcsvContent.value, filename: '多机对比_高频' + new Date().getTime() + '.csv' },
|
||||
{ data: lowcsvContent.value, filename: '多机对比_低频' + new Date().getTime() + '.csv' },
|
||||
]
|
||||
|
||||
tables.forEach((table) => {
|
||||
const csvContent = table.data
|
||||
|
||||
// 创建Blob对象
|
||||
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' })
|
||||
|
||||
// 创建下载链接并触发下载
|
||||
const link = document.createElement('a')
|
||||
if (link.download !== undefined) {
|
||||
const url = URL.createObjectURL(blob)
|
||||
link.setAttribute('href', url)
|
||||
link.setAttribute('download', table.filename)
|
||||
link.style.visibility = 'hidden'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
if (csvContent.length) {
|
||||
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' })
|
||||
const link = document.createElement('a')
|
||||
if (link.download !== undefined) {
|
||||
const url = URL.createObjectURL(blob)
|
||||
link.setAttribute('href', url)
|
||||
link.setAttribute('download', table.filename)
|
||||
link.style.visibility = 'hidden'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user