/// <summary> /// Receives an FsmTimerEvent and adds it to the incoming event queue to be processed by /// the event handler thread of the finite state machine. This method receives the event /// with normal priority. /// </summary> /// <param name="fsmEvent">FsmTimer event to be added to the incoming event queue.</param> public virtual void ReceiveEvent(IFsmEvent fsmEvent) { if (fsmEvent == null) { throw new ArgumentNullException(@"fsmEvent"); } this.ReceiveEvent(fsmEvent, false); }
/// <summary> /// Processes a FsmEvent by calling Execute(currentState) on the FsmEvent. /// </summary> /// <param name="fsmEvent">FsmEvent to be executed.</param> protected virtual void ProcessEvent(IFsmEvent fsmEvent) { if (fsmEvent == null) { throw new ArgumentNullException(@"fsmEvent"); } if (Logger.IsDebugEnabled) { var message = string.Format(CultureInfo.CurrentUICulture, Resources.FiniteStateMachineProcessesAnEventCurrentState_Event_, this.CurrentStateType.FullName, fsmEvent.Message); Logger.Debug(message); } fsmEvent.Execute(this.currentState); }
/// <summary> /// Sends an event to a foreign finite state machine /// </summary> /// <param name="fsmReceiver">FsmStateMachine to receive the event</param> /// <param name="fsmEvent">FsmEvent to be sent</param> public virtual void SendEvent(IFiniteStateMachine fsmReceiver, IFsmEvent fsmEvent) { if (fsmReceiver == null) { throw new ArgumentNullException(@"fsmReceiver"); } if (fsmEvent == null) { throw new ArgumentNullException(@"fsmEvent"); } if (Logger.IsDebugEnabled) { var message = string.Format(CultureInfo.CurrentUICulture, Resources.FiniteStateMachineSendsEvent_To_, fsmEvent.Message, fsmReceiver); Logger.Debug(message); } fsmReceiver.ReceiveEvent(fsmEvent); }
/// <summary> /// Receives an FsmTimerEvent and adds it to the incoming event queue to be processed by /// the event handler thread of the finite state machine. This method receives the event /// with normal or high Priority according the Flag highPriority set to true or false. /// FsmEvents of high priority are inserted at the beginning of the event queue. /// </summary> /// <param name="fsmEvent">FsmTimer event to be added to the incoming event queue.</param> /// <param name="highPriority">True if FsmEvent has to be handled with high priority. False if it has to be handled with normal priority.</param> public virtual void ReceiveEvent(IFsmEvent fsmEvent, bool highPriority) { if (fsmEvent == null) { throw new ArgumentNullException(@"fsmEvent"); } if (Logger.IsDebugEnabled) { var message = string.Format(CultureInfo.CurrentUICulture, Resources.FiniteStateMachineReceivesEvent_, fsmEvent.Message); Logger.Debug(message); } if (fsmEvent == null) { throw new ArgumentNullException(@"fsmEvent"); } this.eventQueue.PutEvent(fsmEvent, highPriority); }
/// <summary> /// Adds an FsmEvent to the event queue. This method adds the event /// with normal or high Priority according the Flag highPriority set to true or false. /// FsmEvents of high priority are inserted at the beginning of the event queue. /// </summary> /// <param name="fsmEvent">FsmTimer event to be added to the event queue.</param> /// <param name="highPriority">True if FsmEvent has to be added with high priority. False if it has to be added with normal priority.</param> public void PutEvent(IFsmEvent fsmEvent, bool highPriority) { lock (this.eventListLowPriority) { if (!this.shutdown) { if (highPriority) { this.eventListHighPriority.AddLast(fsmEvent); } else { this.eventListLowPriority.AddLast(fsmEvent); } this.queueEvent.Set(); // a new event is in the queue } else { this.queueEvent.Set(); // let the other waiting threads run ... } } }
/// <summary> /// Adds an FsmEvent to the event queue. This method adds the event /// with normal priority. /// </summary> /// <param name="fsmEvent">FsmTimer event to be added to the event queue.</param> public void PutEvent(IFsmEvent fsmEvent) { this.PutEvent(fsmEvent, false); }
/// <summary> /// Initializes a new instance of the <see cref="EventHandlingFailedEventArgs"/> class. /// </summary> /// <param name="currentState">State of the current.</param> /// <param name="fsmEvent">The FSM event.</param> /// <param name="occurredException">The occurred exception.</param> public EventHandlingFailedEventArgs(IFsmState currentState, IFsmEvent fsmEvent, Exception occurredException) { this.currentState = currentState; this.fsmEvent = fsmEvent; this.occurredException = occurredException; }