예제 #1
0
        /// <summary>
        /// Performs common construction behaviors.
        /// </summary>
        /// <param name="thread">The state machine's thread.</param>
        private void construct(NSFEventThread thread)
        {
            ConsecutiveLoopDetectionEnabled = true;
            ConsecutiveLoopLimit            = 1000;
            EventLimitDetectionEnabled      = true;
            EventLimit        = 100;
            EventThread       = thread;
            QueuedEvents      = 0;
            LoggingEnabled    = true;
            RunStatus         = NSFEventHandlerRunStatus.EventHandlerStopped;
            TerminationStatus = NSFEventHandlerTerminationStatus.EventHandlerReady;

            resetEvent           = new NSFEvent("Reset", this);
            runToCompletionEvent = new NSFEvent("RunToCompletion", this);
            startEvent           = new NSFEvent("Start", this);
            stopEvent            = new NSFEvent("Stop", this);
            terminateEvent       = new NSFEvent("Terminate", this);

            StateChangeActions.setExceptionAction(handleStateChangeActionException);

            if (isTopStateMachine())
            {
                EventThread.addEventHandler(this);
            }
        }
        /// <summary>
        /// Creates an event handler
        /// </summary>
        /// <param name="name">The user defined name for the state machine.</param>
        /// <param name="thread">The thread on which events for the state machine are queued.</param>
        public NSFEventHandler(NSFString name, NSFEventThread thread)
            : base(name)
        {
            EventThread       = thread;
            LoggingEnabled    = true;
            RunStatus         = NSFEventHandlerRunStatus.EventHandlerStopped;
            TerminationStatus = NSFEventHandlerTerminationStatus.EventHandlerReady;
            startEvent        = new NSFEvent("Start", this);
            stopEvent         = new NSFEvent("Stop", this);
            terminateEvent    = new NSFEvent("Terminate", this);

            EventThread.addEventHandler(this);
        }
예제 #3
0
        /// <summary>
        /// Creates a scheduled action.
        /// </summary>
        /// <param name="name">The name of the scheduled action.</param>
        /// <param name="action">The action to execute.</param>
        /// <param name="eventThread">The thread on which the action will execute.</param>
        /// <remarks>
        /// Use null or String.Empty for the name if no name is desired.
        /// The action will be logged in the trace if the name is anything other than null or String.Empty.
        /// </remarks>
        public NSFScheduledAction(NSFString name, NSFVoidAction <NSFContext> action, NSFEventThread eventThread)
            : base(name)
        {
            Actions += action;
            Actions.setExceptionAction(handleActionException);

            eventHandler        = new NSFEventHandler(Name, eventThread);
            executeActionsEvent = new NSFEvent(Name, this, eventHandler);

            eventHandler.LoggingEnabled = false;
            eventHandler.addEventReaction(executeActionsEvent, executeActions);

            eventHandler.startEventHandler();
        }
 /// <summary>
 /// Creates a state machine
 /// </summary>
 /// <param name="name">The user defined name for the state machine.</param>
 /// <param name="thread">The thread on which events for the state machine are queued.</param>
 public NSFStateMachine(NSFString name, NSFEventThread thread)
     : base(name, (NSFRegion)null, null, null)
 {
     construct(thread);
 }
        /// <summary>
        /// Performs common construction behaviors.
        /// </summary>
        /// <param name="thread">The state machine's thread.</param>
        private void construct(NSFEventThread thread)
        {
            ConsecutiveLoopDetectionEnabled = true;
            ConsecutiveLoopLimit = 1000;
            EventLimitDetectionEnabled = true;
            EventLimit = 100;
            EventThread = thread;
            QueuedEvents = 0;
            LoggingEnabled = true;
            RunStatus = NSFEventHandlerRunStatus.EventHandlerStopped;
            TerminationStatus = NSFEventHandlerTerminationStatus.EventHandlerReady;

            resetEvent = new NSFEvent("Reset", this);
            runToCompletionEvent = new NSFEvent("RunToCompletion", this);
            startEvent = new NSFEvent("Start", this);
            stopEvent = new NSFEvent("Stop", this);
            terminateEvent = new NSFEvent("Terminate", this);

            StateChangeActions.setExceptionAction(handleStateChangeActionException);

            if (isTopStateMachine())
            {
                EventThread.addEventHandler(this);
            }
        }
        /// <summary>
        /// Creates an event handler
        /// </summary>
        /// <param name="name">The user defined name for the state machine.</param>
        /// <param name="thread">The thread on which events for the state machine are queued.</param>
        public NSFEventHandler(NSFString name, NSFEventThread thread)
            : base(name)
        {
            EventThread = thread;
            LoggingEnabled = true;
            RunStatus = NSFEventHandlerRunStatus.EventHandlerStopped;
            TerminationStatus = NSFEventHandlerTerminationStatus.EventHandlerReady;
            startEvent = new NSFEvent("Start", this);
            stopEvent = new NSFEvent("Stop", this);
            terminateEvent = new NSFEvent("Terminate", this);

            EventThread.addEventHandler(this);
        }
예제 #7
0
 /// <summary>
 /// Creates a state machine
 /// </summary>
 /// <param name="name">The user defined name for the state machine.</param>
 /// <param name="thread">The thread on which events for the state machine are queued.</param>
 public NSFStateMachine(NSFString name, NSFEventThread thread)
     : base(name, (NSFRegion)null, null, null)
 {
     construct(thread);
 }