1717 * This project was forked on 01/01/2013 by Automatak, LLC and modifications
1818 * may have been made to this file. Automatak, LLC licenses these modifications
1919 * to you under the terms of the License.
20+ *
21+ * Modified and integrated into OSHMI by Ricardo Lastra Olsen (2016-2023).
22+ *
2023 */
2124
2225#include < iostream>
@@ -53,6 +56,10 @@ MySOEHandler::MySOEHandler()
5356 saddress.sin_family = AF_INET;
5457 saddress.sin_addr .s_addr = inet_addr (" 127.0.0.1" );
5558 saddress.sin_port = htons ((unsigned short )I104M_WRITEUDPPORT);
59+ saddress_red.sin_family = AF_INET;
60+ saddress_red.sin_port = htons ((unsigned short )I104M_WRITEUDPPORT);
61+ saddress_red_driver.sin_family = AF_INET;
62+ saddress_red_driver.sin_port = htons ((unsigned short )I104M_WRITEUDPPORT);
5663
5764 if (shandle == 0 )
5865 Init ();
@@ -158,7 +165,7 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Bin
158165 std::cout << " [" << pair.index << " ] : " <<
159166 ValueToString (pair.value ) << " : " <<
160167 static_cast <int >(pair.value .flags .value ) << " : " <<
161- pair.value .time << " RTU:" << msg.sec << std::endl;
168+ pair.value .time . value << " RTU:" << msg.sec << std::endl;
162169
163170 count++;
164171 if (!((count + 1 ) % max_pointspkt)) // se a próxima é do próximo pacote, manda agora
@@ -191,7 +198,7 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Bin
191198 obj->iq = xlatequalif (pair.value .flags .value );
192199 obj->iq |= pair.value .value ? 1 : 0 ;
193200
194- time_t tmi = pair.value .time / 1000 ;
201+ time_t tmi = pair.value .time . value / 1000 ;
195202 struct tm *unxtm = localtime ( &tmi );
196203 // struct tm *unxtm = gmtime(&tmi);
197204
@@ -200,12 +207,12 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Bin
200207 obj->dia = unxtm->tm_mday ;
201208 obj->hora = unxtm->tm_hour ;
202209 obj->min = unxtm->tm_min ;
203- obj->ms = (unsigned short )(unxtm->tm_sec * 1000 + pair.value .time % 1000 );
210+ obj->ms = (unsigned short )(unxtm->tm_sec * 1000 + pair.value .time . value % 1000 );
204211
205212 std::cout << " [" << pair.index << " ] : " <<
206213 ValueToString (pair.value ) << " : " <<
207214 static_cast <int >(pair.value .flags .value ) << " : " <<
208- pair.value .time << " RTU:" << msg.sec << std::endl;
215+ pair.value .time . value << " RTU:" << msg.sec << std::endl;
209216
210217 count++;
211218 if (!((count + 1 ) % max_pointspkt)) // se a próxima é do próximo pacote, manda agora
@@ -255,10 +262,9 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Dou
255262 obj->iq = xlatequalif (pair.value .flags .value );
256263 obj->iq |= (static_cast <int >(pair.value .value )) & 0x03 ;
257264
258- std::cout << " [" << pair.index << " ] : " <<
259- ValueToString (pair.value ) << " : " <<
260- static_cast <int >(pair.value .flags .value ) << " : " <<
261- pair.value .time << " RTU:" << msg.sec << std::endl;
265+ std::cout << " [" << pair.index << " ] : " << DoubleBitSpec::to_human_string (pair.value .value ) << " : "
266+ << static_cast <int >(pair.value .flags .value ) << " : "
267+ << pair.value .time .value << " RTU:" << msg.sec << std::endl;
262268
263269 count++;
264270 if (!((count + 1 ) % max_pointspkt)) // se a próxima é do próximo pacote, manda agora
@@ -291,7 +297,7 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Dou
291297 obj->iq = xlatequalif (pair.value .flags .value );
292298 obj->iq |= (static_cast <int >(pair.value .value )) & 0x03 ;
293299
294- time_t tmi = pair.value .time / 1000 ;
300+ time_t tmi = pair.value .time . value / 1000 ;
295301 struct tm *unxtm = localtime (&tmi);
296302 // struct tm *unxtm = gmtime(&tmi);
297303
@@ -300,12 +306,11 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Dou
300306 obj->dia = unxtm->tm_mday ;
301307 obj->hora = unxtm->tm_hour ;
302308 obj->min = unxtm->tm_min ;
303- obj->ms = (unsigned short )(unxtm->tm_sec * 1000 + pair.value .time % 1000 );
309+ obj->ms = (unsigned short )(unxtm->tm_sec * 1000 + pair.value .time . value % 1000 );
304310
305- std::cout << " [" << pair.index << " ] : " <<
306- ValueToString (pair.value ) << " : " <<
307- static_cast <int >(pair.value .flags .value ) << " : " <<
308- pair.value .time << " RTU:" << msg.sec << std::endl;
311+ std::cout << " [" << pair.index << " ] : " << DoubleBitSpec::to_human_string (pair.value .value ) << " : "
312+ << static_cast <int >(pair.value .flags .value ) << " : "
313+ << pair.value .time .value << " RTU:" << msg.sec << std::endl;
309314
310315 count++;
311316 if (!((count + 1 ) % max_pointspkt)) // se a próxima é do próximo pacote, manda agora
@@ -390,18 +395,18 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Ana
390395 obj->fr = (float )pair.value .value ;
391396 obj->qds = xlatequalif (pair.value .flags .value );
392397
393- time_t tmi = pair.value .time / 1000 ;
398+ time_t tmi = pair.value .time . value / 1000 ;
394399 struct tm * unxtm = localtime (&tmi);
395400
396401 obj->ano = unxtm->tm_year % 100 ;
397402 obj->mes = unxtm->tm_mon + 1 ;
398403 obj->dia = unxtm->tm_mday ;
399404 obj->hora = unxtm->tm_hour ;
400405 obj->min = unxtm->tm_min ;
401- obj->ms = (unsigned short )(unxtm->tm_sec * 1000 + pair.value .time % 1000 );
406+ obj->ms = (unsigned short )(unxtm->tm_sec * 1000 + pair.value .time . value % 1000 );
402407
403408 std::cout << " [" << pair.index << " ] : " << pair.value .value << " : "
404- << static_cast <int >(pair.value .flags .value ) << " : " << pair.value .time << msg.sec << " RTU:" << msg.sec
409+ << static_cast <int >(pair.value .flags .value ) << " : " << pair.value .time . value << msg.sec << " RTU:" << msg.sec
405410 << std::endl;
406411
407412 count++;
@@ -453,7 +458,7 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Cou
453458 std::cout << " [" << pair.index << " ] : " <<
454459 pair.value .value << " : " <<
455460 static_cast <int >(pair.value .flags .value ) << " : " <<
456- pair.value .time << " RTU:" << msg.sec << std::endl;
461+ pair.value .time . value << " RTU:" << msg.sec << std::endl;
457462
458463 count++;
459464
@@ -503,7 +508,7 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Fro
503508 std::cout << " [" << pair.index << " ] : " <<
504509 pair.value .value << " : " <<
505510 static_cast <int >(pair.value .flags .value ) << " : " <<
506- pair.value .time << " RTU:" << msg.sec << std::endl;
511+ pair.value .time . value << " RTU:" << msg.sec << std::endl;
507512
508513 count++;
509514
@@ -556,7 +561,7 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Bin
556561 std::cout << " [" << pair.index << " ] : " <<
557562 ValueToString (pair.value ) << " : " <<
558563 static_cast <int >(pair.value .flags .value ) << " : " <<
559- pair.value .time << " RTU:" << msg.sec << std::endl;
564+ pair.value .time . value << " RTU:" << msg.sec << std::endl;
560565
561566 count++;
562567 if (!((count + 1 ) % max_pointspkt)) // se a próxima é do próximo pacote, manda agora
@@ -589,7 +594,7 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Bin
589594 obj->iq = xlatequalif (pair.value .flags .value );
590595 obj->iq |= pair.value .value ? 1 : 0 ;
591596
592- time_t tmi = pair.value .time / 1000 ;
597+ time_t tmi = pair.value .time . value / 1000 ;
593598 struct tm *unxtm = localtime (&tmi);
594599 // struct tm *unxtm = gmtime(&tmi);
595600
@@ -598,12 +603,12 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Bin
598603 obj->dia = unxtm->tm_mday ;
599604 obj->hora = unxtm->tm_hour ;
600605 obj->min = unxtm->tm_min ;
601- obj->ms = (unsigned short )(unxtm->tm_sec * 1000 + pair.value .time % 1000 );
606+ obj->ms = (unsigned short )(unxtm->tm_sec * 1000 + pair.value .time . value % 1000 );
602607
603608 std::cout << " [" << pair.index << " ] : " <<
604609 ValueToString (pair.value ) << " : " <<
605610 static_cast <int >(pair.value .flags .value ) << " : " <<
606- pair.value .time << " RTU:" << msg.sec << std::endl;
611+ pair.value .time . value << " RTU:" << msg.sec << std::endl;
607612
608613 count++;
609614 if (!((count + 1 ) % max_pointspkt)) // se a próxima é do próximo pacote, manda agora
@@ -653,7 +658,7 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Ana
653658 std::cout << " [" << pair.index << " ] : " <<
654659 pair.value .value << " : " <<
655660 static_cast <int >(pair.value .flags .value ) << " : " <<
656- pair.value .time << " RTU:" << msg.sec << std::endl;
661+ pair.value .time . value << " RTU:" << msg.sec << std::endl;
657662
658663 count++;
659664
0 commit comments