Example #1
0
        //IfKit attach event handler
        //Here we'll display the interface kit details as well as determine how many output and input
        //fields to display as well as determine the range of values for input sensitivity slider
        void ifKit_Attach(object sender, AttachEventArgs e)
        {
            InterfaceKit ifKit = (InterfaceKit)sender;

            m_phidet21Info.attachedTxt    = ifKit.Attached.ToString();
            m_phidet21Info.nameTxt        = ifKit.Name;
            m_phidet21Info.serialTxt      = ifKit.SerialNumber.ToString();
            m_phidet21Info.versionTxt     = ifKit.Version.ToString();
            m_phidet21Info.digiInNumTxt   = ifKit.inputs.Count.ToString();
            m_phidet21Info.digiOutNumTxt  = ifKit.outputs.Count.ToString();
            m_phidet21Info.sensorInNumTxt = ifKit.sensors.Count.ToString();
            m_attached = true;

            if (m_attachedEvent != null)
            {
                m_eventCode[PhidgetCallbackCode.ATTACH]++;
                m_attachedEvent.Set();
            }
            if (m_pCallback != null)
            {
                m_pCallback(PhidgetCallbackCode.ATTACH);
            }


            try
            {
                SetSensitivity(3, 300);
            }
            catch (Exception err)
            {
            }
        }
Example #2
0
 private void rfid_Attach(object sender, AttachEventArgs e)
 {
     if (_rfid.outputs.Count > 0)
     {
         _rfid.Antenna = true;
     }
 }
Example #3
0
        //Bridge Attach event handler...populate the fields and controls
        void br_Attach(object sender, AttachEventArgs e)
        {
            Bridge attached = (Bridge)sender;

            attachedTxt.Text   = attached.Attached.ToString();
            nameTxt.Text       = attached.Name;
            serialTxt.Text     = attached.SerialNumber.ToString();
            versiontxt.Text    = attached.Version.ToString();
            numBridgesTxt.Text = attached.bridges.Count.ToString();

            dataRateBar.Minimum = attached.DataRateMax / 8;
            dataRateBar.Maximum = attached.DataRateMin / 8;

            dataRateBox.Enabled = true;
            dataRateBar.Enabled = true;
            dataRateBar.Value   = 10;
            bridgeCmb.Enabled   = true;
            enCheck.Enabled     = true;
            enCheck.Checked     = false;
            gainCmb.Enabled     = true;
            valueTxt.Enabled    = true;
            startBut.Enabled    = true;
            set1.Enabled        = true;
            set2.Enabled        = true;

            dataRateBar.Value = br.DataRate / 8;
            dataRateBox.Text  = br.DataRate.ToString();

            bridgeCmb.SelectedIndex = 0;
        }
        private void ServoBoard_Attach(object sender, AttachEventArgs e)
        {
            for (int i = 0; i < _servoBoard.servos.Count; i++)
            {
                if (_servoCount == 0)
                {
                    SetServoProperties(i, _servos[i].ServoType, _servos[i].ServoMinPulseWidth, _servos[i].ServoMaxPulseWidth, _servos[i].ServoMaxVelocity, _servos[i].ServoDegrees);

                    _servos[i].MinAcceleration = _servoBoard.servos[i].AccelerationMin;
                    _servos[i].MaxAcceleration = _servoBoard.servos[i].AccelerationMax;
                    _servos[i].Acceleration    = _servos[i].MaxAcceleration;

                    _servos[i].MinVelocity   = _servoBoard.servos[i].VelocityMin;
                    _servos[i].MaxVelocity   = _servoBoard.servos[i].VelocityMax;
                    _servos[i].VelocityLimit = _servos[i].MaxVelocity;

                    RegisterBindings(i);
                }
                _servoBoard.servos[i].VelocityLimit = _servos[i].VelocityLimit;
                _servoBoard.servos[i].Acceleration  = _servos[i].Acceleration < _servoBoard.servos[i].AccelerationMax ? _servos[i].Acceleration : _servoBoard.servos[i].AccelerationMax;;

                _servos[i].Calibration.OutputLimitMax = _servoBoard.servos[i].PositionMax;
                _servos[i].Calibration.OutputLimitMin = _servoBoard.servos[i].PositionMin;
            }

            if (_servoCount == 0)
            {
                _servoCount = _servoBoard.servos.Count;
                ConfigManager.LogManager.LogDebug("Detaching phidget servo board after config. (SerialNumber=\"" + _serialNumber + "\")");
                _servoBoard.close();
                _servoBoard = null;
            }
        }
Example #5
0
        //accelerometer attach event handler
        void accel_Attach(object sender, AttachEventArgs e)
        {
            Accelerometer attached = (Accelerometer)sender;

            attachedTxt.Text = attached.Attached.ToString();
            nameTxt.Text     = attached.Name;
            serialTxt.Text   = attached.SerialNumber.ToString();
            versionTxt.Text  = attached.Version.ToString();
            axesTxt.Text     = attached.axes.Count.ToString();
            rangeTxt.Text    = attached.axes[0].AccelerationMin == -attached.axes[0].AccelerationMax ?
                               "±" + attached.axes[0].AccelerationMax.ToString() + "g" :
                               attached.axes[0].AccelerationMin.ToString() + "g to " + attached.axes[0].AccelerationMax.ToString() + "g";

            try
            {
                attached.axes[0].Sensitivity = 0;
                attached.axes[1].Sensitivity = 0;
                if (attached.axes.Count == 3)
                {
                    attached.axes[2].Sensitivity = 0;
                }
            }
            catch (PhidgetException ex)
            {
                MessageBox.Show(ex.Description);
            }

            axis1SensitivityScrl.Enabled = true;
            axis2SensitivityScrl.Enabled = true;
            if (attached.axes.Count == 3)
            {
                axis3SensitivityScrl.Enabled = true;
            }
        }
