示例#1
0
 public override void execute(MachineState ms, byte[] parameters)
 {
     int res = ~ms.registers[parameters[0]].value & 0xFF;
     ms.registers[parameters[0]].value = (byte) (res);
     ms.flags["S"] = res >> 4 > 0x8 ? 1 : 0;
     ms.flags["Z"] = res == 0 ? 1 : 0;
 }
        public MachineState GetMachineState()
        {
            if (!TcpClient.Connected)
                throw new InvalidOperationException("The socket is not connected.");

            SendPacket(new byte[0], PacketID.GetMachineState);

            MachineState mstate = new MachineState();
            byte b = ReadByte(TcpClient.GetStream());
            uint length = ReadUInt32(TcpClient.GetStream());

            mstate.IsRunning = ReadBool(TcpClient.GetStream());
            mstate.RegisterA = ReadUInt16(TcpClient.GetStream());
            mstate.RegisterB = ReadUInt16(TcpClient.GetStream());
            mstate.RegisterC = ReadUInt16(TcpClient.GetStream());
            mstate.RegisterX = ReadUInt16(TcpClient.GetStream());
            mstate.RegisterY = ReadUInt16(TcpClient.GetStream());
            mstate.RegisterZ = ReadUInt16(TcpClient.GetStream());
            mstate.RegisterI = ReadUInt16(TcpClient.GetStream());
            mstate.RegisterJ = ReadUInt16(TcpClient.GetStream());
            mstate.RegisterPC = ReadUInt16(TcpClient.GetStream());
            mstate.RegisterSP = ReadUInt16(TcpClient.GetStream());
            mstate.RegisterEX = ReadUInt16(TcpClient.GetStream());
            mstate.RegisterIA = ReadUInt16(TcpClient.GetStream());
            mstate.ClockSpeed = ReadUInt32(TcpClient.GetStream());
            mstate.CyclesSinceReset = ReadUInt64(TcpClient.GetStream());
            mstate.QueuedInterrupts = ReadByte(TcpClient.GetStream());

            LastKnownMachineState = mstate;
            return mstate;
        }
示例#3
0
        public override void execute(MachineState ms, byte[] parameters)
        {
            ms.flags["C"] = (ms.registers[parameters[0]].value + ms.registers[parameters[1]].value) > 255 ? 1 : 0;
            ms.flags["S"] = (ms.registers[parameters[0]].value + ms.registers[parameters[1]].value) >> 4 > 0x8 ? 1 : 0;
            int res = (ms.registers[parameters[0]].value + ms.registers[parameters[1]].value) & 0xFF;
            ms.registers[parameters[1]].value = (byte) res;

            ms.flags["Z"] = res == 0 ? 1 : 0;
        }
示例#4
0
 public int process( Work work, String message )
 {
     int result = 0;
     if (this.state == MachineState.IDLE)
     {
         result = work(this.register, message);
         this.state = MachineState.WORK;
     }
     return result;
 }
示例#5
0
 public override void execute(MachineState ms, byte[] parameters)
 {
     int res = ms.registers[parameters[1]].value - ms.registers[parameters[0]].value;
     ms.flags["C"] = res > 255 ? 1 : 0;
     ms.flags["S"] = res >> 4 > 0x8 ? 1 : 0;
     ms.flags["Z"] = res == 0 ? 1 : 0;
     if(res < 0) {
         ms.flags["C"] = 1;
     }
     ms.registers[parameters[1]].value = (byte) (res);
 }
示例#6
0
 public override void execute(MachineState ms, byte[] parameters)
 {
     int address = parameters[0] << 12 | parameters[1] << 8 | parameters[2] << 4 | parameters[3];
     if(address == 0xFF00)
     {
         if (ms.inputBuffer.Length > 0)
         {
             ms.registers[cond].value = Convert.ToByte(ms.inputBuffer.ToCharArray()[0]);
             ms.inputBuffer = ms.inputBuffer.Remove(0, 1);
         }
         return;
     }
     ms.registers[cond].value = ms.memory[address];
 }
 public void IncreaseStateTime(double delta, MachineState.State state)
 {
     if (state == MachineState.State.busy)
     {
         busyTime += delta;
     }
     if (state == MachineState.State.idle)
     {
         idleTime += delta;
     }
     if (state == MachineState.State.broken)
     {
         brokenTime += delta;
     }
     if (state == MachineState.State.blocked)
     {
         blockedTime += delta;
     }
 }
示例#8
0
        public void Run(int millisecondsBetweenSteps = 0)
        {
            if (State == MachineState.Running)
                throw new InvalidOperationException("A run operation may not be performed while the machine is already running.");

            State = MachineState.Running;

            while (State == MachineState.Running)
                if (_breakPending)
                {
                    State = MachineState.Ready;
                    _breakPending = false;
                }
                else
                {
                    Step();
                    Thread.Sleep(millisecondsBetweenSteps);
                }
        }
示例#9
0
        private bool StatePassed(string input)
        {
            bool done     = false;
            char currChar = '\0';

            currState    = MachineState.BeginningState;
            inputMessage = InputMessage.NoneFound;
            counter      = -1;
            if (input != "")
            {
                while (!done)
                {
                    switch (currChar)
                    {
                    case '\0':
                    case ' ':
                        if (counter + 1 >= input.Length)
                        {
                            done = true;
                            break;
                        }
                        currChar = input[++counter];
                        if (currChar == 'H' || currChar == 'h' || currChar == 'A' || currChar == 'a' || currChar == 'T' || currChar == 't')
                        {
                            AddPossibilities(currChar);
                            currState = MachineState.TransitionState;
                        }
                        break;

                    default:
                        if (currState == MachineState.TransitionState)
                        {
                            if (currChar == 'H' || currChar == 'h')
                            {
                                if (hiController.StateHiCheck(currChar, input, counter))
                                {
                                    inputMessage = InputMessage.Hi;
                                }
                                else if (helloController.StateHelloCheck(currChar, input, counter))
                                {
                                    inputMessage = InputMessage.Hello;
                                }
                                else if (howdyController.StateHowdyCheck(currChar, input, counter))
                                {
                                    inputMessage = InputMessage.Howdy;
                                }
                                else if (howController.StateHowDoCheck(currChar, input, counter))
                                {
                                    inputMessage = InputMessage.HowDoYou;
                                }
                                else if (howController.StateHowCheck(currChar, input, counter))
                                {
                                    inputMessage = InputMessage.HowAreYou;
                                }
                                else if (howController.StateHowAreCheck(currChar, input, counter))
                                {
                                    inputMessage = InputMessage.HowAreYouDoing;
                                }
                            }
                            else if (currChar == 'T' || currChar == 't')
                            {
                                if (thanksController.StateThanksCheck(currChar, input, counter))
                                {
                                    inputMessage = InputMessage.Thanks;
                                }
                            }
                            else if (currChar == 'A' || currChar == 'a')
                            {
                                if (alohaController.StateAlohaCheck(currChar, input, counter))
                                {
                                    inputMessage = InputMessage.Aloha;
                                }
                                else if (ahoyController.StateAhoyCheck(currChar, input, counter))
                                {
                                    inputMessage = InputMessage.Ahoy;
                                }
                            }
                            currState = MachineState.BeginningState;
                        }
                        if (++counter >= input.Length)
                        {
                            inputMessage = InputMessage.NoneFound;
                            done         = true;
                        }
                        else
                        {
                            currChar = input[counter];
                        }
                        break;
                    }

                    if (inputMessage != InputMessage.NoneFound)
                    {
                        done = true;
                    }
                }
            }
            return(true);
        }
