123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- using System;
- using System.Collections.Generic;
- using Wayne.Lib;
- using Wayne.ForecourtControl.Fusion;
- #if _SINP
- using Wayne.ForecourtControl.Nfs;
- #endif
- namespace Wayne.ForecourtControl.Vir.Fusion
- {
- internal class FUSIONVirId: IVirId
- {
- // Fields
- private int deviceId;
- private string virId;
-
- // Methods
- public FUSIONVirId(int deviceId, string virId)
- {
- this.deviceId = deviceId;
- this.virId = virId;
- }
- public string Id
- {
- get { return virId; }
- }
- }
- internal class FUSIONVir : IVir //, IDisposable
- {
- // Fields
- private int id;
- List<IVirId> virIdList;
- public FUSIONManager manager;
- // Events
- public event EventHandler<VIRStateChangedEventArgs> OnVirIdStateChange;
- // Methods
- public FUSIONVir(int fcId, int id)
- {
- //Trace.Add(this);
- if (!FUSIONFactory.fusionForecourtControlList.ContainsKey(fcId))
- {
- Trace.WriteLine(string.Format("fusionForecourtControl id={0} NOT exist - creating", fcId));
- Wayne.ForecourtControl.Fusion.FUSIONFactory.CreateForecourtControl(fcId);
- }
- if (FUSIONFactory.fusionForecourtControlList.ContainsKey(fcId))
- {
- Trace.WriteLine(string.Format("fusionForecourtControl id={0} adding event OnConnectionStateChange", fcId));
- manager = ((FUSIONForecourtControl)(FUSIONFactory.fusionForecourtControlList[fcId])).manager;
- //this.manager.ifsfManager.clientSocket.OnConnectionStateChange += new EventHandler<ConnectionChangedEventArgs>(clientSocket_OnConnectionStateChange); //new EventHandler<ConnectionChangedEventArgs>(this, (IntPtr)this.clientSocket_OnConnectionStateChange);
- }
- else
- Trace.WriteLine(string.Format("fusionForecourtControl id={0} NOT exist - error!!!", fcId));
- this.id = id;
- this.virIdList = new List<IVirId>();
-
- if (manager != null)
- manager.ifsfManager.GetDeviceState(Wayne.FDCPOSLibrary.DeviceType.DT_Vir, id, null, null, null);
- }
- // Properties
- public int Id
- {
- get
- {
- return this.id;
- }
- }
- public System.Collections.ObjectModel.ReadOnlyCollection<IVirId> VirIds
- {
- get { return virIdList.AsReadOnly(); }
- }
- //public void Dispose()
- //{
- // foreach (FUSIONVirId virId in this.virIdList)
- // {
- // virId.Dispose();
- // }
- //}
- public FUSIONVirId getVirId(string virId)
- {
- foreach (FUSIONVirId virIdElem in virIdList)
- {
- if (virIdElem.Id == virId)
- return virIdElem;
- }
- return null;
- }
- public DeviceConnectionState State(string virId)
- {
- FUSIONVirId virIdElem = getVirId(virId);
- if (virIdElem != null)
- {
- return DeviceConnectionState.Connected;
- }
- return DeviceConnectionState.Disconnected;
- }
- public void Connected(string virId)
- {
- FUSIONVirId virIdElem = getVirId(virId);
- if (virIdElem == null)
- {
- this.virIdList.Add(new FUSIONVirId(this.Id, virId));
- if (this.OnVirIdStateChange != null)
- {
- this.OnVirIdStateChange.BeginInvoke(this, new VIRStateChangedEventArgs(this.Id, virId, DeviceConnectionState.Connected), null, null);
- }
- Trace.WriteLine(string.Format("Connected: virId={0} added", virId));
- }
- else
- Trace.WriteLine(string.Format("Connected: virId={0} already connected", virId));
- }
- public void Disconnected(string virId)
- {
- FUSIONVirId virIdElem = getVirId(virId);
- if (virIdElem != null)
- {
- this.virIdList.Remove(virIdElem);
- if (this.OnVirIdStateChange != null)
- {
- this.OnVirIdStateChange.BeginInvoke(this, new VIRStateChangedEventArgs(this.Id, virId, DeviceConnectionState.Disconnected), null, null);
- }
- Trace.WriteLine(string.Format("Disconnected: virId={0} removed", virId));
- }
- else
- Trace.WriteLine(string.Format("Disconnected: virId={0} not found!", virId));
- }
- }
- }
|