Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refs #11 Updated conversion of ack validity to pivot. Updated impacte… #12

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/hnz_pivot_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ Datapoint* HNZPivotFilter::convertTCACKToPivot(const std::string& assetName, std
pivot.setIdentifier(exchangeConfig->getPivotId());
pivot.setCause(7);

pivot.addQuality(dataObject.doValid, false, false, false);
pivot.addQuality(false, false, false, false);
pivot.setConfirmation(dataObject.doValid);

appendTimestamp(pivot, false, 0, false, false);

Expand All @@ -377,7 +378,8 @@ Datapoint* HNZPivotFilter::convertTVCACKToPivot(const std::string& assetName, st
pivot.setIdentifier(exchangeConfig->getPivotId());
pivot.setCause(7);

pivot.addQuality(dataObject.doValid, false, false, false);
pivot.addQuality(false, false, false, false);
pivot.setConfirmation(dataObject.doValid);

appendTimestamp(pivot, false, 0, false, false);

Expand Down
109 changes: 107 additions & 2 deletions tests/test_plugin_ingest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ static const std::vector<std::string> allPivotAttributeNames = {
"GTIM.MvTyp.t.SecondSinceEpoch", "GTIM.MvTyp.t.FractionOfSecond", "GTIM.MvTyp.t.TimeQuality.clockNotSynchronized",
// TC/TVC messages
"GTIC.ComingFrom", "GTIC.Identifier", "GTIC.Cause.stVal", "GTIC.TmValidity.stVal", "GTIC.TmOrg.stVal",
"GTIC.Confirmation.stVal",
"GTIC.SpcTyp.stVal", "GTIC.SpcTyp.ctlVal", "GTIC.SpcTyp.q.Validity", "GTIC.SpcTyp.q.DetailQuality.oldData",
"GTIC.SpcTyp.t.SecondSinceEpoch", "GTIC.SpcTyp.t.FractionOfSecond", "GTIC.SpcTyp.t.TimeQuality.clockNotSynchronized",
"GTIC.DpcTyp.stVal", "GTIC.DpcTyp.ctlVal", "GTIC.DpcTyp.q.Validity", "GTIC.DpcTyp.q.DetailQuality.oldData",
Expand Down Expand Up @@ -1275,7 +1276,6 @@ TEST_F(PivotHNZPluginIngest, TCAckToPivot)
"do_type":"TC",
"do_station":12,
"do_addr":142,
"do_value":0,
"do_valid":0
}
});
Expand All @@ -1293,6 +1293,40 @@ TEST_F(PivotHNZPluginIngest, TCAckToPivot)
{"GTIC.Identifier", {"string", "ID222222"}},
{"GTIC.Cause.stVal", {"int64_t", "7"}},
{"GTIC.TmOrg.stVal", {"string", "substituted"}},
{"GTIC.Confirmation.stVal", {"int64_t", "0"}},
{"GTIC.SpcTyp.q.Validity", {"string", "good"}},
// NB: Time was added by hnztopivot plugin
{"GTIC.SpcTyp.t.SecondSinceEpoch", {"int64_t_range", std::to_string(sec) + ";" + std::to_string(sec+1)}},
{"GTIC.SpcTyp.t.FractionOfSecond", {"int64_t_range", "0;99999999"}},
});
if(HasFatalFailure()) return;
}

