Пример #1
0
        /// <see cref="ISMState.AddInternalTrigger"/>
        public void AddInternalTrigger(ISMState targetState, StateMachineController.TransitionHandler handler, SMOperator stateOperator)
        {
            if (this.stateMachine.Commissioned)
            {
                throw new SMException("Unable to add trigger to a commissioned state machine");
            }
            if (targetState == null)
            {
                throw new ArgumentNullException("targetState");
            }
            if (stateOperator == null)
            {
                throw new ArgumentNullException("stateOperator");
            }

            SMState target = this.stateMachine.GetState(targetState.Name);

            if (target != null)
            {
                SMInternalTrigger intTrigger = new SMInternalTrigger(this, target, handler, stateOperator);
                this.stateMachine.RegisterTrigger(intTrigger);
            }
            else
            {
                throw new SMException("State '" + targetState.Name + "' doesn't exist!");
            }
        }
Пример #2
0
        /// <see cref="ISMState.AddInternalTrigger"/>
        public void AddInternalTrigger(ISMState targetState, StateMachineController.TransitionHandler handler, RCSet <ISMState> neededStates)
        {
            if (this.stateMachine.Commissioned)
            {
                throw new SMException("Unable to add trigger to a commissioned state machine");
            }
            if (targetState == null)
            {
                throw new ArgumentNullException("targetState");
            }
            if (neededStates == null || neededStates.Count == 0)
            {
                throw new ArgumentNullException("neededStates");
            }

            SMState target = this.stateMachine.GetState(targetState.Name);

            if (target != null)
            {
                ISMState[] neededStatesArray = new ISMState[neededStates.Count];
                int        i = 0;
                foreach (ISMState st in neededStates)
                {
                    neededStatesArray[i] = st;
                    i++;
                }
                //RCSet<SMState> neededStateObjects = new RCSet<SMState>();
                //foreach (ISMState s in neededStates)
                //{
                //    SMState sObj = this.stateMachine.StateObjectMap.GetStateObject(s);
                //    if (null != sObj)
                //    {
                //        neededStateObjects.Add(sObj);
                //    }
                //    else { throw new SMException("State '" + s.Name + "' was not found in the object map!"); }
                //}
                SMInternalTrigger intTrigger =
                    new SMInternalTrigger(this, target, handler, new SMOperator(SMOperatorType.AND, neededStatesArray));
                this.stateMachine.RegisterTrigger(intTrigger);
            }
            else
            {
                throw new SMException("State '" + targetState.Name + "' doesn't exist!");
            }
        }