Example #1
0
 private void sensor_TemperatureChange(object sender, TemperatureChangeEventArgs e)
 {
     Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
     {
         ValueBox.Text = e.Temperature.ToString();
     }));
 }
        private void TemperatureChange(object sender, TemperatureChangeEventArgs e)
        {
            if (increasing && e.Temperature > topValue && lastValue < topValue)
            {
                Trigger();
            }
            else if (!increasing && e.Temperature < topValue && lastValue > topValue)
            {
                Trigger();
            }

            lastValue = e.Temperature;
        }
Example #3
0
        void Sensor_TemperatureChange(object sender, TemperatureChangeEventArgs e)
        {
            //when event fires, get temperature value and poll temperature values of all the others
            DateTime now  = DateTime.Now;
            TimeSpan diff = now.Subtract(start);

            try
            {
                writer.WriteLine(sensors[0].thermocouples[0].Temperature + "," + sensors[1].thermocouples[0].Temperature +
                                 "," + sensors[2].thermocouples[0].Temperature + "," + sensors[3].thermocouples[0].Temperature +
                                 "," + sensors[4].thermocouples[0].Temperature);
            }
            catch (PhidgetException ex)
            {
                MessageBox.Show(ex.Description, "Phidget Exception: " + ex.Code, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if ((int)diff.TotalMilliseconds > update.TotalMilliseconds +
                (zedGraphControl1.GraphPane.CurveList[0].NPts > 5000 ? 5000 : zedGraphControl1.GraphPane.CurveList[0].NPts))
            {
                try
                {
                    zedGraphControl1.GraphPane.CurveList[0].AddPoint(new XDate(now), sensors[0].thermocouples[0].Temperature);
                    zedGraphControl1.GraphPane.CurveList[1].AddPoint(new XDate(now), sensors[1].thermocouples[0].Temperature);
                    zedGraphControl1.GraphPane.CurveList[2].AddPoint(new XDate(now), sensors[2].thermocouples[0].Temperature);
                    zedGraphControl1.GraphPane.CurveList[3].AddPoint(new XDate(now), sensors[3].thermocouples[0].Temperature);
                    zedGraphControl1.GraphPane.CurveList[4].AddPoint(new XDate(now), sensors[4].thermocouples[0].Temperature);
                }
                catch (PhidgetException ex)
                {
                    MessageBox.Show(ex.Description, "Phidget Exception: " + ex.Code, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                dataCount.Text = zedGraphControl1.GraphPane.CurveList[0].NPts.ToString();

                zedGraphControl1.GraphPane.XAxis.Title.Text = "Time (" + zedGraphControl1.GraphPane.XAxis.Scale.Format + ")";

                zedGraphControl1.AxisChange();
                zedGraphControl1.Refresh();

                update = diff;
            }
        }
Example #4
0
        //Temperature Change event handler...We'll display the current temperature reading from the sensor to the
        //specified textbox as they come in
        void tempSensor_TemperatureChange(object sender, TemperatureChangeEventArgs e)
        {
            int index = (int)thermoCmb.SelectedItem;

            if (index == e.Index)
            {
                thermoTempTxt.Text = e.Temperature.ToString();
                thermoPotTxt.Text  = e.Potential.ToString();
                try
                {
                    onboardTempTxt.Text = ((TemperatureSensor)sender).ambientSensor.Temperature.ToString();
                }
                catch (PhidgetException ex)
                {
                    if (ex.Type == PhidgetException.ErrorType.PHIDGET_ERR_UNKNOWNVAL)
                    {
                        onboardTempTxt.Text = "Err";
                    }
                }
            }
        }
Example #5
0
        void therm_TemperatureChange(object sender, TemperatureChangeEventArgs e)
        {
            DateTime now  = DateTime.Now;
            TimeSpan diff = now.Subtract(start);

            //only actually update sometimes - otherwise it really freezes the display and the dataset gets too large
            //change the update rate at the ammount of data increases to a max of 5 second
            if ((int)diff.TotalMilliseconds > update.TotalMilliseconds +
                (zedGraphControl1.GraphPane.CurveList[0].NPts > 5000?5000:zedGraphControl1.GraphPane.CurveList[0].NPts))
            {
                zedGraphControl1.GraphPane.CurveList[0].AddPoint(new XDate(now), therm.ambientSensor.Temperature);
                zedGraphControl1.GraphPane.CurveList[1].AddPoint(new XDate(now), therm.thermocouples[0].Temperature);

                dataCount.Text = zedGraphControl1.GraphPane.CurveList[0].NPts.ToString();

                zedGraphControl1.GraphPane.XAxis.Title.Text = "Time (" + zedGraphControl1.GraphPane.XAxis.Scale.Format + ")";

                zedGraphControl1.AxisChange();
                zedGraphControl1.Refresh();

                update = diff;
            }
        }
        void therm_TemperatureChange(object sender, TemperatureChangeEventArgs e)
        {
            DateTime now = DateTime.Now;
            TimeSpan diff = now.Subtract(start);

            //only actually update sometimes - otherwise it really freezes the display and the dataset gets too large
            //change the update rate at the ammount of data increases to a max of 5 second
            if ((int)diff.TotalMilliseconds > update.TotalMilliseconds +
                (zedGraphControl1.GraphPane.CurveList[0].NPts>5000?5000:zedGraphControl1.GraphPane.CurveList[0].NPts))
            {
                zedGraphControl1.GraphPane.CurveList[0].AddPoint(new XDate(now), therm.ambientSensor.Temperature);
                zedGraphControl1.GraphPane.CurveList[1].AddPoint(new XDate(now), therm.thermocouples[0].Temperature);

                dataCount.Text = zedGraphControl1.GraphPane.CurveList[0].NPts.ToString();

                zedGraphControl1.GraphPane.XAxis.Title.Text = "Time (" + zedGraphControl1.GraphPane.XAxis.Scale.Format + ")";

                zedGraphControl1.AxisChange();
                zedGraphControl1.Refresh();

                update = diff;
            }
        }
Example #7
0
 //Temperature Changed event handler...we'll display the current measured
 //temperature to the console.
 static void tempSensor_TemperatureChange(object sender,
                                          TemperatureChangeEventArgs e)
 {
     Console.WriteLine("Temperature change: {0}", e.Temperature);
 }
 //Temperature Change event handler...We'll display the current temperature reading from the sensor to the
 //specified textbox as they come in
 void tempSensor_TemperatureChange(object sender, TemperatureChangeEventArgs e)
 {
     int index = (int)thermoCmb.SelectedItem;
     if (index == e.Index)
     {
         thermoTempTxt.Text = e.Temperature.ToString();
         thermoPotTxt.Text = e.Potential.ToString();
         try
         {
             onboardTempTxt.Text = ((TemperatureSensor)sender).ambientSensor.Temperature.ToString();
         }
         catch (PhidgetException ex)
         {
             if (ex.Type == PhidgetException.ErrorType.PHIDGET_ERR_UNKNOWNVAL)
                 onboardTempTxt.Text = "Err";
         }
     }
 }
 /// <summary>
 /// Eventhandler for handling temperature changes in the 
 /// environment.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void tempSensor_TemperatureChange(object sender, TemperatureChangeEventArgs e)
 {
     currentTemperature = (int)e.Temperature;
 }
 //Temperature Changed event handler...we'll display the current measured
 //temperature to the console.
 static void tempSensor_TemperatureChange(object sender, 
                                             TemperatureChangeEventArgs e)
 {
     Console.WriteLine("Temperature change: {0}", e.Temperature);
 }
Example #11
0
        void Sensor_TemperatureChange(object sender, TemperatureChangeEventArgs e)
        {
            //when event fires, get temperature value and poll temperature values of all the others
            DateTime now = DateTime.Now;
            TimeSpan diff = now.Subtract(start);

            try
            {
                writer.WriteLine(sensors[0].thermocouples[0].Temperature + "," + sensors[1].thermocouples[0].Temperature +
                            "," + sensors[2].thermocouples[0].Temperature + "," + sensors[3].thermocouples[0].Temperature +
                            "," + sensors[4].thermocouples[0].Temperature);
            }
            catch (PhidgetException ex)
            {
                MessageBox.Show(ex.Description, "Phidget Exception: " + ex.Code, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if ((int)diff.TotalMilliseconds > update.TotalMilliseconds +
                (zedGraphControl1.GraphPane.CurveList[0].NPts > 5000 ? 5000 : zedGraphControl1.GraphPane.CurveList[0].NPts))
            {
                try
                {
                    zedGraphControl1.GraphPane.CurveList[0].AddPoint(new XDate(now), sensors[0].thermocouples[0].Temperature);
                    zedGraphControl1.GraphPane.CurveList[1].AddPoint(new XDate(now), sensors[1].thermocouples[0].Temperature);
                    zedGraphControl1.GraphPane.CurveList[2].AddPoint(new XDate(now), sensors[2].thermocouples[0].Temperature);
                    zedGraphControl1.GraphPane.CurveList[3].AddPoint(new XDate(now), sensors[3].thermocouples[0].Temperature);
                    zedGraphControl1.GraphPane.CurveList[4].AddPoint(new XDate(now), sensors[4].thermocouples[0].Temperature);
                }
                catch (PhidgetException ex)
                {
                    MessageBox.Show(ex.Description, "Phidget Exception: " + ex.Code, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                dataCount.Text = zedGraphControl1.GraphPane.CurveList[0].NPts.ToString();

                zedGraphControl1.GraphPane.XAxis.Title.Text = "Time (" + zedGraphControl1.GraphPane.XAxis.Scale.Format + ")";

                zedGraphControl1.AxisChange();
                zedGraphControl1.Refresh();

                update = diff;
            }
        }