| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539 |
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Configuration;
- using System.IO.Ports;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using Timer = System.Timers.Timer;
- using System.Collections;
- using Edge.Core.Processor;
- using Edge.Core.IndustryStandardInterface.Pump;
- using Wayne.FDCPOSLibrary;
- using System.Xml;
- using Edge.Core.Database.Models;
- using System.Threading.Tasks;
- using Edge.Core.Processor.Communicator;
- using Edge.Core.Processor.Dispatcher.Attributes;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Logging.Abstractions;
- using Stateless;
- using Microsoft.Extensions.DependencyInjection;
- namespace ZhongSheng_NonIC_Pump
- {
- public class StatePumpHandler : IFdcPumpController//, IDeviceHandler<byte[], MessageTemplateBase>
- {
- private IServiceProvider services;
- private IContext<byte[], MessageTemplateBase> context;
- private ILogger logger = NullLogger.Instance;
- private PumpGroupHandler parent;
- private LogicalDeviceState currentState = LogicalDeviceState.FDC_OFFLINE;
- public event EventHandler<FdcPumpControllerOnStateChangeEventArg> OnStateChange;
- /// <summary>
- /// fired on fueling process is on going, the fuel amount should keep changing.
- /// </summary>
- public event EventHandler<FdcTransactionDoneEventArg> OnCurrentFuellingStatusChange;
- StateMachine<LogicalDeviceState, Trigger> stateless
- = new StateMachine<LogicalDeviceState, Trigger>(LogicalDeviceState.FDC_OFFLINE);
- protected List<LogicalNozzle> nozzles;
- public IEnumerable<LogicalNozzle> Nozzles => this.nozzles;
- protected enum Trigger
- {
- //AnyPumpMsgReceived,
- AnyPumpMsgHaveNotReceivedForWhile,
- NozzleLifted_And_开机,
- NozzleLifted_And_停机,
- NozzleReplaced_And_开机,
- NozzleReplaced_And_停机,
- NozzleFuelNumbersIsRunning,
- //PumpAuthorizedByFC,
- }
- public int AmountDecimalDigits => 2;
- public int VolumeDecimalDigits => 2;
- public int PriceDecimalDigits => 2;
- public int VolumeTotalizerDecimalDigits => 2;
- /// <summary>
- /// </summary>
- public int PumpId { get; private set; }
- /// <summary>
- /// will set it to 油机端的配置值,枪号为以整个加油站为基础的油枪顺序编号, 就是全站枪号
- /// </summary>
- public int PumpPhysicalId { get; private set; }
- public string Name => "ZhongSheng_NonIC_Pump";
- /// <summary>
- /// 每把枪就是一个Pump即一个加油点
- /// </summary>
- /// <param name="pumpId"></param>
- /// <param name="dispenserSideNozzleId">油机端的配置值,枪号为以整个加油站为基础的油枪顺序编号, 就是全站枪号?</param>
- public StatePumpHandler(PumpGroupHandler parent, byte pumpId,
- byte dispenserSideNozzleId, IServiceProvider services)
- {
- this.parent = parent;
- this.services = services;
- var loggerFactory = services.GetRequiredService<ILoggerFactory>();
- this.logger = loggerFactory.CreateLogger("PumpHandler");
- this.PumpId = pumpId;
- this.PumpPhysicalId = dispenserSideNozzleId;
- //每把枪就是一个Pump即一个加油点
- this.nozzles = new List<LogicalNozzle>() { new LogicalNozzle(pumpId, dispenserSideNozzleId, 1, null) };
- }
- internal void TriggerPumpOffline()
- {
- if (this.currentState != LogicalDeviceState.FDC_OFFLINE)
- {
- this.currentState = LogicalDeviceState.FDC_OFFLINE;
- this.OnStateChange?.Invoke(this, new FdcPumpControllerOnStateChangeEventArg(LogicalDeviceState.FDC_OFFLINE));
- }
- }
- public void Init(IContext<byte[], MessageTemplateBase> context)
- {
- this.context = context;
- }
- public async Task Process(IContext<byte[], MessageTemplateBase> context)
- {
- this.context = context;
- if (context.Incoming.Message is PumpInIdleResponse)
- {
- if (this.currentState != LogicalDeviceState.FDC_READY)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", Switched to FDC_READY from " + this.currentState + " by received a PumpInIdleResponse");
- this.currentState = LogicalDeviceState.FDC_READY;
- this.OnStateChange?.Invoke(this, new FdcPumpControllerOnStateChangeEventArg(LogicalDeviceState.FDC_READY));
- }
- }
- else if (context.Incoming.Message is PumpInOperationResponse pumpInOperation)
- {
- if (pumpInOperation.PumpStateBlocks?.Any(s => s.NozzleNumber == this.PumpPhysicalId) ?? false)
- {
- var pumpStateBlock = pumpInOperation.PumpStateBlocks.First(s => s.NozzleNumber == this.PumpPhysicalId);
- if (pumpStateBlock.NozzleLiftState == NozzleLiftStateEnum.未提)
- {
- if (this.currentState != LogicalDeviceState.FDC_READY)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", Switched to FDC_READY from " + this.currentState + " by PumpState-> " + pumpStateBlock.ToString());
- //if (this.currentState == LogicalDeviceState.FDC_OFFLINE)
- // logger.LogInformation("Pump: " + this.PumpId + ", Pump side 加油机状态信息配置: " + pumpStateBlock.ToString());
- //if (this.currentState == LogicalDeviceState.FDC_FUELLING)
- // logger.LogDebug("Pump: " + this.PumpId + ", Pump side 加油机状态信息配置: " + pumpStateBlock.ToString());
- this.currentState = LogicalDeviceState.FDC_READY;
- this.OnStateChange?.Invoke(this, new FdcPumpControllerOnStateChangeEventArg(LogicalDeviceState.FDC_READY));
- }
- }
- else if (pumpStateBlock.NozzleLiftState == NozzleLiftStateEnum.已提)
- {
- if (pumpStateBlock.AuthMode == PumpAuthModeEnum.自授权模式)
- {
- /*in this mode, pump will auth itself and directly go into Athorized state, and then fuelling state.
- */
- if (this.currentState != LogicalDeviceState.FDC_AUTHORISED)
- {
- //simulate the Calling state by request from vendor for a temp solution, this will let the FdcServer trigger a authorize calling, but later he said this is not necessary.
- //logger.LogDebug("Pump: " + this.PumpId + ", Switched to simulated FDC_CALLING from " + this.currentState + " by PumpState-> " + pumpStateBlock.ToString());
- //this.currentState = LogicalDeviceState.FDC_CALLING;
- //this.OnStateChange?.Invoke(this, new FdcPumpControllerOnStateChangeEventArg(LogicalDeviceState.FDC_CALLING, this.nozzles.First()));
- logger.LogDebug("Pump: " + this.PumpId + ", Switched to FDC_AUTHORISED from " + this.currentState + " by PumpState-> " + pumpStateBlock.ToString());
- this.currentState = LogicalDeviceState.FDC_AUTHORISED;
- this.OnStateChange?.Invoke(this, new FdcPumpControllerOnStateChangeEventArg(LogicalDeviceState.FDC_AUTHORISED, this.nozzles.First()));
- }
- }
- else
- {
- if (pumpStateBlock.PumpAuthorizeState == PumpAuthorizeStateEnum.未授权
- && this.currentState != LogicalDeviceState.FDC_CALLING)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", Switched to FDC_CALLING from " + this.currentState + " by PumpState-> " + pumpStateBlock.ToString());
- this.currentState = LogicalDeviceState.FDC_CALLING;
- this.OnStateChange?.Invoke(this, new FdcPumpControllerOnStateChangeEventArg(LogicalDeviceState.FDC_CALLING, this.nozzles.First()));
- }
- else if (pumpStateBlock.PumpAuthorizeState == PumpAuthorizeStateEnum.授权成功
- && this.currentState != LogicalDeviceState.FDC_AUTHORISED)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", Switched to FDC_AUTHORISED from " + this.currentState + " by PumpState-> " + pumpStateBlock.ToString());
- this.currentState = LogicalDeviceState.FDC_AUTHORISED;
- this.OnStateChange?.Invoke(this, new FdcPumpControllerOnStateChangeEventArg(LogicalDeviceState.FDC_AUTHORISED, this.nozzles.First()));
- }
- }
- }
- else if (pumpStateBlock.NozzleLiftState == NozzleLiftStateEnum.第二条枪提起)
- {
- this.logger.LogCritical("根据油机方的技术人员说明,对于此项目,我们中控这边对接的油机,都会是单枪单显,或者是2枪2显,不会有单面双单价(2枪共一个加油点)的型号,但是为什么现在收到这样的数据?");
- //if (this.currentState != LogicalDeviceState.FDC_CALLING)
- //{
- // this.currentState = LogicalDeviceState.FDC_CALLING;
- // this.OnStateChange?.Invoke(this, new FdcPumpControllerOnStateChangeEventArg(LogicalDeviceState.FDC_CALLING, this.nozzles.First()));
- //}
- }
- }
- if (pumpInOperation.FuellingDataBlocks?.Any(s => s.NozzleNumber == this.PumpPhysicalId) ?? false)
- {
- var fuellingDataBlock = pumpInOperation.FuellingDataBlocks.First(s => s.NozzleNumber == this.PumpPhysicalId);
- if (this.currentState != LogicalDeviceState.FDC_FUELLING)
- {
- //sometimes the pump will not report authorized state and directly go into fuelling, so here add one from air for process completion.
- if (this.currentState != LogicalDeviceState.FDC_AUTHORISED)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", Switched to FDC_AUTHORISED from " + this.currentState + " by manual inserting");
- this.currentState = LogicalDeviceState.FDC_AUTHORISED;
- this.OnStateChange?.Invoke(this, new FdcPumpControllerOnStateChangeEventArg(LogicalDeviceState.FDC_AUTHORISED, this.nozzles.First()));
- }
- logger.LogDebug("Pump: " + this.PumpId + ", Switched to FDC_FUELLING from " + this.currentState + " by received a FuellingDataBlock-> " + fuellingDataBlock.ToString());
- this.currentState = LogicalDeviceState.FDC_FUELLING;
- this.OnStateChange?.Invoke(this, new FdcPumpControllerOnStateChangeEventArg(LogicalDeviceState.FDC_FUELLING, this.nozzles.First()));
- }
- if (this.logger.IsEnabled(LogLevel.Trace))
- this.logger.LogTrace("Pump " + this.PumpId + ": Reporting Fuelling in progress: " + fuellingDataBlock.ToString());
- this.nozzles.First().RealPriceOnPhysicalPump = fuellingDataBlock.Price;
- this.OnCurrentFuellingStatusChange?.Invoke(this, new FdcTransactionDoneEventArg(new FdcTransaction()
- {
- Amount = fuellingDataBlock.Amount,
- Volumn = fuellingDataBlock.Volume,
- Finished = false,
- Nozzle = this.nozzles.First(),
- Price = fuellingDataBlock.Price,
- }));
- }
- }
- else if (context.Incoming.Message is PumpNotifyTransactionDoneEvent trxDoneEvent
- && trxDoneEvent.交易枪号 == this.PumpPhysicalId)
- {
- logger.LogDebug("Pump " + this.PumpId + ": " + "Report a trx done, 交易金额: " + trxDoneEvent.交易金额 +
- ", 油量总量: " + trxDoneEvent.油量总量 +
- ", 交易单价: " + trxDoneEvent.交易单价);
- this.context.Outgoing.Write(new AckPumpTransactionRequest(trxDoneEvent.FrameSeqNo)
- {
- SourceAddress = this.parent.pumpGroupConfig.FccCommAddress,
- TargetAddress = this.parent.pumpGroupConfig.DispenserCommBoardAddress,
- });
- // at least within 62 years, exception will not throw here
- int newTrxSeqNumber = (int)(DateTime.Now.Subtract(new DateTime(2020, 1, 1)).TotalSeconds);
- this.OnCurrentFuellingStatusChange?.Invoke(this, new FdcTransactionDoneEventArg(new FdcTransaction()
- {
- Amount = trxDoneEvent.交易金额,
- Volumn = trxDoneEvent.交易油量,
- AmountTotalizer = trxDoneEvent.金额总量,
- VolumeTotalizer = trxDoneEvent.油量总量,
- Finished = true,
- Nozzle = this.nozzles.First(),
- Price = trxDoneEvent.交易单价,
- SequenceNumberGeneratedOnPhysicalPump = newTrxSeqNumber,
- }));
- }
- }
- public virtual async Task<LogicalDeviceState> QueryStatusAsync()
- {
- return this.currentState;
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns>MoneyTotalizer:VolumnTotalizer</returns>
- public async Task<Tuple<int, int>> QueryTotalizerAsync(byte logicalNozzleId)
- {
- var result = new System.Tuple<int, int>(-1, -1);
- logger.LogDebug("Pump: " + this.PumpId + ", " + "Start QueryTotalizer pump with logical nozzle: " + logicalNozzleId);
- var nozzlePhysicalId = this.nozzles.FirstOrDefault(n => n.LogicalId == logicalNozzleId)?.PhysicalId;
- if (nozzlePhysicalId == null)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + " Nozzle with logicalId: " + logicalNozzleId + " does not exists, totalizer will return -1, -1");
- return new System.Tuple<int, int>(-1, -1);
- }
- var frameSeqNo = this.parent.GenerateNewFrameNo();
- var response = await this.context.Outgoing.WriteAsync(
- new ReadPumpAccumulatorRequest()
- {
- SourceAddress = this.parent.pumpGroupConfig.FccCommAddress,
- TargetAddress = this.parent.pumpGroupConfig.DispenserCommBoardAddress,
- FrameSeqNo = frameSeqNo
- },
- (request, testResponse) =>
- testResponse is ReadPumpAccumulatorResponse r
- && (r.NozzleAndAccumulators?.Exists(d => d.枪号 == this.PumpPhysicalId) ?? false),
- 3000) as ReadPumpAccumulatorResponse;
- if (response != null)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + " Queried Totalizer for logical nozzle: " + logicalNozzleId +
- ", response detail-> 油量累计: " + (response.NozzleAndAccumulators?.FirstOrDefault(n => n.枪号 == this.PumpPhysicalId)?.油量累计 ?? -1) +
- ", 金额累计: " + (response.NozzleAndAccumulators?.FirstOrDefault(n => n.枪号 == this.PumpPhysicalId)?.金额累计 ?? -1));
- var t = response.NozzleAndAccumulators.First(d => d.枪号 == this.PumpPhysicalId);
- result = new System.Tuple<int, int>((int)t.金额累计, t.油量累计);
- }
- else
- {
- logger.LogError("Pump: " + this.PumpId + ", " + "QueryTotalizer timed out");
- }
- return result;
- }
- public virtual async Task<bool> ChangeFuelPriceAsync(int newPriceWithoutDecimalPoint, byte logicalNozzleId)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + "start ChangeFuelPriceAsync pump with nozzle: " + logicalNozzleId);
- var nozzlePhysicalId = this.nozzles.FirstOrDefault(n => n.LogicalId == logicalNozzleId)?.PhysicalId;
- if (nozzlePhysicalId == null)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + " Nozzle with logicalId: " + logicalNozzleId + " does not exists, ChangeFuelPriceAsync failed");
- return false;
- }
- var frameSeqNo = this.parent.GenerateNewFrameNo();
- var response = await this.context.Outgoing.WriteAsync(
- new ChangePumpPriceRequest((byte)this.PumpPhysicalId, newPriceWithoutDecimalPoint)
- {
- SourceAddress = this.parent.pumpGroupConfig.FccCommAddress,
- TargetAddress = this.parent.pumpGroupConfig.DispenserCommBoardAddress,
- FrameSeqNo = frameSeqNo
- },
- (request, testResponse) =>
- testResponse is AckChangePumpPriceResponse r && r.FrameSeqNo == frameSeqNo, 3000) as AckChangePumpPriceResponse;
- if (response != null)
- {
- if (response.参数 == 0x00)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + " ChangeFuelPrice is Acked.");
- return true;
- }
- else
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + " Nozzle with logicalId: " + logicalNozzleId + " change price response received with an error code: " + response.参数 + ", ChangeFuelPriceAsync failed");
- return false;
- }
- }
- return false;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="logicalNozzleId">useless for this type of pump, it always one pump one nozzle</param>
- /// <returns></returns>
- public virtual async Task<bool> AuthorizeAsync(byte logicalNozzleId)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + "start AuthorizeAsync pump with nozzle: " + logicalNozzleId);
- var nozzlePhysicalId = this.nozzles.FirstOrDefault(n => n.LogicalId == logicalNozzleId)?.PhysicalId;
- if (nozzlePhysicalId == null)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + " Nozzle with logicalId: " + logicalNozzleId + " does not exists, AuthorizeAsync failed");
- return false;
- }
- var frameSeqNo = this.parent.GenerateNewFrameNo();
- var response = await this.context.Outgoing.WriteAsync(
- new StartPumpRequest((byte)this.PumpPhysicalId, StartPumpRequest.PresetType.随意加油, 987699)
- {
- SourceAddress = this.parent.pumpGroupConfig.FccCommAddress,
- TargetAddress = this.parent.pumpGroupConfig.DispenserCommBoardAddress,
- FrameSeqNo = frameSeqNo
- },
- (request, testResponse) =>
- testResponse is AckStartPumpResponse r, 3000) as AckStartPumpResponse;
- if (response != null)
- {
- if (response.参数 == 0x00)
- return true;
- else
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + " Nozzle with logicalId: " + logicalNozzleId + " auth response received with an error code: " + response.参数 + ", AuthorizeAsync failed");
- return false;
- }
- }
- return false;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="moneyAmount"></param>
- /// <param name="logicalNozzleId">useless for this type of pump, it always one pump one nozzle</param>
- /// <returns></returns>
- public virtual async Task<bool> AuthorizeWithAmountAsync(int moneyAmountWithoutDecimalPoint, byte logicalNozzleId)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + "start AuthorizeWithAmountAsync pump with amount: " + moneyAmountWithoutDecimalPoint + ", nozzle: " + logicalNozzleId);
- var nozzlePhysicalId = this.nozzles.FirstOrDefault(n => n.LogicalId == logicalNozzleId)?.PhysicalId;
- if (nozzlePhysicalId == null)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + " Nozzle with logicalId: " + logicalNozzleId + " does not exists, AuthorizeWithAmountAsync failed");
- return false;
- }
- var frameSeqNo = this.parent.GenerateNewFrameNo();
- var response = await this.context.Outgoing.WriteAsync(
- new StartPumpRequest((byte)this.PumpPhysicalId, StartPumpRequest.PresetType.定金额加油, moneyAmountWithoutDecimalPoint)
- {
- SourceAddress = this.parent.pumpGroupConfig.FccCommAddress,
- TargetAddress = this.parent.pumpGroupConfig.DispenserCommBoardAddress,
- FrameSeqNo = frameSeqNo
- },
- (request, testResponse) =>
- testResponse is AckStartPumpResponse r, 3000) as AckStartPumpResponse;
- if (response != null)
- {
- if (response.参数 == 0x00)
- return true;
- else
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + " Nozzle with logicalId: " + logicalNozzleId + " auth response received with an error code: " + response.参数 + ", AuthorizeAsync failed");
- return false;
- }
- }
- return false;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="volumnWithoutDecimalPoint"></param>
- /// <param name="logicalNozzleId">useless for this type of pump, it always one pump one nozzle</param>
- /// <returns></returns>
- public virtual async Task<bool> AuthorizeWithVolumeAsync(int volumnWithoutDecimalPoint, byte logicalNozzleId)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + "start AuthorizeWithVolumeAsync pump with volume: " + volumnWithoutDecimalPoint + ", nozzle: " + logicalNozzleId);
- var nozzlePhysicalId = this.nozzles.FirstOrDefault(n => n.LogicalId == logicalNozzleId)?.PhysicalId;
- if (nozzlePhysicalId == null)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + " Nozzle with logicalId: " + logicalNozzleId + " does not exists, AuthorizeWithVolumeAsync failed");
- return false;
- }
- var frameSeqNo = this.parent.GenerateNewFrameNo();
- var response = await this.context.Outgoing.WriteAsync(
- new StartPumpRequest((byte)this.PumpPhysicalId, StartPumpRequest.PresetType.定油量体积加油, volumnWithoutDecimalPoint)
- {
- SourceAddress = this.parent.pumpGroupConfig.FccCommAddress,
- TargetAddress = this.parent.pumpGroupConfig.DispenserCommBoardAddress,
- FrameSeqNo = frameSeqNo
- },
- (request, testResponse) =>
- testResponse is AckStartPumpResponse r, 3000) as AckStartPumpResponse;
- if (response != null)
- {
- if (response.参数 == 0x00)
- return true;
- else
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + " Nozzle with logicalId: " + logicalNozzleId + " auth response received with an error code: " + response.参数 + ", AuthorizeAsync failed");
- return false;
- }
- }
- return false;
- }
- public virtual async Task<bool> FuelingRoundUpByAmountAsync(int amount)
- {
- throw new NotImplementedException();
- }
- #region not implemented
- public async Task<bool> UnAuthorizeAsync(byte logicalNozzleId)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + "start UnAuthorizeAsync pump with nozzle: " + logicalNozzleId);
- var nozzlePhysicalId = this.nozzles.FirstOrDefault(n => n.LogicalId == logicalNozzleId)?.PhysicalId;
- if (nozzlePhysicalId == null)
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + " Nozzle with logicalId: " + logicalNozzleId + " does not exists, UnAuthorizeAsync failed");
- return false;
- }
- var frameSeqNo = this.parent.GenerateNewFrameNo();
- var response = await this.context.Outgoing.WriteAsync(
- new StopPumpRequest((byte)this.PumpPhysicalId)
- {
- SourceAddress = this.parent.pumpGroupConfig.FccCommAddress,
- TargetAddress = this.parent.pumpGroupConfig.DispenserCommBoardAddress,
- FrameSeqNo = frameSeqNo
- },
- (request, testResponse) =>
- testResponse is AckStopPumpResponse r, 3000) as AckStopPumpResponse;
- if (response != null)
- {
- if (response.参数 == 0x00)
- return true;
- else
- {
- logger.LogDebug("Pump: " + this.PumpId + ", " + " Nozzle with logicalId: " + logicalNozzleId + " auth response received with an error code: " + response.参数 + ", UnAuthorizeAsync failed");
- return false;
- }
- }
- return false;
- }
- public async Task<bool> SuspendFuellingAsync()
- {
- throw new NotImplementedException();
- }
- public async Task<bool> ResumeFuellingAsync()
- {
- throw new NotImplementedException();
- }
- public async Task<bool> FuelingRoundUpByVolumeAsync(int volume)
- { throw new NotImplementedException(); }
- #endregion
- /// <summary>
- /// </summary>
- protected Dictionary<byte, FuelSaleTransaction> logicalNozzleIdToLastFuelSaleTrxMapping = new Dictionary<byte, FuelSaleTransaction>();
- public void OnFdcServerInit(Dictionary<string, object> parameters)
- {
- if (parameters.ContainsKey("LastPriceChange"))
- {
- }
- /* Load Last sale(from db) for void the case of FC accidently disconnect from Pump in fueling,
- and may cause a fueling trx gone from FC control */
- if (parameters.ContainsKey("LastFuelSaleTrx"))
- {
- // nozzle logical id:lastSale
- //var lastFuelSaleTrxes = parameters["LastFuelSaleTrx"] as Dictionary<byte, FuelSaleTransaction>;
- //foreach (var lastFuelSaleTrx in lastFuelSaleTrxes)
- //{
- // logger.Info("Pump: " + this.pumpId + ", OnFdcServerInit, load last fuel sale " +
- // "on logical nozzle: " + lastFuelSaleTrx.Key + " with value: " + lastFuelSaleTrx.Value);
- // this.logicalNozzleIdToLastFuelSaleTrxMapping.Remove(lastFuelSaleTrx.Key);
- // this.logicalNozzleIdToLastFuelSaleTrxMapping.Add(lastFuelSaleTrx.Key, lastFuelSaleTrx.Value);
- //}
- }
- }
- public async Task<bool> LockNozzleAsync(byte logicalNozzleId)
- {
- return false;
- }
- public async Task<bool> UnlockNozzleAsync(byte logicalNozzleId)
- {
- return false;
- }
- }
- }
|