@@ -41,7 +41,6 @@ m_szIPAddress(IPAddress)
41
41
m_usIPPort=usIPPort;
42
42
lastKnownSensorState = 0 ;
43
43
initSensorData = true ;
44
- reqState = Idle;
45
44
notificationEnabled = false ;
46
45
m_bReceiverStarted = false ;
47
46
}
@@ -95,6 +94,7 @@ void Comm5TCP::OnDisconnect()
95
94
void Comm5TCP::Do_Work ()
96
95
{
97
96
bool bFirstTime = true ;
97
+ int count = 0 ;
98
98
while (!m_stoprequested)
99
99
{
100
100
m_LastHeartbeat = mytime (NULL );
@@ -111,6 +111,10 @@ void Comm5TCP::Do_Work()
111
111
{
112
112
sleep_milliseconds (40 );
113
113
update ();
114
+ if (count++ >= 100 ) {
115
+ count = 0 ;
116
+ querySensorState ();
117
+ }
114
118
}
115
119
}
116
120
_log.Log (LOG_STATUS, " Comm5 MA-5XXX: TCP/IP Worker stopped..." );
@@ -131,7 +135,6 @@ void Comm5TCP::processSensorData(const std::string& line)
131
135
}
132
136
lastKnownSensorState = sensorbitfield;
133
137
initSensorData = false ;
134
- reqState = Idle;
135
138
}
136
139
137
140
void Comm5TCP::ParseData (const unsigned char * data, const size_t len)
@@ -153,13 +156,8 @@ void Comm5TCP::ParseData(const unsigned char* data, const size_t len)
153
156
bool on = (relaybitfield & (1 << i)) != 0 ? true : false ;
154
157
SendSwitch (i + 1 , 1 , 255 , on, 0 , " Relay " + boost::lexical_cast<std::string>(i + 1 ));
155
158
}
156
- reqState = Idle;
157
- } else if (reqState == QuerySensorState && startsWith (line, " 210" )) {
158
- processSensorData (line);
159
- } else if (startsWith (line, " 210 OK" )) {
160
- // Command executed
161
- reqState = Idle;
162
- } else if (notificationEnabled && startsWith (line, " 210" )) {
159
+ }
160
+ else if (startsWith (line, " 210" ) && (!startsWith (line, " 210 OK" ))) {
163
161
processSensorData (line);
164
162
}
165
163
}
@@ -171,13 +169,11 @@ void Comm5TCP::ParseData(const unsigned char* data, const size_t len)
171
169
void Comm5TCP::queryRelayState ()
172
170
{
173
171
write (" OUTPUTS\n " );
174
- reqState = QueryRelayState;
175
172
}
176
173
177
174
void Comm5TCP::querySensorState ()
178
175
{
179
176
write (" QUERY\n " );
180
- reqState = QuerySensorState;
181
177
}
182
178
183
179
void Comm5TCP::enableNotifications ()
0 commit comments