Skip to content

Commit

Permalink
Version 6.30.
Browse files Browse the repository at this point in the history
  • Loading branch information
riclolsen committed Jul 8, 2023
1 parent e96a164 commit 2ebd879
Show file tree
Hide file tree
Showing 15 changed files with 254 additions and 218 deletions.
53 changes: 29 additions & 24 deletions DNP3/MySOEHandler.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
* This project was forked on 01/01/2013 by Automatak, LLC and modifications
* may have been made to this file. Automatak, LLC licenses these modifications
* to you under the terms of the License.
*
* Modified and integrated into OSHMI by Ricardo Lastra Olsen (2016-2023).
*
*/

#include <iostream>
Expand Down Expand Up @@ -53,6 +56,10 @@ MySOEHandler::MySOEHandler()
saddress.sin_family = AF_INET;
saddress.sin_addr.s_addr = inet_addr("127.0.0.1");
saddress.sin_port = htons((unsigned short)I104M_WRITEUDPPORT);
saddress_red.sin_family = AF_INET;
saddress_red.sin_port = htons((unsigned short)I104M_WRITEUDPPORT);
saddress_red_driver.sin_family = AF_INET;
saddress_red_driver.sin_port = htons((unsigned short)I104M_WRITEUDPPORT);

if (shandle == 0)
Init();
Expand Down Expand Up @@ -158,7 +165,7 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Bin
std::cout << "[" << pair.index << "] : " <<
ValueToString(pair.value) << " : " <<
static_cast<int>(pair.value.flags.value) << " : " <<
pair.value.time << " RTU:" << msg.sec << std::endl;
pair.value.time.value << " RTU:" << msg.sec << std::endl;

count++;
if (!((count + 1) % max_pointspkt)) // se a próxima é do próximo pacote, manda agora
Expand Down Expand Up @@ -191,7 +198,7 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Bin
obj->iq = xlatequalif(pair.value.flags.value);
obj->iq |= pair.value.value ? 1 : 0;

time_t tmi = pair.value.time / 1000;
time_t tmi = pair.value.time.value / 1000;
struct tm *unxtm = localtime( &tmi );
//struct tm *unxtm = gmtime(&tmi);

Expand All @@ -200,12 +207,12 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Bin
obj->dia = unxtm->tm_mday;
obj->hora = unxtm->tm_hour;
obj->min = unxtm->tm_min;
obj->ms = (unsigned short)(unxtm->tm_sec * 1000 + pair.value.time % 1000);
obj->ms = (unsigned short)(unxtm->tm_sec * 1000 + pair.value.time.value % 1000);

std::cout << "[" << pair.index << "] : " <<
ValueToString(pair.value) << " : " <<
static_cast<int>(pair.value.flags.value) << " : " <<
pair.value.time << " RTU:" << msg.sec << std::endl;
pair.value.time.value << " RTU:" << msg.sec << std::endl;

count++;
if (!((count + 1) % max_pointspkt)) // se a próxima é do próximo pacote, manda agora
Expand Down Expand Up @@ -255,10 +262,9 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Dou
obj->iq = xlatequalif(pair.value.flags.value);
obj->iq |= (static_cast<int>(pair.value.value)) & 0x03;

std::cout << "[" << pair.index << "] : " <<
ValueToString(pair.value) << " : " <<
static_cast<int>(pair.value.flags.value) << " : " <<
pair.value.time << " RTU:" << msg.sec << std::endl;
std::cout << "[" << pair.index << "] : " << DoubleBitSpec::to_human_string(pair.value.value) << " : "
<< static_cast<int>(pair.value.flags.value) << " : "
<< pair.value.time.value << " RTU:" << msg.sec << std::endl;

count++;
if (!((count + 1) % max_pointspkt)) // se a próxima é do próximo pacote, manda agora
Expand Down Expand Up @@ -291,7 +297,7 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Dou
obj->iq = xlatequalif(pair.value.flags.value);
obj->iq |= (static_cast<int>(pair.value.value)) & 0x03;

time_t tmi = pair.value.time / 1000;
time_t tmi = pair.value.time.value / 1000;
struct tm *unxtm = localtime(&tmi);
//struct tm *unxtm = gmtime(&tmi);

Expand All @@ -300,12 +306,11 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Dou
obj->dia = unxtm->tm_mday;
obj->hora = unxtm->tm_hour;
obj->min = unxtm->tm_min;
obj->ms = (unsigned short)(unxtm->tm_sec * 1000 + pair.value.time % 1000);
obj->ms = (unsigned short)(unxtm->tm_sec * 1000 + pair.value.time.value % 1000);

