using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Wayne.FDCPOSLibrary;
namespace Edge.Core.IndustryStandardInterface.ATG
{
///
/// 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.
///
public interface IAutoTankGaugeController
{
///
/// Fired once ATG connection changed.
/// may change.
///
event EventHandler OnStateChange;
event EventHandler OnAlarm;
///
/// Gets the name of this implementation of ATG, most used for descriptive purpose.
///
string MetaConfigName { get; }
///
/// Fc internal asigned id for identify this device.
///
int DeviceId { get; }
///
/// Gets the Tank readings of this implementation of ATG
///
IEnumerable Tanks { get; }
///
/// Gets the state of the controller.
///
AtgState State { get; }
///
/// Read one reading for a tank.
///
///
///
Task GetTankReadingAsync(int tankNumber);
///
/// Read readings for all tanks.
///
/// readings for all tanks
Task> GetTanksReadingAsync();
///
/// read tank delivery info.
///
///
///
///
/// only the records have the timestamp more recent will returned.
///
Task> GetTankDeliveryAsync(int tankNumber, int pageRowCount = 10, int pageIndex = 0, DateTime? filterTimestamp = null);
///
/// read tank Inventory info.
///
///
///
///
/// only the records have the timestamp more recent will returned.
///
Task> GetTankInventoryAsync(int tankNumber, int pageRowCount = 10, int pageIndex = 0, DateTime? filterTimestamp = null);
///
/// read tank Alarm history info.
///
///
///
///
///
///
Task> GetTankAlarmAsync(int tankNumber, int pageRowCount = 10, int pageIndex = 0, DateTime? filterTimestamp = null);
///
/// 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
///
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; }
///
/// This Alarm is for which tank.
///
public byte TankNumber { get; set; }
public AlarmType Type { get; set; }
public DateTime CreatedTimeStamp { get; set; }
///
/// the fix time of this alarm.
///
public DateTime? ClearedTimeStamp { get; set; }
public string Description { get; set; }
}
public enum AlarmPriority
{
///
/// need take a look when available.
///
Warning,
///
/// need take a look right now.
///
Alarm,
}
///
/// logical concept.
///
public class Tank
{
///
/// Gets or sets the tank number which assigned in device internal
///
public byte TankNumber { get; set; }
///
/// descriptive info for this Tank.
///
public string Label { get; set; }
public Product Product { get; set; }
public TankLimit Limit { get; set; }
///
/// by mm.
///
public double? Diameter { get; set; }
///
///
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
{
///
/// 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.
///
public double MaxVolume { get; set; }
///
/// 100% volume of this tank, by Liter.
///
public double FullVolume { get; set; }
///
/// % of the Max Volume, typical value 0.9
/// above this value will trigger high product alarm.
///
public double HighProduct { get; set; }
///
/// Liter of the low product threashold value, by Liter, typical value 30.
/// lower thatn this value will trigger low product alarm.
///
public double LowProduct { get; set; }
///
/// mm of the high water warning threashold value, by mm, typical value 100.
/// higher than this value will trigger high water warning.
///
public double HighWaterWarning { get; set; }
///
/// mm of the high water alarm threashold value, by mm, typical value 125.
/// higher than this value will trigger high water alarm.
///
public double HighWaterAlarm { get; set; }
///
/// by centigrade(celsius), typical value -50
///
public double FuelTemperatureLowLimit { get; set; }
///
/// by centigrade(celsius), typical value 60
///
public double FuelTemperatureHighLimit { get; set; }
}
public class Product
{
///
///
///
public string ProductCode { get; set; }
///
/// descriptive info for the product.
///
public string ProductLabel { get; set; }
}
///
/// represents a physical hardware of a probe, which used to measure liquid depth.
///
public class Probe
{
///
/// unique in a ATG system.
///
public int DeviceId { get; set; }
///
/// hardware id, serial number? mac?
///
public string HardwareIdentity { get; set; }
///
/// phsycial length of the probe hardware, by mm.
///
public double? ProbeLength { get; set; }
///
/// 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.
///
public double ProbeOffset { get; set; }
///
/// user may want to 'hidden' some water in a tank, this is the value of the water height reading need to be substracted.
///
public double WaterOffset { get; set; }
///
/// may device manufactor dependency.
///
public string State { get; set; }
}
public class ProbeReading
{
///
/// Fuel Height is the depth of all liquid in the tank in inches or millimeters.
///
public double? Height { get; set; }
///
/// 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.
///
public double? Water { get; set; }
public IEnumerable Temperature { get; set; }
public double? Density { get; set; }
}
public class TankReading
{
public int? TankNumber { get; set; }
///
/// Fuel Volume in tank, by Liter.
///
public double? Volume { get; set; }
///
/// 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.
///
public double? TcVolume { get; set; }
///
/// 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.
///
public double? Ullage { get; set; }
///
/// 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.
///
public double? WaterVolume { get; set; }
#region values read from real physical probe, all other business are actually rely on these hardware readings
///
/// Fuel Height is the depth of all liquid in the tank in inches or millimeters.
///
public double? Height { get; set; }
///
/// 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.
///
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; }
}
}