Skip to content

Commit

Permalink
Fixed bug in EventTypeFromString, picked up by new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
neilstephens committed Aug 8, 2024
1 parent 62d4da1 commit 698cc93
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 5 additions & 5 deletions Code/tests/DNP3Port_tests/TestDNP3EventHandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ std::pair<std::shared_ptr<DataPort>,std::shared_ptr<DataPort>> MakePorts(const m
for(size_t idx = 0; idx < num_indexes; ++idx)
{
Json::Value point = Json::objectValue;
point["Index"] = idx;
point["Index"] = Json::UInt(idx);
conf[PointType].append(point);
}
}
Expand All @@ -65,10 +65,10 @@ std::pair<std::shared_ptr<DataPort>,std::shared_ptr<DataPort>> MakePorts(const m
conf["UnsolClass2"] = true;
conf["UnsolClass3"] = true;
conf["DoUnsolOnStartup"] = true;
conf["IntegrityScanRatems"] = 0;
conf["EventClass1ScanRatems"] = 0;
conf["EventClass2ScanRatems"] = 0;
conf["EventClass3ScanRatems"] = 0;
conf["IntegrityScanRatems"] = Json::UInt(0);
conf["EventClass1ScanRatems"] = Json::UInt(0);
conf["EventClass2ScanRatems"] = Json::UInt(0);
conf["EventClass3ScanRatems"] = Json::UInt(0);


//make an outstation port
Expand Down
5 changes: 4 additions & 1 deletion include/opendatacon/IOTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,10 @@ inline EventType EventTypeFromString(const std::string StrEventType)
do
{
EventTypeResult = EventTypeResult+1;
if (StrEventType.find(ToString(EventTypeResult)) != std::string::npos)
auto FindStr = ToString(EventTypeResult);
if(FindStr.length() > StrEventType.length())
continue;
if (StrEventType.find(FindStr, StrEventType.length()-FindStr.length()) != std::string::npos)
break;
} while (EventTypeResult != EventType::AfterRange);
return EventTypeResult;
Expand Down

0 comments on commit 698cc93

Please sign in to comment.