12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using Wayne.Lib.StateEngine;
- using Wayne.Lib.StateEngine.Generic;
- using WayneChina_IcCardReader_SinoChem.MessageEntity.Incoming;
- namespace SinochemInternetPlusApp.States.ICCardMode
- {
- public class WaitForCardData : TimeoutState<FuelingPoint>
- {
- protected override void Enter(StateEntry stateEntry, ref Transition transition)
- {
- base.Enter(stateEntry, ref transition);
- }
- protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
- {
- if (stateEngineEvent.Type.Equals(EventType.OnlineVerification))
- {
- GenericEvent<CardOnlineVerificationEventArgs> genericEvent = stateEngineEvent as GenericEvent<CardOnlineVerificationEventArgs>;
- if (genericEvent != null && genericEvent.EventArgs != null)
- {
- genericEvent.Handled = true;
- Main.OnlineVerificationRequest = genericEvent.EventArgs.OnlineVerificationRequest;
- transition = new Transition(this, TransitionType.Done);
- }
- }
- else if (stateEngineEvent.Type.Equals(EventType.ReaderStateChanged))
- {
- GenericEvent<CardReaderStateEventArgs> readerEvent = stateEngineEvent as GenericEvent<CardReaderStateEventArgs>;
- if (readerEvent != null && readerEvent.EventArgs != null)
- {
- if (readerEvent.EventArgs.CardReaderState.State == CardReaderState.Idle)
- {
- DebugLog("User aborts card processing before PIN");
- readerEvent.Handled = true;
- transition = new Transition(this, TransitionType.Abort);
- }
- }
- }
- else if (stateEngineEvent.Type.Equals(EventType.ExternalCheckFailure))
- {
- GenericEvent<ExternalCheckFailedEventArgs> e = stateEngineEvent as GenericEvent<ExternalCheckFailedEventArgs>;
- if (e != null && e.EventArgs != null)
- {
- //可能为:1、外部验证错误,2:PIN验证错误
- DebugLog($"Error type: {e.EventArgs.ExternalCheckErrorRequest.ErrorType.ToString()}");
- e.Handled = true;
- transition = new Transition(this, TransitionType.Error);
- }
- }
- }
- protected override void Timeout(ref Transition transition)
- {
- transition = new Transition(this, TransitionType.Timeout);
- }
- protected override int TimeoutInterval =>
- TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.ICCardMode_WaitForCardData, 15);
- }
- }
|