using System; using Wayne.Lib; using Wayne.Lib.Log; namespace Wayne.ForecourtControl.Fusion { internal class FUSIONNozzle : INozzle, IIdentifiableEntity { // Fields private int fuelGrade; private int id; private NozzleState nozzleState = NozzleState.In; private FUSIONPump pump; private IIdentifiableEntity parentDevice; private int primaryTankGroupId; private int primaryTankGroupPercentage; private int secondaryTankGroupId; private FUSIONManager manager; private readonly DebugLogger debugLogger; // Methods public FUSIONNozzle(int id, FUSIONManager manager, FUSIONPump pump) { this.id = id; this.pump = pump; this.manager = manager; debugLogger = manager.DebugLogger; } internal void Dispose() { } public void ReadPumpAccumulatorAsync(EventHandler> accumulatorsRead, object userToken) { this.pump.Manager.ifsfManager.GetFuelPointTotals(this.pump.realId, this.id, accumulatorsRead, userToken, this); } // Properties public string EntitySubType { get { return ""; } } public string EntityType { get { return "Nozzle"; } } /// /// This is used by the logger and should never be set by inheriting classes /// public string FullEntityName { get; set; } public int FuelGrade { get { if (manager.FuelGradeShift != 0) return this.fuelGrade + manager.FuelGradeShift; else return this.fuelGrade; } } /// /// use this property to move the values internally, this removes interference from the fuelgradeshift /// internal int WritableFuelGrade { get { return this.fuelGrade; } set { this.fuelGrade = value; } } public int Id { get { if (pump.Manager.IdNozzleShift > 0) return this.id + pump.Manager.IdNozzleShift; else return this.id + pump.Manager.IdShift; } } public int realId { get { return this.id; } set { this.id = value; } } public IIdentifiableEntity ParentEntity { get { return this.parentDevice; } } public int PrimaryTankGroupId { get { return this.primaryTankGroupId; } set { this.primaryTankGroupId = value; } } public int PrimaryTankGroupPercentage { get { return this.primaryTankGroupPercentage; } set { this.primaryTankGroupPercentage = value; } } public int SecondaryTankGroupId { get { return this.secondaryTankGroupId; } set { this.secondaryTankGroupId = value; } } /// /// Tank that nozzle is connected to /// public int PrimaryTankNo { get; set; } /// /// Tank that nozzle is connected to /// public int SecondaryTankNo { get; set; } public NozzleState State { get { return this.nozzleState; } set { if (debugLogger.IsActive()) debugLogger.Add(string.Format("old State={0}, new State={1}", nozzleState, value)); if (this.nozzleState != value) { this.nozzleState = value; pump.NozzleStateChange(this, this.nozzleState); } } } } }