コード例 #1
0
        public void ChargeTimeEntered(object sender, ChargePhone.ChargeTimeEventArgs e)
        {
            //Transact PaymentForm = sender as Transact;
            ChargePhone        ChargePhoneForm = sender as ChargePhone;
            NextStageEventArgs nextStageEvent  = new NextStageEventArgs();
            EventHandler <NextStageEventArgs> GoToNextHandler = gotoNextStage;

            if (GoToNextHandler == null)
            {
                return;   //error
            }
            CurrentUIstageState           = e_CurrentUIstageState.USER_SELECTED;
            nextStageEvent.UI_Stage_State = CurrentUIstageState;
            nextStageEvent.UI_Stage       = CurrentUIstage;
            GoToNextHandler(this, nextStageEvent);
            //log Status
            //Check that current STAGE is the slot selection STAGE
            if (CurrentUIstage == e_CurrentUIstage.CHARGE_TIME_STAGE)
            {
                this.CurrentSlotChargeTime = e.ChargeTime;
                this.MoneyCharged          = this.getMoneyCharged();
                Console.WriteLine("Passed this part");
                CurrentUIstageState = e_CurrentUIstageState.PROCESSING_INPUT;
                //log Status
                //Check that the current mode is charging

                if (ChargingOrRetrieving == e_ChargingOrRetrieving.CHARGING)
                {
                    //  m_Slot[CurrentSlot].setChargeTime(CurrentSlotChargeTime);
                    CurrentUIstage      = e_CurrentUIstage.PASSWORD_GENERATION_STAGE;
                    CurrentUIstageState = e_CurrentUIstageState.WAITING_FOR_INPUT;
                    //log Status
                    nextStageEvent.UI_Stage_State = CurrentUIstageState;
                    nextStageEvent.UI_Stage       = CurrentUIstage;
                    GoToNextHandler(this, nextStageEvent);
                    // mainForm.showChargeTimeSTAGE();
                    //PaymentForm.Hide();
                }
                else
                {
                    //post error
                }
            }
        }
コード例 #2
0
        public void ChargeRetrieveEvent(object sender, QikTop.ChargeRetrieveEventArgs e)
        {
            QikTop             QikTopForm     = sender as QikTop;
            NextStageEventArgs nextStageEvent = new NextStageEventArgs();
            EventHandler <NextStageEventArgs> GoToNextHandler = gotoNextStage;

            if (GoToNextHandler == null)
            {
                return;     //error
            }
            CurrentUIstageState           = e_CurrentUIstageState.USER_SELECTED;
            nextStageEvent.UI_Stage_State = CurrentUIstageState;
            nextStageEvent.UI_Stage       = CurrentUIstage;
            // GoToNextHandler(this, nextStageEvent);
            //log Status
            //Check that current STAGE is the slot selection STAGE

            if (CurrentUIstage == e_CurrentUIstage.START_STAGE)
            {
                ChargingOrRetrieving = e.ChargeRetrieve;
                CurrentUIstageState  = e_CurrentUIstageState.PROCESSING_INPUT;
                //log Status
                nextStageEvent.UI_Stage_State = CurrentUIstageState;
                nextStageEvent.UI_Stage       = CurrentUIstage;
                GoToNextHandler(this, nextStageEvent);
                //Check that the current mode is charging
                // QikTopForm.gotoSlotSelection();
                CurrentUIstage      = e_CurrentUIstage.SLOT_SELECTION_STAGE;
                CurrentUIstageState = e_CurrentUIstageState.WAITING_FOR_INPUT;
                //log Status
                nextStageEvent.UI_Stage_State = CurrentUIstageState;
                nextStageEvent.UI_Stage       = CurrentUIstage;
                GoToNextHandler(this, nextStageEvent);
            }
            else
            {
                //post error
            }
        }
