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 )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user