std::cout << "[" << pair.index << "] : " <<
ValueToString(pair.value) << " : " <<
static_cast<int>(pair.value.flags.value) << " : " <<
pair.value.time << " RTU:" << msg.sec << std::endl;
std::cout << "[" << pair.index << "] : " << DoubleBitSpec::to_human_string(pair.value.value) << " : "
<< static_cast<int>(pair.value.flags.value) << " : "
<< pair.value.time.value << " RTU:" << msg.sec << std::endl;

count++;
if (!((count + 1) % max_pointspkt)) // se a próxima é do próximo pacote, manda agora
Expand Down Expand Up @@ -390,18 +395,18 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Ana
obj->fr = (float)pair.value.value;
obj->qds = xlatequalif(pair.value.flags.value);

time_t tmi = pair.value.time / 1000;
time_t tmi = pair.value.time.value / 1000;
struct tm* unxtm = localtime(&tmi);

obj->ano = unxtm->tm_year % 100;
obj->mes = unxtm->tm_mon + 1;
obj->dia = unxtm->tm_mday;
obj->hora = unxtm->tm_hour;
obj->min = unxtm->tm_min;
obj->ms = (unsigned short)(unxtm->tm_sec * 1000 + pair.value.time % 1000);
obj->ms = (unsigned short)(unxtm->tm_sec * 1000 + pair.value.time.value % 1000);

std::cout << "[" << pair.index << "] : " << pair.value.value << " : "
<< static_cast<int>(pair.value.flags.value) << " : " << pair.value.time << msg.sec << " RTU:" << msg.sec
<< static_cast<int>(pair.value.flags.value) << " : " << pair.value.time.value << msg.sec << " RTU:" << msg.sec
<< std::endl;

count++;
Expand Down Expand Up @@ -453,7 +458,7 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Cou
std::cout << "[" << pair.index << "] : " <<
pair.value.value << " : " <<
static_cast<int>(pair.value.flags.value) << " : " <<
pair.value.time << " RTU:" << msg.sec << std::endl;
pair.value.time.value << " RTU:" << msg.sec << std::endl;

count++;

Expand Down Expand Up @@ -503,7 +508,7 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Fro
std::cout << "[" << pair.index << "] : " <<
pair.value.value << " : " <<
static_cast<int>(pair.value.flags.value) << " : " <<
pair.value.time << " RTU:" << msg.sec << std::endl;
pair.value.time.value << " RTU:" << msg.sec << std::endl;

count++;

Expand Down Expand Up @@ -556,7 +561,7 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Bin
std::cout << "[" << pair.index << "] : " <<
ValueToString(pair.value) << " : " <<
static_cast<int>(pair.value.flags.value) << " : " <<
pair.value.time << " RTU:" << msg.sec << std::endl;
pair.value.time.value << " RTU:" << msg.sec << std::endl;

count++;
if (!((count + 1) % max_pointspkt)) // se a próxima é do próximo pacote, manda agora
Expand Down Expand Up @@ -589,7 +594,7 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Bin
obj->iq = xlatequalif(pair.value.flags.value);
obj->iq |= pair.value.value ? 1 : 0;

time_t tmi = pair.value.time / 1000;
time_t tmi = pair.value.time.value / 1000;
struct tm *unxtm = localtime(&tmi);
//struct tm *unxtm = gmtime(&tmi);

Expand All @@ -598,12 +603,12 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Bin
obj->dia = unxtm->tm_mday;
obj->hora = unxtm->tm_hour;
obj->min = unxtm->tm_min;
obj->ms = (unsigned short)(unxtm->tm_sec * 1000 + pair.value.time % 1000);
obj->ms = (unsigned short)(unxtm->tm_sec * 1000 + pair.value.time.value % 1000);

std::cout << "[" << pair.index << "] : " <<
ValueToString(pair.value) << " : " <<
static_cast<int>(pair.value.flags.value) << " : " <<
pair.value.time << " RTU:" << msg.sec << std::endl;
pair.value.time.value << " RTU:" << msg.sec << std::endl;

count++;
if (!((count + 1) % max_pointspkt)) // se a próxima é do próximo pacote, manda agora
Expand Down Expand Up @@ -653,7 +658,7 @@ void MySOEHandler::Process(const HeaderInfo& info, const ICollection<Indexed<Ana
std::cout << "[" << pair.index << "] : " <<
pair.value.value << " : " <<
static_cast<int>(pair.value.flags.value) << " : " <<
pair.value.time << " RTU:" << msg.sec << std::endl;
pair.value.time.value << " RTU:" << msg.sec << std::endl;

count++;

Expand Down
78 changes: 36 additions & 42 deletions DNP3/MySOEHandler.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
* This project was forked on 01/01/2013 by Automatak, LLC and modifications
* may have been made to this file. Automatak, LLC licenses these modifications
* to you under the terms of the License.
*
* Modified and integrated into OSHMI by Ricardo Lastra Olsen (2016-2023).
*
*/

#ifndef ASIODNP3_MYSOEHANDLER_H
#define ASIODNP3_MYSOEHANDLER_H

Expand Down Expand Up @@ -154,20 +158,30 @@ class MySOEHandler : public ISOEHandler
redundant_hmi = true;
}

