update
This commit is contained in:
parent
f7a0d76771
commit
6491bc3594
@ -221,15 +221,30 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
//此处增加一条协议配置
|
||||
#if 0
|
||||
#if 1
|
||||
int i;
|
||||
for (i = 0; i < PROCESSES_NUM; i++)
|
||||
{
|
||||
if (config.processes[i].state == FALSE) break;
|
||||
}
|
||||
memcpy(&config.processes[i], &config.processes[0], sizeof(struProcess));
|
||||
config.processes[i].proto = PROTOCOL_FTP2MINIO;
|
||||
snprintf(config.processes[i].option.ftp2minio.ftp.user, sizeof(config.processes[i].option.ftp2minio.ftp.user), "%s", "administrator");
|
||||
snprintf(config.processes[i].name, sizeof(config.processes[i].name), "%s", "本地调试");
|
||||
config.processes[i].state = TRUE;
|
||||
config.processes[i].time_accept = FALSE;
|
||||
config.processes[i].proto = PROTOCOL_LOCAL_DEBUG;
|
||||
config.processes[i].mode = PROCESS_MODE_MASTER;
|
||||
config.processes[i].time_gap = 300;
|
||||
config.processes[i].poll_gap = 5;
|
||||
config.processes[i].order = 0;
|
||||
memset(config.processes[i].units, -1, sizeof(config.processes[i].units));
|
||||
config.processes[i].units[0] = 255;
|
||||
config.processes[i].option.network.ignored_source = TRUE;
|
||||
config.processes[i].option.network.socket_type = SOCK_STREAM;
|
||||
config.processes[i].option.network.bind_port = 9009;
|
||||
config.processes[i].option.network.bind_addr = INADDR_ANY;
|
||||
config.processes[i].option.network.target_port = 0;
|
||||
config.processes[i].option.network.target_addr = INADDR_ANY;
|
||||
|
||||
config.units[255].state = TRUE;
|
||||
#endif
|
||||
unsigned int m_runCount = 0;
|
||||
unsigned int count = 0;
|
||||
|
@ -1131,10 +1131,10 @@ BOOLEAN CRYDevice::processRymodbustcpParam(const Json::Value jsonRoot, int pid)
|
||||
}
|
||||
|
||||
//增加ftp协议参数
|
||||
if (jsonRoot["enableFtp"].isInt()) {
|
||||
config_config.processes[pid].option.rymodbus.bHaveFTP = jsonRoot["enableFtp"].asInt();
|
||||
} else if (jsonRoot["enableFtp"].isString()) {
|
||||
config_config.processes[pid].option.rymodbus.bHaveFTP = atoi(jsonRoot["enableFtp"].asCString());
|
||||
if (jsonRoot["ftpMode"].isInt()) {
|
||||
config_config.processes[pid].option.rymodbus.bHaveFTP = jsonRoot["ftpMode"].asInt();
|
||||
} else if (jsonRoot["ftpMode"].isString()) {
|
||||
config_config.processes[pid].option.rymodbus.bHaveFTP = atoi(jsonRoot["ftpMode"].asCString());
|
||||
} else { //默认存在允许ftp功能
|
||||
config_config.processes[pid].option.rymodbus.bHaveFTP = TRUE;
|
||||
}
|
||||
@ -1365,6 +1365,9 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
{
|
||||
if (uid < 0 || uid >= UNIT_NUM) return FALSE;
|
||||
if (point < 0) return FALSE;
|
||||
//vLog(LOG_DEBUG, "process unit(%d), point(%d), and type(%d)\n", uid, point, type);
|
||||
//vLog(LOG_DEBUG, "yx count is: %d, and yc count is: %d\n", config_config.units[uid].yxcount, config_config.units[uid].yccount);
|
||||
vLog(LOG_DEBUG, "%s", jsonRoot.toStyledString().c_str());
|
||||
switch (type)
|
||||
{
|
||||
case POINT_TYPE_YX:
|
||||
@ -1375,11 +1378,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
} else if (jsonRoot["col1"].isInt()) {
|
||||
BYTE funcCode = (BYTE)jsonRoot["col1"].asInt();
|
||||
config_config.units[uid].yxs[point].m_param[0] = funcCode;
|
||||
} else {
|
||||
config_config.units[uid].yxs[point].m_param[0] = 0;
|
||||
}
|
||||
//功能码
|
||||
if (jsonRoot["funcCode"].isString()) {
|
||||
} else if (jsonRoot["funcCode"].isString()) {
|
||||
BYTE funcCode = (BYTE)atoi(jsonRoot["funcCode"].asCString());
|
||||
config_config.units[uid].yxs[point].m_param[0] = funcCode;
|
||||
} else if (jsonRoot["funcCode"].isInt()) {
|
||||
@ -1395,11 +1394,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
} else if (jsonRoot["col2"].isInt()) {
|
||||
BYTE offSet = (BYTE)jsonRoot["col2"].asInt();
|
||||
config_config.units[uid].yxs[point].m_param[3] = offSet;
|
||||
} else {
|
||||
config_config.units[uid].yxs[point].m_param[3] = 0;
|
||||
}
|
||||
//偏移量
|
||||
if (jsonRoot["offSet"].isString()) {
|
||||
} else if (jsonRoot["offSet"].isString()) {
|
||||
BYTE offSet = (BYTE)atoi(jsonRoot["offSet"].asCString());
|
||||
config_config.units[uid].yxs[point].m_param[3] = offSet;
|
||||
} else if (jsonRoot["offSet"].isInt()) {
|
||||
@ -1417,12 +1412,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
WORD registerAddr = (WORD)jsonRoot["col3"].asInt();
|
||||
config_config.units[uid].yxs[point].m_param[1] = (registerAddr & 0xff);
|
||||
config_config.units[uid].yxs[point].m_param[2] = ((registerAddr >> 8) & 0xff);
|
||||
} else {
|
||||
config_config.units[uid].yxs[point].m_param[1] = 0;
|
||||
config_config.units[uid].yxs[point].m_param[2] = 0;
|
||||
}
|
||||
//寄存器
|
||||
if (jsonRoot["registerAddr"].isString()) {
|
||||
} else if (jsonRoot["registerAddr"].isString()) {
|
||||
WORD registerAddr = (WORD)atoi(jsonRoot["registerAddr"].asCString());
|
||||
config_config.units[uid].yxs[point].m_param[1] = (registerAddr & 0xff);
|
||||
config_config.units[uid].yxs[point].m_param[2] = ((registerAddr >> 8) & 0xff);
|
||||
@ -1434,7 +1424,6 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
config_config.units[uid].yxs[point].m_param[1] = 0;
|
||||
config_config.units[uid].yxs[point].m_param[2] = 0;
|
||||
}
|
||||
//
|
||||
break;
|
||||
case POINT_TYPE_YC:
|
||||
if (point >= config_config.units[uid].yccount) return FALSE;
|
||||
@ -1444,11 +1433,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
} else if (jsonRoot["col1"].isInt()) {
|
||||
BYTE funcCode = jsonRoot["col1"].asInt();
|
||||
config_config.units[uid].ycs[point].m_param[0] = funcCode;
|
||||
} else {
|
||||
config_config.units[uid].ycs[point].m_param[0] = 0;
|
||||
}
|
||||
//功能码
|
||||
if (jsonRoot["funcCode"].isString()) {
|
||||
} else if (jsonRoot["funcCode"].isString()) {
|
||||
BYTE funcCode = (BYTE)atoi(jsonRoot["funcCode"].asCString());
|
||||
config_config.units[uid].ycs[point].m_param[0] = funcCode;
|
||||
} else if (jsonRoot["funcCode"].isInt()) {
|
||||
@ -1468,12 +1453,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
config_config.units[uid].ycs[point].m_param[4] = dataType;
|
||||
if (dataType == 2 || dataType == 8) config_config.units[uid].ycs[point].m_param[3] = 1;
|
||||
else config_config.units[uid].ycs[point].m_param[3] = 2;
|
||||
} else {
|
||||
config_config.units[uid].ycs[point].m_param[4] = 0;
|
||||
config_config.units[uid].ycs[point].m_param[3] = 1;
|
||||
}
|
||||
//数据格式
|
||||
if (jsonRoot["dataType"].isString()) {
|
||||
} else if (jsonRoot["dataType"].isString()) {
|
||||
BYTE dataType = (BYTE)atoi(jsonRoot["dataType"].asCString());
|
||||
config_config.units[uid].ycs[point].m_param[4] = dataType;
|
||||
if (dataType == 2 || dataType == 8) config_config.units[uid].ycs[point].m_param[3] = 1;
|
||||
@ -1494,11 +1474,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
} else if (jsonRoot["col3"].isInt()) {
|
||||
BYTE signMark = jsonRoot["col3"].asInt();
|
||||
config_config.units[uid].ycs[point].m_param[5] = signMark;
|
||||
} else {
|
||||
config_config.units[uid].ycs[point].m_param[5] = 0;
|
||||
}
|
||||
//数据类型
|
||||
if (jsonRoot["signMark"].isString()) {
|
||||
} else if (jsonRoot["signMark"].isString()) {
|
||||
BYTE signMark = (BYTE)atoi(jsonRoot["signMark"].asCString());
|
||||
config_config.units[uid].ycs[point].m_param[5] = signMark;
|
||||
} else if (jsonRoot["signMark"].isInt()) {
|
||||
@ -1516,12 +1492,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
WORD registerAddr = (WORD)jsonRoot["col4"].asInt();
|
||||
config_config.units[uid].ycs[point].m_param[1] = (registerAddr & 0xff);
|
||||
config_config.units[uid].ycs[point].m_param[2] = ((registerAddr >> 8) & 0xff);
|
||||
} else {
|
||||
config_config.units[uid].ycs[point].m_param[1] = 0;
|
||||
config_config.units[uid].ycs[point].m_param[2] = 0;
|
||||
}
|
||||
//寄存器
|
||||
if (jsonRoot["registerAddr"].isString()) {
|
||||
} else if (jsonRoot["registerAddr"].isString()) {
|
||||
WORD registerAddr = (WORD)atoi(jsonRoot["registerAddr"].asCString());
|
||||
config_config.units[uid].ycs[point].m_param[1] = (registerAddr & 0xff);
|
||||
config_config.units[uid].ycs[point].m_param[2] = ((registerAddr >> 8) & 0xff);
|
||||
@ -1543,11 +1514,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
} else if (jsonRoot["col1"].isInt()) {
|
||||
BYTE funcCode = jsonRoot["col1"].asInt();
|
||||
config_config.units[uid].yms[point].m_param[0] = funcCode;
|
||||
} else {
|
||||
config.units[uid].yms[point].m_param[0] = 0;
|
||||
}
|
||||
//功能码
|
||||
if (jsonRoot["funcCode"].isString()) {
|
||||
} else if (jsonRoot["funcCode"].isString()) {
|
||||
BYTE funcCode = (BYTE)atoi(jsonRoot["funcCode"].asCString());
|
||||
config.units[uid].yms[point].m_param[0] = funcCode;
|
||||
} else if (jsonRoot["funcCode"].isInt()) {
|
||||
@ -1569,12 +1536,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
if (dataType == 0) config.units[uid].yms[point].m_param[3] = 1;
|
||||
if (dataType == 7 || dataType == 8) config.units[uid].yms[point].m_param[3] = 4;
|
||||
else config.units[uid].yms[point].m_param[3] = 2;
|
||||
} else {
|
||||
config.units[uid].yms[point].m_param[4] = 0;
|
||||
config.units[uid].yms[point].m_param[3] = 1;
|
||||
}
|
||||
//数据格式
|
||||
if (jsonRoot["dataType"].isString()) {
|
||||
} else if (jsonRoot["dataType"].isString()) {
|
||||
BYTE dataType = (BYTE)atoi(jsonRoot["dataType"].asCString());
|
||||
config.units[uid].yms[point].m_param[4] = dataType;
|
||||
if (dataType == 0) config.units[uid].yms[point].m_param[3] = 1;
|
||||
@ -1599,12 +1561,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
WORD registerAddr = (WORD)jsonRoot["col4"].asInt();
|
||||
config_config.units[uid].yms[point].m_param[1] = (registerAddr & 0xff);
|
||||
config_config.units[uid].yms[point].m_param[2] = ((registerAddr >> 8) & 0xff);
|
||||
} else {
|
||||
config.units[uid].yms[point].m_param[1] = 0;
|
||||
config.units[uid].yms[point].m_param[2] = 0;
|
||||
}
|
||||
//寄存器
|
||||
if (jsonRoot["registerAddr"].isString()) {
|
||||
} else if (jsonRoot["registerAddr"].isString()) {
|
||||
WORD registerAddr = (WORD)atoi(jsonRoot["registerAddr"].asCString());
|
||||
config.units[uid].yms[point].m_param[1] = (registerAddr & 0xff);
|
||||
config.units[uid].yms[point].m_param[2] = ((registerAddr >> 8) & 0xff);
|
||||
@ -1636,11 +1593,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
} else if (jsonRoot["col1"].isInt()) {
|
||||
BYTE funcCode = (BYTE)jsonRoot["col1"].asInt();
|
||||
config_config.units[uid].yks[point].m_param[0] = funcCode;
|
||||
} else {
|
||||
config_config.units[uid].yks[point].m_param[0] = 0;
|
||||
}
|
||||
//功能码
|
||||
if (jsonRoot["funcCode"].isString()) {
|
||||
} else if (jsonRoot["funcCode"].isString()) {
|
||||
BYTE funcCode = (BYTE)atoi(jsonRoot["funcCode"].asCString());
|
||||
config_config.units[uid].yks[point].m_param[0] = funcCode;
|
||||
} else if (jsonRoot["funcCode"].isInt()) {
|
||||
@ -1658,12 +1611,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
WORD registerAddr = (WORD)jsonRoot["col4"].asInt();
|
||||
config_config.units[uid].yks[point].m_param[6] = (registerAddr & 0xff);
|
||||
config_config.units[uid].yks[point].m_param[7] = ((registerAddr >> 8) & 0xff);
|
||||
} else {
|
||||
config_config.units[uid].yks[point].m_param[6] = 0xFF;
|
||||
config_config.units[uid].yks[point].m_param[7] = 0xFF;
|
||||
}
|
||||
//合闸寄存器
|
||||
if (jsonRoot["closeRegisterAddr"].isString()) {
|
||||
} else if (jsonRoot["closeRegisterAddr"].isString()) {
|
||||
WORD registerAddr = (WORD)atoi(jsonRoot["closeRegisterAddr"].asCString());
|
||||
config_config.units[uid].yks[point].m_param[6] = (registerAddr & 0xff);
|
||||
config_config.units[uid].yks[point].m_param[7] = ((registerAddr >> 8) & 0xff);
|
||||
@ -1684,12 +1632,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
WORD closeVal = (WORD)jsonRoot["col6"].asInt();
|
||||
config_config.units[uid].yks[point].m_param[10] = (closeVal & 0xff);
|
||||
config_config.units[uid].yks[point].m_param[11] = ((closeVal >> 8) & 0xff);
|
||||
} else {
|
||||
config_config.units[uid].yks[point].m_param[10] = 0xFF;
|
||||
config_config.units[uid].yks[point].m_param[11] = 0xFF;
|
||||
}
|
||||
//合闸值
|
||||
if (jsonRoot["closeValue"].isString()) {
|
||||
} else if (jsonRoot["closeValue"].isString()) {
|
||||
WORD closeVal = (WORD)atoi(jsonRoot["closeValue"].asCString());
|
||||
config_config.units[uid].yks[point].m_param[10] = (closeVal & 0xff);
|
||||
config_config.units[uid].yks[point].m_param[11] = ((closeVal >> 8) & 0xff);
|
||||
@ -1710,12 +1653,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
WORD registerAddr = (WORD)jsonRoot["col8"].asInt();
|
||||
config_config.units[uid].yks[point].m_param[14] = (registerAddr & 0xff);
|
||||
config_config.units[uid].yks[point].m_param[15] = ((registerAddr >> 8) & 0xff);
|
||||
} else {
|
||||
config_config.units[uid].yks[point].m_param[14] = 0xFF;
|
||||
config_config.units[uid].yks[point].m_param[15] = 0xFF;
|
||||
}
|
||||
//分闸寄存器
|
||||
if (jsonRoot["openRegisterAddr"].isString()) {
|
||||
} else if (jsonRoot["openRegisterAddr"].isString()) {
|
||||
WORD registerAddr = (WORD)atoi(jsonRoot["openRegisterAddr"].asCString());
|
||||
config_config.units[uid].yks[point].m_param[14] = (registerAddr & 0xff);
|
||||
config_config.units[uid].yks[point].m_param[15] = ((registerAddr >> 8) & 0xff);
|
||||
@ -1736,12 +1674,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
WORD openVal = (WORD)jsonRoot["col10"].asInt();
|
||||
config_config.units[uid].yks[point].m_param[18] = (openVal & 0xff);
|
||||
config_config.units[uid].yks[point].m_param[19] = ((openVal >> 8) & 0xff);
|
||||
} else {
|
||||
config_config.units[uid].yks[point].m_param[18] = 0xFF;
|
||||
config_config.units[uid].yks[point].m_param[19] = 0xFF;
|
||||
}
|
||||
//分闸值
|
||||
if (jsonRoot["openValue"].isString()) {
|
||||
} else if (jsonRoot["openValue"].isString()) {
|
||||
WORD openVal = (WORD)atoi(jsonRoot["openValue"].asCString());
|
||||
config_config.units[uid].yks[point].m_param[18] = (openVal & 0xff);
|
||||
config_config.units[uid].yks[point].m_param[19] = ((openVal >> 8) & 0xff);
|
||||
@ -1768,11 +1701,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
} else if (jsonRoot["col1"].isInt()) {
|
||||
BYTE setType = (BYTE)jsonRoot["col1"].asInt();
|
||||
config_config.units[uid].yts[point].m_param[0] = setType;
|
||||
} else {
|
||||
config_config.units[uid].yts[point].m_param[0] = 0;
|
||||
}
|
||||
//设值方式
|
||||
if (jsonRoot["setType"].isString()) {
|
||||
} else if (jsonRoot["setType"].isString()) {
|
||||
BYTE setType = (BYTE)atoi(jsonRoot["setType"].asCString());
|
||||
config_config.units[uid].yts[point].m_param[0] = setType;
|
||||
} else if (jsonRoot["setType"].isInt()) {
|
||||
@ -1788,11 +1717,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
} else if (jsonRoot["col2"].isInt()) {
|
||||
BYTE funcCode = (BYTE)jsonRoot["col2"].asInt();
|
||||
config_config.units[uid].yts[point].m_param[1] = funcCode;
|
||||
} else {
|
||||
config_config.units[uid].yts[point].m_param[1] = 0;
|
||||
}
|
||||
//功能码
|
||||
if (jsonRoot["funcCode"].isString()) {
|
||||
} else if (jsonRoot["funcCode"].isString()) {
|
||||
BYTE funcCode = (BYTE)atoi(jsonRoot["funcCode"].asCString());
|
||||
config_config.units[uid].yts[point].m_param[1] = funcCode;
|
||||
} else if (jsonRoot["funcCode"].isInt()) {
|
||||
@ -1810,12 +1735,7 @@ BOOLEAN CRYDevice::processModbusPointParam(const Json::Value jsonRoot, int uid,
|
||||
WORD registerAddr = (WORD)jsonRoot["col5"].asInt();
|
||||
config_config.units[uid].yts[point].m_param[6] = (registerAddr & 0xff);
|
||||
config_config.units[uid].yts[point].m_param[7] = ((registerAddr >> 8) & 0xff);
|
||||
} else {
|
||||
config_config.units[uid].yts[point].m_param[6] = 0xFF;
|
||||
config_config.units[uid].yts[point].m_param[7] = 0xFF;
|
||||
}
|
||||
//寄存器地址
|
||||
if (jsonRoot["registerAddr"].isString()) {
|
||||
} else if (jsonRoot["registerAddr"].isString()) {
|
||||
WORD registerAddr = (WORD)atoi(jsonRoot["registerAddr"].asCString());
|
||||
config_config.units[uid].yts[point].m_param[6] = (registerAddr & 0xff);
|
||||
config_config.units[uid].yts[point].m_param[7] = ((registerAddr >> 8) & 0xff);
|
||||
@ -2598,8 +2518,10 @@ bool CRYDevice::ry_run(void)
|
||||
last_connect_sec = system32.timers;
|
||||
|
||||
while ((msg[msg_count] = nopoll_conn_get_msg(conn)) != NULL) {
|
||||
#if 0
|
||||
#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+");
|
||||
|
@ -83,7 +83,7 @@ private:
|
||||
int status;
|
||||
|
||||
int msg_count = 0;
|
||||
noPollMsg *msg[4096];
|
||||
noPollMsg *msg[2048];
|
||||
|
||||
bool m_dataAcquisitionReload = false;
|
||||
|
||||
|
@ -1690,7 +1690,6 @@ BOOLEAN CHostModbusTcpBFProcess::OnPreCreate(int id)
|
||||
snprintf(m_remotePath, sizeof(m_remotePath), "%s", m_nOptions.ftp.remotePath);
|
||||
snprintf(m_localPath, sizeof(m_localPath), "%s", m_nOptions.ftp.localPath);
|
||||
|
||||
vLog(LOG_DEBUG, "file size is: %d\n", sizeof(struRYDeviceData) * 250 / 1024);
|
||||
//读取文件
|
||||
m_lastReadDirNo = 1;
|
||||
m_lastReadFileNo = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user