public void StopTest()
        {
            if (!TestRunning)
            {
                return;
            }

            StopCapture();

#if (DEBUG)
            Console.WriteLine("Test Done");
#endif

            if (_CognitiveDisplay != null)  //close the cognitive display if it is open
            {
                _CognitiveDisplay.Close();
                _CognitiveDisplay.Dispose();
                _CognitiveDisplay = null;
            }

            //fire the test complete event
            if (TestComplete != null)
            {
                TestComplete(_CallbackState, _CallbackScriptID, DataCapture.CapturedPackets);
            }

            if (PostTestComplete != null)
            {
                PostTestComplete(_CallbackState);
            }
        }
        public void RunTest(object state, TestScript script)
        {
            if (TestRunning)    //don't allow a new test to be run while one is already running
            {
                throw new InvalidOperationException("A script is already running.");
            }

            if (_ScriptRenderer != null)    //clean up any existing script renderer
            {
                _ScriptRenderer.Dispose();
            }

            ScriptEngine ScriptEngine = new ScriptEngine(script.ScriptBody);

            //create a new script renderer for this control
            _ScriptRenderer = new TestScriptRenderer(this, ScriptEngine, ScriptEngine.Cognitive);

            if (ScriptEngine.Cognitive)
            {
                _CognitiveDisplay = new CognitiveMapForm();
                _CognitiveDisplay.Show();
                _CognitiveDisplay.RunScript(this, ScriptEngine);

                DrawPressureMode = ScriptEngine.PressureFeedback;
                DrawInk          = ScriptEngine.DirectFeedback;
            }
            else /*IsDirect*/
            {
                DrawPressureMode = ScriptEngine.PressureFeedback;
                DrawInk          = ScriptEngine.DirectFeedback;
            }

            mLabelInstructions.Text = ScriptEngine.Instructions;

            _CallbackScriptID = script.TestScriptID;
            _CallbackState    = state;

            //clear collected samples
            Clear();

            _TestTimeout    = ScriptEngine.TimeLimit;
            _TestLastSample = _TestStart = DateTime.UtcNow;
            StartCapture();
        }
        public void RunTest(object state, TestScript script)
        {
            if (TestRunning)    //don't allow a new test to be run while one is already running
                throw new InvalidOperationException("A script is already running.");

            if (_ScriptRenderer != null)    //clean up any existing script renderer
                _ScriptRenderer.Dispose();

            ScriptEngine ScriptEngine = new ScriptEngine(script.ScriptBody);

            //create a new script renderer for this control
            _ScriptRenderer = new TestScriptRenderer(this, ScriptEngine, ScriptEngine.Cognitive);

            if (ScriptEngine.Cognitive)
            {
                _CognitiveDisplay = new CognitiveMapForm();
                _CognitiveDisplay.Show();
                _CognitiveDisplay.RunScript(this, ScriptEngine);

                DrawPressureMode = ScriptEngine.PressureFeedback;
                DrawInk = ScriptEngine.DirectFeedback;
            }
            else /*IsDirect*/
            {
                DrawPressureMode = ScriptEngine.PressureFeedback;
                DrawInk = ScriptEngine.DirectFeedback;
            }

            mLabelInstructions.Text = ScriptEngine.Instructions;

            _CallbackScriptID = script.TestScriptID;
            _CallbackState = state;

            //clear collected samples
            Clear();

            _TestTimeout = ScriptEngine.TimeLimit;
            _TestLastSample = _TestStart = DateTime.UtcNow;
            StartCapture();
        }
        public void StopTest()
        {
            if (!TestRunning)
                return;

            StopCapture();

            #if(DEBUG)
            Console.WriteLine("Test Done");
            #endif

            if (_CognitiveDisplay != null)  //close the cognitive display if it is open
            {
                _CognitiveDisplay.Close();
                _CognitiveDisplay.Dispose();
                _CognitiveDisplay = null;
            }

            //fire the test complete event
            if (TestComplete != null)
                TestComplete(_CallbackState, _CallbackScriptID, DataCapture.CapturedPackets);

            if (PostTestComplete != null)
                PostTestComplete(_CallbackState);
        }