protected override Scenario.ScenarioResult internalRun(CancellationToken ct)
        {
            log.Info("sending a message of type: " + message.GetType().Name);
            IResponse         resp  = null;
            AsyncMessageToken token = null;

            if (device == null)
            {
                throw new DeviceNotInitException("The device object was not initilized correctly!");
            }
            try
            {
                if (temporaryConnection)
                {
                    device.connect();
                }

                if (device.SupportsAsyncOperations)
                {
                    token = device.sendAsyncMsg(message);
                }
                else
                {
                    device.sendMsg(message);
                }

                if (receiveAnswer)
                {
                    if (device.SupportsAsyncOperations)
                    {
                        resp = device.receiveAsyncAnswer(token);
                    }
                    else
                    {
                        resp = device.receiveAnswer(ct);
                    }
                    if (resp == null)
                    {
                        throw new UnknownOPException("response arrived as NULL");
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                throw ex;
            }
            finally
            {
                if (temporaryConnection)
                {
                    device.disconnect();
                }
            }

            ScenarioResult.RunResult runResult = ScenarioResult.RunResult.Pass;
            return(new ScenarioResult(runResult, resp));
        }
Exemple #2
0
        public override IResponse receiveAsyncAnswer(AsyncMessageToken messageToken)
        {
            Task <IResponse> t = Task <IResponse> .Run(() => findResponseInList(messageToken.Value)).TimeoutAfter(RECIEVE_TIMEOUT_MS);

            while (!t.IsCompleted)
            {
                System.Windows.Forms.Application.DoEvents();
                System.Threading.Thread.Sleep(1);
            }
            IResponse r = t.Result;

            t.Dispose();
            return(r);
        }
Exemple #3
0
 public virtual IResponse receiveAsyncAnswer(AsyncMessageToken messageToken)
 {
     throw new NotImplementedException();
 }