示例#10
0
 public override int execute(MachineState ms, byte[] parameters, int pc)
 {
     int address = parameters[0] << 12 | parameters[1] << 8 | parameters[2] << 4 | parameters[3];
     int value = ms.memory[address];
     return value;
 }
示例#11
0
    //==========================================================================
    //
    //==========================================================================

    void Awake()
    {
        currentState = MachineState.Idle;
        listeners    = new List <IMachineListener> ();
    }
示例#12
0
 public void Resume()
 {
     machineState = MachineState.Running;
 }
示例#13
0
        // ------------------------------------------------------------------
        // Desc:
        // ------------------------------------------------------------------
        public void Start()
        {
            if ( machineState == MachineState.Running ||
                 machineState == MachineState.Paused )
                return;

            machineState = MachineState.Running;
            if ( onStart != null )
                onStart ();

            if ( mode == State.Mode.Exclusive ) {
                if ( initState != null ) {
                    EnterStates( initState, startState );
                }
                else {
                    Debug.LogError( "FSM error: can't find initial state in " + name );
                }
            }
            else { // if ( _toEnter.mode == State.Mode.Parallel )
                for ( int i = 0; i < children.Count; ++i ) {
                    EnterStates( children[i], startState );
                }
            }
        }
示例#14
0
 public override void execute(MachineState ms, byte[] parameters)
 {
     ms.registers[parameters[0]].value =(byte) ( ms.registers[parameters[0]].value + ms.registers[parameters[1]].value + ms.flags["C"]);
 }
示例#15
0
        private void ExecuteInstruction(Instruction instruction)
        {
            bool incrementProgramCounter = true;

            MachineState newState = State;

            Opcode opcode = (Opcode)instruction.Nibble1;

            switch (opcode)
            {
                case Opcode.ImmediateLoad:
                    _registers[instruction.Nibble2] = instruction.Byte2;
                    break;
                case Opcode.DirectLoad:
                    _registers[instruction.Nibble2] = _memory[instruction.Byte2];
                    break;
                case Opcode.IndirectStore:
                    _memory[_registers[instruction.Nibble4]] = _registers[instruction.Nibble3];
                    break;
                case Opcode.Move:
                    _registers[instruction.Nibble4] = _registers[instruction.Nibble3];
                    break;
                case Opcode.IndirectLoad:
                    _registers[instruction.Nibble3] = _memory[_registers[instruction.Nibble4]];
                    break;
                case Opcode.IntegerAdd:
                    _registers[instruction.Nibble2] = (byte)(_registers[instruction.Nibble3] + _registers[instruction.Nibble4]);
                    break;
                case Opcode.JumpEqual:
                    if (_registers[instruction.Nibble2] == _registers[0x00])
                    {
                        ProgramCounter = instruction.Byte2;
                        incrementProgramCounter = false;
                    }
                    break;
                case Opcode.JumpLessEqual:
                    if (_registers[instruction.Nibble2] <= _registers[0x00])
                    {
                        ProgramCounter = instruction.Byte2;
                        incrementProgramCounter = false;
                    }
                    break;
                case Opcode.FloatingPointAdd:
                    _registers[instruction.Nibble2] = FloatingPointAdd(_registers[instruction.Nibble3], _registers[instruction.Nibble4]);
                    break;
                case Opcode.Or:
                    _registers[instruction.Nibble2] = (byte)(_registers[instruction.Nibble3] | _registers[instruction.Nibble4]);
                    break;
                case Opcode.And:
                    _registers[instruction.Nibble2] = (byte)(_registers[instruction.Nibble3] & _registers[instruction.Nibble4]);
                    break;
                case Opcode.Xor:
                    _registers[instruction.Nibble2] = (byte)(_registers[instruction.Nibble3] ^ _registers[instruction.Nibble4]);
                    break;
                case Opcode.Ror:
                    _registers[instruction.Nibble2] = (byte)((_registers[instruction.Nibble2] >> instruction.Nibble4) | (_registers[instruction.Nibble2] << (sizeof(byte) - instruction.Nibble4)));
                    break;
                case Opcode.DirectStore:
                    _memory[instruction.Byte2] = _registers[instruction.Nibble2];
                    break;
                case Opcode.Halt:
                    newState = MachineState.Halted;
                    break;
                default:
                    newState = MachineState.InvalidInstruction;
                    break;
            }

            State = newState;

            if (incrementProgramCounter)
                IncrementProgramCounter(instruction);
        }
 /// <summary>
 /// Set server state.
 /// </summary>
 /// <param name="state">Server state.</param>
 private void SetState(MachineState state)
 {
     UpdateState(state, true);
 }
示例#17
0
 public override ExecutionResult Evaluate(MachineState state)
 {
     throw new InvalidOperationException("Cannot execute `Conditional` node");
 }
示例#18
0
 public override void OnMachineState(MachineId machineId, string stateName, bool isEntry)
 {
     base.OnMachineState(machineId, stateName, isEntry);
     MachineState?.Invoke(machineId, stateName, isEntry);
 }
