Skip to content

Commit

Permalink
Set IntegrityScanNeeded on comms down, not up.
Browse files Browse the repository at this point in the history
SetCommsGood() isn't sync'd with link status, so can't rely on it to happen before first IIN processing
  • Loading branch information
neilstephens committed Nov 30, 2024
1 parent 372e8a1 commit 7af7a59
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions Code/Ports/DNP3Port/DNP3MasterPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,6 @@ void DNP3MasterPort::RePublishEvents()
void DNP3MasterPort::SetCommsGood()
{
UpdateCommsPoint(false);

auto pConf = static_cast<DNP3PortConf*>(this->pConf.get());
if(pConf->pPointConf->SetQualityOnLinkStatus)
{
// Trigger integrity scan to get point quality
// Only way to get true state upstream
// Can't just reset quality, because it would make new events for old values
pChanH->Post([this]()
{
if(!IntegrityScanDone && pChanH->GetLinkDeadness() == LinkDeadness::LinkUpChannelUp)
{
if(auto log = odc::spdlog_get("DNP3Port"))
log->debug("{}: Setting IntegrityScanNeeded for SetQualityOnLinkStatus.",Name);
IntegrityScanNeeded = true;
}
});
}
}

void DNP3MasterPort::SetCommsFailed()
Expand All @@ -218,6 +201,16 @@ void DNP3MasterPort::SetCommsFailed()
SetCommsFailedQuality<EventType::Analog, EventType::AnalogQuality>(pConf->pPointConf->AnalogIndexes);
SetCommsFailedQuality<EventType::AnalogOutputStatus, EventType::AnalogOutputStatusQuality>(pConf->pPointConf->AnalogOutputStatusIndexes);
SetCommsFailedQuality<EventType::BinaryOutputStatus, EventType::BinaryOutputStatusQuality>(pConf->pPointConf->BinaryOutputStatusIndexes);

// An integrity scan will be needed when/if the link comes back
// It's the only way to get the true state upstream
// Can't just reset quality, because it would make new events for old values
pChanH->Post([this]()
{
if(auto log = odc::spdlog_get("DNP3Port"))
log->debug("{}: Setting IntegrityScanNeeded for SetQualityOnLinkStatus.",Name);
IntegrityScanNeeded = true;
});
}
}

Expand Down

0 comments on commit 7af7a59

Please sign in to comment.