public void AddNozzle(LogicalNozzle newNozzle) { this._Nozzles_油枪组.Add(newNozzle); var safe = this.PropertyChanged; safe?.Invoke(this, new PropertyChangedEventArgs("Nozzle")); }
public void UpdatePumpStateByMessage(PumpStateChangeRequest msg) { PumpStateChangeRequest.ParseSubMessages(msg.SubMessageRaw, msg.SubMessageCount, msg); if (msg.StateNozzleOperatingSubMessages == null && msg.StateCardInsertedSubMessages == null) { if (this.Nozzles_油枪组.Any()) { this.Nozzles_油枪组.ToList().ForEach(n => n.ResetState()); } this.PumpState = LogicalPump.LogicalPumpState.Idle; } else { if (msg.StateNozzleOperatingSubMessages != null && msg.StateNozzleOperatingSubMessages.Any()) { // further set state for specified Nozzle foreach (var busyNozzle in msg.StateNozzleOperatingSubMessages) { var targetLogicalNozzle = this.Nozzles_油枪组.FirstOrDefault(n => n.NozzleNumber == busyNozzle.MZN枪号); // the purpose adding nozzle here is just like a trying to recovery the most info for a pump, so some nozzles will be missed. if (targetLogicalNozzle == null) { targetLogicalNozzle = new LogicalNozzle() { NozzleNumber = busyNozzle.MZN枪号, }; this.AddNozzle(targetLogicalNozzle); } targetLogicalNozzle.ResetState(); targetLogicalNozzle.Amount = busyNozzle.AMN数额; targetLogicalNozzle.Volumn = busyNozzle.VOL升数; targetLogicalNozzle.Price = busyNozzle.PRC价格; targetLogicalNozzle.NozzleState = LogicalNozzle.PumpNozzleState.BusyLiftedOrFueling; } this.PumpState = LogicalPump.LogicalPumpState.NozzleLiftedOrFueling; } else if (msg.StateCardInsertedSubMessages != null && msg.StateCardInsertedSubMessages.Any()) { foreach (var cardInsertedNozzle in msg.StateCardInsertedSubMessages) { var targetLogicalNozzle = this.Nozzles_油枪组.FirstOrDefault(n => n.NozzleNumber == cardInsertedNozzle.MZN枪号); // the purpose adding nozzle here is just like a trying to recovery the most info for a pump, so some nozzles will be missed. if (targetLogicalNozzle == null) { targetLogicalNozzle = new LogicalNozzle() { NozzleNumber = cardInsertedNozzle.MZN枪号 }; this.AddNozzle(targetLogicalNozzle); } targetLogicalNozzle.ResetState(); targetLogicalNozzle.InsertedCardNumber = cardInsertedNozzle.ASN卡应用号; targetLogicalNozzle.InsertedCardStateCode = cardInsertedNozzle.CardSt卡状态; targetLogicalNozzle.InsertedCardBalance = cardInsertedNozzle.BAL余额; targetLogicalNozzle.NozzleState = LogicalNozzle.PumpNozzleState.BusyCardInserted; } this.PumpState = LogicalPump.LogicalPumpState.CardInserted; } } }