Ejemplo n.º 1
0
 public override void OnInput(char c)
 {
     switch (state)
     {
         case TState.EStateTransferActive:
             {
                 switch (c)
                 {
                     case '0':
                         {
                             state = TState.GettingDeviceID;
                         }
                         break;
                     case '1':
                         {
                             if (currentInterval > 1)
                             {
                                 --currentInterval;
                                 SendMessageToMyself(Message.KMsgSetParameters);
                             }
                         }
                         break;
                     case '3':
                         {
                             if (currentInterval < 5)
                             {
                                 currentInterval++;
                                 SendMessageToMyself(Message.KMsgSetParameters);
                             }
                         }
                         break;
                     case '\r':
                         {
                             SuspendTransfer();
                             SendMessageToMyself(deviceID, Message.KMsgSuspendTransfer);
                         }
                         break;
                     default:
                         break;
                 }
             }
             break;
         case TState.EStateTransferSuspended:
             {
                 switch (c)
                 {
                     case '\r':
                         {
                             SendMessageToMyself(Message.KMsgResumeTransfer);
                         }
                         break;
                     default:
                         break;
                 }
             }
         // Для других состояний
         default:
             break;
     }
 }
Ejemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     switch (mState)
     {
         case TState.LOADED:
             initTest();
             foreach (TreeNode rn in this.treeView1.Nodes)
             {
                 foreach (TreeNode sn in rn.Nodes)
                 {
                     if (sn.Checked)
                     {
                         TestCase ts = sn.Tag as TestCase;
                         if (ts != null)
                             tm.Cases.Add(ts);
                     }
                 }
             }
             _resetTreeNodeColor();
             this.textBox1.Text = "";
             _onOutPut("**** Test Start ****");
             _onOutPut("  ");
             button1.Text = "Pause";
             mState = TState.TESTING;
             break;
         case TState.PAUSING:
             mState = TState.TESTING;
             button1.Text = "Pause";
             break;
         case TState.TESTING:
             mState = TState.PAUSING;
             button1.Text = "Start";
             break;
     }
 }
Ejemplo n.º 3
0
        public override void MainOverride()
        {
            UseMessageInput(DefaultMailBox);
            UseKbdInput();

            state = TState.EStateGettingDeviceID;

            ProcessIncomingMessages();
        }
 public bool IsIncludeIn(TState state)
 {
     return
         (_state.Equals(state) ||
          (_superstate != null && _superstate.IsIncludeIn(state)));
 }
Ejemplo n.º 5
0
 private LineStateInfo(bool isDirty = false, bool multilineToken = false)
 {
     EndLineState   = default(TState);
     IsDirty        = isDirty;
     MultilineToken = multilineToken;
 }
Ejemplo n.º 6
0
 public LineStateInfo(TState endLineState)
 {
     EndLineState   = endLineState;
     IsDirty        = false;
     MultilineToken = false;
 }
 public override bool ResultsInTransitionFrom(TState source, object[] args, out TState destination)
 {
     destination = default(TState);
     return(false);
 }
Ejemplo n.º 8
0
 public Async(TState state, Func <Task> action, Reflection.InvocationInfo actionDescription)
     : base(state, actionDescription)
 {
     _action = action;
 }
Ejemplo n.º 9
0
 protected ActivateActionBehaviour(TState state, Reflection.InvocationInfo actionDescription)
 {
     _state             = state;
     _actionDescription = actionDescription ?? throw new ArgumentNullException(nameof(actionDescription));
 }
