update
This commit is contained in:
parent
cf35246594
commit
80eceabf9a
@ -2849,13 +2849,6 @@ bool CRYDevice::publishinitDeviceData(int uid)
|
|||||||
{
|
{
|
||||||
if (uid < 0 || uid >= UNIT_NUM) return false;
|
if (uid < 0 || uid >= UNIT_NUM) return false;
|
||||||
|
|
||||||
if ((config.units[uid].state & 0x80) != 0x80) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ((config.units[uid].state & 0x40) == 0x40) { //该设备已经发送过初始化
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Json::Value root;
|
Json::Value root;
|
||||||
Json::Value values;
|
Json::Value values;
|
||||||
|
|
||||||
@ -2882,7 +2875,6 @@ bool CRYDevice::publishinitDeviceData(int uid)
|
|||||||
root["deviceId"] = static_units[uid].deviceId;
|
root["deviceId"] = static_units[uid].deviceId;
|
||||||
root["values"] = values;
|
root["values"] = values;
|
||||||
|
|
||||||
config.units[uid].state |= 0x40;
|
|
||||||
return publish_sensor_data("", "initDeviceData", root);
|
return publish_sensor_data("", "initDeviceData", root);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -2919,7 +2911,6 @@ bool CRYDevice::publishAnalogData(int uid)
|
|||||||
datatime *= 1000;
|
datatime *= 1000;
|
||||||
root["dataTime"] = datatime;
|
root["dataTime"] = datatime;
|
||||||
root["deviceId"] = static_units[uid].deviceId;
|
root["deviceId"] = static_units[uid].deviceId;
|
||||||
// root["isStore"] = config.units[uid].state & 0x20 ? false : true;
|
|
||||||
|
|
||||||
if (values.size()) {
|
if (values.size()) {
|
||||||
root["values"] = values;
|
root["values"] = values;
|
||||||
@ -3020,14 +3011,6 @@ bool CRYDevice::publishdeviceEventData(void)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRYDevice::releaseAllUnits(void)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < UNIT_NUM; i++) {
|
|
||||||
if ((config.units[i].state & 0x01) != 0x01) continue;
|
|
||||||
config.units[i].state &= 0xBF; //0x40取反
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int CRYDevice::sendMsg(std::string sMessage)
|
int CRYDevice::sendMsg(std::string sMessage)
|
||||||
{
|
{
|
||||||
if (NULL != m_ws && m_ws->getReadyState() == easywsclient::WebSocket::OPEN)
|
if (NULL != m_ws && m_ws->getReadyState() == easywsclient::WebSocket::OPEN)
|
||||||
@ -3117,7 +3100,6 @@ BOOLEAN CRYDevice::ry_init(const char *host, const int port, const char *nodeId,
|
|||||||
snprintf(url, sizeof(url), "/node/%s/%s", m_nodeId, m_version);
|
snprintf(url, sizeof(url), "/node/%s/%s", m_nodeId, m_version);
|
||||||
snprintf(cPort, sizeof(cPort), "%d", m_port);
|
snprintf(cPort, sizeof(cPort), "%d", m_port);
|
||||||
vLog(LOG_DEBUG, "%d here to connect:%s:%s.\n", __LINE__, m_host, cPort);
|
vLog(LOG_DEBUG, "%d here to connect:%s:%s.\n", __LINE__, m_host, cPort);
|
||||||
releaseAllUnits();
|
|
||||||
conn = nopoll_conn_new(ctx, m_host, cPort, NULL, url, NULL, NULL);
|
conn = nopoll_conn_new(ctx, m_host, cPort, NULL, url, NULL, NULL);
|
||||||
g_conn = conn;
|
g_conn = conn;
|
||||||
}
|
}
|
||||||
@ -3222,7 +3204,6 @@ bool CRYDevice::ry_run(void)
|
|||||||
snprintf(url, sizeof(url), "/node/%s/%s", m_nodeId, m_version);
|
snprintf(url, sizeof(url), "/node/%s/%s", m_nodeId, m_version);
|
||||||
snprintf(cPort, sizeof(cPort), "%d", m_port);
|
snprintf(cPort, sizeof(cPort), "%d", m_port);
|
||||||
vLog(LOG_DEBUG, "%d here to connect:%s:%s.\n", __LINE__, m_host, cPort);
|
vLog(LOG_DEBUG, "%d here to connect:%s:%s.\n", __LINE__, m_host, cPort);
|
||||||
releaseAllUnits();
|
|
||||||
conn = nopoll_conn_new(ctx, m_host, cPort, NULL, url, NULL, NULL);
|
conn = nopoll_conn_new(ctx, m_host, cPort, NULL, url, NULL, NULL);
|
||||||
g_conn = conn;
|
g_conn = conn;
|
||||||
last_connect_sec = system32.timers;
|
last_connect_sec = system32.timers;
|
||||||
@ -3240,7 +3221,7 @@ bool CRYDevice::ry_run(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
publishdeviceEventData();
|
publishdeviceEventData();
|
||||||
int i = 0;
|
// int i = 0;
|
||||||
#if 1
|
#if 1
|
||||||
for (int i = 0; i < UNIT_NUM; i++)
|
for (int i = 0; i < UNIT_NUM; i++)
|
||||||
{
|
{
|
||||||
@ -3249,8 +3230,8 @@ bool CRYDevice::ry_run(void)
|
|||||||
m_nCurUnit++;
|
m_nCurUnit++;
|
||||||
if (m_nCurUnit >= UNIT_NUM) m_nCurUnit = 0;
|
if (m_nCurUnit >= UNIT_NUM) m_nCurUnit = 0;
|
||||||
#endif
|
#endif
|
||||||
if ((config.units[i].state & 0x01) != TRUE) break;
|
if ((config.units[i].state & 0x01) != TRUE) continue;
|
||||||
if (config.units[i].type != MASTER_UNIT) break;
|
if (config.units[i].type != MASTER_UNIT) continue;
|
||||||
MakeYKFrame(i);
|
MakeYKFrame(i);
|
||||||
MakeYTFrame(i);
|
MakeYTFrame(i);
|
||||||
if (sec_changed) {
|
if (sec_changed) {
|
||||||
|
@ -2315,25 +2315,11 @@ void* idle_process(void* param)
|
|||||||
config.units[i].softdog++;
|
config.units[i].softdog++;
|
||||||
if (config.units[i].softdog > UNIT_WATCHDOG_TIME) {
|
if (config.units[i].softdog > UNIT_WATCHDOG_TIME) {
|
||||||
config.units[i].softdog = UNIT_WATCHDOG_TIME;
|
config.units[i].softdog = UNIT_WATCHDOG_TIME;
|
||||||
config.units[i].value = SPI_ON;
|
//config.units[i].value = SPI_ON;
|
||||||
|
config.units[i].value |= SPI_ON;
|
||||||
} else {
|
} else {
|
||||||
config.units[i].value = SPI_OFF;
|
//config.units[i].value = SPI_OFF;
|
||||||
if ((config.units[i].state & 0x80) != 0x80) {
|
config.units[i].value &= ~SPI_ON;
|
||||||
int j = 0;
|
|
||||||
for (j = 0; j < config.units[i].yxcount; j++) {
|
|
||||||
if ((config.units[i].yxs[j].qds & 0x80) == 0x80) break;
|
|
||||||
}
|
|
||||||
if (j < config.units[i].yxcount) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (j = 0; j < config.units[i].yccount; j++) {
|
|
||||||
if ((config.units[i].ycs[j].qds & 0x80) == 0x80) break;
|
|
||||||
}
|
|
||||||
if (j < config.units[i].yccount) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
config.units[i].state |= 0x80;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -408,10 +408,9 @@ static void* ryftp_process(void* param)
|
|||||||
m_datalen2mbaddr_map.insert(datalen2mbaddrmap::value_type(m_datalen_mbaddr[i].address, i + 1));
|
m_datalen2mbaddr_map.insert(datalen2mbaddrmap::value_type(m_datalen_mbaddr[i].address, i + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
int len = 0;
|
|
||||||
//struRYDeviceData t_data;
|
//struRYDeviceData t_data;
|
||||||
FIELDDES fields[1024];
|
FIELDDES fields[1024];
|
||||||
len = calcFields(fields);
|
calcFields(fields);
|
||||||
|
|
||||||
//判断是否链接单元
|
//判断是否链接单元
|
||||||
int uid = mbt->GetUnitID(0); //默认只接一个设备
|
int uid = mbt->GetUnitID(0); //默认只接一个设备
|
||||||
@ -486,6 +485,7 @@ static void* ryftp_process(void* param)
|
|||||||
if (result == CURLE_OK) {
|
if (result == CURLE_OK) {
|
||||||
//成功,处理文件
|
//成功,处理文件
|
||||||
vLog(LOG_DEBUG, "%s get %s to local memory, with name: %s, and password: %s okay, and file length is: %d.\n", processName, remote, user, password, chunk.size);
|
vLog(LOG_DEBUG, "%s get %s to local memory, with name: %s, and password: %s okay, and file length is: %d.\n", processName, remote, user, password, chunk.size);
|
||||||
|
config.units[uid].value &= ~0x02;
|
||||||
ftpget_retry_count = 0;
|
ftpget_retry_count = 0;
|
||||||
if (chunk.size <= (int)(sizeof(struRYDeviceData) << 5)) {
|
if (chunk.size <= (int)(sizeof(struRYDeviceData) << 5)) {
|
||||||
vLog(LOG_DEBUG, "%s PLC文件生成未完成!\n", processName);
|
vLog(LOG_DEBUG, "%s PLC文件生成未完成!\n", processName);
|
||||||
@ -602,6 +602,7 @@ static void* ryftp_process(void* param)
|
|||||||
mbt->m_iv = 0;
|
mbt->m_iv = 0;
|
||||||
mbt->m_currentDirNo = -1;
|
mbt->m_currentDirNo = -1;
|
||||||
mbt->m_currentFileNo = -1;
|
mbt->m_currentFileNo = -1;
|
||||||
|
config.units[uid].value |= 0x02; //
|
||||||
}
|
}
|
||||||
//此处空闲读取未读的文件
|
//此处空闲读取未读的文件
|
||||||
if (mbt->m_bHaveUnReadFile) {
|
if (mbt->m_bHaveUnReadFile) {
|
||||||
@ -934,11 +935,12 @@ BOOLEAN CHostADSBFProcess::OnTimer(void)
|
|||||||
if (m_bRouteAdded == FALSE)
|
if (m_bRouteAdded == FALSE)
|
||||||
{
|
{
|
||||||
long ret = AddRemoteRoute(m_remoteIp, m_localNetId, m_localIp, std::string("isoftstone"), std::string("admin"), std::string("admin"));
|
long ret = AddRemoteRoute(m_remoteIp, m_localNetId, m_localIp, std::string("isoftstone"), std::string("admin"), std::string("admin"));
|
||||||
vLog(LOG_DEBUG, "%s add route return value is: %d\n", m_pidName.c_str(), ret);
|
vLog(LOG_DEBUG, "%s add route(%s to %s) return value is: %d\n", m_localIp.c_str(), m_remoteIp.c_str(), m_pidName.c_str(), ret);
|
||||||
if (ret != 0) return TRUE;
|
if (ret != 0) return TRUE;
|
||||||
}
|
}
|
||||||
m_bRouteAdded = TRUE;
|
m_bRouteAdded = TRUE;
|
||||||
//添加成功
|
//添加成功
|
||||||
|
vLog(LOG_DEBUG, "%s start to connect(%s:%d)\n", m_pidName.c_str(), m_remoteIp.c_str(), m_remotePort);
|
||||||
m_turbine = new AdsDevice{m_remoteIp, AmsNetId(m_remoteNetId), m_remotePort};
|
m_turbine = new AdsDevice{m_remoteIp, AmsNetId(m_remoteNetId), m_remotePort};
|
||||||
const auto state = m_turbine->GetState();
|
const auto state = m_turbine->GetState();
|
||||||
if ((uint16_t)state.ads >= ADSSTATE::ADSSTATE_MAXSTATES || (uint16_t)state.device >= ADSSTATE::ADSSTATE_MAXSTATES)
|
if ((uint16_t)state.ads >= ADSSTATE::ADSSTATE_MAXSTATES || (uint16_t)state.device >= ADSSTATE::ADSSTATE_MAXSTATES)
|
||||||
@ -960,6 +962,7 @@ BOOLEAN CHostADSBFProcess::OnTimer(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
readRealData();
|
readRealData();
|
||||||
|
FeedDog();
|
||||||
// } catch (const AdsException& ex) {
|
// } catch (const AdsException& ex) {
|
||||||
// vLog(LOG_ERROR, "%s AdsException message: %s, remote is: %s:%d\n", m_pidName.c_str(), ex.what(), m_remoteIp.c_str(), m_remotePort);
|
// vLog(LOG_ERROR, "%s AdsException message: %s, remote is: %s:%d\n", m_pidName.c_str(), ex.what(), m_remoteIp.c_str(), m_remotePort);
|
||||||
// } catch (const std::runtime_error& ex) {
|
// } catch (const std::runtime_error& ex) {
|
||||||
@ -1066,6 +1069,7 @@ BOOLEAN CHostADSBFProcess::readRealData()
|
|||||||
DWORD nValue = 0;
|
DWORD nValue = 0;
|
||||||
int point;
|
int point;
|
||||||
|
|
||||||
|
UnitFeedDog(uid);
|
||||||
for (int i = 0; i < MAX_BLOCKF_SIZE;)
|
for (int i = 0; i < MAX_BLOCKF_SIZE;)
|
||||||
{
|
{
|
||||||
//vLog(LOG_DEBUG, "registerAddr is: %d\n", registerAddr);
|
//vLog(LOG_DEBUG, "registerAddr is: %d\n", registerAddr);
|
||||||
|
@ -447,11 +447,10 @@ static void* ryftp_process(void* param)
|
|||||||
m_datalen2mbaddr_map.insert(datalen2mbaddrmap::value_type(m_datalen_mbaddr[i].address, i + 1));
|
m_datalen2mbaddr_map.insert(datalen2mbaddrmap::value_type(m_datalen_mbaddr[i].address, i + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
int len = 0;
|
|
||||||
//struRYDeviceData t_data;
|
//struRYDeviceData t_data;
|
||||||
FIELDDES fields[1024];
|
FIELDDES fields[1024];
|
||||||
|
|
||||||
len = calcFields(fields);
|
calcFields(fields);
|
||||||
|
|
||||||
//判断是否链接单元
|
//判断是否链接单元
|
||||||
int uid = mbt->GetUnitID(0); //默认只接一个设备
|
int uid = mbt->GetUnitID(0); //默认只接一个设备
|
||||||
@ -525,6 +524,7 @@ static void* ryftp_process(void* param)
|
|||||||
if (result == CURLE_OK) {
|
if (result == CURLE_OK) {
|
||||||
//成功,处理文件
|
//成功,处理文件
|
||||||
vLog(LOG_DEBUG, "%s get %s to local memory, with name: %s, and password: %s okay, and file length is: %d.\n", processName, remote, user, password, chunk.size);
|
vLog(LOG_DEBUG, "%s get %s to local memory, with name: %s, and password: %s okay, and file length is: %d.\n", processName, remote, user, password, chunk.size);
|
||||||
|
config.units[uid].value &= ~0x02;
|
||||||
ftpget_retry_count = 0;
|
ftpget_retry_count = 0;
|
||||||
if (chunk.size <= (int)(sizeof(struRYDeviceData) << 5)) {
|
if (chunk.size <= (int)(sizeof(struRYDeviceData) << 5)) {
|
||||||
vLog(LOG_DEBUG, "%s PLC文件生成未完成!\n", processName);
|
vLog(LOG_DEBUG, "%s PLC文件生成未完成!\n", processName);
|
||||||
@ -641,6 +641,7 @@ static void* ryftp_process(void* param)
|
|||||||
mbt->m_iv = 0;
|
mbt->m_iv = 0;
|
||||||
mbt->m_currentDirNo = -1;
|
mbt->m_currentDirNo = -1;
|
||||||
mbt->m_currentFileNo = -1;
|
mbt->m_currentFileNo = -1;
|
||||||
|
config.units[uid].value |= 0x02; //
|
||||||
}
|
}
|
||||||
//此处空闲读取未读的文件
|
//此处空闲读取未读的文件
|
||||||
if (mbt->m_bHaveUnReadFile) {
|
if (mbt->m_bHaveUnReadFile) {
|
||||||
|
@ -52,11 +52,11 @@ BOOLEAN CRTUStatusProcess::OnTimer(void)
|
|||||||
for (i = 0; i < UNIT_NUM; i++)
|
for (i = 0; i < UNIT_NUM; i++)
|
||||||
{
|
{
|
||||||
//单元状态在idle_process中计算,此处刷新单元状态
|
//单元状态在idle_process中计算,此处刷新单元状态
|
||||||
if (GetUnitYX(uid, i + PROCESSES_NUM) != config.units[i].value)
|
if (GetUnitYX(uid, i + PROCESSES_NUM) != (config.units[i].value & 0x01))
|
||||||
{
|
{
|
||||||
SetUnitSOE(uid, i + PROCESSES_NUM, config.units[i].value, system32.now);
|
SetUnitSOE(uid, i + PROCESSES_NUM, (config.units[i].value & 0x01), system32.now);
|
||||||
}
|
}
|
||||||
SetUnitYX(uid, i + PROCESSES_NUM, config.units[i].value); //单元通讯中断,设置单元数据无效
|
SetUnitYX(uid, i + PROCESSES_NUM, (config.units[i].value & 0x01)); //单元通讯中断,设置单元数据无效
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UnitFeedDog(uid);
|
UnitFeedDog(uid);
|
||||||
|
4
das-dn/third_party/AdsLib/Sockets.cpp
vendored
4
das-dn/third_party/AdsLib/Sockets.cpp
vendored
@ -111,8 +111,8 @@ bool IpV4::operator==(const IpV4& ref) const
|
|||||||
return value == ref.value;
|
return value == ref.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Socket::Socket(const struct addrinfo* const host, const int type)
|
Socket::Socket(const struct addrinfo* const host, const int type) :
|
||||||
: m_WSAInitialized(!InitSocketLibrary()),
|
m_WSAInitialized(!InitSocketLibrary()),
|
||||||
m_DestAddr(SOCK_DGRAM == type ? reinterpret_cast<const struct sockaddr*>(&m_SockAddress) : nullptr),
|
m_DestAddr(SOCK_DGRAM == type ? reinterpret_cast<const struct sockaddr*>(&m_SockAddress) : nullptr),
|
||||||
m_DestAddrLen(0),
|
m_DestAddrLen(0),
|
||||||
m_LastError(0),
|
m_LastError(0),
|
||||||
|
Loading…
Reference in New Issue
Block a user