using SinochemCarplateService.Models; using System; using System.Collections.Generic; using Wayne.Lib; using Wayne.Lib.StateEngine; using Wayne.Lib.StateEngine.Generic; namespace SinochemInternetPlusApp.States.CarPlateMode { class CalculateMAC : TimeoutState { private byte sqNo; protected override void Enter(StateEntry stateEntry, ref Transition transition) { base.Enter(stateEntry, ref transition); transition = new Transition(this, TransitionType.Done); return; DebugLog("Start to calculate MAC"); //Main.GetMAC(new CarPlateTrxRequest() //{ // amount = 10.00, // card_No = "08888118001000078417", // car_Number = "晋A12345", // gun = "2", //}, out sqNo); } protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition) { if (stateEngineEvent.Type.Equals(EventType.DataSigned)) { GenericEvent signDataEvent = stateEngineEvent as GenericEvent; if (signDataEvent != null && signDataEvent.EventArgs != null) { signDataEvent.Handled = true; DebugLog($" Signed Data arrived\n Mac Value: {signDataEvent.EventArgs.SignedDataResponse.MacValue}\n"); ; transition = new Transition(this, TransitionType.Done); } } //if (stateEngineEvent.Type is EventType) //{ // switch ((EventType)stateEngineEvent.Type) // { // case EventType.ICCardReaderMACResponse: // transition = new Transition(this, TransitionType.ICCardReaderMACResponse); // 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.CarPlateMode_CalculateMAC, 10); } }