Max allowed Channels

Supporting Visual Studio on Windows
Post Reply
bigj4155
Phidgetsian
Posts: 8
Joined: Sat Dec 01, 2018 8:32 am
Contact:

Max allowed Channels

Post by bigj4155 »

Not sure if my other post was deleted when I fixed some typos in the subject name and body. So sorry if this is a dup.

My basic question is : Is there a Maximum amount of channels you can open at once? My problem is that I currently have 33 potential channels "I still have maybe 20 channels to setup on top of this" when I let the program roll through and open them all I get a exception "Phidget22.PhidgetException: 'PhidgetException 0x00000003 " but when I scale back to just 31 channels it works flawlessly. It does not matter which 2 channels I disable just that I do not have more than 31. Any hints?

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Phidget22;
using Phidget22.Events;


namespace RoomControlv2
{
    public partial class MainScreen : Form
    {
        Manager myPhidgetManager = new Manager();
        int PhidgetUpdateCycle =1000;
        HumiditySensor humidity = new HumiditySensor();
        double RmHumidity = 0;
        TemperatureSensor humiditytemp = new TemperatureSensor(); //temperature sensor in humidity phidget. Free reading.
        double RmHumidityTemp = 0; //temperature sensor in humidity phidget. Free reading.
        TemperatureSensor temperature = new TemperatureSensor();
        double RmTemperature = 3;
        VoltageInput light = new VoltageInput();
        double RmLight = 0;
        VoltageRatioInput waterlevel = new VoltageRatioInput();
        double RmWaterLevel = 0;
        PHSensor ph = new PHSensor();
        double RmPh = 0;

        TemperatureSensor ThermoCouple1TC0 = new TemperatureSensor();
        double RmThermoCouple1TC0 = 0;
        TemperatureSensor ThermoCouple1TC1 = new TemperatureSensor();
        double RmThermoCouple1TC1 = 0;
        TemperatureSensor ThermoCouple1TC2 = new TemperatureSensor();
        double RmThermoCouple1TC2 = 0;
        TemperatureSensor ThermoCouple1TC3 = new TemperatureSensor();
        double RmThermoCouple1TC3 = 0;
        TemperatureSensor ThermoCouple1TC4 = new TemperatureSensor(); //ambient temp in sensor
        double RmThermoCouple1TC4 = 0;

        TemperatureSensor ThermoCouple2TC0 = new TemperatureSensor();
        double RmThermoCouple2TC0 = 0;
        TemperatureSensor ThermoCouple2TC1 = new TemperatureSensor();
        double RmThermoCouple2TC1 = 0;
        TemperatureSensor ThermoCouple2TC2 = new TemperatureSensor();
        double RmThermoCouple2TC2 = 0;
        TemperatureSensor ThermoCouple2TC3 = new TemperatureSensor();
        double RmThermoCouple2TC3 = 0;
        TemperatureSensor ThermoCouple2TC4 = new TemperatureSensor(); //ambient temp in sensor
        double RmThermoCouple2TC4 = 0;

        DigitalInput DigitalInput0 = new DigitalInput();
        bool RmDigitalInput0 = false;
        DigitalInput DigitalInput1 = new DigitalInput();
        bool RmDigitalInput1 = false;
        DigitalInput DigitalInput2 = new DigitalInput();
        bool RmDigitalInput2 = false;
        DigitalInput DigitalInput3 = new DigitalInput();
        bool RmDigitalInput3 = false;
        DigitalInput DigitalInput4 = new DigitalInput();
        bool RmDigitalInput4 = false;
        DigitalInput DigitalInput5 = new DigitalInput();
        bool RmDigitalInput5 = false;
        DigitalInput DigitalInput6 = new DigitalInput();
        bool RmDigitalInput6 = false;
        DigitalInput DigitalInput7 = new DigitalInput();
        bool RmDigitalInput7 = false;
        DigitalInput DigitalInput8 = new DigitalInput();
        bool RmDigitalInput8 = false;
        DigitalInput DigitalInput9 = new DigitalInput();
        bool RmDigitalInput9 = false;
        DigitalInput DigitalInput10 = new DigitalInput();
        bool RmDigitalInput10 = false;
        DigitalInput DigitalInput11 = new DigitalInput();
        bool RmDigitalInput11 = false;
        DigitalInput DigitalInput12 = new DigitalInput();
        bool RmDigitalInput12 = false;
        DigitalInput DigitalInput13 = new DigitalInput();
        bool RmDigitalInput13 = false;
        DigitalInput DigitalInput14 = new DigitalInput();
        bool RmDigitalInput14 = false;
        DigitalInput DigitalInput15 = new DigitalInput();
        bool RmDigitalInput15 = false;

        VoltageRatioInput AirSpeed = new VoltageRatioInput();
        double RmAirSpeed = 0;





        public MainScreen()
        {
            InitializeComponent();

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void btnPhidgetStart_Click(object sender, EventArgs e)
        {
            Net.AddServer("ServerName", "192.168.150.144", 5661, "", 0);
            setup_humidity();
            setup_humidtiyTemp();
            setup_temperature();
            setup_light();
            setup_waterlevel();
            setup_ph();
            setup_ThermoCouple1TC0();
            setup_ThermoCouple1TC1();
            setup_ThermoCouple1TC2();
            setup_ThermoCouple1TC3();
            setup_ThermoCouple1TC4(); //ambient temp in sensor
            setup_ThermoCouple2TC0();
            setup_ThermoCouple2TC1();
            setup_ThermoCouple2TC2();
            setup_ThermoCouple2TC3();
            setup_ThermoCouple2TC4(); //ambient temp in sensor
            setup_DigitalInput0();
            setup_DigitalInput1();
            setup_DigitalInput2();
            setup_DigitalInput3();
            setup_DigitalInput4();
            setup_DigitalInput5();
            setup_DigitalInput6();
            setup_DigitalInput7();
            setup_DigitalInput8();
            setup_DigitalInput9();
            setup_DigitalInput10();
            setup_DigitalInput11();
            setup_DigitalInput12();
            setup_DigitalInput13();
            setup_DigitalInput14();
            setup_DigitalInput15();
            setup_AirSpeed();
        }

        private void MainScreen_FormClosing(object sender, FormClosingEventArgs e)
        {
            Application.DoEvents();
            humidity.Close();
            humiditytemp.Close();
            temperature.Close();
            light.Close();
            waterlevel.Close();
            ph.Close();
            ThermoCouple1TC0.Close();
            ThermoCouple1TC1.Close();
            ThermoCouple1TC2.Close();
            ThermoCouple1TC3.Close();
            ThermoCouple1TC4.Close();
            ThermoCouple2TC0.Close();
            ThermoCouple2TC1.Close();
            ThermoCouple2TC2.Close();
            ThermoCouple2TC3.Close();
            ThermoCouple2TC4.Close();
            DigitalInput0.Close();
            DigitalInput1.Close();
            DigitalInput2.Close();
            DigitalInput3.Close();
            DigitalInput4.Close();
            DigitalInput5.Close();
            DigitalInput6.Close();
            DigitalInput7.Close();
            DigitalInput8.Close();
            DigitalInput9.Close();
            DigitalInput10.Close();
            DigitalInput11.Close();
            DigitalInput12.Close();
            DigitalInput13.Close();
            DigitalInput14.Close();
            DigitalInput15.Close();
            AirSpeed.Close();

        }

        #region Humidity Setup
        void setup_humidity()
        {
            humidity.Attach += humidity_attach;
            humidity.HumidityChange += humidity_change;
            humidity.Channel = 0; //selects the channel on the device to open
            humidity.DeviceSerialNumber = 512923; //selects the device or hub to open
            humidity.HubPort = 1; //selects the port on the hub to open
            humidity.IsHubPortDevice = false; //is the device a port on a VINT hub?
            humidity.IsRemote = true;
            humidity.Open(); //open the device specified by the above parameters
        }

        void humidity_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            HumiditySensor attachedDevice = (HumiditySensor)sender;
            if (attachedDevice.Attached == true)
            {
                attachedDevice.HumidityChangeTrigger = .5;
                attachedDevice.DataInterval = PhidgetUpdateCycle;
            }
        }