Example #6
0
 //attach event handler...display the serial number of the attached RFID phidget
 private void RFID_Attached(object sender, AttachEventArgs e)
 {
     m_rfid.Antenna = true;
     m_serial       = e.Device.SerialNumber;
     TurnGUIButtonOn();
     //Attach(sender, e);
 }
Example #7
0
        //IfKit attach event handler
        //Here we'll display the interface kit details as well as determine how many output and input
        //fields to display as well as determine the range of values for input sensitivity slider
        void ifKit_Attach(object sender, AttachEventArgs e)
        {
            _isOpen = true;
            var interfaceKit = (InterfaceKit)sender;
            //TODO: Log event

            const string message1 = "InterfaceKit attached";

            var message2 = string.Format("Attached: {0}", interfaceKit.Attached.ToString());
            var message3 = string.Format("Name: {0}", interfaceKit.Name);
            var message4 = string.Format("SerialNumber: {0}", interfaceKit.SerialNumber.ToString(CultureInfo.InvariantCulture));
            var message5 = string.Format("Version: {0}", interfaceKit.Version.ToString(CultureInfo.InvariantCulture));

            var message6 = string.Format("Number of digital inputs: {0}", interfaceKit.inputs.Count.ToString(CultureInfo.InvariantCulture));
            var message7 = string.Format("Number of digital outputs: {0}", interfaceKit.outputs.Count.ToString(CultureInfo.InvariantCulture));
            var message8 = string.Format("Number of sensor inputs (analog): {0}", interfaceKit.sensors.Count.ToString(CultureInfo.InvariantCulture));

            ReportMessage(message1);
            ReportMessage(message2);
            ReportMessage(message3);
            ReportMessage(message4);
            ReportMessage(message5);
            ReportMessage(message6);
            ReportMessage(message7);
            ReportMessage(message8);
        }
Example #8
0
        private void StepperBoard_Attach(object sender, AttachEventArgs e)
        {
            for (int i = 0; i < _stepperBoard.steppers.Count; i++)
            {
                if (_motorCount == 0)
                {
                    _steppers[i].MinAcceleration = _stepperBoard.steppers[i].AccelerationMin;
                    _steppers[i].MaxAcceleration = _stepperBoard.steppers[i].AccelerationMax;
                    _steppers[i].Acceleration    = _steppers[i].MaxAcceleration;

                    _steppers[i].MinVelocity   = _stepperBoard.steppers[i].VelocityMin;
                    _steppers[i].MaxVelocity   = _stepperBoard.steppers[i].VelocityMax;
                    _steppers[i].VelocityLimit = _steppers[i].MaxVelocity;

                    RegisterBindings(i);
                }
                _stepperBoard.steppers[i].VelocityLimit = _steppers[i].VelocityLimit;
                _stepperBoard.steppers[i].Acceleration  = _steppers[i].Acceleration;
            }

            if (_motorCount == 0)
            {
                _motorCount = _stepperBoard.steppers.Count;
                ConfigManager.LogManager.LogDebug("Detaching phidget stepper board after config. (SerialNumber=\"" + _serialNumber + "\")");
                _stepperBoard.close();
                _stepperBoard = null;
            }
        }
        //Bridge Attach event handler...populate the fields and controls
        void br_Attach(object sender, AttachEventArgs e)
        {
            Bridge attached = (Bridge)sender;
            attachedTxt.Text = attached.Attached.ToString();
            nameTxt.Text = attached.Name;
            serialTxt.Text = attached.SerialNumber.ToString();
            versiontxt.Text = attached.Version.ToString();
            numBridgesTxt.Text = attached.bridges.Count.ToString();

            dataRateBar.Minimum = attached.DataRateMax / 8;
            dataRateBar.Maximum = attached.DataRateMin / 8;

            dataRateBox.Enabled = true;
            dataRateBar.Enabled = true;
            dataRateBar.Value = 10;
            bridgeCmb.Enabled = true;
            enCheck.Enabled = true;
            enCheck.Checked = false;
            gainCmb.Enabled = true;
            valueTxt.Enabled = true;
            startBut.Enabled = true;
            set1.Enabled = true;
            set2.Enabled = true;

            dataRateBar.Value = br.DataRate / 8;
            dataRateBox.Text = br.DataRate.ToString();

            bridgeCmb.SelectedIndex = 0;
        }
 private void OnAttach(object sender, AttachEventArgs e)
 {
     input.DataInterval = this.dataIntervalMs;
     input.VoltageRatioChangeTrigger = 0;
     Console.WriteLine("Attached on channel " + input.Channel + " data interval " + input.DataInterval + "ms");
     input.VoltageRatioChange += OnVoltageChange;
 }
        void rfid_Attach(object sender, AttachEventArgs e)
        {
            RFID attached = (RFID)sender;
            //attachedTxt.Text = e.Device.Attached.ToString();
            attachedTxt.Text = attached.Attached.ToString();
            nameTxt.Text = attached.Name;
            serialTxt.Text = attached.SerialNumber.ToString();
            versionTxt.Text = attached.Version.ToString();
            outputsTxt.Text = attached.outputs.Count.ToString();

            switch (attached.ID)
            {
                case Phidget.PhidgetID.RFID_2OUTPUT_READ_WRITE:
                    this.Bounds = new Rectangle(this.Location, new Size(302, 465));
                    writeBox.Visible = true;
                    break;
                case Phidget.PhidgetID.RFID:
                case Phidget.PhidgetID.RFID_2OUTPUT:
                default:
                    this.Bounds = new Rectangle(this.Location, new Size(302, 465));
                    writeBox.Visible = false;
                    break;
            }

            if (rfid.outputs.Count > 0)
            {
                antennaChk.Checked = true;
                rfid.Antenna = true;
                antennaChk.Enabled = true;
                ledChk.Enabled = true;
                output0Chk.Enabled = true;
                output1chk.Enabled = true;
            }
        }
