Esempio n. 1
0
        /// <summary>
        /// Tests disconnecting of the device with sensors still connected.
        /// </summary>
        /// <param name="testDevice"></param>
        public static void TestDeviceDrop(ITestDevice testDevice)
        {
            Console.WriteLine("Starting device drop test of " + testDevice.GetType().Name + "...");
            Console.WriteLine();

            // Get main thread ID
            mainThreadId = Thread.CurrentThread.ManagedThreadId;

            // Get Device
            Console.WriteLine("\nGetting device...");
            IDevice device = testDevice.GetDevice();
            device.Disconnected += new Action<IDevice>(device_Disconnected);
            device.Dropped += new Action<IDevice>(device_Dropped);

            // Create sensor
            Console.WriteLine("\nCreating raw sensor on channel A...");
            ISensor sensor = testDevice.GetSensor(device);
            sensor.Started += new SensorEventHandler(sensor_Started);
            sensor.Stopped += new SensorEventHandler(sensor_Stopped);
            sensor.Removed += new SensorEventHandler(sensor_Removed);
            sensor.Dropped += new SensorEventHandler(sensor_Dropped);

            // Start sensor
            Console.WriteLine("\nStarting sensor...");
            sensor.Start();

            return;
        }
 /// <summary>
 /// Construct and initialize a test device controller object.
 /// </summary>
 /// <param name="Name">The name of the device</param>
 /// <param name="TestClient">A test device object which will communicate with this controller</param>
 public TestController(string Name, ITestDevice TestClient)
     : base(Name)
 {
     this.TestClient = TestClient;
     this.TestClient.OnDataReceived += TestClient_OnDataReceived;
     this.TestClient.OnError        += TestClient_OnError;
 }
 /// <summary>
 /// Construct and initialize a test device controller object.
 /// </summary>
 /// <param name="Name">The name of the device</param>
 /// <param name="TestClient">A test device object which will communicate with this controller</param>
 public TestController(string Name, ITestDevice TestClient)
     : base(Name)
 {
     this.TestClient = TestClient;
     this.TestClient.OnDataReceived += TestClient_OnDataReceived;
     this.TestClient.OnError += TestClient_OnError;
 }
Esempio n. 4
0
        protected void DoNext(ITestDevice device)
        {
            cts = new CancellationTokenSource();
            ThreadPool.QueueUserWorkItem(state => ReadPacketTask(cts.Token));

            _device      = device;
            unsubscriber = device.Subscribe(this);
            _device.SendPacket(sendPacket.GetSendPacket(_device.GetPhysicalAddress(), _device.GetSourceIPAddress()));
        }
Esempio n. 5
0
 public override void Start(ITestDevice device)
 {
     DoNext(device);
 }
Esempio n. 6
0
        static void GatherData(ITestDevice testDevice, ISensor sensor)
        {
            const int dataPrintSeconds = 5;

            DateTime startTime = DateTime.Now;

            int totalSamples = 0;

            //Get Data for a certain amount of time
            while ((DateTime.Now - startTime).TotalSeconds < dataPrintSeconds)
            {
                int samples;
                String currentData = testDevice.GetCurrentData(sensor, out samples);

                totalSamples += samples;

                float samplesPerSecond = (float)(totalSamples / (DateTime.Now - startTime).TotalSeconds);
                Console.WriteLine(String.Format("{0:0.000}: {1}", samplesPerSecond, currentData));
            }

            return;
        }
Esempio n. 7
0
        /// <summary>
        /// Tests normal user operation getting data from a sensor.
        /// </summary>
        /// <param name="testDevice"></param>
        public static void TestNormalOperation(ITestDevice testDevice)
        {
            Console.WriteLine("Starting normal operation test of " + testDevice.GetType().Name + "...");
            Console.WriteLine();

            // Get main thread ID
            mainThreadId = Thread.CurrentThread.ManagedThreadId;

            // Get Device
            Console.WriteLine("\nGetting device...");
            IDevice device = testDevice.GetDevice();
            device.Disconnected += new Action<IDevice>(device_Disconnected);

            // Create sensor
            Console.WriteLine("\nCreating raw sensor on channel A...");
            ISensor sensor = testDevice.GetSensor(device);
            sensor.Started += new SensorEventHandler(sensor_Started);
            sensor.Stopped += new SensorEventHandler(sensor_Stopped);
            sensor.Removed += new SensorEventHandler(sensor_Removed);
            sensor.Dropped += new SensorEventHandler(sensor_Dropped);

            // Start sensor
            Console.WriteLine("\nStarting sensor...");
            sensor.Start();

            // Gather Data
            Console.WriteLine("\nGathering data...");
            GatherData(testDevice, sensor);

            // Stop sensor
            Console.WriteLine("\nStopping sensor...");
            sensor.Stop();

            // Remove Sensor
            Console.WriteLine("\nRemoving sensor...");
            sensor.Dispose();

            // Disconnect Device
            Console.WriteLine("\nRemoving device...");
            device.Dispose();

            // Remove device events
            device.Disconnected -= device_Disconnected;
            device.Dropped -= device_Dropped;

            // Remove sensor events
            sensor.Started -= sensor_Started;
            sensor.Stopped -= sensor_Stopped;
            sensor.Removed -= sensor_Removed;
            sensor.Dropped -= sensor_Dropped;

            return;
        }
Esempio n. 8
0
        /// <summary>
        /// Tests the device using the device-specific tests.
        /// </summary>
        /// <param name="testDevice"></param>
        public static void TestDeviceSpecificTests(ITestDevice testDevice)
        {
            // Do device specific tests
            Console.WriteLine("Starting device-specific tests...");
            testDevice.RunSpecificTests();

            return;
        }
Esempio n. 9
0
 abstract public void Start(ITestDevice device);