示例#19
0
        /// <inheritdoc />
        public async Task <Result <MachineState> > SetLocalMachineStateAsync(OperationContext context, MachineState state)
        {
            var counter = state switch
            {
                MachineState.Unknown => GlobalStoreCounters.SetMachineStateUnknown,
                MachineState.Open => GlobalStoreCounters.SetMachineStateOpen,
                MachineState.DeadUnavailable => GlobalStoreCounters.SetMachineStateDeadUnavailable,
                MachineState.Closed => GlobalStoreCounters.SetMachineStateClosed,
                _ => throw new NotImplementedException($"Unexpected machine state transition to state: {state}"),
            };

            return(await context.PerformOperationWithTimeoutAsync(
                       Tracer,
                       async nestedContext =>
            {
                var result = await _clusterStateKey.UseNonConcurrentReplicatedHashAsync(
                    nestedContext,
                    _configuration.RetryWindow,
                    RedisOperation.SetLocalMachineState,
                    (batch, key) => CallHeartbeatAsync(nestedContext, ClusterState, batch, key, state),
                    timeout: _configuration.ClusterRedisOperationTimeout).ThrowIfFailureAsync();

                return new Result <MachineState>(result.priorState);
            },
                       counter : Counters[counter],
                       extraEndMessage : r => r.Succeeded?$"OldState=[{r.Value}] NewState=[{state}]" : $"NewState=[{state}]",
                       timeout : Configuration.ClusterRedisOperationTimeout));
        }
示例#20
0
        private async Task <BoolResult> UpdateClusterStateCoreAsync(OperationContext context, ClusterState clusterState, MachineState machineState)
        {
            (var inactiveMachineIdSet, var closedMachineIdSet, var getUnknownMachinesResult) = await _clusterStateKey.UseNonConcurrentReplicatedHashAsync(
                context, _configuration.RetryWindow, RedisOperation.UpdateClusterState, async (batch, key) =>
            {
                var heartbeatResultTask = CallHeartbeatAsync(context, clusterState, batch, key, machineState);

                var getUnknownMachinesTask = batch.GetUnknownMachinesAsync(
                    key,
                    clusterState.MaxMachineId);

                await Task.WhenAll(heartbeatResultTask, getUnknownMachinesTask);

                var heartbeatResult          = await heartbeatResultTask;
                var getUnknownMachinesResult = await getUnknownMachinesTask;

                return(heartbeatResult.inactiveMachineIdSet, heartbeatResult.closedMachineIdSet, getUnknownMachinesResult);
            },
                timeout : _configuration.ClusterRedisOperationTimeout).ThrowIfFailureAsync();

            Contract.Assert(inactiveMachineIdSet != null, "inactiveMachineIdSet != null");
            Contract.Assert(closedMachineIdSet != null, "closedMachineIdSet != null");

            if (getUnknownMachinesResult.maxMachineId != clusterState.MaxMachineId)
            {
                Tracer.Debug(context, $"Retrieved unknown machines from ({clusterState.MaxMachineId}, {getUnknownMachinesResult.maxMachineId}]");
                foreach (var item in getUnknownMachinesResult.unknownMachines)
                {
                    context.LogMachineMapping(Tracer, item.Key, item.Value);
                }
            }

            clusterState.AddUnknownMachines(getUnknownMachinesResult.maxMachineId, getUnknownMachinesResult.unknownMachines);
            clusterState.SetMachineStates(inactiveMachineIdSet, closedMachineIdSet).ThrowIfFailure();

            Tracer.Debug(context, $"Inactive machines: Count={inactiveMachineIdSet.Count}, [{string.Join(", ", inactiveMachineIdSet)}]");
            Tracer.TrackMetric(context, "InactiveMachineCount", inactiveMachineIdSet.Count);

            foreach (var machineMapping in clusterState.LocalMachineMappings)
            {
                if (!clusterState.TryResolveMachineId(machineMapping.Location, out var machineId))
                {
                    return(new BoolResult($"Invalid redis cluster state on machine {machineMapping}. (Missing location {machineMapping.Location})"));
                }
                else if (machineId != machineMapping.Id)
                {
                    Tracer.Warning(context, $"Machine id mismatch for location {machineMapping.Location}. Registered id: {machineMapping.Id}. Cluster state id: {machineId}. Updating registered id with cluster state id.");
                    machineMapping.Id = machineId;
                }

                if (getUnknownMachinesResult.maxMachineId < machineMapping.Id.Index)
                {
                    return(new BoolResult($"Invalid redis cluster state on machine {machineMapping} (redis max machine id={getUnknownMachinesResult.maxMachineId})"));
                }
            }

            return(BoolResult.Success);
        }
示例#21
0
 public override MachineState Execute(MachineState state)
 {
     return(state
            .WithAccumulator(state.Accumulator + Argument)
            .WithInstructionPointer(state.InstructionPointer + 1));
 }
示例#22
0
 public override Value Evaluate(MachineState state)
 {
     return(state.GetVariable(Name.Name).Value);
 }
示例#23
0
        private async Task <(MachineState priorState, BitMachineIdSet inactiveMachineIdSet)> CallHeartbeatAsync(OperationContext context, RedisBatch batch, MachineState state)
        {
            var heartbeatResult = await batch.HeartbeatAsync(
                _clusterStateKey,
                LocalMachineId.Index,
                state,
                _clock.UtcNow,
                _configuration.RecomputeInactiveMachinesExpiry,
                _configuration.MachineExpiry);

            if (heartbeatResult.priorState != state)
            {
                Tracer.Debug(context, $"Machine state changed from {heartbeatResult.priorState} to {state}");
            }

            return(heartbeatResult);
        }
        /// <summary>
        /// Update or set server state.
        /// </summary>
        /// <param name="state">Server state.</param>
        /// <param name="setState">True if set state.</param>
        private void UpdateState(MachineState state, bool setState)
        {
            Status newStatus = status;
            switch (state)
            {
                case MachineState.MachineState_Running:
                    newStatus = Status.RUNNING;
                    break;
                case MachineState.MachineState_Starting:
                case MachineState.MachineState_Restoring:
                    newStatus = Status.STARTING;
                    break;
                case MachineState.MachineState_Stopping:
                case MachineState.MachineState_Saving:
                    newStatus = Status.STOPING;
                    break;
                default :
                    ClearConsoleHWnd();
                    newStatus = Status.POWEREDOFF;
                    break;
            }

            if (newStatus == status)
            {
                return;
            }

            status = newStatus;

            if (newStatus == Status.POWEREDOFF)
            {
                if (restarting)
                {
                    StartServer();
                }
                else if (!setState)
                {
                    if (stoping)
                    {
                        stoping = false;
                        tray.ShowTrayInfo(name, name + " was successfully powered off.");
                    }
                    else
                    {
                        tray.ShowTrayError(name, name + " was powered off.");
                    }
                }

                tray.SetServerPoweredOff();
            }
            else if (newStatus == Status.RUNNING)
            {
                if (consoleVisible)
                {
                    ShowConsole();
                }
                else
                {
                    HideConsole();
                }

                if (serverSession != null)
                {
                    serverSession.UnlockMachine();
                }

                if (restarting)
                {
                    restarting = false;
                    stoping = false;
                    tray.ShowTrayInfo(name, name + " was successfully restarted.");
                }
                else if (!setState && starting)
                {
                    starting = false;
                    tray.ShowTrayInfo(name, name + " was successfully started.");
                }
                else if (!setState && !starting)
                {
                    tray.ShowTrayWarning(name, name + " was started.");
                }
                else
                {
                    tray.ShowTrayInfo(name, name + " is already running.");
                }

                tray.SetServerRunning();
            }
        }