        void humidity_change(object sender, Phidget22.Events.HumiditySensorHumidityChangeEventArgs e)
        {
            RmHumidity = Math.Round(e.Humidity, 4);
        }

        #endregion

        #region HumidityTemp Setup
        void setup_humidtiyTemp()
        {
            humiditytemp.Attach += temperature_attach;
            humiditytemp.TemperatureChange += temperature_change;
            humiditytemp.Channel = 0; //selects the channel on the device to open
            humiditytemp.DeviceSerialNumber = 512923; //selects the device or hub to open
            humiditytemp.HubPort = 1; //selects the port on the hub to open
            humiditytemp.IsHubPortDevice = false; //is the device a port on a VINT hub?
            humiditytemp.IsRemote = true;
            humiditytemp.Open(); //open the device specified by the above parameters
        }

        #endregion

        #region temperature Setup
        void setup_temperature()
        {
            temperature.Attach += temperature_attach;
            temperature.TemperatureChange += temperature_change;
            temperature.Channel = 0; //selects the channel on the device to open
            temperature.DeviceSerialNumber = 512923; //selects the device or hub to open
            temperature.HubPort = 2; //selects the port on the hub to open
            temperature.IsHubPortDevice = false; //is the device a port on a VINT hub?
            temperature.IsRemote = true;
            temperature.Open(); //open the device specified by the above parameters
        }
        #endregion

        #region light Setup
        void setup_light()
        {
            light.Attach += light_attach;
            light.SensorChange += light_SensorChange;
            light.Channel = 1; //selects the channel on the device to open
            light.DeviceSerialNumber = 512923; //selects the device or hub to open
            light.HubPort = 5; //selects the port on the hub to open
            light.IsHubPortDevice = false; //is the device a port on a VINT hub?
            light.IsRemote = true;
            light.Open(); //open the device specified by the above parameters
        }

        void light_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            VoltageInput attachedDevice = (VoltageInput)sender;
            //if (attachedDevice.Attached == true)
            //{
                attachedDevice.DataInterval = PhidgetUpdateCycle;
                attachedDevice.SensorType = VoltageSensorType.PN_1143;
                attachedDevice.VoltageChangeTrigger = .1;
            //}
        }

        void light_SensorChange(object sender, VoltageInputSensorChangeEventArgs e)
        {
            RmLight = e.SensorValue;
        }

        #endregion

        #region Water Level Setup

        private void setup_waterlevel()
        {
            waterlevel.Attach += waterlevel_attach;
            waterlevel.VoltageRatioChange += waterlevel_change;
            waterlevel.SensorChange += waterlevel_SensorChange;
            waterlevel.Channel = 2; //selects the channel on the device to open
            waterlevel.DeviceSerialNumber = 512923; //selects the device or hub to open
            waterlevel.HubPort = 5; //selects the port on the hub to open
            waterlevel.IsHubPortDevice = false; //is the device a port on a VINT hub?
            waterlevel.IsRemote = true;
            waterlevel.Open(); //open the device specified by the above parameters
        }

