123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Threading.Tasks;
- using Wayne.FDCPOSLibrary;
- namespace Edge.Core.IndustryStandardInterface.ATG
- {
- /// <summary>
- /// Aka ATG.
- /// A Tank Level Gauge connects to one or more (maximum 31) Tank Probes.
- /// A Tank Probe is the item of forecourt equipment which is capable of
- /// measuring the level of product in a tank and hence volume can be calculated.
- /// Each Tank Probe (TP) represents a tank. The unique identifier is the Unit Number.
- /// There are real tank probes and virtual tank probes. A virtual tank probe describes a tank without a physical probe installed. Parent device of a TP device is a TLG.
- /// </summary>
- public interface IAutoTankGaugeController
- {
- /// <summary>
- /// Fired once ATG connection changed.
- /// <see cref="Tanks"/> may change.
- /// </summary>
- event EventHandler<AtgStateChangeEventArg> OnStateChange;
- event EventHandler<AtgAlarmEventArg> OnAlarm;
- /// <summary>
- /// Gets the name of this implementation of ATG, most used for descriptive purpose.
- /// </summary>
- string MetaConfigName { get; }
- /// <summary>
- /// Fc internal asigned id for identify this device.
- /// </summary>
- int DeviceId { get; }
- /// <summary>
- /// Gets the Tank readings of this implementation of ATG
- /// </summary>
- IEnumerable<Tank> Tanks { get; }
- /// <summary>
- /// Gets the state of the controller.
- /// </summary>
- AtgState State { get; }
- /// <summary>
- /// Read one reading for a tank.
- /// </summary>
- /// <param name="tankNumber"></param>
- /// <returns></returns>
- Task<TankReading> GetTankReadingAsync(int tankNumber);
- /// <summary>
- /// Read readings for all tanks.
- /// </summary>
- /// <returns>readings for all tanks</returns>
- Task<IEnumerable<TankReading>> GetTanksReadingAsync();
-
- /// <summary>
- /// read tank delivery info.
- /// </summary>
- /// <param name="tankNumber"></param>
- /// <param name="pageRowCount"></param>
- /// <param name="pageIndex"></param>
- /// <param name="filterTimestamp">only the records have the timestamp more recent will returned.</param>
- /// <returns></returns>
- Task<IEnumerable<Delivery>> GetTankDeliveryAsync(int tankNumber, int pageRowCount = 10, int pageIndex = 0, DateTime? filterTimestamp = null);
- /// <summary>
- /// read tank Inventory info.
- /// </summary>
- /// <param name="tankNumber"></param>
- /// <param name="pageRowCount"></param>
- /// <param name="pageIndex"></param>
- /// <param name="filterTimestamp">only the records have the timestamp more recent will returned.</param>
- /// <returns></returns>
- Task<IEnumerable<Inventory>> GetTankInventoryAsync(int tankNumber, int pageRowCount = 10, int pageIndex = 0, DateTime? filterTimestamp = null);
- /// <summary>
- /// read tank Alarm history info.
- /// </summary>
- /// <param name="tankNumber"></param>
- /// <param name="pageRowCount"></param>
- /// <param name="pageIndex"></param>
- /// <param name="filterTimestamp"></param>
- /// <returns></returns>
- Task<IEnumerable<Alarm>> GetTankAlarmAsync(int tankNumber, int pageRowCount = 10, int pageIndex = 0, DateTime? filterTimestamp = null);
- /// <summary>
- /// Gets the console's SystemUnit setting value.
- ///
- /// Length
- /// Metric US or Imperial
- /// 1 millimeter [mm] = 0.03937 inches [in]
- /// 1 centimeter [cm] = 0.3937 inches [in]
- /// 1 meter [m] = 1.0936 yard [yd]
- /// 1 kilometer [km] = 0.6214 mile
- ///
- /// 1 yard [yd] = 3 ft
- /// 1 mile = 1760 yd
- /// 2.54 cm = 1 inch [in]
- /// 0.3048 m = 1 foot [ft] = 12 in
- ///
- /// Volume/Capacity
- /// 1 cu cm [cm3] 0.0610 in3
- /// 1 cu decimeter [dm3] = 1,000 cm3 0.0353 ft3
- /// 1 cu meter [m3] 1,000 dm3 1.3080 yd3
- /// 1 liter [l] = 1 dm3 2.113 fluid pt = 1.7598 pt
- /// </summary>
- SystemUnit SystemUnit { get; }
- }
- public class Alarm
- {
- public Alarm() { }
- public Alarm(AlarmPriority priority, AlarmType type)
- {
- this.Priority = priority;
- this.Type = type;
- }
- public int Id { get; set; }
- public AlarmPriority Priority { get; set; }
- /// <summary>
- /// This Alarm is for which tank.
- /// </summary>
- public byte TankNumber { get; set; }
- public AlarmType Type { get; set; }
- public DateTime CreatedTimeStamp { get; set; }
- /// <summary>
- /// the fix time of this alarm.
- /// </summary>
- public DateTime? ClearedTimeStamp { get; set; }
- public string Description { get; set; }
- }
- public enum AlarmPriority
- {
- /// <summary>
- /// need take a look when available.
- /// </summary>
- Warning,
- /// <summary>
- /// need take a look right now.
- /// </summary>
- Alarm,
- }
- /// <summary>
- /// logical concept.
- /// </summary>
- public class Tank
- {
- /// <summary>
- /// Gets or sets the tank number which assigned in device internal
- /// </summary>
- public byte TankNumber { get; set; }
- /// <summary>
- /// descriptive info for this Tank.
- /// </summary>
- public string Label { get; set; }
- public Product Product { get; set; }
- public TankLimit Limit { get; set; }
- /// <summary>
- /// by mm.
- /// </summary>
- public double? Diameter { get; set; }
- /// <summary>
- /// </summary>
- public TankState State { get; set; }
- public Probe Probe { get; set; }
- public override string ToString()
- {
- return $"Tank with No.: {TankNumber} has Label: {Label ?? ""}, ProductCode: {Product?.ProductCode ?? ""}, ProductLabel: {Product?.ProductLabel ?? ""}";
- }
- }
- public class TankLimit
- {
- /// <summary>
- /// The max volume of this tank can safely save material, by Liter.
- /// by considering the material expansion along with temp rise, the Max volume must less than Full Volume.
- /// </summary>
- public double MaxVolume { get; set; }
- /// <summary>
- /// 100% volume of this tank, by Liter.
- /// </summary>
- public double FullVolume { get; set; }
- /// <summary>
- /// % of the Max Volume, typical value 0.9
- /// above this value will trigger high product alarm.
- /// </summary>
- public double HighProduct { get; set; }
- /// <summary>
- /// Liter of the low product threashold value, by Liter, typical value 30.
- /// lower thatn this value will trigger low product alarm.
- /// </summary>
- public double LowProduct { get; set; }
- /// <summary>
- /// mm of the high water warning threashold value, by mm, typical value 100.
- /// higher than this value will trigger high water warning.
- /// </summary>
- public double HighWaterWarning { get; set; }
- /// <summary>
- /// mm of the high water alarm threashold value, by mm, typical value 125.
- /// higher than this value will trigger high water alarm.
- /// </summary>
- public double HighWaterAlarm { get; set; }
- /// <summary>
- /// by centigrade(celsius), typical value -50
- /// </summary>
- public double FuelTemperatureLowLimit { get; set; }
- /// <summary>
- /// by centigrade(celsius), typical value 60
- /// </summary>
- public double FuelTemperatureHighLimit { get; set; }
- }
- public class Product
- {
- /// <summary>
- ///
- /// </summary>
- public string ProductCode { get; set; }
- /// <summary>
- /// descriptive info for the product.
- /// </summary>
- public string ProductLabel { get; set; }
- }
- /// <summary>
- /// represents a physical hardware of a probe, which used to measure liquid depth.
- /// </summary>
- public class Probe
- {
- /// <summary>
- /// unique in a ATG system.
- /// </summary>
- public int DeviceId { get; set; }
- /// <summary>
- /// hardware id, serial number? mac?
- /// </summary>
- public string HardwareIdentity { get; set; }
- /// <summary>
- /// phsycial length of the probe hardware, by mm.
- /// </summary>
- public double? ProbeLength { get; set; }
- /// <summary>
- /// the lowest point of the probe may not reached the bottom of the tank, this is the length of this distance.
- /// the fuel and water height readings will combine with this value before send out for ATG client applications.
- /// </summary>
- public double ProbeOffset { get; set; }
- /// <summary>
- /// user may want to 'hidden' some water in a tank, this is the value of the water height reading need to be substracted.
- /// </summary>
- public double WaterOffset { get; set; }
- /// <summary>
- /// may device manufactor dependency.
- /// </summary>
- public string State { get; set; }
- }
- public class ProbeReading
- {
- /// <summary>
- /// Fuel Height is the depth of all liquid in the tank in inches or millimeters.
- /// </summary>
- public double? Height { get; set; }
- /// <summary>
- /// Water Height is the depth of the water in the tank.
- /// Note: If you are using high alcohol probes that cannot detect water, Water Height will not appear on the display or the printed reports.
- /// </summary>
- public double? Water { get; set; }
- public IEnumerable<double> Temperature { get; set; }
- public double? Density { get; set; }
- }
- public class TankReading
- {
- public int? TankNumber { get; set; }
- /// <summary>
- /// Fuel Volume in tank, by Liter.
- /// </summary>
- public double? Volume { get; set; }
- /// <summary>
- /// Gets or sets the value of Temperature Compensated Volume.
- /// The product in the tank expands and contracts with temperature.
- /// The colder the temperature, the more the product will contract.
- /// The higher the temperature, the more the product will expand.
- /// Temperature Compensated Volume is at 60 degrees Fahrenheit, unless your system was programmed to use another temperature value.
- /// Note: If Temperature Compensated Volume was set to “Disable” using the System Setup function,
- /// you will not be able to print the Temperature Compensated Volume on the report.
- /// </summary>
- public double? TcVolume { get; set; }
- /// <summary>
- /// Ullage is the amount of room left in the tank. Normally,
- /// a tank is not totally full, this is done so that the product has some room to expand.
- /// you can't fill the tank with full product which may cause problem, like when temperature get warmer,
- /// the product will expand.
- /// </summary>
- public double? Ullage { get; set; }
- /// <summary>
- /// Water Volume is the amount of water in the tank in gallons or liters.
- /// Note: If you are using high alcohol probes, Water Volume will not appear in the display or the printed reports.
- /// </summary>
- public double? WaterVolume { get; set; }
- #region values read from real physical probe, all other business are actually rely on these hardware readings
- /// <summary>
- /// Fuel Height is the depth of all liquid in the tank in inches or millimeters.
- /// </summary>
- public double? Height { get; set; }
- /// <summary>
- /// Water Height is the depth of the water in the tank.
- /// Note: If you are using high alcohol probes that cannot detect water, Water Height will not appear on the display or the printed reports.
- /// </summary>
- public double? Water { get; set; }
- public double? Temperature { get; set; }
- public double? Density { get; set; }
- #endregion
- public override string ToString()
- {
- return "Product Height: " + (this?.Height ?? -1) +
- ", Product Volume: " + (this.Volume ?? -1) +
- ", Product TcVolume Volume: " + (this.TcVolume ?? -1) +
- ", Water Height: " + (this?.Water ?? -1) +
- ", Temperature: " + (this?.Temperature ?? -1) +
- ", Density: " + (this?.Density ?? -1);
- }
- }
- public enum SystemUnit
- {
- US = 1,
- Metric = 2,
- ImperialGallons = 3,
- }
- public enum SystemLanguage
- {
- English = 1,
- French = 2,
- Spanish = 3,
- German = 4,
- Portuguese = 5,
- Polish = 6,
- Swedish = 7,
- Janpanese = 8,
- Finnish = 9,
- }
- public enum AlarmType
- {
- #region VeederRoot defined
- TankSetupDataWarning = 1,
- TankLeakAlarm = 2,
- TankHighWaterAlarm = 3,
- TankOverfillAlarm = 4,
- TankLowProductAlarm = 5,
- TankSuddenLossAlarm = 6,
- TankHighProductAlarm = 7,
- TankInvalidFuelLevelAlarm = 8,
- TankProbeOutAlarm = 9,
- TankHighWaterWarning = 10,
- TankDeliveryNeededWarning = 11,
- TankMaximumProductAlarm = 12,
- TankGrossLeakTestFailAlarm = 13,
- TankPeriodicLeakTestFailAlarm = 14,
- TankAnnualLeakTestFailAlarm = 15,
- TankPeriodicTestNeededWarning = 16,
- TankAnnualTestNeedWarning = 17,
- TankPeriodicTestNeededAlarm = 18,
- TankAnnualTestNeededAlarm = 19,
- TankLeakTestActive = 20,
- TankNoCsldIdleTimeWarning = 21,
- TankSiphonBreakActiveWarning = 22,
- TankCsldRateIncreaseWarning = 23,
- TankAccuChartCalibrationWarning = 24,
- TankHrmReconciliationWarning = 25,
- TankHrmReconciliationAlarm = 26,
- TankColdTemperatureWarning = 27,
- TankMissingDeliveryTicketWarning = 28,
- TankLineGrossLeakAlarm = 29,
- //Shawn added
- TankHighTemperatureWarning = 5000,
- #endregion
- }
- public enum DeliveryReadingDataName
- {
- StartingVolume = 1,
- StartingTcVolume = 2,
- StartingWater = 3,
- StartingTemp = 4,
- EndingVolume = 5,
- EndingTcVolume = 6,
- EndingWater = 7,
- EndingTemp = 8,
- StartingHeight = 9,
- EndingHeight = 10,
- }
- public class Delivery
- {
- public byte TankNumber { get; set; }
- public DateTime StartingDateTime { get; set; }
- public double StartingFuelHeight { get; set; }
- public double StartingFuelVolume { get; set; }
- public double StartingFuelTCVolume { get; set; }
- public double StartingWaterHeight { get; set; }
- public double StartingTemperture { get; set; }
- public DateTime? EndingDateTime { get; set; }
- public double? EndingFuelHeight { get; set; }
- public double? EndingFuelVolume { get; set; }
- public double? EndingFuelTCVolume { get; set; }
- public double? EndingWaterHeight { get; set; }
- public double? EndingTemperture { get; set; }
- public string Description { get; set; }
- }
- public class Inventory
- {
- public int TankNumber { get; set; }
- public DateTime TimeStamp { get; set; }
- public double FuelHeight { get; set; }
- public double FuelVolume { get; set; }
- public double FuelTCVolume { get; set; }
- public double WaterHeight { get; set; }
- public double Temperture { get; set; }
- public string Description { get; set; }
- }
- }
|