示例#25
0
 public override int execute(MachineState ms, byte[] parameters, int pc)
 {
     return parameters[0] << 12 | parameters[1] << 8 | parameters[2] << 4 | parameters[3];
 }
示例#26
0
 public abstract ExecutionResult Evaluate(MachineState state);
示例#27
0
 public override void execute(MachineState ms, byte[] parameters)
 {
     int temp = ms.registers[parameters[1]].value;
     ms.registers[parameters[1]].value = ms.registers[parameters[0]].value;
     ms.registers[parameters[0]].value = (byte) (temp);
 }
示例#28
0
 [NotNull] public abstract ExecutionResult Evaluate([NotNull] MachineState state);
示例#29
0
        // ------------------------------------------------------------------
        // Desc:
        // ------------------------------------------------------------------
        protected void ProcessStop()
        {
            ClearCurrentStatesRecursively();

            if ( onStop != null )
                onStop ();

            machineState = MachineState.Stopped;
        }
 void Start()
 {
     currentState = MachineState.WORKING;
     GenerateLifeTime();
     timer = new Timer(lifeTime);
 }
示例#31
0
 public abstract MachineState Execute(MachineState state);
示例#32
0
        static void Main(string[] args)
        {
            Initialization.Start();
            //Console.WriteLine("\nLet's create your first note! Press <Enter> and have fun...\n");
            //while (Console.ReadKey().Key != ConsoleKey.Enter) { ClearCurrentConsoleLine(0); }
            currentState = MachineState.Home;
            while (true)
            {
                switch (currentState)
                {
                case MachineState.Home:
                {
                    currentState = MachineState.Home;
                    Menu.HomeState();
                    Console.WriteLine($"You have {notes.Count} notes.\n");
                    MachineState state = currentState;
                    while (true)
                    {
                        ConsoleKey key = Console.ReadKey().Key;
                        ClearCurrentConsoleLine(0);
                        if (key == ConsoleKey.C)
                        {
                            goto case MachineState.Create;
                        }
                        if (key == ConsoleKey.S)
                        {
                            goto case MachineState.ShowAll;
                        }
                        if (key == ConsoleKey.Q)
                        {
                            goto case MachineState.ShowSimple;
                        }
                        if (key == ConsoleKey.F)
                        {
                            goto case MachineState.Find;
                        }
                        if (key == ConsoleKey.P)
                        {
                            goto case MachineState.Settings;
                        }
                    }
                }

                case MachineState.Create:
                {
                    currentState = MachineState.Create;
                    CreateNewNote(out int id);
                    readId = id;
                    goto case MachineState.Read;
                }

                case MachineState.ShowAll:
                {
                    currentState = MachineState.ShowAll;
                    ShowAllNotes();
                    while (true)
                    {
                        ConsoleKey key = Console.ReadKey().Key;
                        if (key == ConsoleKey.Escape)
                        {
                            goto case MachineState.Home;
                        }
                        else if (key == ConsoleKey.R)
                        {
                            if (notes.Count == 0)
                            {
                                Console.Beep();
                                goto case MachineState.Home;
                            }
                            while (true)
                            {
                                Console.Write("Enter note id: ");
                                if (int.TryParse(Console.ReadLine(), out readId))
                                {
                                    if (readId >= 0 && readId < notes.Count)
                                    {
                                        goto case MachineState.Read;
                                    }
                                    else
                                    {
                                        Console.Beep();
                                        ClearCurrentConsoleLine(1);
                                        Console.SetCursorPosition(0, Console.CursorTop - 1);
                                        continue;
                                    }
                                }
                                else
                                {
                                    Console.Beep();
                                    ClearCurrentConsoleLine(1);
                                    Console.SetCursorPosition(0, Console.CursorTop - 1);
                                    continue;
                                }
                            }
                        }
                    }
                }

                case MachineState.ShowSimple:
                {
                    currentState = MachineState.ShowSimple;
                    ShowSimplifiedNotes();
                    while (true)
                    {
                        ConsoleKey key = Console.ReadKey().Key;
                        if (key == ConsoleKey.Escape)
                        {
                            goto case MachineState.Home;
                        }
                        if (key == ConsoleKey.R)
                        {
                            ClearCurrentConsoleLine(1);
                            ClearCurrentConsoleLine(0);
                            if (notes.Count == 0)
                            {
                                Console.Beep();
                                goto case MachineState.Home;
                            }
                            Console.Write("Enter id: ");
                            while (true)
                            {
                                while (!int.TryParse(Console.ReadLine(), out readId))
                                {
                                    ClearCurrentConsoleLine(1);
                                    Console.SetCursorPosition(0, Console.CursorTop - 1);
                                    Console.Write("Enter id: ");
                                    Console.Beep();
                                }
                                if (readId >= 0 && readId < notes.Count)
                                {
                                    goto case MachineState.Read;
                                }
                                Console.Beep();
                                Console.SetCursorPosition(0, Console.CursorTop - 1);
                                ClearCurrentConsoleLine(0);
                                Console.Write("Enter id: ");
                            }
                        }
                    }
                }

                case MachineState.Find:
                {
                    currentState = MachineState.Find;
                    Menu.FindState();
                    Find(out int results);
                    while (true)
                    {
                        ConsoleKey key = Console.ReadKey().Key;
                        if (key == ConsoleKey.Escape)
                        {
                            goto case MachineState.Home;
                        }
                        if (key == ConsoleKey.F)
                        {
                            goto case MachineState.Find;
                        }
                        if (key == ConsoleKey.R)
                        {
                            if (results == 0)
                            {
                                Console.Beep();
                                goto case MachineState.Home;
                            }
                            ClearCurrentConsoleLine(1);
                            ClearCurrentConsoleLine(0);
                            Console.Write("Enter id: ");
                            while (true)
                            {
                                while (!int.TryParse(Console.ReadLine(), out readId))
                                {
                                    ClearCurrentConsoleLine(1);
                                    Console.SetCursorPosition(0, Console.CursorTop - 1);
                                    Console.Write("Enter id: ");
                                    Console.Beep();
                                }
                                if (readId >= 0 && readId < notes.Count)
                                {
                                    goto case MachineState.Read;
                                }
                                Console.Beep();
                                Console.SetCursorPosition(0, Console.CursorTop - 1);
                                ClearCurrentConsoleLine(0);
                                Console.Write("Enter id: ");
                            }
                        }
                    }
                }

                case MachineState.Read:
                {
ReadMarker:
                    currentState = MachineState.Read;
                    ReadNote(notes[readId]);
                    while (true)
                    {
                        ConsoleKey key = Console.ReadKey().Key;
                        ClearCurrentConsoleLine(0);
                        if (key == ConsoleKey.Escape)
                        {
                            goto case MachineState.Home;
                        }
                        if (key == ConsoleKey.E)         // Edit row
                        {
                            Console.Write("Enter row name:");
                            string row     = Console.ReadLine();
                            string rowCopy = row.Trim().ToLower();
                            var    array   = rowCopy.Split(' ');
                            rowCopy = string.Join("", array);
                            switch (rowCopy)
                            {
                            case ("firstname"):
                                notes[readId].FirstName = Console.ReadLine();
                                goto ReadMarker;

                            case ("lastname"):
                                notes[readId].LastName = Console.ReadLine();
                                goto ReadMarker;

                            case ("middlename"):
                                notes[readId].MiddleName = Console.ReadLine();
                                goto ReadMarker;

                            case ("number"):
                                notes[readId].Number = Console.ReadLine();
                                goto ReadMarker;

                            case ("country"):
                                notes[readId].Country = Console.ReadLine();
                                goto ReadMarker;

                            case ("organization"):
                                notes[readId].Organization = Console.ReadLine();
                                goto ReadMarker;

                            case ("job"):
                                notes[readId].Job = Console.ReadLine();
                                goto ReadMarker;

                            case ("birthdate"):
                                notes[readId].Birthday = Console.ReadLine();
                                goto ReadMarker;

                            default:
                                break;
                            }
                            switch (row)
                            {
                            default:
                                try
                                {
                                    notes[readId].additionalNotes[row] = Console.ReadLine();
                                }
                                catch (KeyNotFoundException)
                                {
                                }
                                catch (NullReferenceException)
                                { }
                                goto ReadMarker;
                            }
                        }
                        if (key == ConsoleKey.A)         // Add row
                        {
                            Console.Write("Enter row name: ");
                            string row = Console.ReadLine();
                            try
                            {
                                notes[readId].additionalNotes.Add(row, "");
                            }
                            catch (NullReferenceException)
                            {
                            }
                            catch (ArgumentException)
                            {
                                ClearCurrentConsoleLine(1);
                                Console.ForegroundColor = ConsoleColor.Cyan;
                                Console.WriteLine($"{row} - Such row already exist");
                                Console.ForegroundColor = Design.textColor;
                                System.Threading.Thread.Sleep(2000);
                            }
                        }
                        if (key == ConsoleKey.X)         // Remove row
                        {
                            Console.Write("Enter row name:");
                            string row = Console.ReadLine().Trim().ToLower();
                            if (Note.lockedFields.Contains(row))
                            {
                                Design.Draw();
                                Console.Beep();
                                Console.ForegroundColor = ConsoleColor.Cyan;
                                Console.Write("You can't remove default rows");
                                Console.ForegroundColor = Design.textColor;
                                System.Threading.Thread.Sleep(4000);
                                goto case MachineState.Read;
                            }
                            else
                            {
                                try
                                {
                                    notes[readId].additionalNotes.Remove(row);
                                }
                                catch (Exception)
                                {
                                    Console.Beep();
                                }
                                goto case MachineState.Read;
                            }
                        }
                        if (key == ConsoleKey.D)         // Delete note
                        {
                            goto case MachineState.Delete;
                        }
                        break;
                    }
                    goto case MachineState.Read;
                }

                case MachineState.Delete:
                {
                    currentState = MachineState.Delete;
                    DeleteNote(readId, out bool deleted);
                    if (deleted)
                    {
                        goto case MachineState.Home;
                    }
                    goto case MachineState.Read;
                }

                case MachineState.Settings:
                {
                    currentState = MachineState.Settings;
                    int frontColorNumber = 0;
                    int backColorNumber  = 0;
                    while (true)
                    {
                        if (Design.textColor == Design.background)
                        {
                            Design.background = ConsoleColor.Black;
                            Design.textColor  = ConsoleColor.White;
                        }
                        Menu.Settings();
                        var key = Console.ReadKey().Key;
                        ClearCurrentConsoleLine(0);
                        if (key == ConsoleKey.UpArrow)
                        {
                            backColorNumber = (backColorNumber == 0) ? 16 : backColorNumber;
                            backColorNumber--;
                            Design.background       = Design.colors[backColorNumber];
                            Console.BackgroundColor = Design.colors[backColorNumber];
                        }
                        if (key == ConsoleKey.DownArrow)
                        {
                            backColorNumber = (backColorNumber == 15) ? 0 : backColorNumber;
                            backColorNumber++;
                            Design.background       = Design.colors[backColorNumber];
                            Console.BackgroundColor = Design.colors[backColorNumber];
                        }
                        if (key == ConsoleKey.LeftArrow)
                        {
                            frontColorNumber = (frontColorNumber == 0) ? 16 : frontColorNumber;
                            frontColorNumber--;
                            Design.textColor        = Design.colors[frontColorNumber];
                            Console.ForegroundColor = Design.colors[frontColorNumber];
                        }
                        if (key == ConsoleKey.RightArrow)
                        {
                            frontColorNumber = (frontColorNumber == 15) ? 0 : frontColorNumber;
                            frontColorNumber++;
                            Design.textColor        = Design.colors[frontColorNumber];
                            Console.ForegroundColor = Design.colors[frontColorNumber];
                        }
                        if (key == ConsoleKey.Escape)
                        {
                            goto case MachineState.Home;
                        }
                    }
                }

                default:
                    Console.Clear();
                    goto case MachineState.Home;
                }
            }
        }
