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:
@@ -202,6 +202,7 @@ TChannel * CFunctionCore::AddChannel( const char * ChannelName, const EChannelSt
|
|||||||
|
|
||||||
bool CFunctionCore::SetChannelState( TChannel * Channel, const EChannelState State )
|
bool CFunctionCore::SetChannelState( TChannel * Channel, const EChannelState State )
|
||||||
{
|
{
|
||||||
|
EChannelState OldState = Channel->State;
|
||||||
TChannelLink * LinkChannel;
|
TChannelLink * LinkChannel;
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
@@ -210,13 +211,13 @@ bool CFunctionCore::SetChannelState( TChannel * Channel, const EChannelState Sta
|
|||||||
|
|
||||||
// Update state
|
// Update state
|
||||||
Channel->State = 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] );
|
ProcessName, Name, Channel->Name, ChannelStateName[State] );
|
||||||
|
|
||||||
// Update linked channels
|
// Update linked channels
|
||||||
LinkChannel = Channel->FirstLink;
|
LinkChannel = Channel->FirstLink;
|
||||||
while (LinkChannel) {
|
while (LinkChannel) {
|
||||||
LinkChannel->Function->ChannelStateEvent( LinkChannel->Channel, Channel->Ref, State );
|
LinkChannel->Function->ChannelStateEvent( LinkChannel->Channel, Channel->Ref, OldState, State );
|
||||||
LinkChannel = LinkChannel->Next;
|
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;
|
TChannelLink * LinkChannel;
|
||||||
|
|
||||||
@@ -233,13 +234,35 @@ bool CFunctionCore::ChannelStateEvent( TChannel * Channel, const char * SourceRe
|
|||||||
if (!(LinkChannel = GetLinkChannel( Channel, SourceRef )))
|
if (!(LinkChannel = GetLinkChannel( Channel, SourceRef )))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (Log) Log->Message( LogLevel, dlLow, "%s/%s: Update Link Channel '%s'-->'%s' - State:%s",
|
if (Log) Log->Message( LogLevel, dlMedium, "%s/%s: Update Link Channel '%s'-->'%s' - State:%s",
|
||||||
ProcessName, Name, Channel->Name, LinkChannel->Channel->Ref, ChannelStateName[State] );
|
ProcessName, Name, Channel->Name, LinkChannel->Channel->Ref, ChannelStateName[NewState] );
|
||||||
|
|
||||||
return true;
|
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
|
// Automated Data Input/Output
|
||||||
bool CFunctionCore::LinkChannel( const char * ChannelName, const char * LinkFunctionName, const char * LinkChannelName, bool Input, bool Output )
|
bool CFunctionCore::LinkChannel( const char * ChannelName, const char * LinkFunctionName, const char * LinkChannelName, bool Input, bool Output )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -121,7 +121,8 @@ public:
|
|||||||
virtual TChannel * AddChannel( const char * ChannelName, const EChannelState State );
|
virtual TChannel * AddChannel( const char * ChannelName, const EChannelState State );
|
||||||
|
|
||||||
virtual bool SetChannelState( TChannel * Channel, 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
|
// Pushing Data Output -> Input
|
||||||
virtual int Output( const char * ChannelName, const char * TargetRef, const bool SourceRef, const char * Data, int Len = -1 );
|
virtual int Output( const char * ChannelName, const char * TargetRef, const bool SourceRef, const char * Data, int Len = -1 );
|
||||||
|
|||||||
@@ -1060,6 +1060,7 @@ bool CSelectableCore::ResolveAddress( THandle * Handle )
|
|||||||
DestroyResolveReq( Handle, true );
|
DestroyResolveReq( Handle, true );
|
||||||
|
|
||||||
HandleState( Handle, csFailed );
|
HandleState( Handle, csFailed );
|
||||||
|
SetStartTime( &Handle->LastAction ); // Allow delay before retrying resolve
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -1101,6 +1102,7 @@ bool CSelectableCore::HandleResolve( THandle * Handle )
|
|||||||
DestroyResolveReq( Handle, true );
|
DestroyResolveReq( Handle, true );
|
||||||
|
|
||||||
HandleState( Handle, csFailed );
|
HandleState( Handle, csFailed );
|
||||||
|
SetStartTime( &Handle->LastAction ); // Allow delay before retrying resolve
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1120,6 +1122,7 @@ bool CSelectableCore::HandleResolve( THandle * Handle )
|
|||||||
Handle->AddressInfo = NULL;
|
Handle->AddressInfo = NULL;
|
||||||
|
|
||||||
HandleState( Handle, csFailed );
|
HandleState( Handle, csFailed );
|
||||||
|
SetStartTime( &Handle->LastAction ); // Allow delay before retrying resolve
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ bool CWatchdogCore::Init( CDataMember * FunctionConfig )
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Set specific parameters
|
// Set specific parameters
|
||||||
SetInterval( FunctionConfig->GetChInt( "Parameters/PingInterval", 500, true ));
|
SetInterval( Config->GetChInt( "PingInterval", 500, true ));
|
||||||
|
|
||||||
// Create handle and set reference, if not done
|
// Create handle and set reference, if not done
|
||||||
if (!(Ping = GetHandle( "Ping" )))
|
if (!(Ping = GetHandle( "Ping" )))
|
||||||
|
|||||||
Reference in New Issue
Block a user