//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()); } }
// 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; }
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(); }
//Initialises the IF kit and waits for sensor change private PhidgetInterfaceKit() { interfaceKit = new InterfaceKit(); interfaceKit.SensorChange += onSensorChange; interfaceKit.open(); interfaceKit.waitForAttachment(1000); }
public Controller() { _interfaceKit = new InterfaceKit(); _interfaceKit.Attach += ifKit_Attach; _interfaceKit.Detach += ifKit_Detach; _interfaceKit.Error += ifKit_Error; _interfaceKit.open(); }
public FiringControllerException TryInitialize() { try { m_RelayBoard.open(); return(null); } catch (PhidgetException e) { return(new FiringControllerException("An error occured opening connection to relay board.", e)); } }
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(); } }
void init() { try{ ifKit1.open(kit1SerialID); ifKit2.open(kit2SerialID); ifKit3.open(kit3SerialID); IsPhidgetConnected = true; }catch (PhidgetException ex) { Debug.Log("Please check connection(s) to the Phidget device! : " + ex); IsPhidgetConnected = false; } }
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 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(); }
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(); }
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); }
public MainWindow() { InitializeComponent(); client = new Client(username, address, port); client.Connected += Client_Connected; client.Error += Client_Error; client.MessageReceived += Client_MessageReceived; interfaceKit.Attach += InterfaceKit_Attach; interfaceKit.open(); rfidReader.Attach += RfidReader_Attach;; rfidReader.open(); servoController.Attach += ServoController_Attach;; servoController.open(); }
// ================ Main Function ==================== private void MainWindow_Load(object sender, EventArgs e) { try { kit.Attach += new AttachEventHandler(kit_Attach); kit.Detach += new DetachEventHandler(kit_Detach); kit.SensorChange += new SensorChangeEventHandler(kit_SensorChange); kit.open("192.168.0.22", 5001); //kit.open("phidgetsbc"); } catch (PhidgetException ex) { MessageBox.Show(ex.Description.ToString()); } foreach (String str in System.IO.Ports.SerialPort.GetPortNames()) { cmbCOM.Items.Add(str); } }
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); } }
static void InitPhidgets() { Console.WriteLine("--- Initializing the program. ---"); Console.WriteLine("- Initializing the InterfaceKit."); Console.WriteLine(); // Initialize the InterfaceKit object, ifKit = new InterfaceKit(); // Hook the phidget specific event handlers. ifKit.Attach += new AttachEventHandler(ifKit_Attach); ifKit.Detach += new DetachEventHandler(ifKit_Detach); ifKit.Error += new ErrorEventHandler(ifKit_Error); // Open the object for device connections. Console.WriteLine("- Opening InterfaceKit on device."); ifKit.open(); // Wait for attachement of the interfaceKit Console.WriteLine("- Waiting for InterfaceKit to be attached"); ifKit.waitForAttachment(); }
private void InitPhidget() { try { //Initialize the InterfaceKit object ifKit = new InterfaceKit(); //Hook the basica event handlers ifKit.Error += new ErrorEventHandler(ifKit_Error); //Open the object for device connections ifKit.open(); //Wait for an InterfaceKit phidget to be attached ifKit.waitForAttachment(3000); //Hook the phidget spcific event handlers ifKit.InputChange += new InputChangeEventHandler(ifKit_InputChange); } 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); } }
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); } }
//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(); }
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"); } }
/// <summary> /// Initializes a new instance of the MainWindow class. /// </summary> public MainWindow() { // initialize the components (controls) of the window this.InitializeComponent(); interfaceKit.Attach += InterfaceKit_Attach; interfaceKit.open(); previousBodyFrameTime = System.DateTime.Now; currentBodyFrameTime = System.DateTime.Now; // one sensor is currently supported this.kinectSensor = KinectSensor.GetDefault(); // open the reader for the depth frames this.depthFrameReader = this.kinectSensor.DepthFrameSource.OpenReader(); // wire handler for frame arrival this.depthFrameReader.FrameArrived += this.Reader_FrameArrived; // get FrameDescription from DepthFrameSource this.depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription; // allocate space to put the pixels being received and converted this.depthPixels = new byte[this.depthFrameDescription.Width * this.depthFrameDescription.Height]; // create the bitmap to display this.depthBitmap = new WriteableBitmap(this.depthFrameDescription.Width, this.depthFrameDescription.Height, 96.0, 96.0, PixelFormats.Gray8, null); // open the reader for the color frames this.colorFrameReader = this.kinectSensor.ColorFrameSource.OpenReader(); // wire handler for frame arrival this.colorFrameReader.FrameArrived += this.Reader_ColorFrameArrived; // create the colorFrameDescription from the ColorFrameSource using Bgra format FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra); // create the bitmap to display this.colorBitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null); //this.depthBitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null); // get the coordinate mapper this.coordinateMapper = this.kinectSensor.CoordinateMapper; // get the color frame details FrameDescription frameDescription = this.kinectSensor.ColorFrameSource.FrameDescription; // set the display specifics this.displayWidth = frameDescription.Width; this.displayHeight = frameDescription.Height; this.displayRect = new Rect(0.0, 0.0, this.displayWidth, this.displayHeight); // open the reader for the body frames this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader(); // a bone defined as a line between two joints this.bones = new List <Tuple <JointType, JointType> >(); // Torso this.bones.Add(new Tuple <JointType, JointType>(JointType.Head, JointType.Neck)); this.bones.Add(new Tuple <JointType, JointType>(JointType.Neck, JointType.SpineShoulder)); this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineShoulder, JointType.SpineMid)); this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineMid, JointType.SpineBase)); this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineShoulder, JointType.ShoulderRight)); this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineShoulder, JointType.ShoulderLeft)); this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineBase, JointType.HipRight)); this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineBase, JointType.HipLeft)); // Right Arm this.bones.Add(new Tuple <JointType, JointType>(JointType.ShoulderRight, JointType.ElbowRight)); this.bones.Add(new Tuple <JointType, JointType>(JointType.ElbowRight, JointType.WristRight)); this.bones.Add(new Tuple <JointType, JointType>(JointType.WristRight, JointType.HandRight)); this.bones.Add(new Tuple <JointType, JointType>(JointType.HandRight, JointType.HandTipRight)); this.bones.Add(new Tuple <JointType, JointType>(JointType.WristRight, JointType.ThumbRight)); // Left Arm this.bones.Add(new Tuple <JointType, JointType>(JointType.ShoulderLeft, JointType.ElbowLeft)); this.bones.Add(new Tuple <JointType, JointType>(JointType.ElbowLeft, JointType.WristLeft)); this.bones.Add(new Tuple <JointType, JointType>(JointType.WristLeft, JointType.HandLeft)); this.bones.Add(new Tuple <JointType, JointType>(JointType.HandLeft, JointType.HandTipLeft)); this.bones.Add(new Tuple <JointType, JointType>(JointType.WristLeft, JointType.ThumbLeft)); // Right Leg this.bones.Add(new Tuple <JointType, JointType>(JointType.HipRight, JointType.KneeRight)); this.bones.Add(new Tuple <JointType, JointType>(JointType.KneeRight, JointType.AnkleRight)); this.bones.Add(new Tuple <JointType, JointType>(JointType.AnkleRight, JointType.FootRight)); // Left Leg this.bones.Add(new Tuple <JointType, JointType>(JointType.HipLeft, JointType.KneeLeft)); this.bones.Add(new Tuple <JointType, JointType>(JointType.KneeLeft, JointType.AnkleLeft)); this.bones.Add(new Tuple <JointType, JointType>(JointType.AnkleLeft, JointType.FootLeft)); // wire handler for body frame arrival this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived; // set the maximum number of bodies that would be tracked by Kinect this.bodyCount = this.kinectSensor.BodyFrameSource.BodyCount; // allocate storage to store body objects this.bodies = new Body[this.bodyCount]; // specify the required face frame results FaceFrameFeatures faceFrameFeatures = FaceFrameFeatures.BoundingBoxInColorSpace | FaceFrameFeatures.PointsInColorSpace | FaceFrameFeatures.RotationOrientation | FaceFrameFeatures.FaceEngagement | FaceFrameFeatures.Glasses | FaceFrameFeatures.Happy | FaceFrameFeatures.LeftEyeClosed | FaceFrameFeatures.RightEyeClosed | FaceFrameFeatures.LookingAway | FaceFrameFeatures.MouthMoved | FaceFrameFeatures.MouthOpen; // create a face frame source + reader to track each face in the FOV this.faceFrameSources = new FaceFrameSource[this.bodyCount]; this.faceFrameReaders = new FaceFrameReader[this.bodyCount]; for (int i = 0; i < this.bodyCount; i++) { // create the face frame source with the required face frame features and an initial tracking Id of 0 this.faceFrameSources[i] = new FaceFrameSource(this.kinectSensor, 0, faceFrameFeatures); // open the corresponding reader this.faceFrameReaders[i] = this.faceFrameSources[i].OpenReader(); } // allocate storage to store face frame results for each face in the FOV this.faceFrameResults = new FaceFrameResult[this.bodyCount]; // populate face result colors - one for each face index this.faceBrush = new List <Brush>() { Brushes.White, Brushes.Orange, Brushes.Green, Brushes.Red, Brushes.LightBlue, Brushes.Yellow }; // set IsAvailableChanged event notifier this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged; // open the sensor this.kinectSensor.Open(); // set the status text //this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText // : Properties.Resources.NoSensorStatusText; // use the window object as the view model in this simple example this.DataContext = this; // setup default music screamUri = new Uri(@screamer_file, UriKind.Relative); screamPlayer = new MediaPlayer(); screamPlayer.Open(screamUri); screamPlayer.Volume = 1; Uri uri = new Uri(static_listen_file, UriKind.Relative); staticListenPlayer = new MediaPlayer(); staticListenPlayer.Open(uri); staticListenPlayer.Play(); staticListenPlayer.MediaEnded += Player_MediaEnded; Uri lookUri = new Uri(static_look_file, UriKind.Relative); staticLookPlayer = new MediaPlayer(); staticLookPlayer.Volume = 0; staticLookPlayer.Open(lookUri); staticLookPlayer.Play(); staticLookPlayer.MediaEnded += StaticLookPlayer_MediaEnded; magicEye.Opacity = 0; client = new Client(username, address, port); client.Connected += Client_Connected; client.Error += Client_Error; client.MessageReceived += Client_MessageReceived; }
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); } }
/// <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); }
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); } }