示例#33
0
 void Instance_MachineStateChanged(MachineState newState, MachineState previousState)
 {
     OnMachineStateChanged(newState);
 }
示例#34
0
 public StateFree_Idle(MachineState tMachine) :
     base(tMachine)
 {
 }
示例#35
0
        public override ExecutionResult Evaluate(MachineState state)
        {
            _expr.Evaluate(state);

            return(new ExecutionResult());
        }
 public static EmbedBuilder ToEmbed <TD>(this MachineState state, TD?network, int?iters, int pc)
     where TD : class, IDeviceNetwork, IEnumerable <(string, Value)>
        private async void currentTimer_Tick(object sender, EventArgs e)
        {
            if (serverRequestData)
            {
                countSenddataToHubs += 1;
                lbCountTrigger.Text  = countSenddataToHubs.ToString();
                if (countSenddataToHubs == everyTiggerTime)
                {
                    countSenddataToHubs = 0;
                    //send data to Hubs server

                    currentTimer.Stop();
                    //send data to Hubs server

                    if (RuningTimer.Enabled)
                    {
                        checkStateMachine = MachineState.isRunning;
                    }
                    else if (DowntimeTimer.Enabled)
                    {
                        checkStateMachine = MachineState.isDowntime;
                    }
                    else if (SettingTimer.Enabled)
                    {
                        checkStateMachine = MachineState.isSetting;
                    }
                    else
                    {
                        checkStateMachine = MachineState.isIdle;
                    }

                    TimeSpan countAlltime = countSettingtimes + countIdletimes + countDownTimetimes + countRunningtimes;
                    if (countSettingtimes.TotalSeconds > 0)
                    {
                        settingPercen = (double)(countSettingtimes.TotalSeconds * 100 / (countAlltime.TotalSeconds));
                    }
                    if (countIdletimes.TotalSeconds > 0)
                    {
                        idlePercen = (double)(countIdletimes.TotalSeconds * 100 / (countAlltime.TotalSeconds));
                    }
                    if (countDownTimetimes.TotalSeconds > 0)
                    {
                        downtimePercen = (double)(countDownTimetimes.TotalSeconds * 100 / (countAlltime.TotalSeconds));
                    }
                    if (countRunningtimes.TotalSeconds > 0)
                    {
                        runningPercen = (double)(countRunningtimes.TotalSeconds * 100 / (countAlltime.TotalSeconds));
                    }

                    var countLastInput = totalInputValue - lastInput;
                    var countLastPass  = totalPassValue - lastPass;

                    if (countLastInput > 0 && countLastPass > 0)
                    {
                        lastInput = totalInputValue;
                        lastPass  = totalPassValue;
                    }
                    var datatoSendtoHub = new MachineData
                    {
                        machineState = checkStateMachine,

                        runningtimes  = runningPercen,
                        downTimetimes = downtimePercen,
                        settingtimes  = settingPercen,
                        idletimes     = idlePercen,

                        RunningTimeSpan = countRunningtimes,
                        DownTimeSpan    = countDownTimetimes,
                        SettingTimeSpan = countSettingtimes,
                        IdleTimeSpan    = countIdletimes,

                        totalInput = totalInputValue,
                        totalPass  = totalPassValue,
                        input      = countLastInput,
                        pass       = countLastPass,
                        yield      = yieldValue,
                        oee        = OEEValue,

                        machineName    = txtMachineName.Text,
                        jobNumber      = txtJobNo.Text,
                        supervisorName = txtSupervisorName.Text,
                        operatorName   = txtOperatorName.Text,
                        startTime      = startTime,
                        endTime        = endTime
                    };

                    var dataJson = JsonConvert.SerializeObject(datatoSendtoHub);
                    try
                    {
                        //await _connection.InvokeAsync("Send", "WinFormsApp", messageTextBox.Text);
                        await _connection.InvokeAsync("SendMachineData", dataJson);

                        Log(Color.Brown, "Senddata to server " + ": " + dataJson, messagesList);
                    }
                    catch (Exception ex)
                    {
                        Log(Color.Red, ex.ToString(), messagesList);
                        serverRequestData   = false;
                        countSenddataToHubs = 0;
                    }

                    currentTimer.Start();
                }
            }
        }
