123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- using System;
- using Wayne.Lib;
- using Wayne.ForecourtControl.Fusion;
- #if _SINP
- using Wayne.ForecourtControl.Nfs;
- #endif
- namespace Wayne.ForecourtControl.OptBridge.Fusion
- {
- internal class FUSIONOpt : IOpt
- {
-
- private DeviceConnectionState connectionState;
- private int id;
- private FUSIONOptBridge _optBridge;
- public FUSIONOptBridge optBridge
- {
- get { return _optBridge; }
- set { _optBridge = value; }
- }
- private int reservedByClientId;
- public int IPPort=0, baudRate = 0, dataBit = 0, stopBit = 0, parity = 0;
- public string COMPort = "", address = "";
- public OPTManagedBy managedBy;
- public OptTCP optTCP;
-
- public event EventHandler<ConnectionChangedEventArgs> OnConnectionStateChange;
- public event EventHandler<OptDataEventArgs> OnDataRead;
-
- public FUSIONOpt(int id, FUSIONOptBridge _optBridge)
- {
- this.id = id;
- this.optBridge = _optBridge;
- }
- internal void FireOnDataRead(byte[] data)
- {
- if (this.OnDataRead != null)
- {
- this.OnDataRead.BeginInvoke(this, new OptDataEventArgs(data, 0), null, null);
- }
- }
- public void ReserveAsync(EventHandler<AsyncCompletedEventArgs> reserveCompleted, object userToken)
- {
-
-
-
- if (reserveCompleted != null)
- reserveCompleted.BeginInvoke(this, new AsyncCompletedEventArgs(true, userToken), null, null);
- }
- public void UnreserveAsync(EventHandler<AsyncCompletedEventArgs> unreserveCompleted, object userToken)
- {
-
-
-
- if (unreserveCompleted != null)
- unreserveCompleted.BeginInvoke(this, new AsyncCompletedEventArgs(true, userToken), null, null);
- }
- public void WriteAsync(byte[] terminalData, bool waitForSendOk, EventHandler<OptWriteCompletedEventArgs> writeCompleted, object userToken)
- {
-
-
-
-
- if (this.managedBy == OPTManagedBy.Fusion)
- this.optBridge.manager.ifsfManager.OptWrite(this.Id, terminalData, writeCompleted, userToken, this);
-
- else
- this.optTCP.OptWrite(terminalData, writeCompleted, userToken, this);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- public DeviceConnectionState ConnectionState
- {
- get
- {
- return this.connectionState;
- }
- }
- public int Id
- {
- get
- {
- return this.id;
- }
- }
- public int ReservedByClientId
- {
- get
- {
- return this.reservedByClientId;
- }
- }
- internal DeviceConnectionState WritableConnectionState
- {
- get
- {
- return this.connectionState;
- }
- set
- {
- if (this.connectionState != value)
- {
- this.connectionState = value;
- Trace.WriteLine(string.Format("FUSIONOpt WritableConnectionState={0}", value));
- if (this.OnConnectionStateChange != null)
- {
- this.OnConnectionStateChange.BeginInvoke(this, new ConnectionChangedEventArgs(this.connectionState), null, null);
- }
- }
- }
- }
- internal int WritableReservedByClientId
- {
- get
- {
- return this.reservedByClientId;
- }
- set
- {
- this.reservedByClientId = value;
- }
- }
- }
- }
|