TEST_F(PivotHNZPluginIngest, TCNAckToPivot)
{
std::string jsonMessageTCAck = QUOTE({
"data_object":{
"do_type":"TC",
"do_station":12,
"do_addr":142,
"do_valid":1
}
});
ReadingSet* readingSet = nullptr;
createReadingSet(readingSet, "TC1", jsonMessageTCAck);
if(HasFatalFailure()) return;
ASSERT_NE(readingSet, nullptr);

auto pivotTimestampPair = PivotTimestamp::fromTimestamp(PivotTimestamp::getCurrentTimestampMs());
long sec = pivotTimestampPair.first;
ASSERT_NO_THROW(plugin_ingest(filter, static_cast<READINGSET*>(readingSet)));
ASSERT_EQ(outputHandlerCalled, 1);
validateReading(lastReading, "TC1", "PIVOT", allPivotAttributeNames, {
{"GTIC.ComingFrom", {"string", "hnzip"}},
{"GTIC.Identifier", {"string", "ID222222"}},
{"GTIC.Cause.stVal", {"int64_t", "7"}},
{"GTIC.TmOrg.stVal", {"string", "substituted"}},
{"GTIC.Confirmation.stVal", {"int64_t", "1"}},
{"GTIC.SpcTyp.q.Validity", {"string", "good"}},
// NB: Time was added by hnztopivot plugin
{"GTIC.SpcTyp.t.SecondSinceEpoch", {"int64_t_range", std::to_string(sec) + ";" + std::to_string(sec+1)}},
Expand All @@ -1308,7 +1342,6 @@ TEST_F(PivotHNZPluginIngest, TCAckToPivotDouble)
"do_type":"TC",
"do_station":12,
"do_addr":143,
"do_value":0,
"do_valid":0
}
});
Expand All @@ -1326,6 +1359,40 @@ TEST_F(PivotHNZPluginIngest, TCAckToPivotDouble)
{"GTIC.Identifier", {"string", "ID333333"}},
{"GTIC.Cause.stVal", {"int64_t", "7"}},
{"GTIC.TmOrg.stVal", {"string", "substituted"}},
{"GTIC.Confirmation.stVal", {"int64_t", "0"}},
{"GTIC.DpcTyp.q.Validity", {"string", "good"}},
// NB: Time was added by hnztopivot plugin
{"GTIC.DpcTyp.t.SecondSinceEpoch", {"int64_t_range", std::to_string(sec) + ";" + std::to_string(sec+1)}},
{"GTIC.DpcTyp.t.FractionOfSecond", {"int64_t_range", "0;99999999"}},
});
if(HasFatalFailure()) return;
}

TEST_F(PivotHNZPluginIngest, TCNAckToPivotDouble)
{
std::string jsonMessageTCAck = QUOTE({
"data_object":{
"do_type":"TC",
"do_station":12,
"do_addr":143,
"do_valid":1
}
});
ReadingSet* readingSet = nullptr;
createReadingSet(readingSet, "TC2", jsonMessageTCAck);
if(HasFatalFailure()) return;
ASSERT_NE(readingSet, nullptr);

auto pivotTimestampPair = PivotTimestamp::fromTimestamp(PivotTimestamp::getCurrentTimestampMs());
long sec = pivotTimestampPair.first;
ASSERT_NO_THROW(plugin_ingest(filter, static_cast<READINGSET*>(readingSet)));
ASSERT_EQ(outputHandlerCalled, 1);
validateReading(lastReading, "TC2", "PIVOT", allPivotAttributeNames, {
{"GTIC.ComingFrom", {"string", "hnzip"}},
{"GTIC.Identifier", {"string", "ID333333"}},
{"GTIC.Cause.stVal", {"int64_t", "7"}},
{"GTIC.TmOrg.stVal", {"string", "substituted"}},
{"GTIC.Confirmation.stVal", {"int64_t", "1"}},
{"GTIC.DpcTyp.q.Validity", {"string", "good"}},
// NB: Time was added by hnztopivot plugin
{"GTIC.DpcTyp.t.SecondSinceEpoch", {"int64_t_range", std::to_string(sec) + ";" + std::to_string(sec+1)}},
Expand Down Expand Up @@ -1359,6 +1426,41 @@ TEST_F(PivotHNZPluginIngest, TVCAckToPivot)
{"GTIC.Identifier", {"string", "ID444444"}},
{"GTIC.Cause.stVal", {"int64_t", "7"}},
{"GTIC.TmOrg.stVal", {"string", "substituted"}},
{"GTIC.Confirmation.stVal", {"int64_t", "0"}},
{"GTIC.IncTyp.q.Validity", {"string", "good"}},
// NB: Time was added by hnztopivot plugin
{"GTIC.IncTyp.t.SecondSinceEpoch", {"int64_t_range", std::to_string(sec) + ";" + std::to_string(sec+1)}},
{"GTIC.IncTyp.t.FractionOfSecond", {"int64_t_range", "0;99999999"}},
});
if(HasFatalFailure()) return;
}