        void waterlevel_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            VoltageRatioInput attachedDevice = (VoltageRatioInput)sender;
            if (attachedDevice.Attached == true)
            {
                attachedDevice.SensorType = VoltageRatioSensorType.PN_1101_Sharp2Y0A21;
                attachedDevice.DataInterval = PhidgetUpdateCycle;
                attachedDevice.VoltageRatioChangeTrigger = .01;
            }
        }

        void waterlevel_change(object sender, Phidget22.Events.VoltageRatioInputVoltageRatioChangeEventArgs e)
        {
            //RmWaterLevel = e.VoltageRatio;
        }

        private void waterlevel_SensorChange(object sender, VoltageRatioInputSensorChangeEventArgs e)
        {
            RmWaterLevel = e.SensorValue;
        }

        #endregion

        #region ph Setup
        void setup_ph()
        {
            ph.Attach += ph_attach;
            ph.PHChange += ph_change;
            ph.Channel = 0; //selects the channel on the device to open
            ph.DeviceSerialNumber = 539561; //selects the device or hub to open
            ph.HubPort = 5; //selects the port on the hub to open
            ph.IsHubPortDevice = false; //is the device a port on a VINT hub?
            ph.IsRemote = true;
            ph.Open(); //open the device specified by the above parameters
        }

        void ph_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            PHSensor attachedDevice = (PHSensor)sender;
            //attachedDevice.DataInterval = PhidgetUpdateCycle;
            attachedDevice.PHChangeTrigger = .05;
            //attachedDevice.PHChangeTrigger = attachedDevice.MinPHChangeTrigger;
            
        }

        void ph_change(object sender, Phidget22.Events.PHSensorPHChangeEventArgs e)
        {
            RmPh = e.PH;            
        }

        #endregion

        #region ThermoCouplers 1 and 2 setup

        /// <summary>
        /// ThermoCoupler 1 setup
        /// </summary>
        #region ThermoCouple1TC0 Setup
        void setup_ThermoCouple1TC0()
        {
            ThermoCouple1TC0.Attach += ThermoCoupleKType_attach;
            ThermoCouple1TC0.TemperatureChange += ThermoCoupleKType_change;
            ThermoCouple1TC0.Channel = 0; //selects the channel on the device to open
            ThermoCouple1TC0.DeviceSerialNumber = 512923; //selects the device or hub to open
            ThermoCouple1TC0.HubPort = 3; //selects the port on the hub to open
            ThermoCouple1TC0.IsHubPortDevice = false; //is the device a port on a VINT hub?
            ThermoCouple1TC0.IsRemote = true;
            ThermoCouple1TC0.Open(); //open the device specified by the above parameters
        }
        #endregion

        #region ThermoCouple1TC1 Setup
        void setup_ThermoCouple1TC1()
        {
            ThermoCouple1TC1.Attach += ThermoCoupleKType_attach;
            ThermoCouple1TC1.TemperatureChange += ThermoCoupleKType_change;
            ThermoCouple1TC1.Channel = 1; //selects the channel on the device to open
            ThermoCouple1TC1.DeviceSerialNumber = 512923; //selects the device or hub to open
            ThermoCouple1TC1.HubPort = 3; //selects the port on the hub to open
            ThermoCouple1TC1.IsHubPortDevice = false; //is the device a port on a VINT hub?
            ThermoCouple1TC1.IsRemote = true;
            ThermoCouple1TC1.Open(); //open the device specified by the above parameters
        }
        #endregion

        #region ThermoCouple1TC2 Setup
        void setup_ThermoCouple1TC2()
        {
            ThermoCouple1TC2.Attach += ThermoCoupleKType_attach;
            ThermoCouple1TC2.TemperatureChange += ThermoCoupleKType_change;
            ThermoCouple1TC2.Channel = 2; //selects the channel on the device to open
            ThermoCouple1TC2.DeviceSerialNumber = 512923; //selects the device or hub to open
            ThermoCouple1TC2.HubPort = 3; //selects the port on the hub to open
            ThermoCouple1TC2.IsHubPortDevice = false; //is the device a port on a VINT hub?
            ThermoCouple1TC2.IsRemote = true;
            ThermoCouple1TC2.Open(); //open the device specified by the above parameters
        }
        #endregion

        #region ThermoCouple1TC3 Setup
        void setup_ThermoCouple1TC3()
        {
            ThermoCouple1TC3.Attach += ThermoCoupleKType_attach;
            ThermoCouple1TC3.TemperatureChange += ThermoCoupleKType_change;
            ThermoCouple1TC3.Channel = 3; //selects the channel on the device to open
            ThermoCouple1TC3.DeviceSerialNumber = 512923; //selects the device or hub to open
            ThermoCouple1TC3.HubPort = 3; //selects the port on the hub to open
            ThermoCouple1TC3.IsHubPortDevice = false; //is the device a port on a VINT hub?
            ThermoCouple1TC3.IsRemote = true;
            ThermoCouple1TC3.Open(); //open the device specified by the above parameters
        }

        #endregion

        //Internal Temp sensor on thermocoupler1
        #region ThermoCouple1TC4 Setup 
        void setup_ThermoCouple1TC4()
        {
            ThermoCouple1TC4.Attach += temperature_attach;
            ThermoCouple1TC4.TemperatureChange += temperature_change;
            ThermoCouple1TC4.Channel = 4; //selects the channel on the device to open
            ThermoCouple1TC4.DeviceSerialNumber = 512923; //selects the device or hub to open
            ThermoCouple1TC4.HubPort = 3; //selects the port on the hub to open
            ThermoCouple1TC4.IsHubPortDevice = false; //is the device a port on a VINT hub?
            ThermoCouple1TC4.IsRemote = true;
            ThermoCouple1TC4.Open(); //open the device specified by the above parameters

        }
        #endregion

        /// <summary>
        /// ThermoCoupler 2 setup
        /// </summary>
        #region ThermoCouple2TC0 Setup
        void setup_ThermoCouple2TC0()
        {
            ThermoCouple2TC0.Attach += ThermoCoupleKType_attach;
            ThermoCouple2TC0.TemperatureChange += ThermoCoupleKType_change;
            ThermoCouple2TC0.Channel = 0; //selects the channel on the device to open
            ThermoCouple2TC0.DeviceSerialNumber = 512923; //selects the device or hub to open
            ThermoCouple2TC0.HubPort = 4; //selects the port on the hub to open
            ThermoCouple2TC0.IsHubPortDevice = false; //is the device a port on a VINT hub?
            ThermoCouple2TC0.IsRemote = true;
            ThermoCouple2TC0.Open(); //open the device specified by the above parameters
        }
        #endregion

        #region ThermoCouple2TC1 Setup
        void setup_ThermoCouple2TC1()
        {
            ThermoCouple2TC1.Attach += ThermoCoupleKType_attach;
            ThermoCouple2TC1.TemperatureChange += ThermoCoupleKType_change;
            ThermoCouple2TC1.Channel = 1; //selects the channel on the device to open
            ThermoCouple2TC1.DeviceSerialNumber = 512923; //selects the device or hub to open
            ThermoCouple2TC1.HubPort = 4; //selects the port on the hub to open
            ThermoCouple2TC1.IsHubPortDevice = false; //is the device a port on a VINT hub?
            ThermoCouple2TC1.IsRemote = true;
            ThermoCouple2TC1.Open(); //open the device specified by the above parameters
        }

        #endregion

        #region ThermoCouple2TC2 Setup
        void setup_ThermoCouple2TC2()
        {
            ThermoCouple2TC2.Attach += ThermoCoupleKType_attach;
            ThermoCouple2TC2.TemperatureChange += ThermoCoupleKType_change;
            ThermoCouple2TC2.Channel = 2; //selects the channel on the device to open
            ThermoCouple2TC2.DeviceSerialNumber = 512923; //selects the device or hub to open
            ThermoCouple2TC2.HubPort = 4; //selects the port on the hub to open
            ThermoCouple2TC2.IsHubPortDevice = false; //is the device a port on a VINT hub?
            ThermoCouple2TC2.IsRemote = true;
            ThermoCouple2TC2.Open(); //open the device specified by the above parameters
        }

        #endregion

        #region ThermoCouple2TC3 Setup
        void setup_ThermoCouple2TC3()
        {
            ThermoCouple2TC3.Attach += ThermoCoupleKType_attach;
            ThermoCouple2TC3.TemperatureChange += ThermoCoupleKType_change;
            ThermoCouple2TC3.Channel = 3; //selects the channel on the device to open
            ThermoCouple2TC3.DeviceSerialNumber = 512923; //selects the device or hub to open
            ThermoCouple2TC3.HubPort = 4; //selects the port on the hub to open
            ThermoCouple2TC3.IsHubPortDevice = false; //is the device a port on a VINT hub?
            ThermoCouple2TC3.IsRemote = true;
            ThermoCouple2TC3.Open(); //open the device specified by the above parameters
        }

        #endregion

        //Internal Temp sensor on thermocoupler1
        #region ThermoCouple2TC4 Setup 
        void setup_ThermoCouple2TC4()
        {
            ThermoCouple2TC4.Attach += temperature_attach;
            ThermoCouple2TC4.TemperatureChange += temperature_change;

            ThermoCouple2TC4.Channel = 4; //selects the channel on the device to open
            ThermoCouple2TC4.DeviceSerialNumber = 512923; //selects the device or hub to open
            ThermoCouple2TC4.HubPort = 4; //selects the port on the hub to open
            ThermoCouple2TC4.IsHubPortDevice = false; //is the device a port on a VINT hub?
            ThermoCouple2TC4.IsRemote = true;
            ThermoCouple2TC4.Open(); //open the device specified by the above parameters
        }

        #endregion

        #endregion

        void temperature_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {            
            TemperatureSensor attachedDevice = (TemperatureSensor)sender;
            if (attachedDevice.Attached == true)
            {
                attachedDevice.DataInterval = PhidgetUpdateCycle;
                attachedDevice.TemperatureChangeTrigger = .5;
            }
        }

        void temperature_change(object sender, Phidget22.Events.TemperatureSensorTemperatureChangeEventArgs e)
        {
            int curChannel;
            int curHubPort;
            int curSerial;
            double curTemp;

            curTemp = ((e.Temperature * 1.8) + 32);
            TemperatureSensor curPhidget = ((TemperatureSensor)sender);
            curChannel = curPhidget.Channel;
            curHubPort = curPhidget.HubPort;
            curSerial = curPhidget.DeviceSerialNumber;

            if (curChannel == 0 && curSerial == 512923 && curHubPort == 1)
            {
                RmHumidityTemp = curTemp;
            }
            if (curChannel == 0 && curSerial == 512923 && curHubPort == 2)
            {
                RmTemperature = curTemp;
            }
            if (curChannel == 4 && curSerial == 512923 && curHubPort == 3)
            {
                RmThermoCouple1TC4 = curTemp;
            }
            if (curChannel == 4 && curSerial == 512923 && curHubPort == 4)
            {
                RmThermoCouple2TC4 = curTemp;
            }
        }

        void ThermoCoupleKType_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            TemperatureSensor attachedDevice = (TemperatureSensor)sender;
            if (attachedDevice.Attached == true)
            {
                attachedDevice.ThermocoupleType = ThermocoupleType.K;
                attachedDevice.DataInterval = PhidgetUpdateCycle;
                attachedDevice.TemperatureChangeTrigger = 1;
            }
        }

        void ThermoCoupleKType_change(object sender, Phidget22.Events.TemperatureSensorTemperatureChangeEventArgs e)
        {
            int curChannel;
            int curHubPort;
            int curSerial;
            TemperatureSensor curPhidget = ((TemperatureSensor)sender);
            double curTemp;

            curChannel = curPhidget.Channel;
            curHubPort = curPhidget.HubPort;
            curSerial = curPhidget.DeviceSerialNumber;
            curTemp = ((e.Temperature * 1.8) + 32);

            if (curChannel == 0 && curSerial == 512923 && curHubPort == 3)
            {
                RmThermoCouple1TC0 = curTemp;
            }
            if (curChannel == 1 && curSerial == 512923 && curHubPort == 3)
            {
                RmThermoCouple1TC1 = curTemp;
            }
            if (curChannel == 2 && curSerial == 512923 && curHubPort == 3)
            {
                RmThermoCouple1TC2 = curTemp;
            }
            if (curChannel == 3 && curSerial == 512923 && curHubPort == 3)
            {
                RmThermoCouple1TC3 = curTemp;
            }
            if (curChannel == 0 && curSerial == 512923 && curHubPort == 4)
            {
                RmThermoCouple2TC0 = curTemp;
            }
            if (curChannel == 0 && curSerial == 512923 && curHubPort == 4)
            {
                RmThermoCouple2TC0 = curTemp;
            }
            if (curChannel == 1 && curSerial == 512923 && curHubPort == 4)
            {
                RmThermoCouple2TC1 = curTemp;
            }
            if (curChannel == 2 && curSerial == 512923 && curHubPort == 4)
            {
                RmThermoCouple2TC2 = curTemp;
            }
            if (curChannel == 3 && curSerial == 512923 && curHubPort == 4)
            {
                RmThermoCouple2TC3 = curTemp;
            }

        }

        #region Digital Input 0-15 setup

        #region DigitalInput0_Setup
        void setup_DigitalInput0()
        {
            DigitalInput0.Attach += DigitalInput0_attach;
            DigitalInput0.Detach += DigitalInput0_detach;
            DigitalInput0.Error += DigitalInput0_error;
            DigitalInput0.StateChange += DigitalInput0_change;

            DigitalInput0.Channel = 0; //selects the channel on the device to open
            DigitalInput0.DeviceSerialNumber = 512923; //selects the device or hub to open
            DigitalInput0.HubPort = 0; //selects the port on the hub to open
            DigitalInput0.IsHubPortDevice = false; //is the device a port on a VINT hub?
            DigitalInput0.IsRemote = true;
            DigitalInput0.Open(); //open the device specified by the above parameters
        }

        void DigitalInput0_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            DigitalInput attachedDevice = (DigitalInput)sender;
        }

        //empty
        void DigitalInput0_detach(object sender, Phidget22.Events.DetachEventArgs e)
        {
            //phidgetInfoBox1.Clear();
        }

        //empty
        void DigitalInput0_error(object sender, Phidget22.Events.ErrorEventArgs e)
        {
            //errorBox.addMessage(e.Description);
        }

        void DigitalInput0_change(object sender, Phidget22.Events.DigitalInputStateChangeEventArgs e)
        {
            RmDigitalInput0 = e.State;
            lblPhidgetDigitalInput0.Text = RmDigitalInput0.ToString();

        }

        #endregion

        #region DigitalInput1_Setup
        void setup_DigitalInput1()
        {

            DigitalInput1.Attach += DigitalInput1_attach;
            DigitalInput1.Detach += DigitalInput1_detach;
            DigitalInput1.Error += DigitalInput1_error;
            DigitalInput1.StateChange += DigitalInput1_change;


            DigitalInput1.Channel = 1; //selects the channel on the device to open
            DigitalInput1.DeviceSerialNumber = 512923; //selects the device or hub to open
            DigitalInput1.HubPort = 0; //selects the port on the hub to open
            DigitalInput1.IsHubPortDevice = false; //is the device a port on a VINT hub?
            DigitalInput1.IsRemote = true;
            DigitalInput1.Open(); //open the device specified by the above parameters

        }

        void DigitalInput1_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            DigitalInput attachedDevice = (DigitalInput)sender;
        }

        //empty
        void DigitalInput1_detach(object sender, Phidget22.Events.DetachEventArgs e)
        {
            //phidgetInfoBox1.Clear();
        }

        //empty
        void DigitalInput1_error(object sender, Phidget22.Events.ErrorEventArgs e)
        {
            //errorBox.addMessage(e.Description);
        }

        void DigitalInput1_change(object sender, Phidget22.Events.DigitalInputStateChangeEventArgs e)
        {
            RmDigitalInput1 = e.State;
            lblPhidgetDigitalInput1.Text = RmDigitalInput1.ToString();

        }

        #endregion

        #region DigitalInput2_Setup
        void setup_DigitalInput2()
        {

            DigitalInput2.Attach += DigitalInput2_attach;
            DigitalInput2.Detach += DigitalInput2_detach;
            DigitalInput2.Error += DigitalInput2_error;
            DigitalInput2.StateChange += DigitalInput2_change;


            DigitalInput2.Channel = 2; //selects the channel on the device to open
            DigitalInput2.DeviceSerialNumber = 512923; //selects the device or hub to open
            DigitalInput2.HubPort = 0; //selects the port on the hub to open
            DigitalInput2.IsHubPortDevice = false; //is the device a port on a VINT hub?
            DigitalInput2.IsRemote = true;
            DigitalInput2.Open(); //open the device specified by the above parameters

        }

        void DigitalInput2_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            DigitalInput attachedDevice = (DigitalInput)sender;
        }

        //empty
        void DigitalInput2_detach(object sender, Phidget22.Events.DetachEventArgs e)
        {
            //phidgetInfoBox1.Clear();
        }

        //empty
        void DigitalInput2_error(object sender, Phidget22.Events.ErrorEventArgs e)
        {
            //errorBox.addMessage(e.Description);
        }

        void DigitalInput2_change(object sender, Phidget22.Events.DigitalInputStateChangeEventArgs e)
        {
            RmDigitalInput2 = e.State;
            lblPhidgetDigitalInput2.Text = RmDigitalInput2.ToString();

        }

        #endregion

        #region DigitalInput3_Setup
        void setup_DigitalInput3()
        {

            DigitalInput3.Attach += DigitalInput3_attach;
            DigitalInput3.Detach += DigitalInput3_detach;
            DigitalInput3.Error += DigitalInput3_error;
            DigitalInput3.StateChange += DigitalInput3_change;


            DigitalInput3.Channel = 3; //selects the channel on the device to open
            DigitalInput3.DeviceSerialNumber = 512923; //selects the device or hub to open
            DigitalInput3.HubPort = 0; //selects the port on the hub to open
            DigitalInput3.IsHubPortDevice = false; //is the device a port on a VINT hub?
            DigitalInput3.IsRemote = true;
            DigitalInput3.Open(); //open the device specified by the above parameters

        }

        void DigitalInput3_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            DigitalInput attachedDevice = (DigitalInput)sender;
        }

        //empty
        void DigitalInput3_detach(object sender, Phidget22.Events.DetachEventArgs e)
        {
            //phidgetInfoBox1.Clear();
        }

        //empty
        void DigitalInput3_error(object sender, Phidget22.Events.ErrorEventArgs e)
        {
            //errorBox.addMessage(e.Description);
        }

        void DigitalInput3_change(object sender, Phidget22.Events.DigitalInputStateChangeEventArgs e)
        {
            RmDigitalInput3 = e.State;
            lblPhidgetDigitalInput3.Text = RmDigitalInput3.ToString();

        }

        #endregion

        #region DigitalInput4_Setup
        void setup_DigitalInput4()
        {

            DigitalInput4.Attach += DigitalInput4_attach;
            DigitalInput4.Detach += DigitalInput4_detach;
            DigitalInput4.Error += DigitalInput4_error;
            DigitalInput4.StateChange += DigitalInput4_change;


            DigitalInput4.Channel = 4; //selects the channel on the device to open
            DigitalInput4.DeviceSerialNumber = 512923; //selects the device or hub to open
            DigitalInput4.HubPort = 0; //selects the port on the hub to open
            DigitalInput4.IsHubPortDevice = false; //is the device a port on a VINT hub?
            DigitalInput4.IsRemote = true;
            DigitalInput4.Open(); //open the device specified by the above parameters

        }

        void DigitalInput4_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            DigitalInput attachedDevice = (DigitalInput)sender;
        }

        //empty
        void DigitalInput4_detach(object sender, Phidget22.Events.DetachEventArgs e)
        {
            //phidgetInfoBox1.Clear();
        }

        //empty
        void DigitalInput4_error(object sender, Phidget22.Events.ErrorEventArgs e)
        {
            //errorBox.addMessage(e.Description);
        }

        void DigitalInput4_change(object sender, Phidget22.Events.DigitalInputStateChangeEventArgs e)
        {
            RmDigitalInput4 = e.State;
            lblPhidgetDigitalInput4.Text = RmDigitalInput4.ToString();

        }

        #endregion

        #region DigitalInput5_Setup
        void setup_DigitalInput5()
        {

            DigitalInput5.Attach += DigitalInput5_attach;
            DigitalInput5.Detach += DigitalInput5_detach;
            DigitalInput5.Error += DigitalInput5_error;
            DigitalInput5.StateChange += DigitalInput5_change;


            DigitalInput5.Channel = 5; //selects the channel on the device to open
            DigitalInput5.DeviceSerialNumber = 512923; //selects the device or hub to open
            DigitalInput5.HubPort = 0; //selects the port on the hub to open
            DigitalInput5.IsHubPortDevice = false; //is the device a port on a VINT hub?
            DigitalInput5.IsRemote = true;
            DigitalInput5.Open(); //open the device specified by the above parameters

        }

        void DigitalInput5_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            DigitalInput attachedDevice = (DigitalInput)sender;
        }

        //empty
        void DigitalInput5_detach(object sender, Phidget22.Events.DetachEventArgs e)
        {
            //phidgetInfoBox1.Clear();
        }

        //empty
        void DigitalInput5_error(object sender, Phidget22.Events.ErrorEventArgs e)
        {
            //errorBox.addMessage(e.Description);
        }

        void DigitalInput5_change(object sender, Phidget22.Events.DigitalInputStateChangeEventArgs e)
        {
            RmDigitalInput5 = e.State;
            lblPhidgetDigitalInput5.Text = RmDigitalInput5.ToString();

        }

        #endregion

        #region DigitalInput6_Setup
        void setup_DigitalInput6()
        {

            DigitalInput6.Attach += DigitalInput6_attach;
            DigitalInput6.Detach += DigitalInput6_detach;
            DigitalInput6.Error += DigitalInput6_error;
            DigitalInput6.StateChange += DigitalInput6_change;


            DigitalInput6.Channel = 6; //selects the channel on the device to open
            DigitalInput6.DeviceSerialNumber = 512923; //selects the device or hub to open
            DigitalInput6.HubPort = 0; //selects the port on the hub to open
            DigitalInput6.IsHubPortDevice = false; //is the device a port on a VINT hub?
            DigitalInput6.IsRemote = true;
            DigitalInput6.Open(); //open the device specified by the above parameters

        }

        void DigitalInput6_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            DigitalInput attachedDevice = (DigitalInput)sender;
        }

        //empty
        void DigitalInput6_detach(object sender, Phidget22.Events.DetachEventArgs e)
        {
            //phidgetInfoBox1.Clear();
        }

        //empty
        void DigitalInput6_error(object sender, Phidget22.Events.ErrorEventArgs e)
        {
            //errorBox.addMessage(e.Description);
        }

        void DigitalInput6_change(object sender, Phidget22.Events.DigitalInputStateChangeEventArgs e)
        {
            RmDigitalInput6 = e.State;
            lblPhidgetDigitalInput6.Text = RmDigitalInput6.ToString();

        }

        #endregion

        #region DigitalInput7_Setup
        void setup_DigitalInput7()
        {

            DigitalInput7.Attach += DigitalInput7_attach;
            DigitalInput7.Detach += DigitalInput7_detach;
            DigitalInput7.Error += DigitalInput7_error;
            DigitalInput7.StateChange += DigitalInput7_change;


            DigitalInput7.Channel = 7; //selects the channel on the device to open
            DigitalInput7.DeviceSerialNumber = 512923; //selects the device or hub to open
            DigitalInput7.HubPort = 0; //selects the port on the hub to open
            DigitalInput7.IsHubPortDevice = false; //is the device a port on a VINT hub?
            DigitalInput7.IsRemote = true;
            DigitalInput7.Open(); //open the device specified by the above parameters

        }

        void DigitalInput7_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            DigitalInput attachedDevice = (DigitalInput)sender;
        }

        //empty
        void DigitalInput7_detach(object sender, Phidget22.Events.DetachEventArgs e)
        {
            //phidgetInfoBox1.Clear();
        }

        //empty
        void DigitalInput7_error(object sender, Phidget22.Events.ErrorEventArgs e)
        {
            //errorBox.addMessage(e.Description);
        }

        void DigitalInput7_change(object sender, Phidget22.Events.DigitalInputStateChangeEventArgs e)
        {
            RmDigitalInput7 = e.State;
            lblPhidgetDigitalInput7.Text = RmDigitalInput7.ToString();

        }

        #endregion

        #region DigitalInput8_Setup
        void setup_DigitalInput8()
        {

            DigitalInput8.Attach += DigitalInput8_attach;
            DigitalInput8.Detach += DigitalInput8_detach;
            DigitalInput8.Error += DigitalInput8_error;
            DigitalInput8.StateChange += DigitalInput8_change;


            DigitalInput8.Channel = 8; //selects the channel on the device to open
            DigitalInput8.DeviceSerialNumber = 512923; //selects the device or hub to open
            DigitalInput8.HubPort = 0; //selects the port on the hub to open
            DigitalInput8.IsHubPortDevice = false; //is the device a port on a VINT hub?
            DigitalInput8.IsRemote = true;
            DigitalInput8.Open(); //open the device specified by the above parameters

        }

        void DigitalInput8_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            DigitalInput attachedDevice = (DigitalInput)sender;
        }

        //empty
        void DigitalInput8_detach(object sender, Phidget22.Events.DetachEventArgs e)
        {
            //phidgetInfoBox1.Clear();
        }

        //empty
        void DigitalInput8_error(object sender, Phidget22.Events.ErrorEventArgs e)
        {
            //errorBox.addMessage(e.Description);
        }

        void DigitalInput8_change(object sender, Phidget22.Events.DigitalInputStateChangeEventArgs e)
        {
            RmDigitalInput8 = e.State;
            lblPhidgetDigitalInput8.Text = RmDigitalInput8.ToString();

        }

        #endregion

        #region DigitalInput9_Setup
        void setup_DigitalInput9()
        {

            DigitalInput9.Attach += DigitalInput9_attach;
            DigitalInput9.Detach += DigitalInput9_detach;
            DigitalInput9.Error += DigitalInput9_error;
            DigitalInput9.StateChange += DigitalInput9_change;


            DigitalInput9.Channel = 9; //selects the channel on the device to open
            DigitalInput9.DeviceSerialNumber = 512923; //selects the device or hub to open
            DigitalInput9.HubPort = 0; //selects the port on the hub to open
            DigitalInput9.IsHubPortDevice = false; //is the device a port on a VINT hub?
            DigitalInput9.IsRemote = true;
            DigitalInput9.Open(); //open the device specified by the above parameters

        }

        void DigitalInput9_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            DigitalInput attachedDevice = (DigitalInput)sender;
        }

        //empty
        void DigitalInput9_detach(object sender, Phidget22.Events.DetachEventArgs e)
        {
            //phidgetInfoBox1.Clear();
        }

        //empty
        void DigitalInput9_error(object sender, Phidget22.Events.ErrorEventArgs e)
        {
            //errorBox.addMessage(e.Description);
        }

        void DigitalInput9_change(object sender, Phidget22.Events.DigitalInputStateChangeEventArgs e)
        {
            RmDigitalInput9 = e.State;
            lblPhidgetDigitalInput9.Text = RmDigitalInput9.ToString();

        }

        #endregion

        #region DigitalInput10_Setup
        void setup_DigitalInput10()
        {

            DigitalInput10.Attach += DigitalInput10_attach;
            DigitalInput10.Detach += DigitalInput10_detach;
            DigitalInput10.Error += DigitalInput10_error;
            DigitalInput10.StateChange += DigitalInput10_change;


            DigitalInput10.Channel = 10; //selects the channel on the device to open
            DigitalInput10.DeviceSerialNumber = 512923; //selects the device or hub to open
            DigitalInput10.HubPort = 0; //selects the port on the hub to open
            DigitalInput10.IsHubPortDevice = false; //is the device a port on a VINT hub?
            DigitalInput10.IsRemote = true;
            DigitalInput10.Open(); //open the device specified by the above parameters

        }

        void DigitalInput10_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            DigitalInput attachedDevice = (DigitalInput)sender;
        }

        //empty
        void DigitalInput10_detach(object sender, Phidget22.Events.DetachEventArgs e)
        {
            //phidgetInfoBox1.Clear();
        }

        //empty
        void DigitalInput10_error(object sender, Phidget22.Events.ErrorEventArgs e)
        {
            //errorBox.addMessage(e.Description);
        }

        void DigitalInput10_change(object sender, Phidget22.Events.DigitalInputStateChangeEventArgs e)
        {
            RmDigitalInput10 = e.State;
            lblPhidgetDigitalInput10.Text = RmDigitalInput10.ToString();

        }

        #endregion

        #region DigitalInput11_Setup
        void setup_DigitalInput11()
        {

            DigitalInput11.Attach += DigitalInput11_attach;
            DigitalInput11.Detach += DigitalInput11_detach;
            DigitalInput11.Error += DigitalInput11_error;
            DigitalInput11.StateChange += DigitalInput11_change;


            DigitalInput11.Channel = 11; //selects the channel on the device to open
            DigitalInput11.DeviceSerialNumber = 512923; //selects the device or hub to open
            DigitalInput11.HubPort = 0; //selects the port on the hub to open
            DigitalInput11.IsHubPortDevice = false; //is the device a port on a VINT hub?
            DigitalInput11.IsRemote = true;
            DigitalInput11.Open(); //open the device specified by the above parameters

        }

        void DigitalInput11_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            DigitalInput attachedDevice = (DigitalInput)sender;
        }

        //empty
        void DigitalInput11_detach(object sender, Phidget22.Events.DetachEventArgs e)
        {
            //phidgetInfoBox1.Clear();
        }

        //empty
        void DigitalInput11_error(object sender, Phidget22.Events.ErrorEventArgs e)
        {
            //errorBox.addMessage(e.Description);
        }

        void DigitalInput11_change(object sender, Phidget22.Events.DigitalInputStateChangeEventArgs e)
        {
            RmDigitalInput11 = e.State;
            lblPhidgetDigitalInput11.Text = RmDigitalInput11.ToString();

        }

        #endregion

        #region DigitalInput12_Setup
        void setup_DigitalInput12()
        {

            DigitalInput12.Attach += DigitalInput12_attach;
            DigitalInput12.Detach += DigitalInput12_detach;
            DigitalInput12.Error += DigitalInput12_error;
            DigitalInput12.StateChange += DigitalInput12_change;


            DigitalInput12.Channel = 12; //selects the channel on the device to open
            DigitalInput12.DeviceSerialNumber = 512923; //selects the device or hub to open
            DigitalInput12.HubPort = 0; //selects the port on the hub to open
            DigitalInput12.IsHubPortDevice = false; //is the device a port on a VINT hub?
            DigitalInput12.IsRemote = true;
            DigitalInput12.Open(); //open the device specified by the above parameters

        }

        void DigitalInput12_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            DigitalInput attachedDevice = (DigitalInput)sender;
        }

        //empty
        void DigitalInput12_detach(object sender, Phidget22.Events.DetachEventArgs e)
        {
            //phidgetInfoBox1.Clear();
        }

        //empty
        void DigitalInput12_error(object sender, Phidget22.Events.ErrorEventArgs e)
        {
            //errorBox.addMessage(e.Description);
        }

        void DigitalInput12_change(object sender, Phidget22.Events.DigitalInputStateChangeEventArgs e)
        {
            RmDigitalInput12 = e.State;
            lblPhidgetDigitalInput12.Text = RmDigitalInput12.ToString();

        }

        #endregion

        #region DigitalInput13_Setup
        void setup_DigitalInput13()
        {

            DigitalInput13.Attach += DigitalInput13_attach;
            DigitalInput13.Detach += DigitalInput13_detach;
            DigitalInput13.Error += DigitalInput13_error;
            DigitalInput13.StateChange += DigitalInput13_change;


            DigitalInput13.Channel = 13; //selects the channel on the device to open
            DigitalInput13.DeviceSerialNumber = 512923; //selects the device or hub to open
            DigitalInput13.HubPort = 0; //selects the port on the hub to open
            DigitalInput13.IsHubPortDevice = false; //is the device a port on a VINT hub?
            DigitalInput13.IsRemote = true;
            DigitalInput13.Open(); //open the device specified by the above parameters

        }

        void DigitalInput13_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            DigitalInput attachedDevice = (DigitalInput)sender;
        }

        //empty
        void DigitalInput13_detach(object sender, Phidget22.Events.DetachEventArgs e)
        {
            //phidgetInfoBox1.Clear();
        }

        //empty
        void DigitalInput13_error(object sender, Phidget22.Events.ErrorEventArgs e)
        {
            //errorBox.addMessage(e.Description);
        }

        void DigitalInput13_change(object sender, Phidget22.Events.DigitalInputStateChangeEventArgs e)
        {
            RmDigitalInput13 = e.State;
            lblPhidgetDigitalInput13.Text = RmDigitalInput13.ToString();

        }

        #endregion

        #region DigitalInput14_Setup
        void setup_DigitalInput14()
        {

            DigitalInput14.Attach += DigitalInput14_attach;
            DigitalInput14.Detach += DigitalInput14_detach;
            DigitalInput14.Error += DigitalInput14_error;
            DigitalInput14.StateChange += DigitalInput14_change;


            DigitalInput14.Channel = 14; //selects the channel on the device to open
            DigitalInput14.DeviceSerialNumber = 512923; //selects the device or hub to open
            DigitalInput14.HubPort = 0; //selects the port on the hub to open
            DigitalInput14.IsHubPortDevice = false; //is the device a port on a VINT hub?
            DigitalInput14.IsRemote = true;
            DigitalInput14.Open(); //open the device specified by the above parameters

        }

        void DigitalInput14_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            DigitalInput attachedDevice = (DigitalInput)sender;
        }

        //empty
        void DigitalInput14_detach(object sender, Phidget22.Events.DetachEventArgs e)
        {
            //phidgetInfoBox1.Clear();
        }

        //empty
        void DigitalInput14_error(object sender, Phidget22.Events.ErrorEventArgs e)
        {
            //errorBox.addMessage(e.Description);
        }

        void DigitalInput14_change(object sender, Phidget22.Events.DigitalInputStateChangeEventArgs e)
        {
            RmDigitalInput14 = e.State;
            lblPhidgetDigitalInput14.Text = RmDigitalInput14.ToString();

        }

        #endregion

        #region DigitalInput15_Setup
        void setup_DigitalInput15()
        {

            DigitalInput15.Attach += DigitalInput15_attach;
            DigitalInput15.Detach += DigitalInput15_detach;
            DigitalInput15.Error += DigitalInput15_error;
            DigitalInput15.StateChange += DigitalInput15_change;


            DigitalInput15.Channel = 15; //selects the channel on the device to open
            DigitalInput15.DeviceSerialNumber = 512923; //selects the device or hub to open
            DigitalInput15.HubPort = 0; //selects the port on the hub to open
            DigitalInput15.IsHubPortDevice = false; //is the device a port on a VINT hub?
            DigitalInput15.IsRemote = true;
            DigitalInput15.Open(); //open the device specified by the above parameters

        }

        void DigitalInput15_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            DigitalInput attachedDevice = (DigitalInput)sender;
        }

        //empty
        void DigitalInput15_detach(object sender, Phidget22.Events.DetachEventArgs e)
        {
            //phidgetInfoBox1.Clear();
        }

        //empty
        void DigitalInput15_error(object sender, Phidget22.Events.ErrorEventArgs e)
        {
            //errorBox.addMessage(e.Description);
        }

        void DigitalInput15_change(object sender, Phidget22.Events.DigitalInputStateChangeEventArgs e)
        {
            RmDigitalInput15 = e.State;
            lblPhidgetDigitalInput15.Text = RmDigitalInput15.ToString();

        }

        #endregion

        #endregion

        #region Air_Speed Setup

        private void setup_AirSpeed()
        {
            AirSpeed.Attach += AirSpeed_attach;
            AirSpeed.VoltageRatioChange += AirSpeed_change;
            AirSpeed.SensorChange += AirSpeed_SensorChange;
            AirSpeed.Channel = 0; //selects the channel on the device to open
            AirSpeed.DeviceSerialNumber = 512923; //selects the device or hub to open
            AirSpeed.HubPort = 5; //selects the port on the hub to open
            AirSpeed.IsHubPortDevice = false; //is the device a port on a VINT hub?
            //AirSpeed.IsLocal = true;
            AirSpeed.IsRemote = true;
            AirSpeed.Open(); //open the device specified by the above parameters

        }

        void AirSpeed_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            VoltageRatioInput attachedDevice = (VoltageRatioInput)sender;
            if (attachedDevice.Attached == true)
            {
                attachedDevice.SensorType = VoltageRatioSensorType.VoltageRatio;
            }
        }

        void AirSpeed_change(object sender, Phidget22.Events.VoltageRatioInputVoltageRatioChangeEventArgs e)
        {
            RmAirSpeed = ((Math.Round(e.VoltageRatio, 2) - .51) * 193);
        }

        private void AirSpeed_SensorChange(object sender, VoltageRatioInputSensorChangeEventArgs e)
        {
            RmAirSpeed = (e.SensorValue - .5);
            lblPhidgetAirSpeed.Text = RmAirSpeed.ToString();
            //sensorTxt.Text = e.SensorValue.ToString() + " " + e.SensorUnit.Symbol;
        }

        #endregion

        private void timerFormUpdate_Tick(object sender, EventArgs e)
        {
            UpdateDataOnForm();
        }

        private void UpdateDataOnForm()
        {
            lblPhidgetHumidity.Text = RmHumidity.ToString();
            lblPhidgetHumidityTemp.Text = RmHumidityTemp.ToString();
            lblPhidgetTemperature.Text = RmTemperature.ToString();
            lblPhidgetThermoCouple1TC0.Text = RmThermoCouple1TC0.ToString();
            lblPhidgetThermoCouple1TC1.Text = RmThermoCouple1TC1.ToString();
            lblPhidgetThermoCouple1TC2.Text = RmThermoCouple1TC2.ToString();
            lblPhidgetThermoCouple1TC3.Text = RmThermoCouple1TC3.ToString();
            lblPhidgetThermoCouple1TC4.Text = RmThermoCouple1TC4.ToString();
            lblPhidgetThermoCouple2TC0.Text = RmThermoCouple2TC0.ToString();
            lblPhidgetThermoCouple2TC1.Text = RmThermoCouple2TC1.ToString();
            lblPhidgetThermoCouple2TC2.Text = RmThermoCouple2TC2.ToString();
            lblPhidgetThermoCouple2TC3.Text = RmThermoCouple2TC3.ToString();
            lblPhidgetThermoCouple2TC4.Text = RmThermoCouple2TC4.ToString();
            lblPhidgetWaterPh.Text = RmPh.ToString();
            lblPhidgetWaterLevel.Text = RmWaterLevel.ToString();
            lblPhidgetLight.Text = RmLight.ToString();
            lblPhidgetAirSpeed.Text = RmAirSpeed.ToString();
            lblPhidgetWaterLevel.Text = RmWaterLevel.ToString();
        }
    }
}