Example #12
0
        private void IsAttached(object sender, AttachEventArgs e)
        {
            //showing if RFID scanners are attached

            labelRFID.Text = "RFID attached";
            readchip();
        }
Example #13
0
 private void IsAttached(object sender, AttachEventArgs e)
 {
     //showing if RFID scanners are attached
     // MessageBox.Show("RFIDReader attached!");
     labelRFID.Text = "RFID attached";
     readchip();
 }
Example #14
0
        //MotorControl Attach event handler...populate the fields and controls
        void freqCounter_Attach(object sender, AttachEventArgs e)
        {
            FrequencyCounter attached = (FrequencyCounter)sender;

            attachedTxt.Text = attached.Attached.ToString();
            nameTxt.Text     = attached.Name;
            serialTxt.Text   = attached.SerialNumber.ToString();
            versiontxt.Text  = attached.Version.ToString();

            channelCmb.Enabled   = true;
            enCB.Enabled         = true;
            filterCmb.Enabled    = true;
            timeOutTxt.Enabled   = true;
            freqTxt.Enabled      = true;
            totalCntTxt.Enabled  = true;
            totalTimeTxt.Enabled = true;

            foreach (String filterType in System.Enum.GetNames(typeof(FrequencyCounterInput.FilterType)))
            {
                if (filterType.Equals(FrequencyCounterInput.FilterType.INVALID.ToString()))
                {
                    break;
                }
                filterCmb.Items.Add(filterType);
            }

            for (int i = 0; i < attached.inputs.Count; i++)
            {
                channelCmb.Items.Add(i.ToString());
            }

            channelCmb.SelectedIndex = 0;
        }
Example #15
0
        void phidgManager_Attach(object sender, AttachEventArgs e)
        {
            //Console.WriteLine("Attached Device: {0}", e.Device.Class);

            //Check if the phidget attached is an RFID reader...
            if (e.Device.Class.ToString() == "RFID")
            {
                //Create the RFID reader object for this reader...
                RFID currentReader = new RFID();

                //Attach events to the new reader that has been attached...
                currentReader.Attach  += new AttachEventHandler(rfid_Attach);
                currentReader.Detach  += new DetachEventHandler(rfid_Detach);
                currentReader.Error   += new ErrorEventHandler(rfid_Error);
                currentReader.Tag     += new TagEventHandler(rfid_Tag);
                currentReader.TagLost += new TagEventHandler(rfid_TagLost);

                tagTable[e.Device.SerialNumber.ToString()] = "init";
                phidgetList.Add(currentReader);

                try {
                    currentReader.open(e.Device.SerialNumber);
                } catch (Exception ex) {
//					FLogger.Log(LogType.Error, "Attach RFID: "+ex.Message);
                }
            }
            return;
        }
Example #16
0
 public void rfid_Attach(object sender, AttachEventArgs e)
 {
     RFID atached = (RFID)sender;
     LBL_RFID.BackColor = Color.Lime;
     rfid.Tag += new TagEventHandler(rfid_Tag);
     rfid.Antenna = true;
     rfid.LED = true;
 }
 void rfid_Attach(object sender, AttachEventArgs e)
 {
     RFID attached = (RFID)sender;
     rfid.Antenna = Enabled;
     rfid.LED = true;
     lblCheckin.Text = "Check -in/-uit";
     // wanneer er een rfid aangesloten is word de antenna aangezet en de LED om aan te geven dat deze aangesloten is
 }
Example #18
0
 void m_RelayBoard_Attach(object sender, AttachEventArgs e)
 {
     isReady = true;
     if (FiringControlReady != null)
     {
         FiringControlReady(this, new FiringControllerReadyArgs());
     }
 }
Example #19
0
 void m_RelayBoard_Attach(object sender, AttachEventArgs e)
 {
     isReady = true;
     if (FiringControlReady != null)
     {
         FiringControlReady(this, new FiringControllerReadyArgs());
     }
 }
Example #20
0
        // ============== Event Subscribers ==================

        private void kit_Attach(object sender, AttachEventArgs e)
        {
            kit.sensors[0].Sensitivity = 150;
            kit.sensors[0].DataRate    = 32;
            kit.outputs[0]             = false;
            kit.outputs[1]             = false;
            kit.outputs[2]             = false;
        }
