Exemple #1
0
        public async Task <InvokeResult <TMavlinkPacket> > WaitForMessageAsync <TMavlinkPacket>(UasMessages messageId, TimeSpan timeout) where TMavlinkPacket : class
        {
            await Task.Delay(1);

            return(InvokeResult <TMavlinkPacket> .FromError("Uknown"));
        }
Exemple #2
0
        public async Task <InvokeResult <TMavlinkPacket> > RequestDataAsync <TMavlinkPacket>(UasMessage msg, UasMessages incomingMessageId) where TMavlinkPacket : class
        {
            await Task.Delay(1);

            return(InvokeResult <TMavlinkPacket> .FromError("Uknown"));
        }
 public Task <InvokeResult <TMavlinkPacket> > RequestDataAsync <TMavlinkPacket>(UasMessage msg, UasMessages incomingMessageId) where TMavlinkPacket : class
 {
     SendMessage(msg);
     return(WaitForMessageAsync <TMavlinkPacket>(incomingMessageId, TimeSpan.FromSeconds(2)));
 }
 public WaitOnRequest(UasMessages msgId)
 {
     CompletionSource = new TaskCompletionSource <MavLinkPacket>();
     MsgId            = msgId;
     Details          = new List <string>();
 }
        public async Task <InvokeResult <TMavlinkPacket> > WaitForMessageAsync <TMavlinkPacket>(UasMessages messageId, TimeSpan timeout) where TMavlinkPacket : class
        {
            try
            {
                var wor = new WaitOnRequest(messageId);
                Sessions[messageId] = wor;

                MavLinkPacket message = null;

                for (var idx = 0; (idx < timeout.TotalMilliseconds / 100) && message == null; ++idx)
                {
                    if (wor.CompletionSource.Task.IsCompleted)
                    {
                        message = wor.CompletionSource.Task.Result;
                    }
                    await Task.Delay(100);
                }

                if (message == null)
                {
                    return(InvokeResult <TMavlinkPacket> .FromError("Timeout waiting for message."));
                }
                else
                {
                    if (message.Message is TMavlinkPacket)
                    {
                        return(InvokeResult <TMavlinkPacket> .Create(message.Message as TMavlinkPacket));
                    }
                    else
                    {
                        return(InvokeResult <TMavlinkPacket> .FromError("Invalid type."));
                    }
                }
            }
            catch (Exception ex)
            {
                return(InvokeResult <TMavlinkPacket> .FromException("AsyncCoupler_WaitOnAsync", ex));
            }
            finally
            {
                Sessions.TryRemove(messageId, out WaitOnRequest obj);
            }
        }
Exemple #6
0
 public Task <InvokeResult <TMavlinkPacket> > RequestDataAsync <TMavlinkPacket>(UasMessage msg, UasMessages incomingMessageId) where TMavlinkPacket : class
 {
     throw new NotImplementedException();
 }
Exemple #7
0
 public Task <InvokeResult <TMavlinkPacket> > WaitForMessageAsync <TMavlinkPacket>(UasMessages messageId, TimeSpan timeout) where TMavlinkPacket : class
 {
     throw new NotImplementedException();
 }