コード例 #3
0
        public void PasswordEntered(object sender, ChargePhone.PasswordEventArgs e)
        {
            //Transact PaymentForm = sender as Transact;
            ChargePhone        ChargePhoneForm = sender as ChargePhone;
            NextStageEventArgs nextStageEvent  = new NextStageEventArgs();
            EventHandler <NextStageEventArgs> GoToNextHandler = gotoNextStage;

            if (GoToNextHandler == null)
            {
                return;     //error
            }
            CurrentUIstageState           = e_CurrentUIstageState.USER_SELECTED;
            nextStageEvent.UI_Stage_State = CurrentUIstageState;
            nextStageEvent.UI_Stage       = CurrentUIstage;
            GoToNextHandler(this, nextStageEvent);
            //log Status
            //Check that current STAGE is the slot selection STAGE
            if (CurrentUIstage == e_CurrentUIstage.PASSWORD_GENERATION_STAGE)
            {
                CurrentSlotPassword = e.Password;
                CurrentUIstageState = e_CurrentUIstageState.PROCESSING_INPUT;
                //log Status
                //Check that the current mode is charging
                if (ChargingOrRetrieving == e_ChargingOrRetrieving.CHARGING)
                {
                    //m_Slot[CurrentSlot].setChargeTime(CurrentSlotChargeTime);
                    CurrentUIstage      = e_CurrentUIstage.PAYMENT_STAGE;
                    CurrentUIstageState = e_CurrentUIstageState.WAITING_FOR_INPUT;
                    //log Status
                    nextStageEvent.UI_Stage_State = CurrentUIstageState;
                    nextStageEvent.UI_Stage       = CurrentUIstage;
                    GoToNextHandler(this, nextStageEvent);
                    //log Status
                    // mainForm.showChargeTimeSTAGE();
                    //PaymentForm.Hide();

                    // System.Threading.Thread.Sleep(2000);
                    MoneyReceived = m_MoneyMachine.getMoney(getMoneyCharged());
                    Console.WriteLine("Received  " + MoneyReceived);
                    if (MoneyReceived == 0)    //User didn't insert
                    {
                        CurrentUIstageState = e_CurrentUIstageState.USER_ERROR;
                    }
                    else if (MoneyReceived == -1)    //
                    {
                        CurrentUIstageState = e_CurrentUIstageState.HARDWARE_ERROR;
                    }
                    else
                    {
                        CurrentUIstageState           = e_CurrentUIstageState.DONE;
                        nextStageEvent.UI_Stage_State = CurrentUIstageState;
                        nextStageEvent.UI_Stage       = CurrentUIstage;
                        //log Status
                        GoToNextHandler(this, nextStageEvent);
                        Console.WriteLine("Going to Insert Money");
                        //System.Threading.Thread.Sleep(3000);
                        //dispense change
                        bool result = m_ChangeDispenser.dispenseChange(MoneyReceived - MoneyCharged);
                        CurrentUIstage                = e_CurrentUIstage.DISPENSE_CHANGE_STAGE;
                        CurrentUIstageState           = e_CurrentUIstageState.GENERATING_FEEDBACK;
                        nextStageEvent.UI_Stage_State = CurrentUIstageState;
                        nextStageEvent.UI_Stage       = CurrentUIstage;
                        //log Status
                        GoToNextHandler(this, nextStageEvent);
                        Console.WriteLine("Going to Dispense change");
                        // System.Threading.Thread.Sleep(3000);
                        if (!result)
                        {
                            CurrentUIstageState = e_CurrentUIstageState.HARDWARE_ERROR;
                            //log error
                        }
                        else
                        {
                            CurrentUIstage                = e_CurrentUIstage.PRINT_RECEIPT_STAGE;
                            CurrentUIstageState           = e_CurrentUIstageState.GENERATING_FEEDBACK;
                            nextStageEvent.UI_Stage_State = CurrentUIstageState;
                            nextStageEvent.UI_Stage       = CurrentUIstage;
                            //log Status
                            GoToNextHandler(this, nextStageEvent);
                            m_Printer.print("Slot Selected is " + CurrentSlot + "\r\n" +
                                            "Time is " + DateTime.Now + "\r\n" +
                                            "Charge time is  " + CurrentSlotChargeTime + "\r\n" +
                                            "Password is " + CurrentSlotPassword + "\r\n" +
                                            "Money requested was " + MoneyCharged + "\r\n" +
                                            "Money received is " + MoneyReceived + "\r\n" +
                                            "Change dispensed is " + (MoneyReceived - MoneyCharged) + "\r\n");
                            CurrentUIstage                = e_CurrentUIstage.PRINT_RECEIPT_STAGE;
                            CurrentUIstageState           = e_CurrentUIstageState.DONE;
                            nextStageEvent.UI_Stage_State = CurrentUIstageState;
                            nextStageEvent.UI_Stage       = CurrentUIstage;
                            GoToNextHandler(this, nextStageEvent);
                            Console.WriteLine("Going to printing");
                            // System.Threading.Thread.Sleep(2000);

                            //insert device
                            CurrentUIstage                = e_CurrentUIstage.INSERT_DEVICE_STAGE;
                            CurrentUIstageState           = e_CurrentUIstageState.WAITING_FOR_INPUT;
                            nextStageEvent.UI_Stage_State = CurrentUIstageState;
                            nextStageEvent.UI_Stage       = CurrentUIstage;
                            GoToNextHandler(this, nextStageEvent);
                            Console.WriteLine("Going to Insert device");
                            // System.Threading.Thread.Sleep(2000);

                            //go to start
                            //insert device
                            CurrentUIstage                = e_CurrentUIstage.START_STAGE;
                            CurrentUIstageState           = e_CurrentUIstageState.WAITING_FOR_INPUT;
                            nextStageEvent.UI_Stage_State = CurrentUIstageState;
                            nextStageEvent.UI_Stage       = CurrentUIstage;
                            GoToNextHandler(this, nextStageEvent);
                            Console.WriteLine("Going to Start");
                        }
                    }
                }
                else
                {
                    //post error
                }
            }
        }