Example #21
0
        //LCD Attach event handler...populate the fields and controls
        void lcdControl_Attach(object sender, AttachEventArgs e)
        {
            TextLCD attached = (TextLCD)sender;

            attachedTxt.Text = attached.Attached.ToString();
            nameTxt.Text     = attached.Name;
            serialTxt.Text   = attached.SerialNumber.ToString();
            versiontxt.Text  = attached.Version.ToString();

            backlightChk.Enabled   = true;
            cursorChk.Enabled      = true;
            cursorBlinkChk.Enabled = true;
            contrastTrkBr.Enabled  = true;

            memoryLocCmb.Enabled        = true;
            customCharScreenCmb.Enabled = true;
            storeCustom.Enabled         = true;

            switch (attached.ID)
            {
            case Phidget.PhidgetID.TEXTLCD_2x20:
            case Phidget.PhidgetID.TEXTLCD_2x20_w_0_8_8:
                break;

            case Phidget.PhidgetID.TEXTLCD_2x20_w_8_8_8:
                if (attached.Version >= 200)
                {
                    brightnessTrkBr.Visible = true;
                    brightnessLbl.Visible   = true;
                    brightnessTrkBr.Enabled = true;
                }
                break;

            case Phidget.PhidgetID.TEXTLCD_ADAPTER:
                screenCmb.Enabled       = true;
                screenSizeCmb.Enabled   = true;
                initButton.Enabled      = true;
                initButton.Visible      = true;
                brightnessTrkBr.Visible = true;
                brightnessLbl.Visible   = true;
                brightnessTrkBr.Enabled = true;
                break;
            }

            foreach (String size in System.Enum.GetNames(typeof(TextLCD.ScreenSizes)))
            {
                screenSizeCmb.Items.Add(size);
            }

            for (int i = 0; i < attached.screens.Count; i++)
            {
                screenCmb.Items.Add(i.ToString());
                customCharScreenCmb.Items.Add(i.ToString());
            }

            screenCmb.SelectedIndex           = 0;
            customCharScreenCmb.SelectedIndex = 0;
        }
Example #22
0
        private void ServoController_Attach(object sender, AttachEventArgs e)
        {
            Console.WriteLine("ServoController_Attach");

            servoMotor          = servoController.servos[0];
            servoMotor.Position = 0;
            Console.WriteLine("min: " + servoMotor.PositionMin);
            Console.WriteLine("max: " + servoMotor.PositionMax);
        }
Example #23
0
        //attach event handler, we'll output the name and serial number of the TextLCD
        //that was attached
        static void tLCD_attach(object sender, AttachEventArgs e)
        {
            TextLCD attached = (TextLCD)sender;
            string name = attached.Name;
            string serialNo = attached.SerialNumber.ToString();

            Console.WriteLine("TextLCD name:{0} serial No.: {1} Attached!", name,
                                    serialNo);
        }
Example #24
0
        private void rfid_Attach(object sender, AttachEventArgs e)
        {
            var attached = (RFID)sender;

            if (_rfid.outputs.Count > 0)
            {
                _rfid.Antenna = true;
            }
        }
    void onAttach(object sender, AttachEventArgs e)
    {
        Debug.Log("Attach");
        accel.DataInterval = 100;
        Debug.Log(accel.MinDataInterval);
        Debug.Log(accel.DataInterval);

        //TODO: Set data interval to minimum
    }
Example #26
0
        //attach event handler, we'll output the name and serial number of the TextLCD
        //that was attached
        static void tLCD_Attach(object sender, AttachEventArgs e)
        {
            TextLCD attached = (TextLCD)sender;
            string  name     = attached.Name;
            string  serialNo = attached.SerialNumber.ToString();

            Console.WriteLine("TextLCD name:{0} serial No.: {1} Attached!", name,
                              serialNo);
        }
Example #27
0
        private void RfidReader_Attach(object sender, AttachEventArgs e)
        {
            rfidReader.Antenna = true;

            Console.WriteLine("RfidReader_Attach");
            // event for when a tag is found
            rfidReader.Tag += RfidReader_Tag;;
            // event for when a tag is lost
            rfidReader.TagLost += RfidReader_TagLost;;
        }
Example #28
0
        //attach event handler... here we'll display the interface kit details as well as determine how many output and input
        //fields to display as well as determine the range of values for the output simulator slider
        void ifk_Attach(object sender, AttachEventArgs e)
        {
            InterfaceKit attached = (InterfaceKit)sender;

            IFKattachedTXT.Text = attached.Attached.ToString();
            IFKnameTXT.Text     = attached.Name;
            IFKserialTXT.Text   = attached.SerialNumber.ToString();
            IFKversionTXT.Text  = attached.Version.ToString();

            digiInNumTxt.Text   = attached.inputs.Count.ToString();
            digiOutNumTxt.Text  = attached.outputs.Count.ToString();
            sensorInNumTxt.Text = attached.sensors.Count.ToString();

            int i;

            for (i = 0; i < attached.inputs.Count; i++)
            {
                digiInArray[i].Visible = true;
            }

            for (i = 0; i < attached.outputs.Count; i++)
            {
                digiOutArray[i].Visible = true;
                digiOutArray[i].Checked = false;
                digiOutArray[i].Enabled = true;
            }

            if (attached.sensors.Count > 0)
            {
                for (i = 0; i < attached.sensors.Count; i++)
                {
                    sensorInArray[i].Visible = true;
                }

                label9.Visible         = true;
                sensitivityTxt.Visible = true;
                inputTrk.Visible       = true;
            }
            else
            {
                label9.Visible         = false;
                sensitivityTxt.Visible = false;
                inputTrk.Visible       = false;
            }

            inputTrk.Enabled = true;
            inputTrk.SetRange(0, 1000);
            inputTrk.Value      = attached.sensors[0].Sensitivity;
            sensitivityTxt.Text = inputTrk.Value.ToString();

            attached.ratiometric = true;

            ratioChk.Enabled = true;
            ratioChk.Checked = attached.ratiometric;
        }
Example #29
0
        void rfid_Attach(object sender, AttachEventArgs e)
        {
            RFID attached = (RFID)sender;

            lblScannerInfo.Text = "Phidget RFID Connected (" + attached.SerialNumber + ")";

            if (rfid.outputs.Count > 0)
            {
                rfid.Antenna = true;
            }
        }
        //Event wanneer er een RFID scanner gekoppelt wordt.
        private void rfid_Attach(object sender, AttachEventArgs e)
        {
            //Laat de gebruiker weten dat de scanner klaar voor gebruik is.
            Console.WriteLine("RFIDReader {0} attached!", e.Device.SerialNumber.ToString());
            panel1.BackColor = Color.CadetBlue;
            lbInfo.Text      = "Scan een RFID tag om te beginnen!";

            //Zet de antenne en LED aan
            rfid.Antenna = true;
            rfid.LED     = true;
        }
