update
This commit is contained in:
parent
2910ea7ee0
commit
bc27da323e
@ -100,8 +100,8 @@ int main(int argc, char** argv)
|
||||
BOOLEAN enable_auto_platform = TRUE;
|
||||
|
||||
char host[256] = {"127.0.0.1"};
|
||||
int port = 7790;
|
||||
char nodeId[128] = {"runyang_dn"};
|
||||
int port = 8080;
|
||||
char nodeId[128] = {"1"};
|
||||
char version[128] = {"0"};
|
||||
|
||||
//获取可执行文件所在目录
|
||||
@ -291,7 +291,7 @@ int main(int argc, char** argv)
|
||||
destroy_thread();
|
||||
freeMem();
|
||||
vLog(LOG_DEBUG, "App: dataAcquisition start reload.\n");
|
||||
} while(1);
|
||||
} while(0);
|
||||
|
||||
pthread_mutex_destroy(&mutex);
|
||||
|
||||
|
@ -87,6 +87,12 @@ bool CRYDevice::configInitializeMemory(void)
|
||||
for (i = 0; i < UNIT_NUM; i++) {
|
||||
config_config.units[i].real_softdog = 0;
|
||||
config_config.units[i].ftp_softdog = 0;
|
||||
|
||||
config_config.units[i].yxs = new struUnitYX[UNIT_YX_MAX];
|
||||
config_config.units[i].ycs = new struUnitYC[UNIT_YC_MAX];
|
||||
config_config.units[i].yms = new struUnitYM[UNIT_YM_MAX];
|
||||
config_config.units[i].yks = new struUnitYK[UNIT_YK_MAX];
|
||||
config_config.units[i].yts = new struUnitYT[UNIT_YT_MAX];
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -2314,7 +2320,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
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];
|
||||
//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++) {
|
||||
@ -2382,7 +2388,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
}
|
||||
}
|
||||
if (config_config.units[uid].ymcount > 0) {
|
||||
config_config.units[uid].yms = new struUnitYM[config_config.units[uid].ymcount];
|
||||
//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,7 +2431,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
}
|
||||
}
|
||||
if (config_config.units[uid].ykcount > 0) {
|
||||
config_config.units[uid].yks = new struUnitYK[config_config.units[uid].ykcount];
|
||||
//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,7 +2466,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
}
|
||||
}
|
||||
if (config_config.units[uid].ytcount > 0) {
|
||||
config_config.units[uid].yts = new struUnitYT[config_config.units[uid].ytcount];
|
||||
//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,7 +2501,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
}
|
||||
}
|
||||
if (config_config.units[uid].yxcount > 0) {
|
||||
config_config.units[uid].yxs = new struUnitYX[config_config.units[uid].yxcount];
|
||||
//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++) {
|
||||
@ -2530,7 +2536,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
}
|
||||
}
|
||||
if (pfdbyxname) {
|
||||
fseek(pfdbyxname, sizeof(struYKStatic) * config_config.units[uid].yxs[k].order, SEEK_SET);
|
||||
fseek(pfdbyxname, sizeof(struYXStatic) * config_config.units[uid].yxs[k].order, SEEK_SET);
|
||||
fwrite(yxs[k].name.c_str(), (MAX_NAME_SIZE << 2), 1, pfdbyxname);
|
||||
}
|
||||
}
|
||||
@ -2548,7 +2554,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:
|
||||
@ -2559,24 +2565,31 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
config_config.units[sub_uid].addr[4] = 1;
|
||||
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;
|
||||
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();
|
||||
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.processes[pid].units[0] = sub_uid;
|
||||
if (config_config.units[sub_uid].yccount > 0)
|
||||
if (s_yccount > 0)
|
||||
{
|
||||
config_config.units[sub_uid].ycs = new struUnitYC[config_config.units[sub_uid].yccount];
|
||||
//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) * config_config.units[sub_uid].yccount);
|
||||
memset(config_config.units[sub_uid].ycs, 0, sizeof(struUnitYC) * s_yccount);
|
||||
}
|
||||
for (int i = 0; i < config_config.units[sub_uid].yccount; i++) {
|
||||
for (int i = 0; i < s_yccount; i++) {
|
||||
std::string key = attrs.ycs[i].name;
|
||||
int order = -1;
|
||||
int point = i;
|
||||
@ -2614,13 +2627,13 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
config_config.units[sub_uid].ycs[point].highSpeed = FALSE;
|
||||
}
|
||||
}
|
||||
if (config_config.units[sub_uid].ymcount > 0)
|
||||
if (s_ymcount > 0)
|
||||
{
|
||||
config_config.units[sub_uid].yms = new struUnitYM[config_config.units[sub_uid].ymcount];
|
||||
//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) * config_config.units[sub_uid].ymcount);
|
||||
memset(config_config.units[sub_uid].yms, 0, sizeof(struUnitYM) * s_ymcount);
|
||||
}
|
||||
for (int i = 0; i < config_config.units[sub_uid].ymcount; i++) {
|
||||
for (int i = 0; i < s_ymcount; i++) {
|
||||
std::string key = attrs.yms[i].name;
|
||||
int order = -1;
|
||||
int point = i;
|
||||
@ -2646,13 +2659,13 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (config_config.units[sub_uid].ykcount > 0)
|
||||
if (s_ykcount > 0)
|
||||
{
|
||||
config_config.units[sub_uid].yks = new struUnitYK[config_config.units[sub_uid].ykcount];
|
||||
//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) * config_config.units[sub_uid].ykcount);
|
||||
memset(config_config.units[sub_uid].yks, 0, sizeof(struUnitYK) * s_ykcount);
|
||||
}
|
||||
for (int i = 0; i < config_config.units[sub_uid].ykcount; i++) {
|
||||
for (int i = 0; i < s_ykcount; i++) {
|
||||
std::string key = attrs.yks[i].name;
|
||||
int order = -1;
|
||||
int point = i;
|
||||
@ -2670,13 +2683,13 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
config_config.units[sub_uid].yks[point].order = order;
|
||||
}
|
||||
}
|
||||
if (config_config.units[sub_uid].ytcount > 0)
|
||||
if (s_ytcount > 0)
|
||||
{
|
||||
config_config.units[sub_uid].yts = new struUnitYT[config_config.units[sub_uid].ytcount];
|
||||
//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) * config_config.units[sub_uid].ytcount);
|
||||
memset(config_config.units[sub_uid].yts, 0, sizeof(struUnitYT) * s_ytcount);
|
||||
}
|
||||
for (int i = 0; i < config_config.units[sub_uid].ytcount; i++) {
|
||||
for (int i = 0; i < s_ytcount; i++) {
|
||||
std::string key = attrs.yts[i].name;
|
||||
int order = -1;
|
||||
int point = i;
|
||||
@ -2694,13 +2707,13 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
config_config.units[sub_uid].yts[point].order = order;
|
||||
}
|
||||
}
|
||||
if (config_config.units[sub_uid].yxcount > 0)
|
||||
if (s_yxcount > 0)
|
||||
{
|
||||
config_config.units[sub_uid].yxs = new struUnitYX[config_config.units[sub_uid].yxcount];
|
||||
//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) * config_config.units[sub_uid].yxcount);
|
||||
memset(config_config.units[sub_uid].yxs, 0, sizeof(struUnitYX) * s_yxcount);
|
||||
}
|
||||
for (int i = 0; i < config_config.units[sub_uid].yxcount; i++) {
|
||||
for (int i = 0; i < s_yxcount; i++) {
|
||||
std::string key = attrs.yxs[i].name;
|
||||
int order = -1;
|
||||
int point = i;
|
||||
@ -2855,7 +2868,7 @@ void CRYDevice::heart_beat(int status)
|
||||
#endif
|
||||
jsonValue["deviceId"] = deviceId;
|
||||
jsonValue["online"] = (config.units[i].real_softdog >= UNIT_WATCHDOG_TIME) ? false : true;
|
||||
#if 0
|
||||
#if 1
|
||||
jsonValue["real"] = (config.units[i].real_softdog >= UNIT_WATCHDOG_TIME) ? false : true;
|
||||
if ((config.units[i].state & 0x20) == 0x20) {
|
||||
jsonValue["ftp"] = (config.units[i].real_softdog >= UNIT_WATCHDOG_TIME) ? false : true;
|
||||
|
@ -704,9 +704,17 @@ CHostADSBFProcess::~CHostADSBFProcess()
|
||||
fclose(pf);
|
||||
}
|
||||
|
||||
vLog(LOG_DEBUG, "waiting for child thread [%s] destroy.\n", (m_cpidName[0] != '\0') ? m_cpidName : "unknow");
|
||||
pthread_join(m_cpid, NULL);
|
||||
vLog(LOG_DEBUG, "child protocol thread [%s] is destroyed.\n", (m_cpidName[0] != '\0') ? m_cpidName : "unknow");
|
||||
if (m_cpid > 0)
|
||||
{
|
||||
vLog(LOG_DEBUG, "waiting for child thread [%s] destroy.\n", (m_cpidName[0] != '\0') ? m_cpidName : "unknow");
|
||||
pthread_join(m_cpid, NULL);
|
||||
vLog(LOG_DEBUG, "child protocol thread [%s] is destroyed.\n", (m_cpidName[0] != '\0') ? m_cpidName : "unknow");
|
||||
}
|
||||
}
|
||||
if (m_turbine)
|
||||
{
|
||||
delete m_turbine;
|
||||
m_turbine = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -908,7 +916,8 @@ BOOLEAN CHostADSBFProcess::OnPreCreate(int id)
|
||||
pthread_attr_setstacksize(&attr, MEMERY_1M);
|
||||
pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
|
||||
|
||||
if (pthread_create(&m_cpid, &attr, ryftp_process, this) < 0) {
|
||||
if (pthread_create(&m_cpid, &attr, ryftp_process, this) < 0)
|
||||
{
|
||||
vLog(LOG_ERROR, "ads create ryftp_process error(%d,%s).\n", errno, strerror(errno));
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -790,13 +790,16 @@ CHostModbusTcpBFProcess::~CHostModbusTcpBFProcess()
|
||||
|
||||
char name[16];
|
||||
memset(name, '\0', sizeof(name));
|
||||
if (pthread_getname_np(m_cpid, name, sizeof(name)) != 0)
|
||||
if (m_cpid > 0)
|
||||
{
|
||||
memset(name, '\0', sizeof(name));
|
||||
if (pthread_getname_np(m_cpid, name, sizeof(name)) != 0)
|
||||
{
|
||||
memset(name, '\0', sizeof(name));
|
||||
}
|
||||
vLog(LOG_DEBUG, "waiting for child thread [%s] destroy.\n", (m_cpidName[0] != '\0') ? m_cpidName : "unknow");
|
||||
pthread_join(m_cpid, NULL);
|
||||
vLog(LOG_DEBUG, "child protocol thread [%s] is destroyed.\n", (m_cpidName[0] != '\0') ? m_cpidName : "unknow");
|
||||
}
|
||||
vLog(LOG_DEBUG, "waiting for child thread [%s] destroy.\n", (m_cpidName[0] != '\0') ? m_cpidName : "unknow");
|
||||
pthread_join(m_cpid, NULL);
|
||||
vLog(LOG_DEBUG, "child protocol thread [%s] is destroyed.\n", (m_cpidName[0] != '\0') ? m_cpidName : "unknow");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,8 +80,8 @@ typedef int SOCKET;
|
||||
#define UNIT_YX_MAX 0x1500
|
||||
#define UNIT_YC_MAX 0x2000
|
||||
#define UNIT_YM_MAX 0xB00
|
||||
#define UNIT_YK_MAX 0x100
|
||||
#define UNIT_YT_MAX 0x100
|
||||
#define UNIT_YK_MAX 0x400
|
||||
#define UNIT_YT_MAX 0x400
|
||||
#define DATABASE_YX_NUM 0x10000
|
||||
#define DATABASE_YC_NUM 0x20000
|
||||
#define DATABASE_YM_NUM 0x1000
|
||||
|
Loading…
Reference in New Issue
Block a user