using Applications.FDC; using Edge.Core.Processor;using Edge.Core.IndustryStandardInterface.Pump; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace VeederRootAtgConsoleDispenserInterfaceApp { public class App : IAppProcessor { public string MetaConfigName { get; set; } private bool isStopped = false; public void Init(IEnumerable processors) { var fdcServerApp = processors.OfType().FirstOrDefault(); if (fdcServerApp == null) throw new ArgumentNullException("Can't find the FdcServerHostApp from processors"); var veederRootAtgConsoleHandler = processors.OfType().FirstOrDefault(); if (veederRootAtgConsoleHandler == null) throw new ArgumentNullException("Can't find the VeederRoot_ATG_Console.Handler from processors"); fdcServerApp.OnStateChange += async (s, a) => { if (this.isStopped) return; var pump = s as IFdcPumpController; if (a.NewPumpState == Wayne.FDCPOSLibrary.LogicalDeviceState.FDC_AUTHORISED) await veederRootAtgConsoleHandler.NotifyFuelTrxEventToAtgConsoleAsync( new VeederRoot_ATG_Console.MessageEntity.DispenserInterface.Outgoing.StartEventReportRequest( 9, 0, 0, (byte)pump.PumpId)); }; fdcServerApp.OnCurrentFuellingStatusChange += async (s, a) => { if (this.isStopped) return; var pump = s as IFdcPumpController; if (a.Transaction.Finished == true) await veederRootAtgConsoleHandler.NotifyFuelTrxEventToAtgConsoleAsync( new VeederRoot_ATG_Console.MessageEntity.DispenserInterface.Outgoing.StopEventReportRequest( 1, 0, 0, (byte)pump.PumpId, VeederRoot_ATG_Console.MessageEntity.DispenserInterface.Outgoing.StopEventReportRequest.FuelingInfo.SingleProductDispensed, new List>() { new Tuple( 9, a.Transaction.VolumeTotalizer??-1, a.Transaction.Volumn) }) ); }; } public async Task Start() { this.isStopped = false; return true; } public async Task Stop() { this.isStopped = true; return true; } } }