fraser
Engineering
Posts: 324
Joined: Thu Nov 19, 2009 4:41 pm
Contact:

Re: Max allowed Channels

Post by fraser »

PhidgetException 0x00000003 is a networking communication error. Have you tracked down what function call is throwing that exception?

ie is it thrown on the 32nd open call?
User avatar
Patrick
Lead Developer
Posts: 3399
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Max allowed Channels

Post by Patrick »

Exception 0x03 is a timeout, not a network error.

This is probably being caused by having initialization for 32 channels all get queued up at once, and it will take a while for all the commands to get issued, and the library is being too conservative in it's internal timeouts.

Try breaking your setup functions into two groups, and call each one will a few seconds delay between - does initialization work?

I will try to reproduce, and see if there is a better way to timeout.

-Patrick
bigj4155
Phidgetsian
Posts: 8
Joined: Sat Dec 01, 2018 8:32 am
Contact:

Re: Max allowed Channels

Post by bigj4155 »

I do not necessarily have an answer as to what fixed my problem but things are working good now "well see my new post Im about to make"

Basically in a bit of frustration in trying to get this project done I went ahead and continued to add in new channels and alone the way I rewrote the attach event handlers to deal with multiple channels shoved through the same event. I do agree that it seems to be linked to queuing up multiple channels at once without adding some kind of pause in between.

My scenario was/is

Before I had a bit of code ran off of a timer that would check the status of each channel and report a "true/false" if it is attached. Before I redid the event handlers I would get all channels flip to "true" and then it would throw an exception on that 32nd channel.

Now - After the rewrite I get the channel connection status in a more staggered pattern and things work great. There was no deliberate thought ito "oo I need to slow down the open.channel calls" and I think it was just a side effect of how I wrote the new code. Shrug...

Up to 55 channels attached now. Everything reports attached within 3 seconds. Bet if I plugged in the old code that tried to attach everything at once and it would fail.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests