示例#1
0
 /// <summary>
 /// Constructs a new DeviceTableEntry instance
 /// </summary>
 /// <param name="instance">The device instance</param>
 /// <param name="address">The address of the device</param>
 /// <param name="maxAppgramLength">The maximum appgram length that this device can receive</param>
 /// <param name="segmentationSupport">The segmentation support of the device</param>
 /// <param name="vendorId">The vendor id of the device</param>
 public DeviceTableEntry(uint instance, Address address, uint maxAppgramLength, Segmentation segmentationSupport, ushort vendorId)
 {
     this.Instance = instance;
     this.Address = address;
     this.MaxAppgramLength = maxAppgramLength;
     this.SegmentationSupport = segmentationSupport;
     this.VendorId = vendorId;
 }
示例#2
0
 /// <summary>
 /// Processes a received complex ack
 /// </summary>
 /// <param name="source">The address of the device that sent the ack</param>
 /// <param name="message">The complex ack header</param>
 /// <param name="segment">The buffer segment containing the ack content</param>
 public void ProcessComplexAck(Address source, ComplexAckMessage message, BufferSegment segment)
 {
     ClientTransaction tx = null;
     lock (_lock)
     {
         tx = _getClientTransaction(source, message.InvokeId);
     }
     if(tx != null)
         tx.OnComplexAck(message, segment);
 }
示例#3
0
 /// <summary>
 /// Gets a device table entry by address
 /// </summary>
 /// <param name="address">The device's address</param>
 /// <returns>The device table entry, or null if no entry exists</returns>
 public DeviceTableEntry GetByAddress(Address address)
 {
     for(int i = 0; i < _count; i++)
     {
         int index = (_start + i) % _entries.Length;
         var entry = _entries[index];
         if (entry != null && entry.Address == address)
             return entry;
     }
     return null;
 }
示例#4
0
 /// <summary>
 /// Processes a received abortion
 /// </summary>
 /// <param name="source">The address of the device that sent the abortion</param>
 /// <param name="message">The abortion</param>
 public void ProcessAbort(Address source, AbortMessage message)
 {
     if (message.Server)
     {
         ClientTransaction tx = null;
         lock(_lock)
         {
             tx = _getClientTransaction(source, message.InvokeId);
         }
         if(tx != null)
             tx.OnAbort(message);
     }
 }
 /// <summary>
 /// Constructs a new inbound unconfirmed request
 /// </summary>
 /// <param name="sourceAddress">The device that sent the request</param>
 /// <param name="source">The device table entry of the device that sent the request</param>
 /// <param name="request">The request instance</param>
 public InboundUnconfirmedRequest(Address sourceAddress, DeviceTableEntry source, IUnconfirmedRequest request)
 {
     this.SourceAddress = sourceAddress;
     this.Source = source;
     this.Request = request;
 }
示例#6
0
 /// <summary>
 /// Processes a received confirmed request
 /// </summary>
 /// <param name="source">The address of the device that sent the request</param>
 /// <param name="message">The confirmed request header</param>
 /// <param name="segment">The buffer segment containing the request content</param>
 public void ProcessConfirmedRequest(Address source, ConfirmedRequestMessage message, BufferSegment segment)
 {
 }
示例#7
0
        /// <summary>
        /// Sends a confirmed request
        /// </summary>
        /// <param name="handle">The transaction handle</param>
        /// <param name="destination">The destination address</param>
        /// <param name="serviceChoice">The service choice of the request</param>
        /// <param name="request">The request to send</param>
        public void SendConfirmedRequest(ClientTransactionHandle handle, Address destination, byte serviceChoice, byte[] request)
        {
            lock(_lock)
            {
                byte invokeId = _getClientInvokeId();

                var transaction = new ClientTransaction(
                    _host,
                    this,
                    handle,
                    invokeId,
                    destination,
                    serviceChoice,
                    request);

                this._clientTransactions.Add(transaction);
            }
        }
示例#8
0
 /// <summary>
 /// Gets the client transaction that matches
 /// a remote address, invoke id pair
 /// </summary>
 /// <param name="address">The remote address</param>
 /// <param name="invokeId">The invoke id</param>
 /// <returns>The client transaction, or null of no transaction exists</returns>
 private ClientTransaction _getClientTransaction(Address address, byte invokeId)
 {
     for(int i = 0; i < _clientTransactions.Count; i++)
     {
         var tx = _clientTransactions[i];
         if (tx.Matches(address, invokeId))
             return tx;
     }
     return null;
 }
示例#9
0
 /// <summary>
 /// Processes a received simple ack
 /// </summary>
 /// <param name="source">The address of the device that sent the ack</param>
 /// <param name="message">The simple ack</param>
 public void ProcessSimpleAck(Address source, SimpleAckMessage message)
 {
     ClientTransaction tx = null;
     lock (_lock)
     {
         tx = _getClientTransaction(source, message.InvokeId);
     }
     if(tx != null)
         tx.OnSimpleAck(message);
 }
示例#10
0
 /// <summary>
 /// Processes a received rejection
 /// </summary>
 /// <param name="source">The address of the device that sent the rejection</param>
 /// <param name="message">The rejection</param>
 public void ProcessReject(Address source, RejectMessage message)
 {
     ClientTransaction tx = null;
     lock (_lock)
     {
         tx = _getClientTransaction(source, message.InvokeId);
     }
     if(tx != null)
         tx.OnReject(message);
 }
示例#11
0
 /// <summary>
 /// Processes a received error
 /// </summary>
 /// <param name="source">The address of the device that sent the error</param>
 /// <param name="message">The error</param>
 public void ProcessError(Address source, ErrorMessage message)
 {
     ClientTransaction tx = null;
     lock (_lock)
     {
         tx = _getClientTransaction(source, message.InvokeId);
     }
     if(tx != null)
         tx.OnError(message);
 }
示例#12
0
 /// <summary>
 /// Determines whether this transaction matches a supplied
 /// remote address and invoke id pair
 /// </summary>
 /// <param name="address">The remote address</param>
 /// <param name="invokeId">The invoke id</param>
 /// <returns>True if the transaction matches, false otherwise</returns>
 public bool Matches(Address address, byte invokeId)
 {
     var entry = this._device;
     if (entry == null)
         return false;
     return entry.Address == address && _invokeId == invokeId;
 }
示例#13
0
 /// <summary>
 /// Constructs a new ClientTransaction instance
 /// </summary>
 /// <param name="host">The host that initiated the transaction</param>
 /// <param name="manager">The transaction manager</param>
 /// <param name="handle">The handle used to control this transaction and process its response</param>
 /// <param name="invokeId">The invocation id for the transaction</param>
 /// <param name="deviceAddress">The address of the destination device</param>
 /// <param name="serviceChoice">The service choice of the request</param>
 /// <param name="request">The request content</param>
 public ClientTransaction(Host host, TransactionManager manager, ClientTransactionHandle handle, byte invokeId, Address deviceAddress, byte serviceChoice, byte[] request)
 {
     this._host = host;
     this._manager = manager;
     this._handle = handle;
     this._invokeId = invokeId;
     this._serviceChoice = serviceChoice;
     this._request = request;
     this._state = ClientState.GetDeviceInfo;
     this._handle.SetTransaction(this);
     host.SearchForDevice(deviceAddress, this);
 }