Example #31
0
 //Initialize collection arrays
 void Analog_Attach(object sender, AttachEventArgs e)
 {
     //4 channels
     channels = new AnalogChannelCollection(this, 4);
     foreach (AnalogChannel channel in channels)
     {
         channel.voltageMax = 10.0;
         channel.voltageMin = -10.0;
         //channel.Voltage = 0;
     }
 }
Example #32
0
        // called when a new rfid reader is attached to the usb port
        void rfid_Attach(object sender, AttachEventArgs e)
        {
            RFID attached = (RFID)sender;

            if (rfid.outputs.Count > 0)
            {
                rfid.Antenna = true;
            }

            MessageBox.Show("Connected to loyalty card reader", "Ready");
        }
Example #33
0
        void gps_Attach(object sender, AttachEventArgs e)
        {
            GPS attached = (GPS)sender;

            serialTxt.Text   = attached.SerialNumber.ToString();
            attachedTxt.Text = attached.Attached.ToString();
            versiontxt.Text  = attached.Version.ToString();
            nameTxt.Text     = attached.Name.ToString();
            timer1.Start();

            mapGraphic = pictureBox1.CreateGraphics();
        }
        void rfid_Attach(object sender, AttachEventArgs e)
        {
            lblTag.Text          = "-";
            lblStatus.Text       = "Connected";
            lblSerialNumber.Text = rfid.DeviceSerialNumber.ToString();

            cbAntenna.Checked = rfid.AntennaEnabled;
            cbAntenna.Enabled = true;
            Console.Beep(2000, 150);
            Console.Beep(2500, 150);
            Console.Beep(3000, 150);
        }
Example #35
0
        //attach event handler...display the serial number of the attached RFID phidget
        void rfid_Attach(object sender, AttachEventArgs e)
        {
            //Get the toast message component
            IServiceProvider services       = Services;
            IMessageDisplay  messageDisplay = (IMessageDisplay)services.GetService(typeof(IMessageDisplay));

            rfid.Antenna = true;
            rfid.LED     = true;

            //pop up a message
            messageDisplay.ShowFormattedMessage("RFIDReader {0} attached!", e.Device.SerialNumber.ToString());
        }
        // Phidget Compass Code
        //spatial attach event handler
        static void spatial_Attach(object sender, AttachEventArgs e)
        {
            Spatial attached = (Spatial)sender;

            switch (attached.ID)
            {
            case Phidget.PhidgetID.SPATIAL_ACCEL_3:
                this.Bounds = new Rectangle(this.Location, new Size(567, 500));
                break;

            case Phidget.PhidgetID.SPATIAL_ACCEL_GYRO_COMPASS:
                this.Bounds = new Rectangle(this.Location, new Size(838, 614));

                break;
            }

            try
            {
                double test = attached.accelerometerAxes[0].Acceleration;
            }
            catch
            { }

            if (attached.accelerometerAxes.Count > 0)
            {
                accelBox.Visible = true;
            }
            if (attached.compassAxes.Count > 0)
            {
                compassBox.Visible      = true;
                compassGraphBox.Visible = true;
            }
            if (attached.gyroAxes.Count > 0)
            {
                gyroBox.Visible      = true;
                gyroGraphBox.Visible = true;
            }

            attached.DataRate = 32;

            dataRateTrack.Minimum = attached.DataRateMax;
            dataRateTrack.Maximum = 496;
            dataRateTrack.Value   = attached.DataRate;
            dataRateTxt.Text      = attached.DataRate.ToString();

            lastMsCountGood[0] = false;
            lastMsCountGood[1] = false;
            lastMsCountGood[2] = false;
            gyroHeading[0]     = 0;
            gyroHeading[1]     = 0;
            gyroHeading[2]     = 0;
        }
Example #37
0
        private void InterfaceKit_Attach(object sender, AttachEventArgs e)
        {
            Debug.WriteLine("InterfaceKit_Attach");
            if (!attachedInterfaceKit)
            {
                attachedInterfaceKit = true;

                var startKnobValue = interfaceKit.sensors[KnobIndex].Value;
                updateFromKnobValue(startKnobValue);

                interfaceKit.SensorChange += InterfaceKit_SensorChange;
            }
        }
Example #38
0
    static void ifKit_Attach(object sender, AttachEventArgs e)
    {
        int serialNumber;
        String name;

        try{
            serialNumber = e.Device.SerialNumber;
            name = e.Device.Name;
            Debug.Log("Hello Device " + serialNumber.ToString() + "," + "Serial Number:" + name + "!");
        }
        catch (PhidgetException ex)
        {
            Debug.Log("Error on function call: " + ex.Code + " - " + ex.Description + "!");
        }
    }
Example #39
0
        //PhidgetServo attach event handling code
        void advServo_Attach(object sender, AttachEventArgs e)
        {
            AdvancedServo attached = (AdvancedServo)sender;

            attachedTxt.Text = attached.Attached.ToString();
            nameTxt.Text = attached.Name;
            serialTxt.Text = attached.SerialNumber.ToString();
            versiontxt.Text = attached.Version.ToString();
            numServosTxt.Text = attached.servos.Count.ToString();

            velocityTrk.Enabled = true;
            positionTrk.Enabled = true;
            accelTrk.Enabled = true;
            engagedCheckBox.Enabled = true;
            speedRampingCheckBox.Enabled = true;
            maxPosnTrackBar.Enabled = true;
            minPosnTrackBar.Enabled = true;

            //Set the default servo type to the one Phidgets sells
            foreach (AdvancedServoServo motor in attached.servos)
                motor.Type = ServoServo.ServoType.HITEC_HS322HD;

            foreach(String servoType in System.Enum.GetNames(typeof(ServoServo.ServoType)))
            {
                //stop here
                if (servoType.Equals(ServoServo.ServoType.USER_DEFINED.ToString()))
                    break;
                servoTypeCmb.Items.Add(servoType);
            }

            servoTypeCmb.Enabled = true;

            for (int i = 0; i < attached.servos.Count; i++)
            {
                servoCmb.Items.Add(i);
            }
            //this will initialize all values
            servoCmb.SelectedIndex = 0;
            servoCmb.Enabled = true;
        }
