123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- 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
- {
- public class ShowTrxListPendingFueling : TimeoutState<FuelingPoint>
- {
- private int requestId;
- protected override void Enter(StateEntry stateEntry, ref Transition transition)
- {
- base.Enter(stateEntry, ref transition);
- Main.NewEpsTrx.UpdateTrxStatusToDb(EpsTrxStatus.BeforeFueling);
- //Main.CurrentEpsTrx.UpdateTrxStatusToDb(EpsTrxStatus.BeforeFueling);
- if (!Main.HasBigSreen())
- {
- Main.DebugLogger.Add("No screen configured");
- transition = new Transition(this, TransitionType.Done);
- return;
- }
- var validTrx = EpsTransactionQuery.GetValidCarPlateEpsTrxModels(
- Main.GetAllNozzlesOnThisSide(),
- ConfigurationValues.AlreadyDoneEpsTrxCountPerDisplay,
- Main.DebugLogger);
- Main.ActiveTrx = validTrx;
- //Main.NewEpsTrx.Model.AvailableNozzleGrade = Main.GetAvailableNozzleInfo();
- var nozzleIdGradeNameDic = Main.GetAvailableNozzleInfo();
- if (nozzleIdGradeNameDic != null)
- {
- foreach (var trx in validTrx)
- {
- if (trx.trx_status == EpsTrxStatus.BeforeFueling || trx.trx_status == EpsTrxStatus.Fueling)
- {
- trx.AvailableNozzleGrade = nozzleIdGradeNameDic;
- }
- }
- }
- var text = Main.Eps.CreateDisplayTrxCommand(validTrx, out requestId, 0);
- if (Main.Eps.CarPlateHandler != null)
- {
- DebugLog(text);
- Main.Eps.CarPlateHandler.BroadcastMessageViaFdc(text);
- Main.DebugLogger.Add("request Id: " + requestId);
- if (!Main.ContainsRequestId(requestId))
- {
- Main.AddRequestId(requestId);
- }
- }
- }
- protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
- {
- if (stateEngineEvent.Type.Equals(EventType.DisplayResponseReceived))
- {
- var e = stateEngineEvent as GenericEvent<DisplayResponseEventArgs>;
- if (e != null && e.EventArgs != null)
- {
- Main.DebugLogger.Add("request Id: " + requestId + " incoming event request Id:" + e.EventArgs.DispResponse.RequestId);
- if (requestId == e.EventArgs.DispResponse.RequestId)
- {
- e.Handled = true;
- if (Main.ContainsRequestId(requestId))
- Main.RemoveRequestId(requestId);
- transition = new Transition(this, TransitionType.Done);
- }
- }
- }
- else if (stateEngineEvent.Type.Equals(EventType.NozzleLifted))
- {
- 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_ShowTrxListPendingFueling, 60);
- }
- }
|