Ejemplo n.º 10
0
 public StateConfiguration(TestMachine <TState, TTrigger, EventArgs> machine, TState state)
 {
     m_machine = machine;
     m_state   = state;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Add an action to be performed along with the state transition.
 /// <para>It is important to consider what to do if the
 /// Action encounters and exception.  Handle the exception within the action if possible, otherwise the exception
 /// is propogated back to the caller that initates the state transition.</para>
 /// <para>The state machine can either remain in the current state by passing it to <paramref name="errorState"/>
 /// otherwise, it might make sense to define a specific error state for the state machine with specific transitions
 /// to recover from the error</para>
 /// </summary>
 /// <param name="action">Action to be performed</param>
 /// <param name="errorState">State to transition to in the event of an exception executing <paramref name="action"/></param>
 public new ConditionalTransitionWithAction WithAction(Action action, TState errorState)
 {
     Action           = action;
     ActionErrorState = errorState;
     return(new ConditionalTransitionWithAction(this));
 }
Ejemplo n.º 12
0
 public override vodi OnSuspend()
 {
     switch (state)
     {
         case TState.EStateTransferActive:
             {
                 state = TState.EStateTransferSuspended;
                 SendMessageToDispatcher(deviceID, Message.KMsgSuspendTransfer);
             }
             break;
         default:
             break;
     }
 }
Ejemplo n.º 13
0
        public override void OnMailBoxMessage(Message msg)
        {
            switch (state)
            {
                case TState.EStateGettingDeviceID:
                    {
                        state = TState.EStateInitTransfer;
                        deviceID = GetDeviceID();
                    }
                    break;

                case TState.EStateSwitchDevice:
                    {
                        state = TState.EStateInitTransfer;
                        SendMessageToDispatcher(deviceID, Message.KMsgSuspendTransfer);
                        deviceID = GetDeviceID();
                    }
                    break;
                case TState.EStateInitTransfer:
                    {
                        ShowInfo(Message.KMsgDevRequest);

                        switch (RequestDevice(deviceID))
                        {
                            case Message.KErrNo:
                                {
                                    if (MainMenu() != NewDevice)
                                    {
                                        state = TState.EStateTransferActive;
                                        SetDeviceParameters();
                                    }
                                    else
                                        state = TState.EStateGettingDeviceID;
                                }
                                break;
                            case Message.KErrDeviceNotRegistered:
                                {
                                    state = TState.EStateGettingDeviceID;
                                    ShowError(Message.KErrDeviceNotRegistered);
                                }
                                break;
                            case Message.KErrDeviceNotReady:
                                {
                                    state = TState.EStateInitTransfer;
                                    ShowError(Message.KErrDeviceNotReady);
                                }
                            default:
                                throw new ArgumentException("Bad message code");
                        }
                    }
                    break;
                case TState.EStateTransferActive:
                    {
                        switch (msg.Command)
                        {
                            case Message.KMsgReceivedData:
                                {
                                    ProcessIncomingData(msg);
                                }
                                break;
                            case Message.KMsgSetParameters:
                                {
                                    SetDeviceParameters();   // ??????
                                }
                                break;
                            case Message.KMsgSuspendTransfer:
                                {
                                    state = TState.EStateTransferSuspended;
                                    ShowInfo(Message.KMsgSuspendTransfer);
                                }
                                break;
                            case Message.KMsgResumeTransfer:
                                {
                                    state = TState.EStateResumeTransfer;
                                }
                                break;
                            case Message.KMsgStopTransfer:
                                {
                                    state = TState.EStateResumeTransfer;
                                    ShowInfo(Message.KMsgStopTransfer);
                                }
                                break;
                            case Message.KMsgError:
                                {
                                    switch (msg.Code)
                                    {
                                        case Message.KErrDeviceNotReady:
                                        case Message.KErrLostConnection:
                                            {
                                                state = TState.EStateResumeTransfer;
                                                ShowError(msg.Code);
                                            }
                                            break;
                                        default:
                                            {
                                                throw new ArgumentException("Bad error code");
                                            }
                                    }
                                }
                                break;
                        }
                    }
                    break;
                case TState.EStateTransferSuspended:
                    {
                        if (msg.Command == Message.KMsgResumeTransfer)
                        {
                            state = TState.EStateResumeTransfer;
                        }
                        else
                            throw new ArgumentException("Bad message code");
                    }
                    break;
                default:
                    throw new ArgumentException("Bad state");
            }
        }
Ejemplo n.º 14
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (mState != TState.NONE)
                return;

            initTest();
            Dictionary<string, List<TestCase>> dic = tm.loadTestCases("./plugins/etest/cases");
            this.treeView1.Nodes.Clear();
            foreach (KeyValuePair<string, List<TestCase>> kvp in dic)
            {
                TreeNode root_node = new TreeNode();
                root_node.Checked = true;
                root_node.Text = kvp.Key;
                root_node.Tag = "root_node";

                foreach (TestCase tcase in kvp.Value)
                {
                    TreeNode node = new TreeNode();
                    node.Checked = true;
                    node.Text = tcase.name();
                    node.Tag = tcase;
                    if (ot_name.Length != 0 && node.Text != ot_name)
                        continue;
                    root_node.Nodes.Add(node);
                }

                if (root_node.Nodes.Count != 0)
                    this.treeView1.Nodes.Add(root_node);
            }
            this.treeView1.ExpandAll();
            button1.Text = "Start";
            mState = TState.LOADED;
        }
Ejemplo n.º 15
0
 internal State(TState stateId) : base(stateId)
 {
 }
Ejemplo n.º 16
0
 public Entry(World world)
 {
     this.isEmpty = true;
     this.state   = WorldUtilities.CreateState <TState>();
     this.state.Initialize(world, freeze: true, restore: false);
 }
Ejemplo n.º 17
0
 StateConfiguration InternalPermit(TTrigger trigger, TState destinationState, string guardDescription)
 {
     return(InternalPermitIf(trigger, destinationState, () => true, guardDescription));
 }
Ejemplo n.º 18
0
 public Configurer Permit(TTrigger trigger, TState changeTo, Action execute)
 => Permit(trigger, changeTo, () => { execute(); return(true); });
Ejemplo n.º 19
0
 private void toolStripMenuItem2_Click(object sender, EventArgs e)
 {
     tm.shutdown();
     button1.Text = "Start";
     textBox1.Text = "";
     mState = this.treeView1.Nodes.Count == 0 ? TState.NONE : TState.LOADED;
 }