Example #40
0
        //Analog Attach event handler...populate the fields and controls
        void analog_Attach(object sender, AttachEventArgs e)
        {
            Phidgets.Analog attached = (Phidgets.Analog)sender;
            attachedTxt.Text = attached.Attached.ToString();
            nameTxt.Text = attached.Name;
            serialTxt.Text = attached.SerialNumber.ToString();
            versiontxt.Text = attached.Version.ToString();
            numChannelsTxt.Text = attached.outputs.Count.ToString();

            for (int i = 0; i < 4; i++)
            {
                ChannelBox.Controls["vSlider" + i].Enabled = true;
                ChannelBox.Controls["en" + i].Enabled = true;

                ((TrackBar)ChannelBox.Controls["vSlider" + i]).Minimum = (int)Math.Round(attached.outputs[i].VoltageMin * 100);
                ((TrackBar)ChannelBox.Controls["vSlider" + i]).Maximum = (int)Math.Round(attached.outputs[i].VoltageMax * 100);

                ((TextBox)ChannelBox.Controls["volt" + i]).Text = attached.outputs[i].Voltage.ToString("F2")+"v";
                ((TrackBar)ChannelBox.Controls["vSlider" + i]).Value = (int)Math.Round(attached.outputs[i].Voltage * 100);
                ((CheckBox)ChannelBox.Controls["en" + i]).Checked = attached.outputs[i].Enabled;
            }
        }
 //Initialize collection arrays
 void FrequencyCounter_Attach(object sender, AttachEventArgs e)
 {
     inputs = new FrequencyCounterInputCollection(this, 2);
 }
Example #42
0
 void therm_Attach(object sender, AttachEventArgs e)
 {
     start = DateTime.Now;
     therm.thermocouples[0].Sensitivity = 0;
     update = new TimeSpan();
 }
 private void rfid_Attach(object sender, AttachEventArgs e)
 {
     if (_rfid.outputs.Count > 0)
     {
         _rfid.Antenna = true;
     }
 }
Example #44
0
 private void accel_Attach(object sender, AttachEventArgs e)
 {
     throw new NotImplementedException();
 }
 private void rfid_Attach(object sender, AttachEventArgs e)
 {
     var attached = (RFID)sender;
     if (_rfid.outputs.Count > 0)
     {
         _rfid.Antenna = true;
     }
 }
Example #46
0
        //MotorControl Attach event handler...populate the fields and controls
        void motoControl_Attach(object sender, AttachEventArgs e)
        {
            MotorControl attached = (MotorControl)sender;
            attachedTxt.Text = attached.Attached.ToString();
            nameTxt.Text = attached.Name;
            serialTxt.Text = attached.SerialNumber.ToString();
            versiontxt.Text = attached.Version.ToString();
            numMotorsTxt.Text = attached.motors.Count.ToString();
            numInputsTxt.Text = attached.inputs.Count.ToString();
            numEncodersTxt.Text = attached.encoders.Count.ToString();
            numSensorsTxt.Text = attached.sensors.Count.ToString();

            //Re-size according to capabilities
            if (attached.inputs.Count > 0)
            {
                this.Bounds = new Rectangle(this.Location, new Size(this.Width, 585));
                digitalInputsGroup.Visible = true;
                for (int i = 0; i < attached.inputs.Count; i++)
                {
                    ((CheckBox)digitalInputsGroup.Controls["input" + i + "Chk"]).Visible = true;
                }
            }
            if (attached.encoders.Count > 0)
            {
                this.Bounds = new Rectangle(this.Location, new Size(this.Width, 641));
                encodersGroup.Visible = true;

                encoderPosition.Text = motoControl.encoders[0].Position.ToString();
            }
            if (attached.sensors.Count > 0)
            {
                this.Bounds = new Rectangle(this.Location, new Size(this.Width, 695));
                sensorsGroup.Visible = true;

                ratiometricCheck.Checked = motoControl.Ratiometric;
            }

            //Set accel range (varies according to controller)
            accelTrk.SetRange((int)Math.Round(attached.motors[0].AccelerationMin), (int)attached.motors[0].AccelerationMax);
            accelTrk.TickFrequency = ((int)attached.motors[0].AccelerationMax - (int)Math.Round(attached.motors[0].AccelerationMin)) / 10;
            accelTrk.Value = accelTrk.Minimum;

            //Enable everything
            motorCmb.Enabled = true;
            velocityTrk.Enabled = true;
            accelTrk.Enabled = true;

            if (attached.ID == Phidget.PhidgetID.MOTORCONTROL_1MOTOR)
            {
                backEmfSensingCheck.Enabled = true;
                brakingTrk.Enabled = true;
            }

            supplyVoltageTimer.Start();

            for (int i = 0; i < attached.motors.Count; i++)
            {
                motorCmb.Items.Add(i);
            }

            motorCmb.SelectedIndex = 0;
        }
 //Attach event hanlder. Display serial number of attached MotorControl phidget
 static void gps_Attach(object sender, AttachEventArgs e)
 {
     Console.WriteLine("GPS attached!",
                             e.Device.SerialNumber.ToString());
 }
