Skip to content

Commit 2ebd879

Browse files
committed
Version 6.30.
1 parent e96a164 commit 2ebd879

15 files changed

+254
-218
lines changed

DNP3/MySOEHandler.cpp

100755100644
Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
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

DNP3/MySOEHandler.h

100755100644
Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
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
*/
24+
2125
#ifndef ASIODNP3_MYSOEHANDLER_H
2226
#define ASIODNP3_MYSOEHANDLER_H
2327

@@ -154,20 +158,30 @@ class MySOEHandler : public ISOEHandler
154158
redundant_hmi = true;
155159
}
156160

157-
void Process(const HeaderInfo& info, const ICollection<Indexed<Binary>>& values) override final;
158-
void Process(const HeaderInfo& info, const ICollection<Indexed<DoubleBitBinary>>& values) override final;
159-
void Process(const HeaderInfo& info, const ICollection<Indexed<Analog>>& values) override final;
160-
void Process(const HeaderInfo& info, const ICollection<Indexed<Counter>>& values) override final;
161-
void Process(const HeaderInfo& info, const ICollection<Indexed<FrozenCounter>>& values) override final;
162-
void Process(const HeaderInfo& info, const ICollection<Indexed<BinaryOutputStatus>>& values) override final;
163-
void Process(const HeaderInfo& info, const ICollection<Indexed<AnalogOutputStatus>>& values) override final;
164-
void Process(const HeaderInfo& info, const ICollection<Indexed<OctetString>>& values) override final;
165-
166-
void Process(const HeaderInfo& info, const ICollection<Indexed<TimeAndInterval>>& values) override final {};
167-
void Process(const HeaderInfo& info, const ICollection<Indexed<BinaryCommandEvent>>& values) override final {};
168-
void Process(const HeaderInfo& info, const ICollection<Indexed<AnalogCommandEvent>>& values) override final {};
169-
void Process(const HeaderInfo& info, const ICollection<Indexed<SecurityStat>>& values) override final {};
170-
void Process(const HeaderInfo& info, const ICollection<DNPTime>& values) override final {};
161+
void Process(const HeaderInfo& info, const ICollection<Indexed<Binary>>& values) override;
162+
void Process(const HeaderInfo& info, const ICollection<Indexed<DoubleBitBinary>>& values) override;
163+
void Process(const HeaderInfo& info, const ICollection<Indexed<Analog>>& values) override;
164+
void Process(const HeaderInfo& info, const ICollection<Indexed<Counter>>& values) override;
165+
void Process(const HeaderInfo& info, const ICollection<Indexed<FrozenCounter>>& values) override;
166+
void Process(const HeaderInfo& info, const ICollection<Indexed<BinaryOutputStatus>>& values) override;
167+
void Process(const HeaderInfo& info, const ICollection<Indexed<AnalogOutputStatus>>& values) override;
168+
void Process(const HeaderInfo& info, const ICollection<Indexed<OctetString>>& values) override;
169+
170+
void Process(const HeaderInfo& info, const ICollection<Indexed<TimeAndInterval>>& values) override {};
171+
void Process(const HeaderInfo& info, const ICollection<Indexed<BinaryCommandEvent>>& values) override{};
172+
void Process(const HeaderInfo& info, const ICollection<Indexed<AnalogCommandEvent>>& values) override{};
173+
// void Process(const HeaderInfo& info, const ICollection<Indexed<SecurityStat>>& values) override;
174+
void Process(const HeaderInfo& info, const ICollection<DNPTime>& values) override {};
175+
176+
void BeginFragment(const ResponseInfo& info) override
177+
{
178+
// std::cout << "Begin receiving measurement data for outstation: " << SlaveAddress << std::endl;
179+
}
180+
181+
void EndFragment(const ResponseInfo& info) override
182+
{
183+
// std::cout << "End receiving measurement data for outstation: " << SlaveAddress << std::endl;
184+
}
171185

172186
void Init();
173187
unsigned char xlatequalif(int qdnp);
@@ -179,15 +193,19 @@ class MySOEHandler : public ISOEHandler
179193

180194
protected:
181195

182-
void Start() final {}
183-
void End() final {}
196+
virtual void Start() {}
197+
virtual void End() {}
184198

185199
private:
186200

187201
void PrintHeaderInfo(const HeaderInfo& header)
188202
{
189-
std::cout << "Header: " << " Group" << GroupVariationToString(header.gv);
190-
std::cout << QualifierCodeToString(header.qualifier) << " timestamps: " << GetTimeString(header.tsmode) << std::endl;
203+
std::cout << "Header: "
204+
<< " Group" << GroupVariationSpec::to_human_string(header.gv);
205+
std::cout << QualifierCodeSpec::to_human_string(header.qualifier)
206+
<< " isEvent: " << header.isEventVariation
207+
<< " tsQuality: " << TimestampQualitySpec::to_human_string(header.tsquality)
208+
<< std::endl;
191209
}
192210

193211
template <class T>
@@ -198,30 +216,6 @@ class MySOEHandler : public ISOEHandler
198216
return oss.str();
199217
}
200218

201-
std::string GetTimeString(TimestampMode tsmode)
202-
{
203-
std::ostringstream oss;
204-
switch (tsmode)
205-
{
206-
case(TimestampMode::SYNCHRONIZED) :
207-
return "synchronized";
208-
break;
209-
case(TimestampMode::UNSYNCHRONIZED):
210-
oss << "unsynchronized";
211-
break;
212-
default:
213-
oss << "no timestamp";
214-
break;
215-
}
216-
217-
return oss.str();
218-
}
219-
220-
std::string ValueToString(const DoubleBitBinary& meas)
221-
{
222-
return DoubleBitToString(meas.value);
223-
}
224-
225219
};
226220

227221
}

DNP3/cpp/INIReader.cpp

100755100644
File mode changed.

DNP3/cpp/INIReader.h

100755100644
File mode changed.

DNP3/ini.c

100755100644
File mode changed.

DNP3/ini.h

100755100644
File mode changed.

0 commit comments

Comments
 (0)