Important Update:

- FunctionCore:
  - Bug Fix: Change Channel OutState before triggering event
- TimingCore:
  - Add method SecondsPassed() (provides seconds instead of milli-seconds)
This commit is contained in:
Charl Wentzel
2019-06-23 20:51:51 +02:00
parent 9f8f69de3f
commit 14af8390ec
2 changed files with 14 additions and 6 deletions

View File

@@ -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;
}
//---------------------------------------------------------------------------

View File

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