Example #48
0
        void accel_Attach(object sender, AttachEventArgs e)
        {
            Accelerometer attached = (Accelerometer)sender;
            label1.Text = "Phidget Accelerometer Attached.";
            label2.Text = "Serial Number: " + attached.SerialNumber;

            attached.axes[0].Sensitivity = 0;
            attached.axes[1].Sensitivity = 0;
            if (attached.axes.Count > 2)
                attached.axes[2].Sensitivity = 0;
        }
Example #49
0
 //Attach event handler. Display the serial number of the attached LED Phidget
 //to the console
 static void led_Attach(object sender, AttachEventArgs e)
 {
     Console.WriteLine("PhidgetLED {0} attached!",
                             e.Device.SerialNumber.ToString());
 }
Example #50
0
 //Attach event handler...Display the serial number of the attached InterfaceKit
 //to the console
 static void ifKit_Attach(object sender, AttachEventArgs e)
 {
     Console.WriteLine("InterfaceKit {0} attached!",
                        e.Device.SerialNumber.ToString());
     /*
     if (e.Device.SerialNumber.ToString() == "13508")
         polhemusKit = (InterfaceKit)sender;
     else
     {
         vibrationKit = (InterfaceKit)sender;
         turnOffVibration();
     }*/
 }
Example #51
0
        //PHSensor Attach event handler...We'll populate the fields in the GUI and enable the modify sensitivity textbox
        void ph_sensor_Attach(object sender, AttachEventArgs e)
        {
            PHSensor attached = (PHSensor)sender;
            attachedTxt.Text = attached.Attached.ToString();
            nameTxt.Text = attached.Name;
            serialTxt.Text = attached.SerialNumber.ToString();
            versionTxt.Text = attached.Version.ToString();

            try
            {
                phTxt.Text = attached.sensor.PH.ToString();
            }
            catch (PhidgetException)
            {
                phTxt.Text = "Unknown";
            }

            try
            {
                potentialTxt.Text = attached.sensor.Potential.ToString();
            }
            catch (PhidgetException)
            {
                potentialTxt.Text = "Unknown";
            }

            try
            {
                sensitivityTxt.Text = attached.sensor.Sensitivity.ToString();
            }
            catch (PhidgetException)
            {
                sensitivityTxt.Text = "Unknown";
            }
            potentialRange.Text = "(" + ph_sensor.sensor.PotentialMin.ToString() + "mV - " +
                ph_sensor.sensor.PotentialMax.ToString() + "mV)";
            phRange.Text = "(" + ph_sensor.sensor.PHMin.ToString() + " - " +
                ph_sensor.sensor.PHMax.ToString() + ")";
            sensitivityTxt.Enabled = true;
            temperatureTxt.Enabled = true;
        }
 //Attach event handler...we'll display the serial number of the PHSensor device
 //that was attached to the console
 static void ph_sensor_Attach(object sender, AttachEventArgs e)
 {
     Console.WriteLine("PH Sensor {0} attached!",
                             e.Device.SerialNumber.ToString());
 }
Example #53
0
        void phid_Attach(object sender, AttachEventArgs e)
        {
            phid.DataRate = phid.DataRateMax;
            gravitySamples = (int)(1 / (phid.DataRate * 0.001) * 2); //2 seconds - same as gyro zeroing time
            zeroGyro();

            //enter board specific magnetic field corrections
            //phid.setCompassCorrectionParameters(0.56977, -0.024783, -0.097665, -0.026208, 2.000875, 1.907259, 2.044313, 0.014403, 0.007221, 0.013597, 0.009518, 0.007360, 0.010222);

            //Do this in a seperate thread so the drawing doens't block the data event and cause errors.
            drawThread = new Thread(new ThreadStart(drawThreadFunc));
            drawThread.Start();
        }
Example #54
0
        //attach event handler..populate the details fields as well as display the attached status.  enable the checkboxes to change
        //the values of the attributes of the RFID reader such as enable or disable the antenna and onboard led.
        void rfid_Attach(object sender, AttachEventArgs e)
        {
            RFID attached = (RFID)sender;
            //attachedTxt.Text = e.Device.Attached.ToString();
            attachedTxt.Text = attached.Attached.ToString();
            nameTxt.Text = attached.Name;
            serialTxt.Text = attached.SerialNumber.ToString();
            versionTxt.Text = attached.Version.ToString();
            outputsTxt.Text = attached.outputs.Count.ToString();

            if (rfid.outputs.Count > 0)
            {
                antennaChk.Checked = true;
                rfid.Antenna = true;
                antennaChk.Enabled = true;
                ledChk.Enabled = true;
                output0Chk.Enabled = true;
                output1chk.Enabled = true;
            }
        }
 //attach event handler
 static void man_Attach(object sender, AttachEventArgs e)
 {
     Console.WriteLine("Device {0} serial no. {1} attached!", e.Device.Name,
                             e.Device.SerialNumber.ToString());
     //printDeviceTable();
 }