void Process(const HeaderInfo& info, const ICollection<Indexed<Binary>>& values) override final;
void Process(const HeaderInfo& info, const ICollection<Indexed<DoubleBitBinary>>& values) override final;
void Process(const HeaderInfo& info, const ICollection<Indexed<Analog>>& values) override final;
void Process(const HeaderInfo& info, const ICollection<Indexed<Counter>>& values) override final;
void Process(const HeaderInfo& info, const ICollection<Indexed<FrozenCounter>>& values) override final;
void Process(const HeaderInfo& info, const ICollection<Indexed<BinaryOutputStatus>>& values) override final;
void Process(const HeaderInfo& info, const ICollection<Indexed<AnalogOutputStatus>>& values) override final;
void Process(const HeaderInfo& info, const ICollection<Indexed<OctetString>>& values) override final;

void Process(const HeaderInfo& info, const ICollection<Indexed<TimeAndInterval>>& values) override final {};
void Process(const HeaderInfo& info, const ICollection<Indexed<BinaryCommandEvent>>& values) override final {};
void Process(const HeaderInfo& info, const ICollection<Indexed<AnalogCommandEvent>>& values) override final {};
void Process(const HeaderInfo& info, const ICollection<Indexed<SecurityStat>>& values) override final {};
void Process(const HeaderInfo& info, const ICollection<DNPTime>& values) override final {};
void Process(const HeaderInfo& info, const ICollection<Indexed<Binary>>& values) override;
void Process(const HeaderInfo& info, const ICollection<Indexed<DoubleBitBinary>>& values) override;
void Process(const HeaderInfo& info, const ICollection<Indexed<Analog>>& values) override;
void Process(const HeaderInfo& info, const ICollection<Indexed<Counter>>& values) override;
void Process(const HeaderInfo& info, const ICollection<Indexed<FrozenCounter>>& values) override;
void Process(const HeaderInfo& info, const ICollection<Indexed<BinaryOutputStatus>>& values) override;
void Process(const HeaderInfo& info, const ICollection<Indexed<AnalogOutputStatus>>& values) override;
void Process(const HeaderInfo& info, const ICollection<Indexed<OctetString>>& values) override;

void Process(const HeaderInfo& info, const ICollection<Indexed<TimeAndInterval>>& values) override {};
void Process(const HeaderInfo& info, const ICollection<Indexed<BinaryCommandEvent>>& values) override{};
void Process(const HeaderInfo& info, const ICollection<Indexed<AnalogCommandEvent>>& values) override{};
// void Process(const HeaderInfo& info, const ICollection<Indexed<SecurityStat>>& values) override;
void Process(const HeaderInfo& info, const ICollection<DNPTime>& values) override {};

void BeginFragment(const ResponseInfo& info) override
{
// std::cout << "Begin receiving measurement data for outstation: " << SlaveAddress << std::endl;
}

void EndFragment(const ResponseInfo& info) override
{
// std::cout << "End receiving measurement data for outstation: " << SlaveAddress << std::endl;
}

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

protected:

void Start() final {}
void End() final {}
virtual void Start() {}
virtual void End() {}

private:

void PrintHeaderInfo(const HeaderInfo& header)
{
std::cout << "Header: " << " Group" << GroupVariationToString(header.gv);
std::cout << QualifierCodeToString(header.qualifier) << " timestamps: " << GetTimeString(header.tsmode) << std::endl;
std::cout << "Header: "
<< " Group" << GroupVariationSpec::to_human_string(header.gv);
std::cout << QualifierCodeSpec::to_human_string(header.qualifier)
<< " isEvent: " << header.isEventVariation
<< " tsQuality: " << TimestampQualitySpec::to_human_string(header.tsquality)
<< std::endl;
}

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

std::string GetTimeString(TimestampMode tsmode)
{
std::ostringstream oss;
switch (tsmode)
{
case(TimestampMode::SYNCHRONIZED) :
return "synchronized";
break;
case(TimestampMode::UNSYNCHRONIZED):
oss << "unsynchronized";
break;
default:
oss << "no timestamp";
break;
}

return oss.str();
}

std::string ValueToString(const DoubleBitBinary& meas)
{
return DoubleBitToString(meas.value);
}

};

}
Expand Down
Empty file modified DNP3/cpp/INIReader.cpp
100755 → 100644
Empty file.
Empty file modified DNP3/cpp/INIReader.h
100755 → 100644
Empty file.
Empty file modified DNP3/ini.c
100755 → 100644
Empty file.
Empty file modified DNP3/ini.h
100755 → 100644
Empty file.
Loading

0 comments on commit 2ebd879

Please sign in to comment.