1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- 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<IProcessor> processors)
- {
- var fdcServerApp = processors.OfType<FdcServerHostApp>().FirstOrDefault();
- if (fdcServerApp == null) throw new ArgumentNullException("Can't find the FdcServerHostApp from processors");
- var veederRootAtgConsoleHandler = processors.OfType<VeederRoot_ATG_Console.Handler>().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<Tuple<byte, double, double>>() {
- new Tuple<byte, double, double>(
- 9,
- a.Transaction.VolumeTotalizer??-1,
- a.Transaction.Volumn) })
- );
- };
- }
- public async Task<bool> Start()
- {
- this.isStopped = false;
- return true;
- }
- public async Task<bool> Stop()
- {
- this.isStopped = true;
- return true;
- }
- }
- }
|