Example #56
0
        //attach event handler... here we'll display the interface kit details as well as determine how many output and input
        //fields to display as well as determine the range of values for the output simulator slider
        void ifk_Attach(object sender, AttachEventArgs e)
        {
            InterfaceKit attached = (InterfaceKit)sender;
            IFKattachedTXT.Text = attached.Attached.ToString();
            IFKnameTXT.Text = attached.Name;
            IFKserialTXT.Text = attached.SerialNumber.ToString();
            IFKversionTXT.Text = attached.Version.ToString();

            digiInNumTxt.Text = attached.inputs.Count.ToString();
            digiOutNumTxt.Text = attached.outputs.Count.ToString();
            sensorInNumTxt.Text = attached.sensors.Count.ToString();

            int i;
            for (i = 0; i < attached.inputs.Count; i++)
            {
                digiInArray[i].Visible = true;
            }

            for (i = 0; i < attached.outputs.Count; i++)
            {
                digiOutArray[i].Visible = true;
                digiOutArray[i].Checked = false;
                digiOutArray[i].Enabled = true;
            }

            if (attached.sensors.Count > 0)
            {
                for (i = 0; i < attached.sensors.Count; i++)
                {
                    sensorInArray[i].Visible = true;
                }

                label9.Visible = true;
                sensitivityTxt.Visible = true;
                inputTrk.Visible = true;
            }
            else
            {
                label9.Visible = false;
                sensitivityTxt.Visible = false;
                inputTrk.Visible = false;
            }

            inputTrk.Enabled = true;
            inputTrk.SetRange(0, 1000);
            inputTrk.Value = attached.sensors[0].Sensitivity;
            sensitivityTxt.Text = inputTrk.Value.ToString();

            attached.ratiometric = true;

            ratioChk.Enabled = true;
            ratioChk.Checked = attached.ratiometric;
        }
Example #57
0
        //PhidgetServo attach event handling code
        void servo_Attach(object sender, AttachEventArgs e)
        {
            Servo attached = (Servo)sender;
            attachedTxt.Text = attached.Attached.ToString();
            nameTxt.Text = attached.Name;
            serialTxt.Text = attached.SerialNumber.ToString();
            versionTxt.Text = attached.Version.ToString();
            servosTxt.Text = attached.servos.Count.ToString();
            positionTrk.Enabled = true;
            engagedCheckBox.Enabled = true;

            //Set the default servo type to the one Phidgets sells
            foreach (ServoServo motor in attached.servos)
                motor.Type = ServoServo.ServoType.HITEC_HS322HD;

            //Setting custom servo parameters example - 600us-2000us == 120 degrees
            //servo.servos[0].setServoParameters(600, 2000, 120);

            foreach (String servoType in System.Enum.GetNames(typeof(ServoServo.ServoType)))
            {
                //stop here
                if (servoType.Equals(ServoServo.ServoType.USER_DEFINED.ToString()))
                    break;
                servoTypeCmb.Items.Add(servoType);
            }

            servoTypeCmb.Enabled = true;

            for (int i = 0; i < attached.servos.Count; i++)
            {
                servoNumCombo.Items.Add(i);
            }

            servoNumCombo.SelectedIndex = 0;
            servoNumCombo.Enabled = true;
        }
Example #58
0
        //LCD Attach event handler...populate the fields and controls
        void lcdControl_Attach(object sender, AttachEventArgs e)
        {
            TextLCD attached = (TextLCD)sender;
            attachedTxt.Text = attached.Attached.ToString();
            nameTxt.Text = attached.Name;
            serialTxt.Text = attached.SerialNumber.ToString();
            versiontxt.Text = attached.Version.ToString();

            backlightChk.Enabled = true;
            cursorChk.Enabled = true;
            cursorBlinkChk.Enabled = true;
            contrastTrkBr.Enabled = true;

            memoryLocCmb.Enabled = true;
            customCharScreenCmb.Enabled = true;
            storeCustom.Enabled = true;

            switch (attached.ID)
            {
                case Phidget.PhidgetID.TEXTLCD_2x20:
                case Phidget.PhidgetID.TEXTLCD_2x20_w_0_8_8:
                    break;
                case Phidget.PhidgetID.TEXTLCD_2x20_w_8_8_8:
                    if (attached.Version >= 200)
                    {
                        brightnessTrkBr.Visible = true;
                        brightnessLbl.Visible = true;
                        brightnessTrkBr.Enabled = true;
                    }
                    break;
                case Phidget.PhidgetID.TEXTLCD_ADAPTER:
                    screenCmb.Enabled = true;
                    screenSizeCmb.Enabled = true;
                    initButton.Enabled = true;
                    initButton.Visible = true;
                    brightnessTrkBr.Visible = true;
                    brightnessLbl.Visible = true;
                    brightnessTrkBr.Enabled = true;
                    break;
            }

            foreach (String size in System.Enum.GetNames(typeof(TextLCD.ScreenSizes)))
            {
                screenSizeCmb.Items.Add(size);
            }

            for (int i = 0; i < attached.screens.Count; i++)
            {
                screenCmb.Items.Add(i.ToString());
                customCharScreenCmb.Items.Add(i.ToString());
            }

            screenCmb.SelectedIndex = 0;
            customCharScreenCmb.SelectedIndex = 0;
        }
Example #59
0
        //attach event handler...we will display the attach status and the attached TextLCD device's details
        //We will also enable the fields used to manipulate the TextLCD as well as do some initializing of
        //ranges and maximum values for some of these fields
        void lcd_Attach(object sender, AttachEventArgs e)
        {
            TextLCD attached = (TextLCD)sender;
            LCDattachedText.Text = attached.Attached.ToString();
            LCDnameText.Text = attached.Name;
            LCDserialText.Text = attached.SerialNumber.ToString();
            LCDversionText.Text = attached.Version.ToString();

            contrastTrkBr.Enabled = true;
            contrastTrkBr.SetRange(0, 255);
            contrastTrkBr.Value = 130;
        }
 //Attach event handler...Display the serial number of the attached
 //spatial to the console
 void accel_Attach(object sender, AttachEventArgs e)
 {
     messageTextBox.Text += "Spatial " + e.Device.SerialNumber.ToString() + " attached!";
 }