Example #1
0
        private void ScriptLogResponse(object[] arguments, string logtype)
        {
            //valid log types
            // time

            if (arguments != null)
            {
                int timeout = 3000;
                int.TryParse((string)arguments[0], out timeout);
                string commandToSend = (string)arguments[1];
                //this is the response to look for if there is no argument
                string checkString = "";
                if (arguments.Length > 2)
                {
                    //this is the response to look for if there is an argument
                    checkString = (string)arguments[2];
                }
                //make sure there is a dialog available
                createTestDialog();
                ResponseAnalyzer res = new ResponseAnalyzer(checkString, ResultWindow);
                bool passedtest = false;
                bool testcomplete = false;
                string collectedData = "";

                //turn on the local buffer so the data is kept
                localBuffer = true;

                //send the command to ther terminal
                sendDataToSerialConnectionBasic(commandToSend);

                //start a timer and continue to check the response for a while
                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();
                long duration = stopWatch.ElapsedMilliseconds;
                bool stopnow = false;
                while (!stopnow && !AllWindowsClosed)
                {
                    //the the GUI redraw
                    Application.DoEvents();
                    //see if the response is in the buffer
                    switch (logtype)
                    {
                        case "time":
                            testcomplete = res.getResponseData(localBufferData, out collectedData);
                            break;

                        default:
                            break;
                    }

                    if (testcomplete)
                    {
                        res.logResponse(commandToSend, collectedData);
                        stopnow = true;
                    }
                    else
                    {
                        //update the timer
                        duration = stopWatch.ElapsedMilliseconds;
                        stopnow = duration > timeout;
                    }
                }
                //timed out or found
                stopWatch.Stop();

                if (passedtest)
                {

                }
                else
                {

                }
                //clear the buffer and stop recording
                resetbuffer();
            }
        }
Example #2
0
        private void ScriptCheckForResponse(object[] arguments, string comparisontype)
        {
            //valid comparison types
            // string
            // greaterthan
            // lessthan
            // between

            if (arguments != null)
            {
                int timeout = 3000;
                int.TryParse((string)arguments[0], out timeout);
                string commandToSend = (string)arguments[1];
                //this is the response to look for
                string checkString = (string)arguments[2];

                //make sure there is a dialog available
                createTestDialog();
                ResponseAnalyzer res = new ResponseAnalyzer(checkString, ResultWindow);
                bool passedtest = false;
                bool testcomplete = false;
                string detail = "";

                //turn on the local buffer so the data is kept
                localBuffer = true;

                //send the command to ther terminal
                sendDataToSerialConnectionBasic(commandToSend);

                //start a timer and continue to check the response for a while
                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();
                long duration = stopWatch.ElapsedMilliseconds;
                bool stopnow = false;
                while (!stopnow)
                {
                    //the the GUI redraw
                    Application.DoEvents();
                    //see if the response is in the buffer
                    switch (comparisontype)
                    {
                        case "string":
                            testcomplete = res.checkForResponse(localBufferData, out passedtest);
                            break;

                        case "between":
                            int lowVal = 0;
                            int.TryParse((string)arguments[3], out lowVal);
                            int highVal = 100;
                            int.TryParse((string)arguments[4], out highVal);
                            testcomplete = res.checkValBetween(localBufferData, lowVal, highVal, out detail, out passedtest);
                            break;

                        default:
                            break;
                    }

                    if (testcomplete)
                    {
                        stopnow = true;
                    }
                    else
                    {
                        //update the timer
                        duration = stopWatch.ElapsedMilliseconds;
                        stopnow = duration > timeout;
                    }
                }
                //timed out or found
                stopWatch.Stop();

                if (passedtest)
                {
                    res.showPass(detail);
                    this.ResultWindow.Location = centerNewWindow(ResultWindow.Width, ResultWindow.Height);
                }
                else
                {
                    res.showFailure(detail);
                    this.ResultWindow.Location = centerNewWindow(ResultWindow.Width, ResultWindow.Height);
                }
                //clear the buffer and stop recording
                resetbuffer();
            }
        }