123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System;
- using System.Collections.Generic;
- using Wayne.Lib;
- using Wayne.Lib.StateEngine;
- using Wayne.Lib.StateEngine.Generic;
- namespace SinochemInternetPlusApp.States.Shared
- {
- class AuthorizePump : TimeoutState<FuelingPoint>
- {
- protected override void Enter(StateEntry stateEntry, ref Transition transition)
- {
- base.Enter(stateEntry, ref transition);
- Main.AuthorizePumpAsync(0); // auth unlimited amount
- }
- protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
- {
- if (stateEngineEvent.Type is EventType)
- {
- switch ((EventType)stateEngineEvent.Type)
- {
- case EventType.PumpAuthOk:
- if (Main.CurrentTrxMode == TransactionMode.CarPlateMode || Main.CurrentTrxMode == TransactionMode.ICCardMode)
- {
- var genericEvent = stateEngineEvent as GenericEvent<GenericEventArg<string>>;
- if (genericEvent != null && Main.CurrentEpsTrx != null)
- {
- Main.CurrentEpsTrx.Model.auth_time = genericEvent.EventArgs.Arg;
- Main.CurrentEpsTrx.Model.trx_status = EpsTrxStatus.Fueling;
- Main.CurrentEpsTrx.SaveToDb();
- }
- }
- transition = new Transition(this, TransitionType.PumpAuthOk);
- stateEngineEvent.Handled = true;
- break;
- case EventType.PumpAuthFailed:
- transition = new Transition(this, TransitionType.PumpAuthFailed);
- stateEngineEvent.Handled = true;
- break;
- }
- }
- }
- protected override void Timeout(ref Transition transition)
- {
- transition = new Transition(this, TransitionType.Timeout);
- }
- protected override int TimeoutInterval =>
- TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.Shared_AuthorizePump, 10);
- }
- }
|