Ejemplo n.º 20
0
 public Configurer Permit(TTrigger trigger, TState changeTo)
 => Permit(trigger, changeTo, () => true);
Ejemplo n.º 21
0
 public Sync(TState state, Action action, Reflection.InvocationInfo actionDescription)
     : base(state, actionDescription)
 {
     _action = action;
 }
Ejemplo n.º 22
0
            public Configurer Permit(TTrigger trigger, TState changeTo, Func <bool> condition)
            {
                Machine.Permits.Add(new Permit(State, trigger, changeTo, condition));

                return(this);
            }
 public Scope(IFdbDatabase db, [AllowNull] TState state)
 {
     this.Db    = db;
     this.State = state;
 }
Ejemplo n.º 24
0
 public Configurer(TState state, StateMachine <TState, TTrigger> machine)
 {
     this.State   = state;
     this.Machine = machine;
 }
Ejemplo n.º 25
0
 public void Release(TState state)
 {
     // Return state to pool
     _states.ReturnToPool(state);
 }
 private protected virtual void CloneCore(TState state)
 {
     state.WindowedBuffer        = WindowedBuffer.Clone();
     state.InitialWindowedBuffer = InitialWindowedBuffer.Clone();
 }
Ejemplo n.º 27
0
 public LineStateInfo(TState endLineState, bool isDirty)
 {
     EndLineState   = endLineState;
     IsDirty        = isDirty;
     MultilineToken = false;
 }
 private static void MapFunctionWithoutBuffer(DataBox <TInput> input, DataBox <TOutput> output, TState state)
 {
     state.ProcessWithoutBuffer(ref input.Value, ref output.Value);
 }
 public bool Includes(TState state)
 {
     return(_state.Equals(state) || _substates.Any(s => s.Includes(state)));
 }
 private static void MapFunctionWithoutBuffer(DataBox <TInput> input, DataBoxForecastingWithConfidenceIntervals <TOutput> output, TState state)
 {
     state.ProcessWithoutBuffer(ref input.Value, ref output.Forecast, ref output.ConfidenceIntervalLowerBound, ref output.ConfidenceIntervalUpperBound);
 }
 public StateRepresentation(TState state)
 {
     _state = state;
 }
 private void InitFunction(TState state)
 {
     state.InitState(_parent.WindowSize, _parent.InitialWindowSize, _parent, _parent.Host);
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Accept the specified trigger and transition to the destination state.
 /// </summary>
 /// <param name="trigger">The accepted trigger.</param>
 /// <param name="destinationState">The state that the trigger will cause a
 /// transition to.</param>
 /// <returns>The reciever.</returns>
 public StateConfiguration Permit(TTrigger trigger, TState destinationState)
 {
     EnforceNotIdentityTransition(destinationState);
     return(InternalPermit(trigger, destinationState, string.Empty));
 }
 /// <summary>
 /// Accept the specified trigger and transition to the destination state.
 /// </summary>
 /// <param name="trigger">The accepted trigger.</param>
 /// <param name="destinationState">The state that the trigger will cause a
 /// transition to.</param>
 /// <param name="guard">Function that must return true in order for the
 /// trigger to be accepted.</param>
 /// <returns>The reciever.</returns>
 public StateConfiguration PermitIf(TTrigger trigger, TState destinationState, Func <bool> guard)
 {
     EnforceNotIdentityTransition(destinationState);
     return(InternalPermitIf(trigger, destinationState, guard));
 }
Ejemplo n.º 35
0
 StateConfiguration InternalPermitIf(TTrigger trigger, TState destinationState, Func <bool> guard, string guardDescription)
 {
     Enforce.ArgumentNotNull(guard, nameof(guard));
     _representation.AddTriggerBehaviour(new TransitioningTriggerBehaviour(trigger, destinationState, guard, guardDescription));
     return(this);
 }
 StateConfiguration InternalPermit(TTrigger trigger, TState destinationState)
 {
     return(InternalPermitIf(trigger, destinationState, () => true));
 }
Ejemplo n.º 37
0
 public IStateConfiguration Allow(TTrigger trigger, TState destinationState)
 {
     m_machine.AddTransition(m_state, trigger, destinationState);
     return(this);
 }
Ejemplo n.º 38
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            switch (mState)
            {
                case TState.NONE:
                case TState.PAUSING:
                case TState.LOADED:
                    break;
                case TState.TESTING:
                    this.timer1.Stop();
                    TestMain.EnumCaseResult r = tm.enumerateCases();
                    if (r == TestMain.EnumCaseResult.ENUMCASE_OVER)
                    {
                        tm.shutdown();

                        _onOutPut("  ");
                        _onOutPut("**** Test Over ****");

                        this.button1.Text = "Start";
                        mState = TState.LOADED;
                    }
                    this.timer1.Start();
                    break;
            }
        }