コード例 #4
0
        public void SlotSelected(object sender, Qik.ChargePhone.SlotSelectedEventArgs e)
        {
            //ChargePhone SlotSelectionForm = sender as ChargePhone;
            NextStageEventArgs nextStageEvent = new NextStageEventArgs();
            EventHandler <NextStageEventArgs> GoToNextHandler = gotoNextStage;

            if (GoToNextHandler == null)
            {
                return;   //error
            }
            CurrentUIstageState           = e_CurrentUIstageState.USER_SELECTED;
            nextStageEvent.UI_Stage_State = CurrentUIstageState;
            nextStageEvent.UI_Stage       = CurrentUIstage;
            GoToNextHandler(this, nextStageEvent);       //Trigger event
            Console.WriteLine("Slot select part 1");
            //log Status
            //Check that current STAGE is the slot selection STAGE
            if (CurrentUIstage == e_CurrentUIstage.SLOT_SELECTION_STAGE)
            {
                CurrentSlot         = e.Slot;
                CurrentUIstageState = e_CurrentUIstageState.PROCESSING_INPUT;
                //log Status
                nextStageEvent.UI_Stage_State = CurrentUIstageState;
                nextStageEvent.UI_Stage       = CurrentUIstage;
                GoToNextHandler(this, nextStageEvent);
                Console.WriteLine("Slot select part 1");
                //Check that the current mode is charging
                if (ChargingOrRetrieving == e_ChargingOrRetrieving.CHARGING)
                {
                    //Update list of slots if necessary
                    //  if (AvailableSlots.IndexOf(m_Slot[CurrentSlot]) != -1)
                    {
                        // AvailableSlots.Remove(m_Slot[CurrentSlot]);
                        // BusySlots.Add(m_Slot[CurrentSlot]);
                        // m_Slot[CurrentSlot].setStatus(Slot.e_Status.OCCUPIED_CHARGING);
                        CurrentUIstage                = e_CurrentUIstage.CHARGE_TIME_STAGE;
                        CurrentUIstageState           = e_CurrentUIstageState.WAITING_FOR_INPUT;
                        nextStageEvent.UI_Stage_State = CurrentUIstageState;
                        nextStageEvent.UI_Stage       = CurrentUIstage;
                        GoToNextHandler(this, nextStageEvent);
                        //log Status
                    }
                    //   else
                    {
                        //post slot selection error
                    }
                }
                else
                {
                    //Update list of slots if necessary
                    if (BusySlots.IndexOf(m_Slot[CurrentSlot]) != -1)
                    {
                        // BusySlots.Remove(m_Slot[CurrentSlot]);
                        // AvailableSlots.Add(m_Slot[CurrentSlot]);
                        // m_Slot[CurrentSlot].setStatus(Slot.e_Status.Available);
                        CurrentUIstage      = e_CurrentUIstage.PASSWORD_ENTRY_STAGE;
                        CurrentUIstageState = e_CurrentUIstageState.WAITING_FOR_INPUT;
                        //log Status
                        nextStageEvent.UI_Stage_State = CurrentUIstageState;
                        nextStageEvent.UI_Stage       = CurrentUIstage;
                        GoToNextHandler(this, nextStageEvent);
                        // mainForm.showPasswordEntrySTAGE();
                    }
                    else if (FinishedSlots.IndexOf(m_Slot[CurrentSlot]) != -1)
                    {
                        // FinishedSlots.Remove(m_Slot[CurrentSlot]);
                        // AvailableSlots.Add(m_Slot[CurrentSlot]);
                        // m_Slot[CurrentSlot].setStatus(Slot.e_Status.Available);
                        CurrentUIstage      = e_CurrentUIstage.PASSWORD_ENTRY_STAGE;
                        CurrentUIstageState = e_CurrentUIstageState.WAITING_FOR_INPUT;
                        //log Status
                        nextStageEvent.UI_Stage_State = CurrentUIstageState;
                        nextStageEvent.UI_Stage       = CurrentUIstage;
                        GoToNextHandler(this, nextStageEvent);
                        // mainForm.showPasswordEntrySTAGE();
                    }
                    else if (OverdueSlots.IndexOf(m_Slot[CurrentSlot]) != -1)
                    {
                        //  OverdueSlots.Remove(m_Slot[CurrentSlot]);
                        //  AvailableSlots.Add(m_Slot[CurrentSlot]);
                        // m_Slot[CurrentSlot].setStatus(Slot.e_Status.Available);
                        CurrentUIstage      = e_CurrentUIstage.PAYMENT_STAGE;
                        CurrentUIstageState = e_CurrentUIstageState.WAITING_FOR_INPUT;
                        //log Status
                        nextStageEvent.UI_Stage_State = CurrentUIstageState;
                        nextStageEvent.UI_Stage       = CurrentUIstage;
                        GoToNextHandler(this, nextStageEvent);
                        // mainForm.showPaymentSTAGE();
                    }
                    else
                    {
                        //post slot selection error
                    }
                }
            }
        }