diff --git a/FunctionCore.cpp b/FunctionCore.cpp index 6b9eac6..d60ab65 100644 --- a/FunctionCore.cpp +++ b/FunctionCore.cpp @@ -219,8 +219,8 @@ bool CFunctionCore::SetChannelInState( TChannel * Channel, const EChannelState S ProcessName, Name, Channel->Ref, LinkChannel->Channel->Ref, ChannelStateName[State] ); // Trigger Linked Channel Events - LinkChannel->Function->ChannelStateEvent( LinkChannel->Channel, Channel->Ref, OldState, State ); LinkChannel->Function->UpdateChannelOutState( LinkChannel->Channel ); + LinkChannel->Function->ChannelStateEvent( LinkChannel->Channel, Channel->Ref, OldState, State ); LinkChannel = LinkChannel->Next; } @@ -323,12 +323,12 @@ bool CFunctionCore::LinkChannel( const char * ChannelName, const char * LinkFunc ProcessName, Name, LinkChannel->Ref, (*LinkedChannel)->Channel->Ref, ((Output)? "Yes" : "No"), ((Input)? "Yes" : "No") ); // Trigger Forward Channel Events - LinkFunction->ChannelStateEvent( LinkChannel, Channel->Ref, CH_off, Channel->InState ); LinkFunction->UpdateChannelOutState( LinkChannel ); + LinkFunction->ChannelStateEvent( LinkChannel, Channel->Ref, CH_off, Channel->InState ); // Trigger Reverse Channel Events - ChannelStateEvent( Channel, LinkChannel->Ref, CH_off, LinkChannel->InState ); UpdateChannelOutState( Channel ); + ChannelStateEvent( Channel, LinkChannel->Ref, CH_off, LinkChannel->InState ); return true; } //--------------------------------------------------------------------------- diff --git a/TimingCore.h b/TimingCore.h index ce97f65..14f8ece 100644 --- a/TimingCore.h +++ b/TimingCore.h @@ -53,6 +53,16 @@ inline long TimePassed( timeval StartTime ) { }; //--------------------------------------------------------------------------- +inline long SecondsPassed( timeval StartTime ) { + timeval CurrTime; + long Duration; + + gettimeofday( &CurrTime, NULL ); + Duration = CurrTime.tv_sec - StartTime.tv_sec; + return Duration; +}; +//--------------------------------------------------------------------------- + // Time remaining from Start time to given time out inline long TimeLeft( timeval StartTime, long MilliSeconds ) { return (MilliSeconds - TimePassed(StartTime)); @@ -69,11 +79,9 @@ inline bool Timeout( timeval StartTime, long MilliSeconds ) { inline long GetUpCounter( timeval StartTime, char * TextStr ) { long Duration; int Days, Hours, Minutes, Seconds; - timeval CurrTime; // Get duration - gettimeofday( &CurrTime, NULL ); - Duration = (!StartTime.tv_sec)? 0 : (CurrTime.tv_sec - StartTime.tv_sec); // Handle zero start + Duration = SecondsPassed( StartTime ); // Create string if (TextStr) {