示例#38
0
 public void Pause()
 {
     mMachineState = MachineState.Paused;
 }
 public void Execute(MachineState machine)
 {
     machine.Instructions.JumpToInstruction(_targetIndex);
 }
示例#40
0
 public void Resume()
 {
     mMachineState = MachineState.Running;
 }
示例#41
0
 /// <inheritdoc />
 public Task <BoolResult> UpdateClusterStateAsync(OperationContext context, ClusterState clusterState, MachineState machineState = MachineState.Open)
 {
     return(context.PerformOperationAsync(
                Tracer,
                () => UpdateClusterStateCoreAsync(context, clusterState, machineState),
                Counters[GlobalStoreCounters.UpdateClusterState]));
 }
示例#42
0
 public override Value Evaluate(MachineState _)
 {
     return(new Value(Value));
 }
示例#43
0
 public override void execute(MachineState ms, byte[] parameters)
 {
     ms.registers[cond].value = (byte) (((parameters[0] & 0xF) << 4 | (parameters[1] & 0xF)) & 0xFF);
 }
示例#44
0
 public override int execute(MachineState ms, byte[] parameters, int pc)
 {
     return ms.stack.Pop() + 3;
 }
示例#45
0
 public override void execute(MachineState ms, byte[] parameters)
 {
     ms.registers[parameters[1]].value = ms.registers[parameters[0]].value;
 }
示例#46
0
        private static int EvaluateLine(string line, int pc, MachineState state)
        {
            var tokens = Tokenizer.TryTokenize(line);

            if (!tokens.HasValue)
            {
                Error(() => {
                    ErrorSpan(tokens.Location);
                    Console.WriteLine();

                    Console.Error.WriteLine(tokens.FormatErrorMessageFragment());
                });

                Console.WriteLine("Press any key to try this line again");
                Console.ReadKey(true);
                return(pc);
            }

            var parsed = Parser.TryParseLine(tokens.Value);

            if (!parsed.HasValue)
            {
                Error(() => {
                    ErrorSpan(tokens.Location);
                    Console.WriteLine();

                    Console.Error.WriteLine(parsed.FormatErrorMessageFragment());
                });

                Console.WriteLine("Press any key to try this line again");
                Console.ReadKey(true);
                return(pc);
            }

            if (parsed.Remainder.Any())
            {
                Error(() => {
                    Console.WriteLine("Failed to parse entire line");
                    foreach (var token in parsed.Remainder)
                    {
                        Console.WriteLine($" - {token}");
                    }
                });

                Console.WriteLine("Press any key to try this line again");
                Console.ReadKey(true);
                return(pc);
            }

            try
            {
                return(parsed.Value.Evaluate(pc, state));
            }
            catch (ExecutionException ee)
            {
                var c = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"Runtime Error: {ee.Message}");
                Console.ForegroundColor = c;
                return(pc + 1);
            }
        }