TEST_F(PivotHNZPluginIngest, TVCNAckToPivot)
{
std::string jsonMessageTVCAck = QUOTE({
"data_object":{
"do_type":"TVC",
"do_station":12,
"do_addr":31,
"do_value":0,
"do_valid":1
}
});
ReadingSet* readingSet = nullptr;
createReadingSet(readingSet, "TVC1", jsonMessageTVCAck);
if(HasFatalFailure()) return;
ASSERT_NE(readingSet, nullptr);

auto pivotTimestampPair = PivotTimestamp::fromTimestamp(PivotTimestamp::getCurrentTimestampMs());
long sec = pivotTimestampPair.first;
ASSERT_NO_THROW(plugin_ingest(filter, static_cast<READINGSET*>(readingSet)));
ASSERT_EQ(outputHandlerCalled, 1);
validateReading(lastReading, "TVC1", "PIVOT", allPivotAttributeNames, {
{"GTIC.ComingFrom", {"string", "hnzip"}},
{"GTIC.Identifier", {"string", "ID444444"}},
{"GTIC.Cause.stVal", {"int64_t", "7"}},
{"GTIC.TmOrg.stVal", {"string", "substituted"}},
{"GTIC.Confirmation.stVal", {"int64_t", "1"}},
{"GTIC.IncTyp.q.Validity", {"string", "good"}},
// NB: Time was added by hnztopivot plugin
{"GTIC.IncTyp.t.SecondSinceEpoch", {"int64_t_range", std::to_string(sec) + ";" + std::to_string(sec+1)}},
Expand Down Expand Up @@ -1739,6 +1841,7 @@ TEST_F(PivotHNZPluginIngest, InvalidMessages)
{"GTIC.Identifier", {"string", "ID444444"}},
{"GTIC.Cause.stVal", {"int64_t", "7"}},
{"GTIC.TmOrg.stVal", {"string", "substituted"}},
{"GTIC.Confirmation.stVal", {"int64_t", "0"}},
{"GTIC.IncTyp.q.Validity", {"string", "good"}},
// NB: Time was added by hnztopivot plugin
{"GTIC.IncTyp.t.SecondSinceEpoch", {"int64_t_range", std::to_string(sec) + ";" + std::to_string(sec+1)}},
Expand Down Expand Up @@ -2022,6 +2125,7 @@ TEST_F(PivotHNZPluginIngest, InvalidMessages)
{"GTIC.Identifier", {"string", "ID222222"}},
{"GTIC.Cause.stVal", {"int64_t", "7"}},
{"GTIC.TmOrg.stVal", {"string", "substituted"}},
{"GTIC.Confirmation.stVal", {"int64_t", "0"}},
{"GTIC.SpcTyp.q.Validity", {"string", "good"}},
// NB: Time was added by hnztopivot plugin
{"GTIC.SpcTyp.t.SecondSinceEpoch", {"int64_t_range", std::to_string(sec) + ";" + std::to_string(sec+1)}},
Expand Down Expand Up @@ -2050,6 +2154,7 @@ TEST_F(PivotHNZPluginIngest, InvalidMessages)
{"GTIC.Identifier", {"string", "ID444444"}},
{"GTIC.Cause.stVal", {"int64_t", "7"}},
{"GTIC.TmOrg.stVal", {"string", "substituted"}},
{"GTIC.Confirmation.stVal", {"int64_t", "0"}},
{"GTIC.IncTyp.q.Validity", {"string", "good"}},
// NB: Time was added by hnztopivot plugin
{"GTIC.IncTyp.t.SecondSinceEpoch", {"int64_t_range", std::to_string(sec) + ";" + std::to_string(sec+1)}},
Expand Down
Loading