Beispiel #1
0
        protected virtual void OnSend(RXSendMessage sendMsg)
        {
            var maybeReadRequest           = AttributeReadRequest.DecodeFromByteArray(sendMsg.Bytes);
            AttributeReadResult readResult = new AttributeReadResult
            {
                ReadState = AttributeReadState.Error
            };

            if (Attributes.ContainsKey(maybeReadRequest.RequestKey))
            {
                var value = Attributes[maybeReadRequest.RequestKey];
                readResult = new AttributeReadResult
                {
                    RequestGuid = maybeReadRequest.RequestGuid,
                    ReadState   = AttributeReadState.Successful,
                    Value       = value
                };
            }
            else
            {
                readResult = new AttributeReadResult
                {
                    RequestGuid = maybeReadRequest.RequestGuid,
                    ReadState   = AttributeReadState.NonExsited
                };
            }
            RXReceiveMessage receiveMessage = new RXReceiveMessage
            {
                RXConnection = this,
                Bytes        = readResult.EncodeToBytesArray()
            };

            OnReceived?.Invoke(this, receiveMessage);
        }
Beispiel #2
0
 public Task SendAsync(RXSendMessage sendMsg)
 {
     return(Task.Run(() =>
     {
         OnSend(sendMsg);
     }));
 }
        public async Task SendAsync(RXSendMessage rxMessage)
        {
            var rxConnection = _SelectConnection(_RXConnectionList.ToArray(), rxMessage);

            if (rxConnection == null)
            {
                System.Diagnostics.Debug.WriteLine("NO CONNECTION, SEND SHIT");
            }
            else
            {
                await rxConnection.SendAsync(rxMessage);
            }
        }
        public IRXConnection _SelectConnection(IRXConnection[] preFilteredConnection, RXSendMessage message)
        {
            if (preFilteredConnection.Length == 0)
            {
                return(null);
            }
            IRXConnection connection = null;

            foreach (var conn in preFilteredConnection)
            {
                if (conn.ConnectionGroup is LocalConnectionGroup)
                {
                    if (message.ChannelCode != 0)
                    {
                        continue;
                    }
                }
                connection = conn;
                break;
            }
            return(connection);
        }
 public async Task SendAsync(RXDevice rxDevice, RXSendMessage rxMessage)
 {
 }