示例#47
0
 public override void execute(MachineState ms, byte[] parameters)
 {
     ms.registers[cond].value = 0;
 }
示例#48
0
 public override void execute(MachineState ms, byte[] parameters)
 {
     ms.registers[ms.registers[parameters[0]].index].value = (byte) (ms.registers[parameters[0]].value >> 1);
 }
示例#49
0
 public override void execute(MachineState ms, byte[] parameters)
 {
     ms.stack.Push(ms.registers[cond].value);
 }
示例#50
0
        public void Start()
        {
            lock (s_syncRoot)
            {
                if (_disposed)
                    return;
                if (State == MachineState.Running)
                    return;

                StopRollTextThread();
                ResetCounters();
                SetRealRolledText();
                if (_rolledText.Length > 0)
                {
                    _stopRollTextEvent.Reset();
                    if (_rolledText.Length > _maxTextLength ||
                        _rollIfLessThanMaxLen)
                    {
                        _rollTextThread = ThreadUtils.StartBackgroundThread(RollLongTextThreadMethod);
                    }
                    else
                    {
                        _rollTextThread = ThreadUtils.StartBackgroundThread(RollShortTextThreadMethod);
                    }
                }
                State = MachineState.Running;
            }
        }
示例#51
0
        // ------------------------------------------------------------------
        // Desc:
        // ------------------------------------------------------------------
        public void Stop()
        {
            if ( machineState == MachineState.Stopped )
                return;

            if ( isUpdating ) {
                machineState = MachineState.Stopping;
            }
            else {
                ProcessStop ();
            }
        }
示例#52
0
        // ------------------------------------------------------------------
        // Desc:
        // ------------------------------------------------------------------
        protected void ProcessStop()
        {
            eventBuffer[0].Clear();
            eventBuffer[1].Clear();
            ClearCurrentStatesRecursively();

            if ( onStop != null )
                onStop ();

            machineState = MachineState.Stopped;
        }
示例#53
0
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 public void Pause()
 {
     machineState = MachineState.Paused;
 }
示例#54
0
        public override Value Evaluate(MachineState state)
        {
            var value = Parameter.Evaluate(state);

            return(Evaluate(value));
        }
示例#55
0
 public override ExecutionResult Evaluate(MachineState state)
 {
     throw new ExecutionException("Static error");
 }
示例#56
0
 public override MachineState Execute(MachineState state)
 {
     return(state.WithInstructionPointer(state.InstructionPointer + 1));
 }
示例#57
0
 public override int execute(MachineState ms, byte[] parameters, int pc)
 {
     if (ms.flags["C"] == 0) return pc + length; // return if C flag isn't set
     return parameters[0] << 12 | parameters[1] << 8 | parameters[2] << 4 | parameters[3];
 }
示例#58
0
        //method handles the enter button clicks
        private void EnterClicked(object sender, EventArgs e)
        {
            switch (curState)
            {
            case MachineState.WaitingForPin:
                //if machine is on waiting for pin state and pin length is 4 then check if the pin is correct or not. log person in if is correct. update log
                if (numberEntered.Length == 4 && bank.CheckPin(Convert.ToInt32(curAccNum), Convert.ToInt32(numberEntered)))
                {
                    curState = MachineState.MainMenu;
                    logUpdater(curAccNum + " card PIN entered correctly");
                }
                else
                {                        //otherwise update log and go to error state
                    curState = MachineState.InvalidPin;
                    logUpdater(curAccNum + " card PIN entered incorrectly");
                }
                numberEntered = "";
                break;

            case MachineState.WithdrawingCustomAmount:
                if (bank.DoAction(ATMAction.WithdrawMoney, Convert.ToInt32(numberEntered), Convert.ToInt32(curAccNum), isBroken))
                {                        //if sucessfully withdrawn money from bank account, ask user if he wants another action, update log
                    curState = MachineState.ConfirmWantAnotherAction;
                    logUpdater(curAccNum + " took £" + numberEntered + " off the account. New balance: " + bank.getAccountBalance(Convert.ToInt32(curAccNum)));
                }
                else
                {                        //otherwise, go to error state, update log
                    curState = MachineState.InsufficientFunds;
                    logUpdater(curAccNum + " failed to withdraw £" + numberEntered + " off the account. Insufficient funds");
                }
                numberEntered = "";
                break;

            case MachineState.ChangingPinNewPin:
                //if the pin length is 4, set the pin to new pin, ask if user wants another action, otherwise go to invalid input state
                if (numberEntered.Length == 4)
                {
                    bank.SetPin(Convert.ToInt32(curAccNum), Convert.ToInt32(numberEntered));
                    curState = MachineState.ConfirmWantAnotherAction;
                    logUpdater(curAccNum + " changed their pin to " + numberEntered);
                }
                else
                {
                    curState = MachineState.InvalidInput;
                }
                numberEntered = "";
                break;

            case MachineState.ChangingPinOldPin:
                //if old pin input is not empty, check if the pin matches the current account pin and if it does
                //switch to state that asks user for the new pin. otherwise go to error state and log
                if (numberEntered.Length == 0)
                {
                    if (bank.CheckPin(Convert.ToInt32(curAccNum), Convert.ToInt32(numberEntered)))
                    {
                        curState = MachineState.ChangingPinNewPin;
                    }
                    else
                    {
                        logUpdater(curAccNum + " pin change failed");
                        curState = MachineState.InvalidInput;
                    }
                }
                numberEntered = "";
                break;
            }
            UpdateMachine();
        }
示例#59
0
 public void Stop()
 {
     lock (s_syncRoot)
     {
         if (_disposed)
             return;
         StopRollTextThread();
         State = MachineState.Stopped;
     }
 }
