123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- using Edge.Core.IndustryStandardInterface.Pump;
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Threading.Tasks;
- using Wayne.FDCPOSLibrary;
- namespace Dfs.WayneChina.GilbarcoDispenserPayTerminal
- {
- public class GilbarcoPumpHandler : IFdcPumpController
- {
- #region Fields
- private LogicalNozzle nozzle;
- private LogicalDeviceState state = LogicalDeviceState.FDC_READY;
- #endregion
- #region Properties
- public string Name => "GilbarcoPumpHandler";
- public int PumpId { get; }
- //Always use 1, since it's controlled by the terminal.
- public int PumpPhysicalId => 1;
- public IEnumerable<LogicalNozzle> Nozzles => new List<LogicalNozzle> { nozzle };
-
- #endregion
-
- #region Decimal point settings, China domestic standard is: 2
- public int AmountDecimalDigits => 2;
- public int VolumeDecimalDigits => 2;
- public int PriceDecimalDigits => 2;
- public int VolumeTotalizerDecimalDigits => 2;
- #endregion
- #region Events
- public event EventHandler<FdcPumpControllerOnStateChangeEventArg> OnStateChange;
- public event EventHandler<FdcTransactionDoneEventArg> OnCurrentFuellingStatusChange;
- #endregion
- #region Logger
- private static NLog.Logger logger = NLog.LogManager.LoadConfiguration("NLog.config").GetLogger("IPosPlusApp");
- #endregion
- #region Construction
- public GilbarcoPumpHandler(int pumpId)
- {
- PumpId = pumpId;
- nozzle = new LogicalNozzle(pumpId, Convert.ToByte(pumpId), 1, null);
- }
- #endregion
- #region IC card terminal handler
- public GilbarcoPayTerminalHandler GilbarcoPayTerminalHandler { get; }
- #endregion
- #region Methods
- public Task<bool> AuthorizeAsync(byte logicalNozzleId)
- {
- return Task.FromResult(true);
- }
- public Task<bool> AuthorizeWithAmountAsync(int moneyAmountWithoutDecimalPoint, byte logicalNozzleId)
- {
- return Task.FromResult(true);
- }
- public Task<bool> AuthorizeWithVolumeAsync(int volumnWithoutDecimalPoint, byte logicalNozzleId)
- {
- return Task.FromResult(true);
- }
- public Task<bool> ChangeFuelPriceAsync(int newPriceWithoutDecimalPoint, byte logicalNozzleId)
- {
- throw new NotImplementedException();
- }
- public Task<bool> FuelingRoundUpByAmountAsync(int amount)
- {
- return Task.FromResult(true);
- }
- public Task<bool> FuelingRoundUpByVolumeAsync(int volume)
- {
- return Task.FromResult(true);
- }
- public Task<bool> LockNozzleAsync(byte logicalNozzleId)
- {
- return Task.FromResult(true);
- }
- public void OnFdcServerInit(Dictionary<string, object> parameters)
- {
- }
- public Task<LogicalDeviceState> QueryStatusAsync()
- {
- return Task.FromResult(LogicalDeviceState.FDC_READY);
- }
- public Task<Tuple<int, int>> QueryTotalizerAsync(byte logicalNozzleId)
- {
- return Task.FromResult(new Tuple<int, int>(-1, -1));
- }
- public Task<bool> ResumeFuellingAsync()
- {
- //Not supported, return false;
- return Task.FromResult(false);
- }
- public Task<bool> SuspendFuellingAsync()
- {
- //Not supported, return false;
- return Task.FromResult(false);
- }
- public Task<bool> UnAuthorizeAsync(byte logicalNozzleId)
- {
- //Not supported, return false;
- return Task.FromResult(false);
- }
- public Task<bool> UnlockNozzleAsync(byte logicalNozzleId)
- {
- return Task.FromResult(true);
- }
- #endregion
- #region Pump State and Fueling Status
- public void FirePumpStateChange(LogicalDeviceState state)
- {
- var logicalNozzle = new LogicalNozzle(PumpId, Convert.ToByte(PumpPhysicalId), 1, null);
- this.state = state;
- if (state == LogicalDeviceState.FDC_READY)
- OnStateChange?.Invoke(this, new FdcPumpControllerOnStateChangeEventArg(LogicalDeviceState.FDC_READY));
- else
- OnStateChange?.Invoke(this, new FdcPumpControllerOnStateChangeEventArg(state, logicalNozzle));
- }
- public void FireNozzleStateChange(LogicalDeviceState? state)
- {
- nozzle = new LogicalNozzle(PumpId, Convert.ToByte(PumpPhysicalId), 1, null);
- if (state.HasValue)
- nozzle.LogicalState = state;
- else
- nozzle.LogicalState = null;
- OnStateChange?.Invoke(this, new FdcPumpControllerOnStateChangeEventArg(LogicalDeviceState.FDC_READY, nozzle));
- }
- public void FireFuelingStatusChange(FdcTransaction fuelingTransaction)
- {
- OnCurrentFuellingStatusChange?.Invoke(this, new FdcTransactionDoneEventArg(fuelingTransaction));
- }
- #endregion
- }
- }
|