public override void ProcessInput(InPutEnum input)
        {
            switch (input)
            {
            case InPutEnum.InPutA:
            case InPutEnum.InputIA:
                Console.WriteLine($"Receive A/IA, remain in {Name} state.");
                break;

            case InPutEnum.InputB:
                TransferToAB();
                break;

            case InPutEnum.InputIB:
                TransferToIB();
                break;

            case InPutEnum.InputE:
                sm.EndMachine();
                break;

            default:
                Console.WriteLine("Input not recgonize, ignore...");
                break;
            }
        }
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("Input command:{A, IA, B, IB, E} to run StateMachine...");
                StateMachine sm = new StateMachine();
                while (!sm.Terminated)
                {
                    string    read = Console.ReadLine();
                    InPutEnum cmd  = EnumEncoder.Encode(read);
                    sm.ProcessInput(cmd);
                }
                PrintElapseTime(sm.StateInstance.StateIni);
                PrintElapseTime(sm.StateInstance.StateBA);
                PrintElapseTime(sm.StateInstance.StateIA);
                PrintElapseTime(sm.StateInstance.StateIB);
                PrintElapseTime(sm.StateInstance.StateAB);

                string readC = Console.ReadLine();
                if (readC == "EXIT")
                {
                    break;
                }
            }
        }
        public override void ProcessInput(InPutEnum input)
        {
            base.ProcessInput(input);
            switch (input)
            {
            case InPutEnum.InPutA:
            case InPutEnum.InputIA:
                TransferToIA();
                break;

            case InPutEnum.InputB:
            case InPutEnum.InputIB:
                TransferToIB();
                break;

            case InPutEnum.InputE:
                sm.EndMachine();
                break;

            default:
                Console.WriteLine("Input not recgonize, ignore...");
                break;
            }
        }
示例#4
0
 public virtual void ProcessInput(InPutEnum input)
 {
     Console.WriteLine($"State {Name} processing {input}");
 }
 public void ProcessInput(InPutEnum input)
 {
     CurrentState.ProcessInput(input);
 }