示例#60
0
        //method used to update all the labels depending on the state of the machine
        private void UpdateMachine()
        {
            int count = 0;

            BankAccounts.DataSource = bank.getAccounts();            //update the account data on bottom right
            //depending on the state of machine, set all the labels to the corresponding menu options
            switch (curState)
            {
            case MachineState.WaitingForCard:
                main_display.Text = "Please, insert your card";
                NumberLabel.Text  = "";
                a1_label.Text     = "";
                a2_label.Text     = "";
                a3_label.Text     = "";
                a4_label.Text     = "";
                b1_label.Text     = "";
                b2_label.Text     = "";
                b3_label.Text     = "";
                b4_label.Text     = "";
                break;

            case MachineState.WaitingForPin:
                main_display.Text = "Please, enter your pin:";
                NumberLabel.Text  = "";
                count             = numberEntered.Length;
                //replace all the numbers of pin with X characters
                for (int i = 0; i < 4; i++)
                {
                    if (count != 0)
                    {
                        NumberLabel.Text += "X ";
                        count--;
                    }
                    else
                    {
                        NumberLabel.Text += "_ ";
                    }
                }
                a1_label.Text = "";
                a2_label.Text = "";
                a3_label.Text = "";
                a4_label.Text = "";
                b1_label.Text = "";
                b2_label.Text = "";
                b3_label.Text = "";
                b4_label.Text = "";
                break;

            case MachineState.MainMenu:
                main_display.Text = "Account number:\n" + curAccNum;
                NumberLabel.Text  = "";
                a3_label.Text     = "";
                a4_label.Text     = "";
                b2_label.Text     = "";
                b3_label.Text     = "";
                b4_label.Text     = "";
                a1_label.Text     = "Check balance";
                a2_label.Text     = "Change pin";
                b1_label.Text     = "Withdraw\nmoney";
                break;

            case MachineState.WithdrawingMoney:
                main_display.Text = "Available balance: £" + bank.getAccountBalance(Convert.ToInt32(curAccNum)).ToString();
                NumberLabel.Text  = "";
                a1_label.Text     = "10";
                a2_label.Text     = "40";
                a3_label.Text     = "500";
                b1_label.Text     = "20";
                b2_label.Text     = "100";
                b3_label.Text     = "Custom";
                b4_label.Text     = "Back";
                break;

            case MachineState.WithdrawingCustomAmount:
                main_display.Text = "Enter the amount\nto be withdrawn:";
                a1_label.Text     = "";
                a2_label.Text     = "";
                a3_label.Text     = "";
                a4_label.Text     = "";
                b1_label.Text     = "";
                b2_label.Text     = "";
                b3_label.Text     = "Back";
                b4_label.Text     = "";
                NumberLabel.Text  = numberEntered;
                break;

            case MachineState.ShowingBalance:
                main_display.Text = "AccountNumber: " + curAccNum + "\nAvailable balance: £" + bank.getAccountBalance(Convert.ToInt32(curAccNum)).ToString();
                NumberLabel.Text  = "";
                a1_label.Text     = "";
                a2_label.Text     = "";
                a3_label.Text     = "";
                a4_label.Text     = "";
                b1_label.Text     = "";
                b2_label.Text     = "";
                b3_label.Text     = "Back";
                b4_label.Text     = "";
                break;

            case MachineState.ChangingPinOldPin:
                Console.WriteLine("gotToOldPinstate");
                main_display.Text = "Enter your old pin:";
                NumberLabel.Text  = "";
                count             = numberEntered.Length;
                //replace all the numbers of pin with X characters

                for (int i = 0; i < 4; i++)
                {
                    if (count != 0)
                    {
                        NumberLabel.Text += "X ";
                        count--;
                    }
                    else
                    {
                        NumberLabel.Text += "_ ";
                    }
                }
                a1_label.Text = "";
                a2_label.Text = "";
                a3_label.Text = "";
                a4_label.Text = "";
                b1_label.Text = "";
                b2_label.Text = "";
                b3_label.Text = "Back";
                b4_label.Text = "";
                break;

            case MachineState.ChangingPinNewPin:
                Console.WriteLine("gotToNewPinstate");
                main_display.Text = "Enter your new pin:";
                NumberLabel.Text  = "";
                count             = numberEntered.Length;
                //replace all the numbers of pin with X characters

                for (int i = 0; i < 4; i++)
                {
                    if (count != 0)
                    {
                        NumberLabel.Text += "X ";
                        count--;
                    }
                    else
                    {
                        NumberLabel.Text += "_ ";
                    }
                }
                a1_label.Text = "";
                a2_label.Text = "";
                a3_label.Text = "";
                a4_label.Text = "";
                b1_label.Text = "";
                b2_label.Text = "";
                b3_label.Text = "Back";
                b4_label.Text = "";
                break;

            case MachineState.ConfirmWantAnotherAction:
                main_display.Text = "Do you want to perform\nanother action?";
                NumberLabel.Text  = "";
                a1_label.Text     = "";
                a2_label.Text     = "";
                a3_label.Text     = "Yes";
                a4_label.Text     = "";
                b1_label.Text     = "";
                b2_label.Text     = "";
                b3_label.Text     = "No";
                b4_label.Text     = "";
                break;

            case MachineState.InvalidPin:
                main_display.Text          = "Invalid pin entered";
                NumberLabel.Text           = "";
                curState                   = MachineState.WaitingForPin;
                temp_message_timer.Enabled = true;
                break;

            case MachineState.EndMessage:
                main_display.Text          = "Thank you for\nusing our ATM";
                NumberLabel.Text           = "";
                a1_label.Text              = "";
                a2_label.Text              = "";
                a3_label.Text              = "";
                a4_label.Text              = "";
                b1_label.Text              = "";
                b2_label.Text              = "";
                b3_label.Text              = "";
                b4_label.Text              = "";
                numberEntered              = "";
                curAccNum                  = "";
                curState                   = MachineState.WaitingForCard;
                temp_message_timer.Enabled = true;
                break;

            case MachineState.InsufficientFunds:
                main_display.Text          = "Insufficient funds!";
                a1_label.Text              = "";
                a2_label.Text              = "";
                a3_label.Text              = "";
                a4_label.Text              = "";
                b1_label.Text              = "";
                b2_label.Text              = "";
                b3_label.Text              = "";
                b4_label.Text              = "";
                numberEntered              = "";
                curState                   = MachineState.ConfirmWantAnotherAction;
                temp_message_timer.Enabled = true;
                break;

            case MachineState.InvalidInput:
                main_display.Text          = "Invalid pin!";
                NumberLabel.Text           = "";
                a1_label.Text              = "";
                a2_label.Text              = "";
                a3_label.Text              = "";
                a4_label.Text              = "";
                b1_label.Text              = "";
                b2_label.Text              = "";
                b3_label.Text              = "";
                b4_label.Text              = "";
                numberEntered              = "";
                curState                   = MachineState.ConfirmWantAnotherAction;
                temp_message_timer.Enabled = true;
                break;
            }
        }