// Use this for initialization void Start() { ifKit = new InterfaceKit(); ifKit.open(); ifKit.waitForAttachment(1000); PhidgetsValue = new int[8]; }
public virtual void Open() { try { if (m_open == true) { return; } //InterfaceKit.enableLogging(Phidget.LogLevel.PHIDGET_LOG_DEBUG, "c:\\PhidgetLog.txt"); if (ifKit == null) { ifKit = new InterfaceKit(); } ifKit.Attach += new AttachEventHandler(ifKit_Attach); ifKit.Detach += new DetachEventHandler(ifKit_Detach); ifKit.Error += new ErrorEventHandler(ifKit_Error); ifKit.InputChange += new InputChangeEventHandler(ifKit_InputChange); ifKit.OutputChange += new OutputChangeEventHandler(ifKit_OutputChange); ifKit.SensorChange += new SensorChangeEventHandler(ifKit_SensorChange); m_open = true; } catch (PhidgetException ex) { throw ((new SystemException("Error initialize Phidget21"))); } openCmdLine(ifKit); }
void Start() { ifKit1 = new InterfaceKit(); ifKit2 = new InterfaceKit(); ifKit3 = new InterfaceKit(); ifKit1.Attach += new AttachEventHandler(ifKit_Attach); ifKit1.Detach += new DetachEventHandler(ifKit_Detach); ifKit1.Error += new ErrorEventHandler(ifKit_Error); ifKit1.SensorChange += new SensorChangeEventHandler(ifKit1_SensorChange); ifKit2.Attach += new AttachEventHandler(ifKit_Attach); ifKit2.Detach += new DetachEventHandler(ifKit_Detach); ifKit2.Error += new ErrorEventHandler(ifKit_Error); ifKit2.SensorChange += new SensorChangeEventHandler(ifKit2_SensorChange); ifKit3.Attach += new AttachEventHandler(ifKit_Attach); ifKit3.Detach += new DetachEventHandler(ifKit_Detach); ifKit3.Error += new ErrorEventHandler(ifKit_Error); ifKit3.SensorChange += new SensorChangeEventHandler(ifKit3_SensorChange); IsPhidgetConnected = true; }
private void passwordEntered_Click(object sender, RoutedEventArgs e) { string pass = passwordBox1.Password; passwordBox1.Password = string.Empty; if (pass == "tennis") { vm.bLoggedIn = true; vm.ClassifyButtonText = "Admin Off"; vm.ReClassifyButtonText = "ReClassify On"; vm.QuickReClassifyButtonText = "Quick reclassify On"; vm.BatchButtonText = "Batch On"; BatchBCS.Visibility = Visibility.Visible; QuickReClassify.Visibility = Visibility.Visible; Classify.Visibility = Visibility.Visible; if (ifKit == null) ifKit = new Phidgets.InterfaceKit(); vm.bControllerOn = false; logger.Info("BCS start"); ReClassify.Visibility = Visibility.Visible; SetFocusBarcode(); } }
/// <summary> /// /// </summary> /// <param name="ifKit"></param> public PhidgetStarterKitModule(InterfaceKit ifKit) : base(ifKit) { this.Ratiometric = ifKit.ratiometric; this.DigitalInputCount = ifKit.inputs.Count; this.DigitalInput = new bool[this.DigitalInputCount]; for (int i = 0; i< this.DigitalInputCount; i++) { this.DigitalInput[i] = ifKit.inputs[i]; } this.DigitalOutputCount = ifKit.outputs.Count; this.DigitalOutput = new bool[this.DigitalOutputCount]; for (int i = 0; i < this.DigitalOutputCount; i++) { this.DigitalOutput[i] = ifKit.outputs[i]; } this.AnalogInputCount = ifKit.sensors.Count; this.AnalogInput = new decimal[this.AnalogInputCount]; for (int i = 0; i < this.AnalogInputCount; i++) { this.AnalogInput[i] = ifKit.sensors[i].Value; } }
public override void OnLoad() { ifKit = PhidgetManager.Get <InterfaceKit>(throwIfNotAttached: false); ifKit.Attach += ifKit_Attach; ifKit.Detach += ifKit_Detach; PopulateOutputs(); CheckCanSave(); OutputBox.SelectedIndex = Index; ControlBox.SelectedIndex = 0; switch (OutputType) { case DigitalOutputType.Toggle: ControlBox.SelectedIndex = 0; break; case DigitalOutputType.On: ControlBox.SelectedIndex = 1; break; case DigitalOutputType.Off: ControlBox.SelectedIndex = 2; break; } }
// Use this for initialization void Start() { ifKit = new InterfaceKit(); ifKit.open(); ifKit.waitForAttachment(1000); PhidgetsValue = new int[8]; }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { vm = new BCSandGSSVM(true); this.Title = "On the Spot BCS"; label1.Visibility = Visibility.Visible; led1.Visibility = Visibility.Visible; vm.bControllerOn = false; logger.Info("BCS start"); PhigTimer = new DispatcherTimer(); PhigTimer.Interval = TimeSpan.FromSeconds(5); PhigTimer.Tick += new EventHandler(timer_Tick); PhigTimer.Start(); batchTimer.Interval = TimeSpan.FromSeconds(30); batchTimer.Tick += BatchTimer_Tick; ifKit = new InterfaceKit(); //Hook the basica event handlers ifKit.Attach += new AttachEventHandler(PhidgitController_Attach); oldcursor = this.Cursor; this.Cursor = Cursors.Wait; //Open the object for device connections ifKit.open(); DataContext = vm; }
//When the application is terminating, close the Phidget. private void Form1_FormClosed(object sender, FormClosedEventArgs e) { lcd.rows[0].DisplayString = ""; lcd.rows[1].DisplayString = ""; lcd.Attach -= new AttachEventHandler(lcd_Attach); lcd.Detach -= new DetachEventHandler(lcd_Detach); lcd.Error -= new ErrorEventHandler(lcd_Error); ifk.Attach -= new AttachEventHandler(ifk_Attach); ifk.Detach -= new DetachEventHandler(ifk_Detach); ifk.Error -= new ErrorEventHandler(ifk_Error); ifk.InputChange -= new InputChangeEventHandler(ifk_InputChange); ifk.OutputChange -= new OutputChangeEventHandler(ifk_OutputChange); ifk.SensorChange -= new SensorChangeEventHandler(ifk_SensorChange); //run any events in the message queue - otherwise close will hang if there are any outstanding events Application.DoEvents(); lcd.close(); ifk.close(); lcd = null; ifk = null; }
//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) { } }
public void Close() { LinearKit.close(); InterfaceKit.close(); Linear2Kit.close(); RotaryKit.close(); PhidgetsManager.close(); }
// Use this for initialization void Start() { if (this.isOpenPhidget) { this.PhidgetKit = new InterfaceKit(); this.PhidgetKit.open(); this.PhidgetKit.waitForAttachment(1000); } }
private void MainWindow_FormClosing(object sender, EventArgs e) { kit.Attach -= new AttachEventHandler(kit_Attach); kit.Detach -= new DetachEventHandler(kit_Detach); kit.SensorChange -= new SensorChangeEventHandler(kit_SensorChange); Application.DoEvents(); kit.close(); kit = null; }
//Initialises the IF kit and waits for sensor change private PhidgetInterfaceKit() { interfaceKit = new InterfaceKit(); interfaceKit.SensorChange += onSensorChange; interfaceKit.open(); interfaceKit.waitForAttachment(1000); }
public void obtenerTemperatura() { InterfaceKit IFK = new InterfaceKit(); IFK.open(); IFK.waitForAttachment(); int sensorvalue = IFK.sensors[0].Value; ctemp = Math.Round(((sensorvalue * 0.22222) - 61.11), 1); IFK.close(); }
public Controller() { _interfaceKit = new InterfaceKit(); _interfaceKit.Attach += ifKit_Attach; _interfaceKit.Detach += ifKit_Detach; _interfaceKit.Error += ifKit_Error; _interfaceKit.open(); }
//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; }
public static void Initialize() { if(interfaceKit == null) { interfaceKit = new InterfaceKit(); interfaceKit.Attach += new AttachEventHandler(InterfaceKitAttach); interfaceKit.Detach += new DetachEventHandler(InterfaceKitDetach); interfaceKit.Error += new ErrorEventHandler(InterfaceKitError); interfaceKit.SensorChange += new SensorChangeEventHandler(InterfaceKitSensorChange); interfaceKit.open(); interfaceKit.waitForAttachment(); } }
//Ifkit detach event handler //Here we display the attached status, which will be false as the device is disconnected. //We will also clear the display fields and hide the inputs and outputs. void ifKit_Detach(object sender, DetachEventArgs e) { //f.ifKit_Detach(sender, e); InterfaceKit ifKit = (InterfaceKit)sender; attachedTxt.Text = ifKit.Attached.ToString(); nameTxt.Text = ""; serialTxt.Text = ""; versionTxt.Text = ""; digiInNumTxt.Text = ""; digiOutNumTxt.Text = ""; sensorInNumTxt.Text = ""; int i; for (i = 0; i < 16; i++) { digiInArray[i].Visible = false; digiInArray[i].Checked = false; ((Label)digitalInputsGroupBox.Controls["digitalInputLabel" + i.ToString()]).Visible = false; } for (i = 0; i < 16; i++) { digiOutArray[i].Enabled = false; digiOutArray[i].Visible = false; digiOutDispArray[i].Visible = false; ((Label)digitalOutputsGroupBox.Controls["digitalOutputLabel" + i.ToString()]).Visible = false; digiOutDispArray[i].Checked = false; } for (i = 0; i < 8; i++) { sensorInArray[i].Visible = false; sensorInArray[i].Text = ""; ((Label)analogInputsGroupBox.Controls["analogInputLabel" + i.ToString()]).Visible = false; } label8.Visible = false; sensitivityTxt.Visible = false; inputTrk.Visible = false; inputTrk.Value = 0; inputTrk.Enabled = false; sensitivityTxt.Text = ""; ratioChk.Enabled = false; ratioChk.Checked = false; ratioChk.Visible = false; sensorsButton.Visible = false; if ((advSensorForm != null) && (advSensorForm.IsDisposed == false)) { advSensorForm.Close(); } }
public void StartPhidget() { try { ikit = new InterfaceKit(); ikit.Attach += (sender, e) => { Console.WriteLine("Analog {0} attached!", e.Device.SerialNumber.ToString()); }; ikit.Detach += (sender, e) => { Console.WriteLine("Analog {0} dettached!", e.Device.SerialNumber.ToString()); }; ikit.Error += (sender, e) => { Console.WriteLine("Error {0}!", e.Description); }; ikit.SensorChange += (sender, e) => { if (sensors == null) return; foreach(Sensor s in sensors) { if (s.ID == e.Index.ToString()) { s.RawValue = e.Value; } if (s.ID == e.Index.ToString() && e.Value < s.Minim) { s.Activated = true; } else { s.Activated = false; } } }; ikit.open(); } catch(PhidgetException ex) { Console.WriteLine(ex.Message); } }
void m_PhidgetManager_Attach(object sender, AttachEventArgs e) { DeviceInfo Infos = new DeviceInfo(); Infos.Name = e.Device.Name; Infos.SerialNumber = e.Device.SerialNumber; Infos.Version = e.Device.Version; InterfaceKit m_kit = new InterfaceKit(); Infos.Device = m_kit; m_Devices.Add(Infos); }
//Initialize the device public void Form1_Load(object sender, EventArgs e) { //opens and loads form3 f.Show(); //initialize form1 controls makeDigiInArray(); makeDigiOutArray(); makeSensorInArray(); label8.Visible = false; inputTrk.Value = 0; inputTrk.Enabled = false; inputTrk.Visible = false; sensitivityTxt.Text = ""; sensitivityTxt.Visible = false; ratioChk.Enabled = false; ratioChk.Checked = false; ratioChk.Visible = false; sensorsButton.Visible = false; //initialize Phidgets interface kit try { //create a new InterfaceKit object ifKit = new InterfaceKit(); //register listeners for InterfaceKit events //register f1 methods as event handlers ifKit.Attach += new AttachEventHandler(ifKit_Attach); ifKit.Detach += new DetachEventHandler(ifKit_Detach); ifKit.Error += new ErrorEventHandler(ifKit_Error); ifKit.InputChange += new InputChangeEventHandler(ifKit_InputChange); ifKit.OutputChange += new OutputChangeEventHandler(ifKit_OutputChange); ifKit.SensorChange += new SensorChangeEventHandler(ifKit_SensorChange); //register f3 methods as event handlers ifKit.Attach += new AttachEventHandler(f.ifKit_Attach); ifKit.Detach += new DetachEventHandler(f.ifKit_Detach); ifKit.SensorChange += new SensorChangeEventHandler(f.ifKit_SensorChange); //Open the Phidget using the command line arguments openCmdLine(ifKit); } catch (PhidgetException ex) { MessageBox.Show(ex.ToString()); } }
//initialize the device private void Form1_Load(object sender, EventArgs e) { makeDigiInArray(); makeDigiOutArray(); makeSensorInArray(); label8.Visible = false; inputTrk.Value = 0; inputTrk.Enabled = false; inputTrk.Visible = false; sensitivityTxt.Text = ""; sensitivityTxt.Visible = false; ratioChk.Enabled = false; ratioChk.Checked = false; try { ifKit = new InterfaceKit(); ifKit.Attach += new AttachEventHandler(ifKit_Attach); //ifKit.Detach += new DetachEventHandler(ifKit_Detach); ifKit.Detach += new DetachEventHandler(ifKit_Detach); ifKit.Error += new ErrorEventHandler(ifKit_Error); ifKit.InputChange += new InputChangeEventHandler(ifKit_InputChange); ifKit.OutputChange += new OutputChangeEventHandler(ifKit_OutputChange); ifKit.SensorChange += new SensorChangeEventHandler(ifKit_SensorChange); //This assumes that if there is a command line argument, it is a serial number //and we try to open that specific device. Otherwise, open any device. String[] args = Environment.GetCommandLineArgs(); if (args.Length > 2 && args[2].Equals("remote")) { ifKit.open(int.Parse(args[1]), null); } else if (args.Length > 1) { ifKit.open(int.Parse(args[1])); } else { ifKit.open(); } } catch (PhidgetException ex) { MessageBox.Show(ex.ToString()); } }
static void _phidgetsManager_Attach(object sender, AttachEventArgs e) { if (e.Device.Type == "PhidgetInterfaceKit") { // if we haven't opened it already, do so now if (!IFKits.ContainsKey(e.Device.SerialNumber)) { InterfaceKit ik = new InterfaceKit(); ik.Attach += new AttachEventHandler(ik_Attach); ik.open(e.Device.SerialNumber); IFKits[e.Device.SerialNumber] = ik; } } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { ifk.SensorChange -= new SensorChangeEventHandler(ifk_SensorChange); ifk.OutputChange -= new OutputChangeEventHandler(ifk_OutputChange); ifk.InputChange -= new InputChangeEventHandler(ifk_InputChange); ifk.Error -= new ErrorEventHandler(ifk_Error); ifk.Detach -= new DetachEventHandler(ifk_Detach); ifk.Attach -= new AttachEventHandler(ifk_Attach); DoEvents(); ifk.close(); ifk = null; }
private void Form1_Load(object sender, EventArgs e) { //build the arrays makeDigiInArray(); makeDigiOutArray(); makeSensorInArray(); //initialize some of the form elements basedo n nothing being attached yet label9.Visible = false; inputTrk.Value = 0; inputTrk.Enabled = false; inputTrk.Visible = false; sensitivityTxt.Text = ""; sensitivityTxt.Visible = false; ratioChk.Enabled = false; ratioChk.Checked = false; contrastTrkBr.Enabled = false; //initiallize the TextLCD object lcd = new TextLCD(); //hook the event handlers lcd.Attach += new AttachEventHandler(lcd_Attach); lcd.Detach += new DetachEventHandler(lcd_Detach); lcd.Error += new ErrorEventHandler(lcd_Error); //initialize the InterfaceKit object ifk = new InterfaceKit(); //hook the event handlers ifk.Attach += new AttachEventHandler(ifk_Attach); ifk.Detach += new DetachEventHandler(ifk_Detach); ifk.Error += new ErrorEventHandler(ifk_Error); ifk.InputChange += new InputChangeEventHandler(ifk_InputChange); ifk.OutputChange += new OutputChangeEventHandler(ifk_OutputChange); ifk.SensorChange += new SensorChangeEventHandler(ifk_SensorChange); //open the phidgets //Since TextLCDs come with an attached InterfaceKit 8/8/8 open the lcd and the interfacekit //as seperate objects. Here we are assuming the PhidgetTextLCD with 8/8/8 is the only Phidget //attached to your pc. If you have more phidgets or want connect to phidgets on other PC's look for the //other variations of open(). lcd.open(); ifk.open(); }
protected override void OnEnabling(EnablingEventArgs e) { if (!e.WasConfiguring) { try { ifKit = PhidgetManager.Get <InterfaceKit>(); } catch (InvalidOperationException) { ErrorLog.AddError(ErrorType.Failure, "The interface kit is not attached"); e.Cancel = true; return; } } }
private void Form1_Load(object sender, EventArgs e) { random = new Random(); ifKit = new InterfaceKit(); //Hook the basica event handlers ifKit.Attach += new AttachEventHandler(ifKit_Attach); ifKit.Detach += new DetachEventHandler(ifKit_Detach); //Hook the phidget spcific event handlers ifKit.SensorChange += new SensorChangeEventHandler(ifKit_SensorChange); //Open the object for device connections ifKit.open(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { makeDigiInArrays(); makeDigiOutArrays(); makeSensorInArrays(); ifk = new InterfaceKit(); ifk.Attach += new AttachEventHandler(ifk_Attach); ifk.Detach += new DetachEventHandler(ifk_Detach); ifk.Error += new ErrorEventHandler(ifk_Error); ifk.InputChange += new InputChangeEventHandler(ifk_InputChange); ifk.OutputChange += new OutputChangeEventHandler(ifk_OutputChange); ifk.SensorChange += new SensorChangeEventHandler(ifk_SensorChange); ifk.open(); }
//Ifkit detach event handler //Here we display the attached status, which will be false as the device is disconnected. //We will also clear the display fields and hide the inputs and outputs. void ifKit_Detach(object sender, DetachEventArgs e) { InterfaceKit ifKit = (InterfaceKit)sender; m_phidet21Info.attachedTxt = ifKit.Attached.ToString(); m_phidet21Info.nameTxt = ""; m_phidet21Info.serialTxt = ""; m_phidet21Info.versionTxt = ""; m_phidet21Info.digiInNumTxt = ""; m_phidet21Info.digiOutNumTxt = ""; m_phidet21Info.sensorInNumTxt = ""; m_attached = false; if (m_detachEvent != null) { m_eventCode[PhidgetCallbackCode.DETACH]++; m_detachEvent.Set(); } }
static void Main(string[] args) { try { //Initialize the InterfaceKit object ifKit = new InterfaceKit(); //Hook the basica event handlers ifKit.Attach += new AttachEventHandler(ifKit_Attach); ifKit.Detach += new DetachEventHandler(ifKit_Detach); ifKit.Error += new ErrorEventHandler(ifKit_Error); //Hook the phidget spcific event handlers ifKit.InputChange += new InputChangeEventHandler(ifKit_InputChange); ifKit.OutputChange += new OutputChangeEventHandler(ifKit_OutputChange); ifKit.SensorChange += new SensorChangeEventHandler(ifKit_SensorChange); //Open the object for device connections ifKit.open(); //Wait for an InterfaceKit phidget to be attached Console.WriteLine("Waiting for InterfaceKit to be attached..."); ifKit.waitForAttachment(); //Wait for user input so that we can wait and watch for some event data //from the phidget Console.WriteLine("Press any key to end..."); Console.Read(); //User input was rad so we'll terminate the program, so close the object ifKit.close(); //set the object to null to get it out of memory ifKit = null; //If no expcetions where thrown at this point it is safe to terminate //the program Console.WriteLine("ok"); } catch (PhidgetException ex) { Console.WriteLine(ex.Description); } }
public void setup_Phidget() { ifKit = new InterfaceKit(); try { ifKit.Attach += new AttachEventHandler(ifKit_Attach); ifKit.Detach += new DetachEventHandler(ifKit_Detach); ifKit.Error += new ErrorEventHandler(ifKit_Error); ifKit.SensorChange += new SensorChangeEventHandler(ifKit_SensorChange); } catch (PhidgetException ex) { Debug.Log("Error on function call: " + ex.Code + " - " + ex.Description + "!"); } // No exception thrown on open ifKit.open(); }
private void Form1_Load(object sender, EventArgs e) { // create the InterfaceKit object and open access to the board _interfaceKit = new InterfaceKit(); _interfaceKit.open(); _interfaceKit.waitForAttachment(1000); // create the Wiimote object _wiimote = new Wiimote(); // setup an event handler to be notified when the Wiimote sends a packet of data _wiimote.WiimoteChanged += Wiimote_WiimoteChanged; // connect the Wiimote _wiimote.Connect(); // set the report type to Buttons and Accelerometer data only _wiimote.SetReportType(InputReport.ButtonsAccel, true); }
//applies RFID methods -- from Interface-FULL lab private void PandyApp_Load(object sender, EventArgs e) { rfid = new RFID(); rfid.Attach += new AttachEventHandler(rfid_Attach); rfid.Detach += new DetachEventHandler(rfid_Detach); rfid.Tag += new TagEventHandler(rfid_Tag); rfid.TagLost += new TagEventHandler(rfid_TagLost); rfid.open(); ifKit = new InterfaceKit(); ifKit.Attach += new AttachEventHandler(ifKit_Attach); ifKit.Detach += new DetachEventHandler(ifKit_Detach); ifKit.SensorChange += new SensorChangeEventHandler(ifKit_SensorChange); openCmdLine(ifKit); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { IfKit = PhidgetManager.Get <InterfaceKit>(false); IfKit.Attach += IfKit_Attach; if (InterfaceKitType == InterfaceKitType.Input) { IfKit.InputChange += InputChange; } else if (InterfaceKitType == InterfaceKitType.Sensor) { IfKit.SensorChange += SensorChange; } if (IfKit.Attached) { SetUpSensorBox(); } }
//Servo servo; //Timer updateTimer; public PhidgetController(PolhemusController inPolhemusController) { polhemusController = inPolhemusController; if (Program.usePens) { penKit = new InterfaceKit(); setUpInterfaceKit(penKit); } Analog analog1 = new Analog(); setUpAnalog(analog1); /* for (int i = 0; i < analog1.outputs.Count; i++) { analog1.outputs[i].Voltage = analog1.outputs[i].VoltageMax; analog1.outputs[i].Enabled = true; }*/ }
//detach event handler.... we will display the device attach status and clear all the other fields void ifk_Detach(object sender, DetachEventArgs e) { InterfaceKit detached = (InterfaceKit)sender; IFKattachedTXT.Text = detached.Attached.ToString(); IFKnameTXT.Text = ""; IFKserialTXT.Text = ""; IFKversionTXT.Text = ""; digiInNumTxt.Text = ""; digiOutNumTxt.Text = ""; sensorInNumTxt.Text = ""; int i; for (i = 0; i < 16; i++) { digiInArray[i].Visible = false; digiInArray[i].Checked = false; } for (i = 0; i < 16; i++) { digiOutArray[i].Visible = false; digiOutArray[i].Checked = false; digiOutArray[i].Enabled = false; } for (i = 0; i < 8; i++) { sensorInArray[i].Visible = false; sensorInArray[i].Text = ""; } label9.Visible = false; sensitivityTxt.Visible = false; inputTrk.Visible = false; inputTrk.Value = 0; inputTrk.Enabled = false; sensitivityTxt.Text = ""; ratioChk.Enabled = false; ratioChk.Checked = false; }
void ifk_Detach(object sender, DetachEventArgs e) { this.Dispatcher.Invoke(new Action(delegate() { InterfaceKit detached = (InterfaceKit)sender; attachedLbl.Content = detached.Attached.ToString(); nameLbl.Content = ""; serialNoLbl.Content = ""; versionLbl.Content = ""; digitalInputCountLbl.Content = ""; digitalOutputCountLbl.Content = ""; sensorCountLbl.Content = ""; for (int i = 0; i < 16; i++) { digiInChkArray[i].Visibility = System.Windows.Visibility.Hidden; digiInLblArray[i].Visibility = System.Windows.Visibility.Hidden; } for (int i = 0; i < 16; i++) { digiOutDispChkArray[i].Visibility = System.Windows.Visibility.Hidden; digiOutChkArray[i].Visibility = System.Windows.Visibility.Hidden; digiOutLblArray[i].Visibility = System.Windows.Visibility.Hidden; } for (int i = 0; i < 8; i++) { sensorInArray[i].Visibility = System.Windows.Visibility.Hidden; sensorInLblArray[i].Visibility = System.Windows.Visibility.Hidden; } ratiometricChk.Visibility = System.Windows.Visibility.Hidden; sensitivityLbl.Visibility = System.Windows.Visibility.Hidden; sensitivitySlider.Visibility = System.Windows.Visibility.Hidden; sensitivityTxt.Visibility = System.Windows.Visibility.Hidden; })); }
public override void OnLoad() { IfKit = PhidgetManager.Get <InterfaceKit>(throwIfNotAttached: false); SensorDataBox.InterfaceKitType = type; SensorDataBox.Index = Index; SensorDataBox.Convertor = Convertor; Sensor.OnLoad(); Sensor.OnRevalidate += Revalidate; sensorControl.Content = Sensor; IfKit.Attach += ifKit_Attach; IfKit.Detach += IfKit_Detach; Revalidate(); shouldCheckValidity = true; CheckCanSave(); }
//Initialize the device private void Form1_Load(object sender, EventArgs e) { makeDigiInArray(); makeDigiOutArray(); makeSensorInArray(); label8.Visible = false; inputTrk.Value = 0; inputTrk.Enabled = false; inputTrk.Visible = false; sensitivityTxt.Text = ""; sensitivityTxt.Visible = false; ratioChk.Enabled = false; ratioChk.Checked = false; ratioChk.Visible = false; sensorsButton.Visible = false; try { ifKit = new InterfaceKit(); ifKit.Attach += new AttachEventHandler(ifKit_Attach); ifKit.Detach += new DetachEventHandler(ifKit_Detach); ifKit.Error += new ErrorEventHandler(ifKit_Error); ifKit.InputChange += new InputChangeEventHandler(ifKit_InputChange); ifKit.OutputChange += new OutputChangeEventHandler(ifKit_OutputChange); ifKit.SensorChange += new SensorChangeEventHandler(ifKit_SensorChange); //Open the Phidget using the command line arguments openCmdLine(ifKit); } catch (PhidgetException ex) { MessageBox.Show(ex.ToString()); } }
private void Form1_Load(object sender, EventArgs e) { try { GroupBox1.Text = "Weather station: " + Serialnumber; ifKit = new InterfaceKit(); //Hook the basica event handlers ifKit.Attach += new AttachEventHandler(ifKit_Attach); ifKit.Detach += new DetachEventHandler(ifKit_Detach); ifKit.Error += new ErrorEventHandler(ifKit_Error); //Hook the phidget spcific event handlers ifKit.InputChange += new InputChangeEventHandler(ifKit_InputChange); //ifKit.OutputChange += new OutputChangeEventHandler(ifKit_OutputChange); ifKit.SensorChange += new SensorChangeEventHandler(ifKit_SensorChange); ifKit.open(Serialnumber); //PictureBox1.Image = Resources.EngineHeedOn; UpdateCard(); } catch (Exception ex) { PictureBox1.Image = Resources.EngineHeedOFF; MessageBox.Show(ex.Message); //Errors err = new Errors(); //err.Card = Serialnumber; //err.Date = DateTime.Now.ToString(); //err.From = System.Environment.MachineName; //err.Message = ex.Message; //err.Method = "Form1_Load"; //objErr.AddErrors(err); } }
/// <summary> /// Constructs a new interface handler. /// </summary> public LEDHandler(InterfaceKit interfaceKit) { this.interfaceKit = interfaceKit; }
private void closeInterfaceKitBoard() { if (configuration.interfaceKitBoardAttached) { _intfKit.Attach -= new AttachEventHandler(intfKit_Attach); _intfKit.Detach -= new DetachEventHandler(intfKit_Detach); _intfKit.Error -= new ErrorEventHandler(intfKit_Error); _intfKit.SensorChange -= new SensorChangeEventHandler(intfKit_SensorChange); _intfKit.close(); _intfKit = null; Helper.Logger("HaptiQ_API.HaptiQ.close::HaptiQ (" + _id + ") interfaceKit (" + configuration.idInterfaceKit + ") disconnected"); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { makeDigiInArrays(); makeDigiOutArrays(); makeSensorInArrays(); ifk = new InterfaceKit(); ifk.Attach += new AttachEventHandler(ifk_Attach); ifk.Detach += new DetachEventHandler(ifk_Detach); ifk.Error += new ErrorEventHandler(ifk_Error); ifk.InputChange += new InputChangeEventHandler(ifk_InputChange); ifk.OutputChange += new OutputChangeEventHandler(ifk_OutputChange); ifk.SensorChange += new SensorChangeEventHandler(ifk_SensorChange); ifk.open(); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { ifk.SensorChange -= new SensorChangeEventHandler(ifk_SensorChange); ifk.OutputChange -= new OutputChangeEventHandler(ifk_OutputChange); ifk.InputChange -= new InputChangeEventHandler(ifk_InputChange); ifk.Error -= new ErrorEventHandler(ifk_Error); ifk.Detach -= new DetachEventHandler(ifk_Detach); ifk.Attach -= new AttachEventHandler(ifk_Attach); DoEvents(); ifk.close(); ifk = null; }
//initialize the device private void Form1_Load(object sender, EventArgs e) { makeDigiInArray(); makeDigiOutArray(); makeSensorInArray(); label8.Visible = false; inputTrk.Value = 0; inputTrk.Enabled = false; inputTrk.Visible = false; sensitivityTxt.Text = ""; sensitivityTxt.Visible = false; ratioChk.Enabled = false; ratioChk.Checked = false; try { ifKit = new InterfaceKit(); ifKit.Attach += new AttachEventHandler(ifKit_Attach); //ifKit.Detach += new DetachEventHandler(ifKit_Detach); ifKit.Detach += new DetachEventHandler(ifKit_Detach); ifKit.Error += new ErrorEventHandler(ifKit_Error); ifKit.InputChange += new InputChangeEventHandler(ifKit_InputChange); ifKit.OutputChange += new OutputChangeEventHandler(ifKit_OutputChange); ifKit.SensorChange += new SensorChangeEventHandler(ifKit_SensorChange); //This assumes that if there is a command line argument, it is a serial number //and we try to open that specific device. Otherwise, open any device. String[] args = Environment.GetCommandLineArgs(); if (args.Length > 2 && args[2].Equals("remote")) ifKit.open(int.Parse(args[1]), null); else if (args.Length > 1) ifKit.open(int.Parse(args[1])); else ifKit.open(); } catch (PhidgetException ex) { MessageBox.Show(ex.ToString()); } }
void setUpInterfaceKit(InterfaceKit ifKit) { //Hook the basica event handlers ifKit.Attach += new AttachEventHandler(ifKit_Attach); ifKit.Detach += new DetachEventHandler(ifKit_Detach); ifKit.Error += new ErrorEventHandler(ifKit_Error); //Hook the phidget spcific event handlers ifKit.InputChange += new InputChangeEventHandler(ifKit_InputChange); ifKit.OutputChange += new OutputChangeEventHandler(ifKit_OutputChange); ifKit.SensorChange += new SensorChangeEventHandler(ifKit_SensorChange); //Open the object for device connections ifKit.open(); //Wait for an InterfaceKit phidget to be attached Console.WriteLine("Waiting for InterfaceKit to be attached..."); ifKit.waitForAttachment(); }
/// <summary> /// Waits for input from keyboard to exit. /// </summary> private void keepAlive() { Console.WriteLine("feed: can goes bananas."); Console.WriteLine("full: toggle 'full' status."); Console.WriteLine("exit: exit program."); String input = Console.ReadLine(); while (!input.Equals("exit")) { if (input.Equals("feed")) { feedMe(); } else if (input.Equals("full")) { toggleFull(); } input = Console.ReadLine(); } Thread.Sleep(SLEEP_TIME_MS); closeCanOnExit(); Thread.Sleep(SLEEP_TIME_MS); servo.close(); ifKit.close(); ifKit = null; servo = null; }
public static void Close() { interfaceKit.close(); interfaceKit = null; }
private void initialiseInterfaceKitBoard() { // Create an InterfaceKit object if attached and configured for this HaptiQ if (configuration.interfaceKitBoardAttached) { _intfKit = new InterfaceKit(); _intfKit.Attach += new AttachEventHandler(intfKit_Attach); _intfKit.Detach += new DetachEventHandler(intfKit_Detach); _intfKit.Error += new ErrorEventHandler(intfKit_Error); _intfKit.SensorChange += new SensorChangeEventHandler(intfKit_SensorChange); _intfKit.open(configuration.idInterfaceKit); Helper.Logger("HaptiQ_API.HaptiQ.HaptiQ::Waiting for HaptiQ (" + _id + ") IntfKit (" + configuration.idInterfaceKit + ") to be attached."); _intfKit.waitForAttachment(); Helper.Logger("HaptiQ_API.HaptiQ.HaptiQ::HaptiQ (" + _id + ") IntfKit(" + configuration.idInterfaceKit + ") Connected"); } }
private void Form1_Load(object sender, EventArgs e) { //build the arrays makeDigiInArray(); makeDigiOutArray(); makeSensorInArray(); //initialize some of the form elements basedo n nothing being attached yet label9.Visible = false; inputTrk.Value = 0; inputTrk.Enabled = false; inputTrk.Visible = false; sensitivityTxt.Text = ""; sensitivityTxt.Visible = false; ratioChk.Enabled = false; ratioChk.Checked = false; contrastTrkBr.Enabled = false; //initiallize the TextLCD object lcd = new TextLCD(); //hook the event handlers lcd.Attach += new AttachEventHandler(lcd_Attach); lcd.Detach += new DetachEventHandler(lcd_Detach); lcd.Error += new ErrorEventHandler(lcd_Error); //initialize the InterfaceKit object ifk = new InterfaceKit(); //hook the event handlers ifk.Attach += new AttachEventHandler(ifk_Attach); ifk.Detach += new DetachEventHandler(ifk_Detach); ifk.Error += new ErrorEventHandler(ifk_Error); ifk.InputChange += new InputChangeEventHandler(ifk_InputChange); ifk.OutputChange += new OutputChangeEventHandler(ifk_OutputChange); ifk.SensorChange += new SensorChangeEventHandler(ifk_SensorChange); //open the phidgets //Since TextLCDs come with an attached InterfaceKit 8/8/8 open the lcd and the interfacekit //as seperate objects. Here we are assuming the PhidgetTextLCD with 8/8/8 is the only Phidget //attached to your pc. If you have more phidgets or want connect to phidgets on other PC's look for the //other variations of open(). lcd.open(); ifk.open(); }
public void ifKitClosePhidgetHardware() { _ifKit.Attach -= new AttachEventHandler(ifKit_Attach); _ifKit.Detach -= new DetachEventHandler(ifKit_Detach); _ifKit.InputChange -= new InputChangeEventHandler(ifKit_InputChange); _ifKit.OutputChange -= new OutputChangeEventHandler(ifKit_OutputChange); _ifKit.SensorChange -= new SensorChangeEventHandler(ifKit_SensorChange); _ifKit.Error -= new Phidgets.Events.ErrorEventHandler(ifKit_Error); //User input was rad so we'll terminate the program, so close the object _ifKit.close(); //set the object to null to get it out of memory _ifKit = null; }
public void ifKitInitPhidgetHardware() { try { //Initialize the InterfaceKit object _ifKit = new InterfaceKit(); //Hook the basica event handlers _ifKit.Attach += new AttachEventHandler(ifKit_Attach); _ifKit.Detach += new DetachEventHandler(ifKit_Detach); _ifKit.Error += new Phidgets.Events.ErrorEventHandler(ifKit_Error); //Hook the phidget spcific event handlers _ifKit.InputChange += new InputChangeEventHandler(ifKit_InputChange); _ifKit.OutputChange += new OutputChangeEventHandler(ifKit_OutputChange); _ifKit.SensorChange += new SensorChangeEventHandler(ifKit_SensorChange); //Open the object for device connections _ifKit.open(); //Wait for an InterfaceKit phidget to be attached Console.WriteLine("Waiting for InterfaceKit to be attached..."); _ifKit.waitForAttachment(); } catch (PhidgetException ex) { Console.WriteLine(ex.Description); } }
//Initialize the device private void Form1_Load(object sender, EventArgs e) { makeDigiInArray(); makeDigiOutArray(); makeSensorInArray(); label8.Visible = false; label9.Visible = false; inputTrk.Value = 0; inputTrk.Enabled = false; inputTrk.Visible = false; sensitivityTxt.Text = ""; sensitivityTxt.Visible = false; ratioChk.Enabled = false; ratioChk.Checked = false; ratioChk.Visible = false; sensorsButton.Visible = false; //Phidget.enableLogging(Phidget.LogLevel.PHIDGET_LOG_VERBOSE, "C:\\biglog.log"); try { ifKit = new InterfaceKit(); ifKit.Attach += new AttachEventHandler(ifKit_Attach); ifKit.Detach += new DetachEventHandler(ifKit_Detach); ifKit.Error += new ErrorEventHandler(ifKit_Error); ifKit.InputChange += new InputChangeEventHandler(ifKit_InputChange); ifKit.OutputChange += new OutputChangeEventHandler(ifKit_OutputChange); ifKit.SensorChange += new SensorChangeEventHandler(ifKit_SensorChange); //Open the Phidget using the command line arguments openCmdLine(ifKit); } catch (PhidgetException ex) { MessageBox.Show(ex.ToString()); } }
private void InterfaceKitsComboBox_SelectedValueChanged(Object sender, EventArgs e) { if ((int)InterfaceKitsComboBox.SelectedItem != 0) { if (_currentInterfaceKitBoard == null) { _currentInterfaceKitBoard = new InterfaceKit(); } else { _currentInterfaceKitBoard.SensorChange -= new Phidgets.Events.SensorChangeEventHandler(currentInterfaceKitBoard_SensorChange); _currentInterfaceKitBoard.close(); } _currentInterfaceKitBoard.SensorChange += new Phidgets.Events.SensorChangeEventHandler(currentInterfaceKitBoard_SensorChange); _currentInterfaceKitBoard.open((int)InterfaceKitsComboBox.SelectedItem); _currentInterfaceKitBoard.waitForAttachment(); } else if (_currentInterfaceKitBoard != null) { _currentInterfaceKitBoard.SensorChange -= new Phidgets.Events.SensorChangeEventHandler(currentInterfaceKitBoard_SensorChange); _currentInterfaceKitBoard.close(); } }
void onDisable() { Debug.Log("Phidget Simple Playground (plug and unplug devices)"); Debug.Log("Press Enter to end anytime"); Debug.Log("Closing...."); try { ifKit.Attach -= new AttachEventHandler(ifKit_Attach); ifKit.Detach -= new DetachEventHandler(ifKit_Detach); ifKit.Error -= new ErrorEventHandler(ifKit_Error); ifKit.SensorChange -= new SensorChangeEventHandler(ifKit_SensorChange); ifKit.close(); } catch (PhidgetException ex) { Debug.Log("Error on function call: " + ex.Code + " - " + ex.Description + "!"); } ifKit = null; }
static void Main(string[] args) { try { //Initialize the InterfaceKit object ifKit = new InterfaceKit(); //Hook the basica event handlers ifKit.Attach += new AttachEventHandler(ifKit_Attach); ifKit.Detach += new DetachEventHandler(ifKit_Detach); ifKit.Error += new ErrorEventHandler(ifKit_Error); //Hook the phidget spcific event handlers ifKit.InputChange += new InputChangeEventHandler(ifKit_InputChange); ifKit.OutputChange += new OutputChangeEventHandler(ifKit_OutputChange); ifKit.SensorChange += new SensorChangeEventHandler(ifKit_SensorChange); //Open the object for device connections ifKit.open(); //Wait for an InterfaceKit phidget to be attached Console.WriteLine("Waiting for InterfaceKit to be attached..."); ifKit.waitForAttachment(); //Wait for user input so that we can wait and watch for some event data //from the phidget Console.WriteLine("Press any key to end..."); Console.Read(); //User input was rad so we'll terminate the program, so close the object ifKit.close(); //set the object to null to get it out of memory ifKit = null; //If no expcetions where thrown at this point it is safe to terminate //the program Console.WriteLine("ok"); } catch (PhidgetException ex) { Console.WriteLine(ex.Description); } }
static void Main(string[] args) { int reponse; double luminosite; double temperature; double temperatureEx; double humidite; int id_profil; int id_reglage; DateTime date_profil; ConnectionSQL cs = new ConnectionSQL(); Reglage reglage; while (true) { reponse = cs.Reponse(); if (reponse == 1) { InterfaceKit ifKit; InterfaceKit ifKitRelay; try { //Initialize the InterfaceKit object ifKit = new InterfaceKit(); ifKitRelay = new InterfaceKit(); //Hook the basica event handlers ifKit.Attach += new AttachEventHandler(ifKit_Attach); ifKit.Detach += new DetachEventHandler(ifKit_Detach); ifKit.Error += new ErrorEventHandler(ifKit_Error); //Hook the phidget spcific event handlers ifKit.InputChange += new InputChangeEventHandler(ifKit_InputChange); ifKit.OutputChange += new OutputChangeEventHandler(ifKit_OutputChange); ifKit.SensorChange += new SensorChangeEventHandler(ifKit_SensorChange); //Open the object for device connections ifKit.open(174971); ifKitRelay.open(87522); //Wait for an InterfaceKit phidget to be attached Console.WriteLine("Waiting for InterfaceKit to be attached..."); ifKit.waitForAttachment(); // conversion des valeurs réupérer par les capteurs pour avoir des valeurs justes humidite = Math.Round((((ifKit.sensors[7].Value) * 0.1909) - 40.2), 1); temperature = Math.Round((((ifKit.sensors[6].Value) * 0.22222) - 61.11), 1); temperatureEx = Math.Round((((ifKit.sensors[4].Value) * 0.22222) - 61.11), 1); luminosite = ifKit.sensors[5].Value; Console.WriteLine("humidite :"+humidite); Console.WriteLine("temperature :"+temperature); // on récupère l'id la date du profil actuel et l'id du réglage pour ajouter les valeurs recueillis par les capteurs à la table historique id_profil = cs.Profil_Actuel_Id(); date_profil = cs.Profil_Actuel_Date(); id_reglage = cs.Id_Reglage(id_profil, luminosite, date_profil); cs.AjoutHistorique(DateTime.Now, luminosite, temperature, temperatureEx, humidite, id_profil, id_reglage); reglage = cs.SelectionnerReglage(id_profil, luminosite, DateTime.Now); if (reglage != null) { // on met plusieurs conditions pour savoir quel actionneurs allumer ou éteindre selon le réglage précédamment sélectionner //inversement des true et false if (reglage.Humidite < humidite) { ifKitRelay.outputs[0] = false; ifKitRelay.outputs[1] = true; //allumer ventilateur //allumer vanne d'arrosage } else { ifKitRelay.outputs[0] = true; ifKitRelay.outputs[1] = false; //allumer vanne d'arrosage //allumer ventilateur } if (reglage.TemperatureInterieur < temperature) { ifKitRelay.outputs[0] = false; ifKitRelay.outputs[2] = true; //allumer ventilateur //eteindre chauffage } else { ifKitRelay.outputs[0] = true; ifKitRelay.outputs[2] = false; //allumer chauffage //eteindre ventilateur } if (luminosite <= 20) { ifKitRelay.outputs[3] = false; } else { ifKitRelay.outputs[3] = true; } } //User input was rad so we'll terminate the program, so close the object ifKit.close(); ifKitRelay.close(); //set the object to null to get it out of memory ifKit = null; ifKitRelay = null; } catch (PhidgetException ex) { Console.WriteLine(ex.Description); } } //TIMER de 10s actuellment Thread.Sleep(10000); } }
//When the application is terminating, close the Phidget. private void Form1_FormClosed(object sender, FormClosedEventArgs e) { lcd.rows[0].DisplayString = ""; lcd.rows[1].DisplayString = ""; lcd.Attach -= new AttachEventHandler(lcd_Attach); lcd.Detach -= new DetachEventHandler(lcd_Detach); lcd.Error -= new ErrorEventHandler(lcd_Error); ifk.Attach -= new AttachEventHandler(ifk_Attach); ifk.Detach -= new DetachEventHandler(ifk_Detach); ifk.Error -= new ErrorEventHandler(ifk_Error); ifk.InputChange -= new InputChangeEventHandler(ifk_InputChange); ifk.OutputChange -= new OutputChangeEventHandler(ifk_OutputChange); ifk.SensorChange -= new SensorChangeEventHandler(ifk_SensorChange); //run any events in the message queue - otherwise close will hang if there are any outstanding events Application.DoEvents(); lcd.close(); ifk.close(); lcd = null; ifk = null; }
/// <summary> /// Initialize interface kit /// </summary> private void initInterFaceKit() { // Initialize the InterfaceKit object ifKit = new InterfaceKit(); // Hook the basic event-handlers ifKit.Attach += new AttachEventHandler(ifKit_Attach); ifKit.Detach += new DetachEventHandler(ifKit_Detach); ifKit.Error += new ErrorEventHandler(ifKit_Error); // Hook the InterfaceKit event-handlers ifKit.InputChange += new InputChangeEventHandler(ifKit_InputChange); ifKit.OutputChange += new OutputChangeEventHandler(ifKit_OutputChange); ifKit.SensorChange += new SensorChangeEventHandler(ifKit_SensorChange); // Open the object for device connections ifKit.open(); // Turn on the green status-light on the front side of the iTrash Thread.Sleep(500); ifKit.outputs[LED_GREEN] = true; // Update the trash type light (turn on the correct one) updateTrashLEDs(ifKit.sensors[SENSOR_ROTATION_ID].Value); }