Example #1
0
 public static string GetStateDesplayName(State State)
 {
     return GetStateDesplayName(State.GetType());
 }
Example #2
0
 public static string GetStateDescription(State State)
 {
     return GetStateDescription(State.GetType());
 }
Example #3
0
 public StateDisplayedDataChangeEventArgs(State CurrentState,string Message)
 {
     this._State = CurrentState;
     this._Message = Message;
 }
Example #4
0
 public StateStatusChangeEventArgs(State CurrentState,State.Statuses StateStatus,string Message)
 {
     this._CurrentState  = CurrentState;
     this._Message = Message;
     this._StateStatus = StateStatus;
 }
Example #5
0
        public void ChangeState(State NewState)
        {
            if (CurrentState !=null)
            {
                //remove event handeling from the recent state.
                CurrentState.StateDisplayedDataChange -=  OnProtocolStateDisplayedDataChange;
                CurrentState.StateStatusChange -=	OnProtocolStateStatusChange;
            }

            if(!this.ShouldStop)
            {
                //do not move to the next state if paused.
                if (ShouldPause && !ShouldStop)
                {
                    SetCurrentStatus( Statuses.Paused,"Paused between states");
                    while (ShouldPause && !ShouldStop)
                    {
                        Thread.Sleep(StateSamplelingRate);
                    }

                }
                if(!this.ShouldStop)
                {

                    SetCurrentStatus( Statuses.Started,"Started");
                    CurrentState = NewState;
                    CurrentState.StateDisplayedDataChange += OnProtocolStateDisplayedDataChange;
                    CurrentState.StateStatusChange +=	OnProtocolStateStatusChange;
                    CurrentState.Start();

                    while (!this.ShouldStop && CurrentState is IRestartableState && CurrentState.CurrentStatus == State.Statuses.FatalError)
                    {//test if restartblr after failier and maintain a pause like state if failed

                        SetCurrentStatus( Statuses.Paused,"Paused after FatalError");
                        while (ShouldPause && !ShouldStop)
                        {
                            Thread.Sleep(StateSamplelingRate);
                        }

                        if (!ShouldStop)
                        {
                            SetCurrentStatus( Statuses.Started,"resumed after FatalError");
                            IRestartableState RestartableCurrentState = CurrentState as IRestartableState;
                            RestartableCurrentState.Restart();
                        }
                    }

                }

            }
        }