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 )
{

View File

@@ -121,7 +121,8 @@ public:
virtual TChannel * AddChannel( const char * ChannelName, const EChannelState State );
virtual bool SetChannelState( TChannel * Channel, const EChannelState State );
virtual bool ChannelStateEvent( TChannel * Channel, const char * SourceRef, const EChannelState State );
virtual bool ChannelStateEvent( TChannel * Channel, const char * SourceRef, const EChannelState OldState, const EChannelState NewState );
virtual EChannelState ChannelOutState( TChannel * Channel, const char * TargetRef );
// Pushing Data Output -> Input
virtual int Output( const char * ChannelName, const char * TargetRef, const bool SourceRef, const char * Data, int Len = -1 );

View File

@@ -1060,6 +1060,7 @@ bool CSelectableCore::ResolveAddress( THandle * Handle )
DestroyResolveReq( Handle, true );
HandleState( Handle, csFailed );
SetStartTime( &Handle->LastAction ); // Allow delay before retrying resolve
return false;
}
return false;
@@ -1101,6 +1102,7 @@ bool CSelectableCore::HandleResolve( THandle * Handle )
DestroyResolveReq( Handle, true );
HandleState( Handle, csFailed );
SetStartTime( &Handle->LastAction ); // Allow delay before retrying resolve
return false;
}
@@ -1120,6 +1122,7 @@ bool CSelectableCore::HandleResolve( THandle * Handle )
Handle->AddressInfo = NULL;
HandleState( Handle, csFailed );
SetStartTime( &Handle->LastAction ); // Allow delay before retrying resolve
return false;
}

View File

@@ -63,7 +63,7 @@ bool CWatchdogCore::Init( CDataMember * FunctionConfig )
return false;
// Set specific parameters
SetInterval( FunctionConfig->GetChInt( "Parameters/PingInterval", 500, true ));
SetInterval( Config->GetChInt( "PingInterval", 500, true ));
// Create handle and set reference, if not done
if (!(Ping = GetHandle( "Ping" )))