Exemple #1
0
        protected override bool PortResponse(PortEvent pEvent)
        {
            if (pEvent.Name == Test.Steps[CurrentStep].Actor.Name)
            {
                try
                {
                    if ((!string.IsNullOrEmpty(CurrentResponse)) && (CurrentResponse.Contains(pEvent.Message)))
                    {
                        return(false);
                    }

                    // TEST ONLY...
                    //System.Threading.Thread.Sleep(100);

                    // DESIGN NOTE:
                    // - Finding the appropriate response by command allows the responses to be out of sequence with the steps of a test
                    // PROBLEM: Each response must be unique to allow lookup. This means if a test contains duplicate commands the count of responses will be less than the count of steps in the test.
                    CurrentResponse = FindResponse(pEvent.Message == Test.Steps[CurrentStep].Actor.Action ? Test.Steps[CurrentStep].Actor.Action : pEvent.Message.IndexOf(' ') == -1 ? pEvent.Message : pEvent.Message.Substring(0, pEvent.Message.IndexOf(' ')).Trim());
                    Step(new TestEvent(InternalSignal.TestStep, Name), Retries);
                    if (++Retries > Test.Steps[CurrentStep].Retries)
                    {
                        NextStep();
                    }
                }
                catch (Exception ex)
                {
                    TransitionToFailed(ex.Message);
                }
            }
            return(false);
        }
Exemple #2
0
 protected void Closing(PortEvent pEvent)
 {
     if (Name == pEvent.Name)
     {
         TransitionTo(m_StateClosing, s_TranIdx_Opened_Closing);
         PostFIFO(new PortEvent(InternalSignal.PortClosing, pEvent));
     }
 }
Exemple #3
0
 protected void Opening(PortEvent pEvent)
 {
     if (Name == pEvent.Name)
     {
         TransitionTo(m_StateOpening, s_TranIdx_Created_Opening);
         PostFIFO(new PortEvent(InternalSignal.PortOpening, pEvent));
     }
 }
Exemple #4
0
 protected virtual void PortTimeout(PortEvent pEvent)
 {
     if ((Retries + 1) <= Test.Steps[CurrentStep].Retries)
     {
         Step(new TestEvent(InternalSignal.TestStep, Name), Retries + 1);
     }
     else
     {
         TransitionToFailed("Response not recevied within timeout from Port '" + pEvent.Name + "' in Solicited Mode.");
     }
 }
Exemple #5
0
        protected virtual bool PortResponse(PortEvent pEvent)
        {
            bool complete = false;

            if (string.IsNullOrEmpty(pEvent.Message))
            {
                return(false);
            }

#if UUT_TEST
            // In test mode, ignore the command being looped back...
            if ((pEvent.Message == Test.Steps[CurrentStep].Actor.Action) ||
                ((pEvent.Message.IndexOf(' ') >= 0) && (Test.Steps[CurrentStep].Actor.Action == pEvent.Message.Substring(0, pEvent.Message.IndexOf(' ')).Trim())))
            {
                return(false);
            }
#endif

            string delimiter = "\r\n";
            string trailer   = string.Empty;
            if (Test.Steps[CurrentStep].Response != null)
            {
                delimiter = Test.Steps[CurrentStep].Response.Delimiter;
                trailer   = Test.Steps[CurrentStep].Response.Trailer;
            }

            bool processResponse = false;
            // Put response element delimiter back if it was stripped during port processing...
            string response = pEvent.Message.EndsWith(delimiter) ? pEvent.Message : pEvent.Message + delimiter;

            // Only accumulate response elements if a trailer has been defined...
            if ((!Test.Steps[CurrentStep].CompleteOnTimeout) && (string.IsNullOrEmpty(trailer)))
            {
                ResponseBuffer  = response;
                processResponse = true;
            }
            // DESIGN NOTE: Also process the trailer (usually the UUT mode prompt) as part of the full response...
            else
            {
                ResponseBuffer += response;
                if ((!string.IsNullOrEmpty(trailer)) && (pEvent.Message.EndsWith(trailer)))
                {
                    processResponse = true;
                }
            }

            if (processResponse)
            {
                complete = ProcessPortResponse();
            }

            return(complete);
        }
Exemple #6
0
 protected void Close(PortEvent pEvent)
 {
     if ((Name == pEvent.Name) && (Port.State == PortState.Opened))
     {
         Port.Close();
         if (Port.State != PortState.Closed)
         {
             TransitionTo(m_StateFaulted, s_TranIdx_Closing_Faulted);
         }
         else
         {
             TransitionTo(m_StateClosed, s_TranIdx_Closing_Closed);
         }
     }
 }
Exemple #7
0
 protected void Open(PortEvent pEvent)
 {
     if ((Name == pEvent.Name) && (Port.State == PortState.Created))
     {
         Port.Open();
         if (Port.State != PortState.Opened)
         {
             TransitionTo(m_StateFaulted, s_TranIdx_Opening_Faulted);
         }
         else
         {
             TransitionTo(m_StateOpened, s_TranIdx_Opening_Opened);
         }
     }
 }
Exemple #8
0
        protected void Transmit(PortEvent pEvent)
        {
            if (Name == pEvent.Name)
            {
                if (pEvent.Timeout >= 0)
                {
                    Port.ReceiveTimeout = pEvent.Timeout;
                }
                if (pEvent.Retries >= 0)
                {
                    Port.TransmitRetries = pEvent.Retries;
                }

                Port.Transmit(pEvent.Message, true);
            }
        }
Exemple #9
0
        internal PortEvent(InternalSignal signal, PortEvent source)
            : base((int)signal)
        {
            switch (signal)
            {
            case InternalSignal.PortOpening:
            case InternalSignal.PortClosing:
                Name    = source.Name;
                Message = source.Message;
                Timeout = source.Timeout;
                Retries = source.Retries;
                Error   = source.Error;
                AdditionalDescription = source.AdditionalDescription;
                break;

            default:
                throw new ArgumentException("Invalid internal port signal.", "signal");
            }
        }