예제 #1
0
        public void TestGetSensorData()
        {
            SensorData data = null;

            data = _plc.GetSensorData();

            Assert.AreEqual(123.456, data.Temperature);
            Assert.AreEqual(78.901, data.Speed);
        }
예제 #2
0
        /// <summary>
        /// Gets the temperature and speed readings from the plc and displays them.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void GetReadings(object sender, EventArgs e)
        {
            SensorData readings;

            try
            {
                readings = _plc.GetSensorData();
            }
            catch
            {
                MessageBox.Show("Error readings sensors.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            lblSpeed.Content       = "Motor Speed: " + readings.Speed.ToString();
            lblTemperature.Content = "Temperature: " + readings.Temperature.ToString();
        }