Skip to content

Commit

Permalink
- spontaneously transmit additional COTs (background-scan, remote-inf…
Browse files Browse the repository at this point in the history
…o-remote, remote-info-local)

Signed-off-by: Michael Zillgith <[email protected]>
  • Loading branch information
mzillgith committed Nov 4, 2022
1 parent 7e05db0 commit 6ea6749
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/iec104.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,10 @@ IEC104Server::send(const vector<Reading*>& readings)
// update internal value
m_updateDataPoint(dp, (IEC60870_5_TypeID)type, value, ts, qd);

if (cot == CS101_COT_PERIODIC || cot == CS101_COT_SPONTANEOUS) {
if (cot == CS101_COT_PERIODIC || cot == CS101_COT_SPONTANEOUS ||
cot == CS101_COT_RETURN_INFO_REMOTE || cot == CS101_COT_RETURN_INFO_LOCAL ||
cot == CS101_COT_BACKGROUND_SCAN)
{
m_enqueueSpontDatapoint(dp, cot, (IEC60870_5_TypeID)type);
}
}
Expand Down
37 changes: 37 additions & 0 deletions tests/test_sendSpontData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,3 +977,40 @@ TEST_F(SendSpontDataTest, CreateReading_M_ME_TF_1)

delete dataobjects;
}

TEST_F(SendSpontDataTest, CreateReading_differentSpontaneousCOTs)
{
iec104Server->setJsonConfig(protocol_stack, exchanged_data, tls);

CS104_Connection_setASDUReceivedHandler(connection, test1_ASDUReceivedHandler, this);

bool result = CS104_Connection_connect(connection);
ASSERT_TRUE(result);

CS104_Connection_sendStartDT(connection);

auto* dataobjects = new vector<Datapoint*>;

dataobjects->push_back(createDataObject("M_ME_NA_1", 45, 984, CS101_COT_SPONTANEOUS, (float)0.1f, false, false, false, false, false, NULL));
dataobjects->push_back(createDataObject("M_ME_NA_1", 45, 984, CS101_COT_BACKGROUND_SCAN, (float)1.0f, false, false, true, false, false, NULL));
dataobjects->push_back(createDataObject("M_ME_NA_1", 45, 984, CS101_COT_PERIODIC, (float)1.0f, false, false, true, false, false, NULL));
dataobjects->push_back(createDataObject("M_ME_NA_1", 45, 984, CS101_COT_RETURN_INFO_LOCAL, (float)1.0f, false, false, true, false, false, NULL));
dataobjects->push_back(createDataObject("M_ME_NA_1", 45, 984, CS101_COT_RETURN_INFO_REMOTE, (float)1.0f, false, false, true, false, false, NULL));
dataobjects->push_back(createDataObject("M_ME_NA_1", 45, 984, CS101_COT_INTERROGATED_BY_STATION, (float)1.0f, false, false, true, false, false, NULL));

Reading* reading = new Reading(std::string("TM1"), *dataobjects);

vector<Reading*> readings;

readings.push_back(reading);

iec104Server->send(readings);

Thread_sleep(500);

ASSERT_EQ(5, receivedAsdu.size());

delete reading;

delete dataobjects;
}

0 comments on commit 6ea6749

Please sign in to comment.