using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Wayne.Lib.StateEngine; using Wayne.Lib.StateEngine.Generic; namespace SinochemInternetPlusApp.States.CarPlateManualMode { public class ShowTrxListFueling : TimeoutState { private int requestId; protected override void Enter(StateEntry stateEntry, ref Transition transition) { base.Enter(stateEntry, ref transition); if (Main.CurrentEpsTrx != null) { Main.DebugLogger.Add("Main.CurrentEpsTrx not null"); var validTrx = EpsTransactionQuery.GetValidCarPlateEpsTrxModels( Main.GetAllNozzlesOnThisSide(), ConfigurationValues.AlreadyDoneEpsTrxCountPerDisplay, Main.DebugLogger); Main.ActiveTrx = validTrx; //Main.CurrentEpsTrx.Model.AvailableNozzleGrade = Main.GetAvailableNozzleInfo(); var nozzleIdGradeNameDic = Main.Eps.NozzleMappingGradeName(); if (nozzleIdGradeNameDic != null) { Main.DebugLogger.Add("nozzleIdGradeNameDic not null"); foreach (var trx in validTrx) { if (trx.id == Main.CurrentEpsTrx.Model.id) { trx.nozzleSelected = Main.CurrentEpsTrx.Model.nozzleSelected; Main.DebugLogger.Add("trx.nozzleSelected set"); } if (trx.trx_status == EpsTrxStatus.BeforeFueling || trx.trx_status == EpsTrxStatus.Fueling) { trx.AvailableNozzleGrade = nozzleIdGradeNameDic; Main.DebugLogger.Add("trx.AvailableNozzleGrade set"); } } } var text = Main.Eps.CreateDisplayTrxCommand(validTrx, out requestId, 1); if (Main.Eps.CarPlateHandler != null) { Main.DebugLogger.Add("Abby" + text); Main.Eps.CarPlateHandler.BroadcastMessageViaFdc(text); if (!Main.ContainsRequestId(requestId)) Main.AddRequestId(requestId); } } else { DebugLog("Unable to show the fueling transactions list"); transition = new Transition(this, TransitionType.Done); } } protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition) { if (stateEngineEvent.Type.Equals(EventType.DisplayResponseReceived)) { var e = stateEngineEvent as GenericEvent; if (e != null && e.EventArgs != null) { if (requestId == e.EventArgs.DispResponse.RequestId) { e.Handled = true; if (Main.ContainsRequestId(requestId)) Main.RemoveRequestId(requestId); transition = new Transition(this, TransitionType.Done); } } } } protected override void Timeout(ref Transition transition) { transition = new Transition(this, TransitionType.Timeout); } protected override int TimeoutInterval => TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.CarPlateMode_ShowTrxListFueling, 10); } }