Important Update:

- FunctionCore:
  - Add OldState to ChannelStateEvent()
  - Add new method ChannelOutState()
  - Update Logging levels
- SelectableCore:
  - Restart LastAction timer of Name Resolve fail (cause delayed re-open)
- Watchdog:
  - Move JSON PingInterval param to "Config" object
This commit is contained in:
Charl Wentzel
2019-06-10 17:25:31 +02:00
parent 7787da5119
commit 253eb91824
4 changed files with 35 additions and 8 deletions

View File

@@ -202,6 +202,7 @@ TChannel * CFunctionCore::AddChannel( const char * ChannelName, const EChannelSt
bool CFunctionCore::SetChannelState( TChannel * Channel, const EChannelState State )
{
EChannelState OldState = Channel->State;
TChannelLink * LinkChannel;
// Validate
@@ -210,13 +211,13 @@ bool CFunctionCore::SetChannelState( TChannel * Channel, const EChannelState Sta
// Update state
Channel->State = State;
if (Log) Log->Message( LogLevel, dlLow, "%s/%s: Update Channel '%s' - State:%s",
if (Log) Log->Message( LogLevel, dlMedium, "%s/%s: Update Channel '%s' - State:%s",
ProcessName, Name, Channel->Name, ChannelStateName[State] );
// Update linked channels
LinkChannel = Channel->FirstLink;
while (LinkChannel) {
LinkChannel->Function->ChannelStateEvent( LinkChannel->Channel, Channel->Ref, State );
LinkChannel->Function->ChannelStateEvent( LinkChannel->Channel, Channel->Ref, OldState, State );
LinkChannel = LinkChannel->Next;
}
@@ -224,7 +225,7 @@ bool CFunctionCore::SetChannelState( TChannel * Channel, const EChannelState Sta
}
//---------------------------------------------------------------------------
bool CFunctionCore::ChannelStateEvent( TChannel * Channel, const char * SourceRef, const EChannelState State )
bool CFunctionCore::ChannelStateEvent( TChannel * Channel, const char * SourceRef, const EChannelState OldState, const EChannelState NewState )
{
TChannelLink * LinkChannel;
@@ -233,13 +234,35 @@ bool CFunctionCore::ChannelStateEvent( TChannel * Channel, const char * SourceRe
if (!(LinkChannel = GetLinkChannel( Channel, SourceRef )))
return false;
if (Log) Log->Message( LogLevel, dlLow, "%s/%s: Update Link Channel '%s'-->'%s' - State:%s",
ProcessName, Name, Channel->Name, LinkChannel->Channel->Ref, ChannelStateName[State] );
if (Log) Log->Message( LogLevel, dlMedium, "%s/%s: Update Link Channel '%s'-->'%s' - State:%s",
ProcessName, Name, Channel->Name, LinkChannel->Channel->Ref, ChannelStateName[NewState] );
return true;
}
//---------------------------------------------------------------------------
EChannelState CFunctionCore::ChannelOutState( TChannel * Channel, const char * TargetRef )
{
TChannelLink * LinkChannel = NULL;
EChannelState State = CH_off;
// Validate
if (!Channel)
return State;
// Check if any linked channels are ready
LinkChannel = Channel->FirstLink;
while (LinkChannel) {
if (!TargetRef || !*TargetRef || !strcasecmp( TargetRef, LinkChannel->Channel->Ref )) {
if (LinkChannel->Channel->State > State)
State = LinkChannel->Channel->State;
}
LinkChannel = LinkChannel->Next;
}
return State;
}
//---------------------------------------------------------------------------
// Automated Data Input/Output
bool CFunctionCore::LinkChannel( const char * ChannelName, const char * LinkFunctionName, const char * LinkChannelName, bool Input, bool Output )
{