using System; using System.Collections.ObjectModel; using System.Collections.Generic; using System.Globalization; using System.Threading; using System.IO; using Wayne.Lib; using Wayne.ForecourtControl.Vir.Fusion; #if _SINP using Wayne.ForecourtControl.Nfs; #endif using Wayne.FDCPOSLibrary; namespace Wayne.ForecourtControl.Fusion { public class FUSIONForecourtControl : IForecourtControl, IConnectable, IIdentifiableEntity, IDisposable { // Fields private string clientName; private string connectionString; private DeviceConnectionState connectionState = DeviceConnectionState.Disconnected; private List fuelPriceList = new List(); private int id; private FUSIONManager _manager; public FUSIONManager manager { get { return _manager; } } private List pricePoleList = new List(); private List pumpList = new List(); private List tankGroupList = new List(); private int siteMode; private bool siteOpened; public ServiceRequestChangeFuelMode srChangeMode = null; public bool fuelPriceReserved; public ConfigurationParams ConfigParam; // Events public event EventHandler OnAlarm; public event EventHandler OnConnectionStateChange; public event EventHandler OnFuelPriceChange; public event EventHandler OnSiteModeChange; #region Methods public FUSIONForecourtControl(int deviceId, ForecourtEntityTypes managedEntityTypes, int[] managedPumpIds) { ConfigParam = new ConfigurationParams(); this.id = deviceId; this._manager = new FUSIONManager(this, managedEntityTypes, managedPumpIds); fuelPriceReserved = false; siteOpened = true; } public void ActivateFuelPricesAsync(EventHandler requestCompleted, object userToken) { Trace.WriteLine(string.Format("ActivateFuelPricesAsync init")); int iFuelGrade; decimal price; ServiceRequestChangeFuelPrice sr = new ServiceRequestChangeFuelPrice(); foreach (IFuelPrice fuelprice in FuelPrices) { try { Monitor.Enter(((FUSIONFuelPrice)fuelprice).locker); iFuelGrade = fuelprice.FuelGrade; Trace.WriteLine(string.Format("fuelGrade={0}, ((FUSIONFuelPrice)fuelprice).Changed={1}", fuelprice.FuelGrade, ((FUSIONFuelPrice)fuelprice).Changed)); if (((FUSIONFuelPrice)fuelprice).Changed) { //for (int mode = ((FUSIONFuelPriceAddPricePerPriceGroup)(fuelprice.PriceGroupDelta)).PriceGroupNumbersMin; mode <= ((FUSIONFuelPriceAddPricePerPriceGroup)(fuelprice.PriceGroupDelta)).PriceGroupNumbersMax; mode++) for (int mode = FUSIONFuelPrice.PriceGroupNumbersMin; mode <= FUSIONFuelPrice.PriceGroupNumbersMax; mode++) { FUSIONFuelPriceAddPricePerPriceGroup pgd = (FUSIONFuelPriceAddPricePerPriceGroup)(fuelprice.PriceGroupDelta); Trace.WriteLine(string.Format("mode = {0}, pgd.getChanged(mode)={1}", mode, pgd.getChanged(mode))); if (pgd.getChanged(mode)) { price = fuelprice.BasePrice + fuelprice.GeneralPriceDelta + fuelprice.PriceGroupDelta[mode]; //this._manager.ifsfManager.ChangeFuelPrice(fuelprice.FuelGrade, price, mode, null, null); this._manager.ifsfManager.ChangeFuelPriceAdd(sr, fuelprice.FuelGrade, price, mode); } } } } catch (Exception ex) { Trace.WriteLine("Exception! " + ex.Message + " - " + ex.StackTrace); } finally { Monitor.Exit(((FUSIONFuelPrice)fuelprice).locker); } } this._manager.ifsfManager.ChangeFuelPriceSend(sr, null, null, null); if (requestCompleted != null) requestCompleted.BeginInvoke(this, new AsyncCompletedEventArgs(true, userToken), null, null); Trace.WriteLine(string.Format("ActivateFuelPricesAsync end")); } private void ActivateFuelPricesCompleted(object sender, AsyncCompletedEventArgs e) { /*TODO AsyncOperation operation; if (!(e.UserToken is ushort)) { throw new Exception("UnreserveFuelPricesAsyncCompleted: Expected usertoken to be Uint16"); } this.manager.ReadFuelPrices(); foreach (NfsFuelPrice price in this.fuelPriceList) { price.WritableReserved = false; } if (this.manager.AsyncManager.TryGetOperation((ushort)e.UserToken, out operation)) { operation.Complete(new AsyncCompletedEventArgs(e.Success, operation.UserToken)); }*/ } public void Connect(string connectionString) { // connection state is set to 'connecting' when the logon is terminated bool bNotifyStateChange = false; if (this._manager.ifsfManager.clientSocket.ConnectionState != DeviceConnectionState.Disconnected && this._manager.ifsfManager.clientSocket.ConnectionState != DeviceConnectionState.Disconnecting) bNotifyStateChange = true; //bool res = this.manager.Connect(connectionString); this.connectionString = connectionString; Thread runConnectThread = new Thread(new ThreadStart(this.ConnectThreadProc)); runConnectThread.Start(); //if (bNotifyStateChange && OnConnectionStateChange != null) // this.OnConnectionStateChange.Invoke(this, new ConnectionChangedEventArgs(this._manager.ifsfManager.clientSocket.ConnectionState)); //foreach (FUSIONPump pump in this.Pumps) //{ // this._manager.ifsfManager.GetDeviceState(pump.Id, null, null); //} } private void ConnectThreadProc() { this.manager.Connect(connectionString); } public void Disconnect() { this.WritableConnectionState = DeviceConnectionState.Disconnecting; this.manager.Disconnect(); } public void Dispose() { this.Dispose(true); GC.SuppressFinalize(this); } private void Dispose(bool disposing) { if (disposing) { this.manager.Dispose(); } } ~FUSIONForecourtControl() { this.Dispose(false); } internal void FireAlarmEvent(AlarmEventArgs args) { if (this.OnAlarm != null) { this.OnAlarm.BeginInvoke(this, args, null, null); } } internal void FireFuelPriceChangeEvent(FuelPriceChangeEventArgs args) { if (this.OnFuelPriceChange != null) { this.OnFuelPriceChange.BeginInvoke(this, args, null, null); } } public void ReserveFuelPricesAsync(EventHandler requestCompleted, object userToken) { fuelPriceReserved = true; srChangeMode = new ServiceRequestChangeFuelMode(); if (FDCGlobal.ProtocolVersion <= FDCVersion.V0007) srChangeMode.RequestType = "ChangeFuelMode"; else srChangeMode.RequestType = "ChangeFPFuelMode"; foreach (IFuelPrice fuelprice in FuelPrices) { ((FUSIONFuelPrice)fuelprice).WritableReserved = true; } if (requestCompleted != null) requestCompleted.BeginInvoke(this, new AsyncCompletedEventArgs(true, userToken), null, null); } private void ReserveFuelPricesAsyncCompleted(object sender, AsyncCompletedEventArgs e) { /*TODO AsyncOperation operation; if (!(e.UserToken is ushort)) { throw new Exception("ReserveFuelPricesAsyncCompleted: Expected usertoken to be Uint16"); } this.manager.ReadFuelPrices(); foreach (NfsFuelPrice price in this.fuelPriceList) { price.WritableReserved = e.Success; } if (this.manager.AsyncManager.TryGetOperation((ushort)e.UserToken, out operation)) { operation.Complete(new AsyncCompletedEventArgs(e.Success, operation.UserToken)); }*/ } public void SetSiteModeAsync(int siteMode, EventHandler requestCompleted, object userToken) { //AsyncOperation operation = this.manager.AsyncManager.RegisterOperation(this, requestCompleted, userToken); //Function function = new Function(4, new Parameter[] { new PrimitiveParameter(0x66, PrimitiveType.UInt16, operation.Id), new PrimitiveParameter(0x69, PrimitiveType.Byte, siteMode) }); //this.manager.Send(function); if (siteMode == 99) { //This is only for testing purpose TestMessages(); return; } string sValue = IniFile.IniReadValue(ConfigurationParams.inifile, "Test", "Operation"); if (sValue != "") { Test(); return; } } public void SetSiteOpenedAsync(bool opened, EventHandler requestCompleted, object userToken) { string sValue = IniFile.IniReadValue(ConfigurationParams.inifile, "Test", "Operation"); if (sValue != "") { Test(); return; } if (opened) { this.manager.ifsfManager.StartForecourt(requestCompleted, userToken, this); } else this.manager.ifsfManager.StopForecourt(requestCompleted, userToken, this); } public void Test() { int par1 = -1, par2 = -1; int id = -1; int trid = -1; int nozzleId = -1; string sValue = IniFile.IniReadValue(ConfigurationParams.inifile, "Test", "Operation"); string[] sElems; StreamReader sr = new StreamReader(ConfigurationParams.getSINPPath("ini\\") + sValue); while (sr.Peek() != -1) { sValue = sr.ReadLine(); sElems = sValue.Split(','); try { if (sElems.GetLength(0) > 1) { try { par1 = Convert.ToInt32(sElems[1]); } catch (Exception ex) { } } if (sElems.GetLength(0) > 2) { try { par2 = Convert.ToInt32(sElems[2]); } catch (Exception ex) { } } sValue = sElems[0]; id = par1; trid = par2; } catch (Exception ex) { } if (sValue == "StartFuelPointTest") { manager.ifsfManager.StartFuelPointTest(id, null, null, null); } else if (sValue == "EndFuelPointTest") { this.manager.ifsfManager.EndFuelPointTest(id, null, null, null); } else if (sValue == "CloseFuelPoint") { this.manager.ifsfManager.CloseFuelPoint(id, null, null, null); } else if (sValue == "OpenFuelPoint") { this.manager.ifsfManager.OpenFuelPoint(id, null, null, null); } else if (sValue == "AuthoriseFuelPoint") { AuthorizeParameters authParams = new AuthorizeParameters(); authParams.PresetType = PresetType.Amount; authParams.PresetValue = 50; this.manager.ifsfManager.AuthoriseFuelPoint(id, trid, FuellingType.Unknown, 0, authParams, null, null, null); } else if (sValue == "SuspendFuelling") { FUSIONPump pump = this.manager.GetPumpById(id); if (pump != null) pump.SuspendAsync(new EventHandler(Test_SuspendResult), null); //this.manager.ifsfManager.SuspendFuelling(id, null, null); } else if (sValue == "ResumeFuelling") { FUSIONPump pump = this.manager.GetPumpById(id); if (pump != null) pump.ResumeAsync(new EventHandler(Test_ResumeResult), null); //this.manager.ifsfManager.ResumeFuelling(id, null, null); } else if (sValue == "TerminateFuelling") { this.manager.ifsfManager.TerminateFuelling(id, null, null, null); } else if (sValue == "LogOff") { this.manager.ifsfManager.LogOff(); } else if (sValue == "LogOn") { this.manager.ifsfManager.LogOn("", ""); } else if (sValue == "GetFuelMode") { this.manager.ifsfManager.GetFuelMode(id, null, null, null); } else if (sValue == "GetModeTable") { this.manager.ifsfManager.GetModeTable(null, null, null); } else if (sValue == "ClearFuelSaleTrx") { this.manager.ifsfManager.ClearFuelSaleTrx(id, trid, 0, "", null, null, null); } else if (sValue == "LockFuelSaleTrx") { this.manager.ifsfManager.LockFuelSaleTrx(id, trid, 0, null, null, null); } else if (sValue == "UnlockFuelSaleTrx") { this.manager.ifsfManager.UnlockFuelSaleTrx(id, trid, 0, null, null, null); } else if (sValue == "getCountrySetting") { this.manager.ifsfManager.GetCountrySettings(null, null, null); } else if (sValue == "GetCurrentFuellingStatus") { this.manager.ifsfManager.GetCurrentFuellingStatus(id, null, null, null); } else if (sValue == "LockNozzle") { this.manager.ifsfManager.LockNozzle(id, nozzleId, null, null, null); } else if (sValue == "UnlockNozzle") { this.manager.ifsfManager.UnlockNozzle(id, nozzleId, null, null, null); } else if (sValue == "GetDeviceState") { this.manager.ifsfManager.GetDeviceState(Wayne.FDCPOSLibrary.DeviceType.DT_FuelDispenser, id, null, null, null); } else if (sValue == "GetFuelPointTotals") { nozzleId = par2; this.manager.ifsfManager.GetFuelPointTotals(id, nozzleId, null, null, null); } else if (sValue == "CloseFuelPoint") { this.manager.ifsfManager.CloseFuelPoint(id, null, null, null); } else if (sValue == "OpenFuelPoint") { this.manager.ifsfManager.OpenFuelPoint(id, null, null, null); } else if (sValue == "ReserveFuelPoint") { FUSIONPump pump = this.manager.GetPumpById(id); if (pump != null) pump.ReserveAsync(FuellingType.Unknown, 0, new EventHandler(Test_ReserveResult), null); //this.manager.ifsfManager.ReserveFuelPoint(id, null, null); } else if (sValue == "FreeFuelPoint") { FUSIONPump pump = this.manager.GetPumpById(id); if (pump != null) pump.UnreserveAsync(new EventHandler(Test_UnreserveResult), null); //this.manager.ifsfManager.FreeFuelPoint(id, null, null); } else if (sValue == "GetFuelSaleTrxDetails") { this.manager.ifsfManager.GetFuelSaleTrxDetails(id, trid, 0, null, null, null); } else if (sValue == "GetAvailableFuelSaleTrxs") { this.manager.ifsfManager.GetAvailableFuelSaleTrxs(id, null, null, null); } else if (sValue == "ChangeFuelMode") { int priceGroup = par2; this.manager.ifsfManager.ChangeFuelMode(id, priceGroup, null, null, null); } else if (sValue == "SendConfig") { this.manager.ifsfManager.SendConfig(sElems[1], null, null, null); } else { } } sr.Close(); } static private void Test_SuspendResult(Object src, Wayne.Lib.AsyncCompletedEventArgs completed) { try { IPump pump = (IPump)completed.UserToken; if (pump != null) { Trace.WriteLine(string.Format("pump={0}, result={1}", ((FUSIONPump)(pump)).realId, completed.Success)); } } catch (Exception ex) { Trace.WriteLine(string.Format("EXCEPTION! Stack chiamate: {0} Messaggio: {1}", ex.StackTrace, ex.Message)); } } static private void Test_ResumeResult(Object src, Wayne.Lib.AsyncCompletedEventArgs completed) { try { IPump pump = (IPump)completed.UserToken; if (pump != null) { Trace.WriteLine(string.Format("pump={0}, result={1}", ((FUSIONPump)(pump)).realId, completed.Success)); } } catch (Exception ex) { Trace.WriteLine(string.Format("EXCEPTION! Stack chiamate: {0} Messaggio: {1}", ex.StackTrace, ex.Message)); } } static private void Test_ReserveResult(Object src, Wayne.Lib.AsyncCompletedEventArgs completed) { try { IPump pump = (IPump)completed.UserToken; if (pump != null) { Trace.WriteLine(string.Format("pump={0}, result={1}", ((FUSIONPump)(pump)).realId, completed.Success)); } } catch (Exception ex) { Trace.WriteLine(string.Format("EXCEPTION! Stack chiamate: {0} Messaggio: {1}", ex.StackTrace, ex.Message)); } } static private void Test_UnreserveResult(Object src, Wayne.Lib.AsyncCompletedEventArgs completed) { try { IPump pump = (IPump)completed.UserToken; if (pump != null) { Trace.WriteLine(string.Format("pump={0}, result={1}", ((FUSIONPump)(pump)).realId, completed.Success)); } } catch (Exception ex) { Trace.WriteLine(string.Format("EXCEPTION! Stack chiamate: {0} Messaggio: {1}", ex.StackTrace, ex.Message)); } } private void TestMessages() { int par1 = -1, par2 = -1, par3 = -1; int id = -1; int trid = -1; int nozzleId = -1; string sValue = IniFile.IniReadValue(ConfigurationParams.inifile, "Test", "Messages"); string[] sElems; StreamReader sr = new StreamReader(ConfigurationParams.getSINPPath("ini\\") + sValue); while (sr.Peek() != -1) { sValue = sr.ReadLine(); sElems = sValue.Split(','); try { if (sElems.GetLength(0) > 1) { try { par1 = Convert.ToInt32(sElems[1]); } catch (Exception ex) { } } if (sElems.GetLength(0) > 2) { try { par2 = Convert.ToInt32(sElems[2]); } catch (Exception ex) { } } if (sElems.GetLength(0) > 3) { try { par3 = Convert.ToInt32(sElems[3]); } catch (Exception ex) { } } sValue = sElems[0]; id = par1; trid = par2; nozzleId = par3; } catch (Exception ex) { } if (sValue == "StartFuelPointTest") { manager.ifsfManager.StartFuelPointTest(id, null, null, null); } else if (sValue == "EndFuelPointTest") { this.manager.ifsfManager.EndFuelPointTest(id, null, null, null); } else if (sValue == "CloseFuelPoint") { this.manager.ifsfManager.CloseFuelPoint(id, null, null, null); } else if (sValue == "OpenFuelPoint") { this.manager.ifsfManager.OpenFuelPoint(id, null, null, null); } else if (sValue == "AuthoriseFuelPoint") { AuthorizeParameters authParams = new AuthorizeParameters(); authParams.PresetType = PresetType.Amount; authParams.PresetValue = 50; this.manager.ifsfManager.AuthoriseFuelPoint(id, trid, FuellingType.OptCardPaid, 0, authParams, null, null, null); } else if (sValue == "SuspendFuelling") { FUSIONPump pump = this.manager.GetPumpById(id); if (pump != null) pump.SuspendAsync(new EventHandler(Test_SuspendResult), null); //this.manager.ifsfManager.SuspendFuelling(id, null, null); } else if (sValue == "ResumeFuelling") { FUSIONPump pump = this.manager.GetPumpById(id); if (pump != null) pump.ResumeAsync(new EventHandler(Test_ResumeResult), null); //this.manager.ifsfManager.ResumeFuelling(id, null, null); } else if (sValue == "TerminateFuelling") { this.manager.ifsfManager.TerminateFuelling(id, null, null, null); } else if (sValue == "LogOff") { this.manager.ifsfManager.LogOff(); } else if (sValue == "LogOn") { this.manager.ifsfManager.LogOn("", ""); } else if (sValue == "GetFuelMode") { this.manager.ifsfManager.GetFuelMode(id, null, null, null); } else if (sValue == "GetModeTable") { this.manager.ifsfManager.GetModeTable(null, null, null); } else if (sValue == "ClearFuelSaleTrx") { this.manager.ifsfManager.ClearFuelSaleTrx(id, trid, 2, "",null, null, null); } else if (sValue == "LockFuelSaleTrx") { this.manager.ifsfManager.LockFuelSaleTrx(id, trid, 2, null, null, null); } else if (sValue == "UnlockFuelSaleTrx") { this.manager.ifsfManager.UnlockFuelSaleTrx(id, trid, 2, null, null, null); } else if (sValue == "GetCountrySettings") { this.manager.ifsfManager.GetCountrySettings(null, null, null); } else if (sValue == "GetCurrentFuellingStatus") { this.manager.ifsfManager.GetCurrentFuellingStatus(id, null, null, null); } else if (sValue == "LockNozzle") { this.manager.ifsfManager.LockNozzle(id, nozzleId, null, null, null); } else if (sValue == "UnlockNozzle") { this.manager.ifsfManager.UnlockNozzle(id, nozzleId, null, null, null); } else if (sValue == "GetDeviceState") { this.manager.ifsfManager.GetDeviceState(Wayne.FDCPOSLibrary.DeviceType.DT_FuelDispenser, id, null, null, null); } else if (sValue == "GetFuelPointTotals") { nozzleId = par2; this.manager.ifsfManager.GetFuelPointTotals(id, nozzleId, null, null, null); } else if (sValue == "CloseFuelPoint") { this.manager.ifsfManager.CloseFuelPoint(id, null, null, null); } else if (sValue == "OpenFuelPoint") { this.manager.ifsfManager.OpenFuelPoint(id, null, null, null); } else if (sValue == "ReserveFuelPoint") { FUSIONPump pump = this.manager.GetPumpById(id); if (pump != null) pump.ReserveAsync(FuellingType.Unknown, 0, new EventHandler(Test_ReserveResult), null); //this.manager.ifsfManager.ReserveFuelPoint(id, null, null); } else if (sValue == "FreeFuelPoint") { FUSIONPump pump = this.manager.GetPumpById(id); if (pump != null) pump.UnreserveAsync(new EventHandler(Test_UnreserveResult), null); //this.manager.ifsfManager.FreeFuelPoint(id, null, null); } else if (sValue == "GetFuelSaleTrxDetails") { this.manager.ifsfManager.GetFuelSaleTrxDetails(id, trid, 2, null, null, null); } else if (sValue == "GetAvailableFuelSaleTrxs") { this.manager.ifsfManager.GetAvailableFuelSaleTrxs(id, null, null, null); } else if (sValue == "ChangeFuelMode") { int priceGroup = par2; this.manager.ifsfManager.ChangeFuelMode(id, priceGroup, null, null, null); } else if (sValue == "SendConfig") { this.manager.ifsfManager.SendConfig(sElems[1], null, null, null); } else if (sValue == "SetDeviceAlarm") { this.manager.ifsfManager.SetDeviceAlarm("1", id, 1, "test alarms", null, null, null); } else if (sValue == "ChangeDSPLimits") { this.manager.ifsfManager.ChangeDSPLimits(id, 1, 1, 9, 88, null, null, null); } else if (sValue == "ChangeFuelPrice") { this.manager.ifsfManager.ChangeFuelPrice(id, 3.39m, 1, null, null, null); } else if (sValue == "CloseDevice") { this.manager.ifsfManager.CloseDevice(id, null, null, null); } else if (sValue == "GetConfiguration") { this.manager.ifsfManager.GetConfiguration(null, null, null); } else if (sValue == "GetDSPLimits") { this.manager.ifsfManager.GetDSPLimits(id,null,null,null); } //else if (sValue == "GetFPState") //{ // this.manager.ifsfManager.GetFPStateResp(id null); //} //else if (sValue == "GetFPState") //{ // this.manager.ifsfManager.GetFPStateResp(id null); //} else { } } sr.Close(); } public override string ToString() { return ("Forecourt Control ClientId=" + this.ClientId.ToString(CultureInfo.InvariantCulture)); } public void UnreserveFuelPricesAsync(EventHandler requestCompleted, object userToken) { //AsyncOperation operation = this.manager.AsyncManager.RegisterOperation(this, requestCompleted, userToken); //AsyncOperation operation2 = this.manager.AsyncManager.RegisterOperation(this, new EventHandler(this, (IntPtr)this.UnreserveFuelPricesAsyncCompleted), operation.Id); //Function function = new Function(6, new Parameter[] { new PrimitiveParameter(0x66, PrimitiveType.UInt16, operation2.Id) }); //this.manager.Send(function); if (this.manager.forecourtControl.fuelPriceReserved) this.manager.ifsfManager.ChangeFuelModeSend(this.manager.forecourtControl.srChangeMode, requestCompleted, userToken, this); foreach (IFuelPrice fuelprice in FuelPrices) { ((FUSIONFuelPrice)fuelprice).WritableReserved = false; } if (requestCompleted != null && !this.manager.forecourtControl.fuelPriceReserved) requestCompleted.BeginInvoke(this, new AsyncCompletedEventArgs(true, userToken), null, null); srChangeMode = null; fuelPriceReserved = false; } private void UnreserveFuelPricesAsyncCompleted(object sender, AsyncCompletedEventArgs e) { //AsyncOperation operation; //if (!(e.UserToken is ushort)) //{ // throw new Exception("UnreserveFuelPricesAsyncCompleted: Expected usertoken to be Uint16"); //} //this.manager.ReadFuelPrices(); //foreach (NfsFuelPrice price in this.fuelPriceList) //{ // price.WritableReserved = false; //} //if (this.manager.AsyncManager.TryGetOperation((ushort)e.UserToken, out operation)) //{ // operation.Complete(new AsyncCompletedEventArgs(e.Success, operation.UserToken)); //} } internal void WriteSiteMode(bool newSiteOpen, int newSiteMode) { //if ((newSiteMode != this.siteMode) || (newSiteOpen != this.siteOpened)) //{ // this.siteOpened = newSiteOpen; // this.siteMode = newSiteMode; // if ((this.OnSiteModeChange != null) && (this.connectionState != DeviceConnectionState.Connecting)) // { // this.OnSiteModeChange.Invoke(this, new SiteModeChangeEventArgs(this.siteMode, this.siteOpened)); // } //} } #endregion #region Properties public int ClientId { get { return int.Parse(this.manager.ifsfManager.clientSocket.workstationID); } } public string ClientName { get { return this.clientName; } } public DeviceConnectionState ConnectionState { get { return this.connectionState; } } public string EntitySubType { get { return ""; } } public string EntityType { get { return "FUSIONForecourtControl"; } } /// /// This is used by the logger and should never be set by implementing classes /// public string FullEntityName { get; set; } public ReadOnlyCollection FuelPrices { get { return this.fuelPriceList.AsReadOnly(); } } public int Id { get { return this.id; } set { id = value; } } public IIdentifiableEntity ParentEntity { get { return null; } } public ReadOnlyCollection PricePoles { get { return this.pricePoleList.AsReadOnly(); } } public ReadOnlyCollection Pumps { get { return this.pumpList.AsReadOnly(); } } public int SiteMode { get { return this.siteMode; } } public bool SiteOpened { get { return this.siteOpened; } } public ReadOnlyCollection TankGroups { get { return this.tankGroupList.AsReadOnly(); } } internal int WritableClientId { get { return this.id; } set { this.id = value; } } internal string WritableClientName { get { return this.clientName; } set { this.clientName = value; } } internal DeviceConnectionState WritableConnectionState { get { return this.connectionState; } set { Trace.WriteLine(string.Format("old connectionState={0}, new connectionState={1}", this.connectionState, value)); if (this.connectionState != value) { this.connectionState = value; if (connectionState == DeviceConnectionState.Connected) { foreach (FUSIONPump pump in Pumps) { //foreach (FUSIONFuelling fuelling in pump.Fuellings) // fuelling.Dispose(); pump.WritableFuellingList.Clear(); //((FUSIONFuelling)pump.CurrentFuelling).Dispose(); } // read current pump status //if (ConfigParam.IsEMSGVersion) //{ manager.ifsfManager.GetDeviceState(Wayne.FDCPOSLibrary.DeviceType.DT_FuellingPoint, -1, null, null, null); //} //else //{ // manager.ifsfManager.GetDeviceState(Wayne.FDCPOSLibrary.DeviceType.DT_TankProbe, -1, null, null, null); //} // read current Vir status //if (FUSIONVirFactory.Virs.Count > 0) // manager.ifsfManager.GetDeviceState(Wayne.FDCPOSLibrary.DeviceType.DT_Vir, -1, null, null, null); // get the list of offline fuelling manager.ifsfManager.GetAvailableFuelSaleTrxs(-1, null, null, null); } if (this.OnConnectionStateChange != null) { this.OnConnectionStateChange.Invoke(this, new ConnectionChangedEventArgs(value)); } } } } internal List WritableFuelPriceList { get { return this.fuelPriceList; } } internal List WritablePricePoleList { get { return this.pricePoleList; } } internal List WritablePumpList { get { return this.pumpList; } } internal int WritableSiteMode { get { return this.siteMode; } set { this.siteMode = value; } } internal bool WritableSiteOpened { get { return this.siteOpened; } set { this.siteOpened = value; } } internal List WritableTankGroupList { get { return this.tankGroupList; } } public IFuelPrice getFuelPriceByProductId(int productId) { foreach (IFuelPrice fuelprice in FuelPrices) { if (productId == fuelprice.FuelGrade) return fuelprice; } return null; } #endregion #region IForecourtControl Members public void ReservePumpClusterAsync(int terminalDeviceId, EventHandler requestCompleted, object userToken) { throw new NotImplementedException(); } public void UnreservePumpClusterAsync(int terminalDeviceId, EventHandler requestCompleted, object userToken) { throw new NotImplementedException(); } #endregion } }