private List <YMeasure> LoadQT(string hwid) { YQt qt = YQt.FindQt(hwid); YDataSet dataset = qt.get_recordedData(0, 0); int progress = 0; do { progress = dataset.loadMore(); } while(progress < 100); Console.WriteLine("Using DataLogger of " + qt.get_friendlyName()); YMeasure summary = dataset.get_summary(); List <YMeasure> res_bad = dataset.get_measures(); List <YMeasure> res = new List <YMeasure>(); foreach (YMeasure m in res_bad) { if (m.get_startTimeUTC() > 100) { res.Add(m); } } String line = String.Format("from {0} to {1} : min={2:0.00} avg={3:0.00} max={4:0.00}", summary.get_startTimeUTC_asDateTime().ToString(fmt), summary.get_endTimeUTC_asDateTime().ToString(fmt), summary.get_minValue(), summary.get_averageValue(), summary.get_maxValue() ); Console.WriteLine(line); return(res); }
// link the instance to a real YoctoAPI object internal override void linkToHardware(string hwdName) { YQt hwd = YQt.FindQt(hwdName); // first redo base_init to update all _func pointers base_init(hwd, hwdName); // then setup Yocto-API pointers and callbacks init(hwd); }
// Configure the value callbacks on the currently selected device // private void setupDevice() { YAccelerometer accelerometer; YCompass compass; YTilt tilt1, tilt2; YGyro gyro; YQt qt1, qt2, qt3, qt4; if (currentSerialNumber != prevSerialNumber && prevSerialNumber != "") { // Unregister previous device tilt1 = YTilt.FindTilt(prevSerialNumber + ".tilt1"); tilt2 = YTilt.FindTilt(prevSerialNumber + ".tilt2"); compass = YCompass.FindCompass(prevSerialNumber + ".compass"); gyro = YGyro.FindGyro(prevSerialNumber + ".gyro"); compass.registerValueCallback(null); tilt1.registerValueCallback(null); tilt2.registerValueCallback(null); gyro.registerAnglesCallback(null); } if (currentSerialNumber == "") { return; } // Register the newly selected device accelerometer = YAccelerometer.FindAccelerometer(currentSerialNumber + ".accelerometer"); tilt1 = YTilt.FindTilt(currentSerialNumber + ".tilt1"); tilt2 = YTilt.FindTilt(currentSerialNumber + ".tilt2"); compass = YCompass.FindCompass(currentSerialNumber + ".compass"); gyro = YGyro.FindGyro(currentSerialNumber + ".gyro"); qt1 = YQt.FindQt(currentSerialNumber + ".qt1"); qt2 = YQt.FindQt(currentSerialNumber + ".qt2"); qt3 = YQt.FindQt(currentSerialNumber + ".qt3"); qt4 = YQt.FindQt(currentSerialNumber + ".qt4"); compass.registerValueCallback(valueCallback); tilt1.registerValueCallback(valueCallback); tilt2.registerValueCallback(valueCallback); if (modeChooser.SelectedIndex != 1) { accelerometer.set_bandwidth(7); qt1.set_logicalName("w"); qt2.set_logicalName("x"); qt3.set_logicalName("y"); qt4.set_logicalName("z"); gyro.registerAnglesCallback(anglesCallback); } else { accelerometer.set_bandwidth(50); qt2.set_logicalName("ax"); qt3.set_logicalName("ay"); qt4.set_logicalName("az"); gyro.registerQuaternionCallback(accelCallback); } }
public static YQtProxy FindQt(string name) { // cases to handle: // name ="" no matching unknwn // name ="" unknown exists // name != "" no matching unknown // name !="" unknown exists YQt func = null; YQtProxy res = (YQtProxy)YFunctionProxy.FindSimilarUnknownFunction("YQtProxy"); if (name == "") { if (res != null) { return(res); } res = (YQtProxy)YFunctionProxy.FindSimilarKnownFunction("YQtProxy"); if (res != null) { return(res); } func = YQt.FirstQt(); if (func != null) { name = func.get_hardwareId(); if (func.get_userData() != null) { return((YQtProxy)func.get_userData()); } } } else { func = YQt.FindQt(name); if (func.get_userData() != null) { return((YQtProxy)func.get_userData()); } } if (res == null) { res = new YQtProxy(func, name); } if (func != null) { res.linkToHardware(name); if (func.isOnline()) { res.arrival(); } } return(res); }
public virtual int _loadQuaternion() { int now_stamp; int age_ms; now_stamp = (int)((YAPI.GetTickCount()) & (0x7FFFFFFF)); age_ms = (((now_stamp - this._qt_stamp)) & (0x7FFFFFFF)); if ((age_ms >= 10) || (this._qt_stamp == 0)) { if (this.load(10) != YAPI.SUCCESS) { return(YAPI.DEVICE_NOT_FOUND); } if (this._qt_stamp == 0) { this._qt_w = YQt.FindQt("" + this._serial + ".qt1"); this._qt_x = YQt.FindQt("" + this._serial + ".qt2"); this._qt_y = YQt.FindQt("" + this._serial + ".qt3"); this._qt_z = YQt.FindQt("" + this._serial + ".qt4"); } if (this._qt_w.load(9) != YAPI.SUCCESS) { return(YAPI.DEVICE_NOT_FOUND); } if (this._qt_x.load(9) != YAPI.SUCCESS) { return(YAPI.DEVICE_NOT_FOUND); } if (this._qt_y.load(9) != YAPI.SUCCESS) { return(YAPI.DEVICE_NOT_FOUND); } if (this._qt_z.load(9) != YAPI.SUCCESS) { return(YAPI.DEVICE_NOT_FOUND); } this._w = this._qt_w.get_currentValue(); this._x = this._qt_x.get_currentValue(); this._y = this._qt_y.get_currentValue(); this._z = this._qt_z.get_currentValue(); this._qt_stamp = now_stamp; } return(YAPI.SUCCESS); }
private void ConfigureYocto3d(string serial) { YQt q1 = YQt.FindQt(serial + ".qt1"); q1.set_logFrequency("25/s"); YQt q2 = YQt.FindQt(serial + ".qt2"); q2.set_logFrequency("25/s"); YQt q3 = YQt.FindQt(serial + ".qt3"); q3.set_logFrequency("25/s"); YQt q4 = YQt.FindQt(serial + ".qt4"); q4.set_logFrequency("25/s"); YDataLogger logger = YDataLogger.FindDataLogger(serial + ".dataLogger"); logger.set_recording(YDataLogger.RECORDING_OFF); logger.set_autoStart(YDataLogger.AUTOSTART_OFF); logger.set_beaconDriven(YDataLogger.BEACONDRIVEN_ON); logger.get_module().saveToFlash(); logger.forgetAllDataStreams(); System.Threading.Thread.Sleep(5000); MessageBox.Show("the Yocto-3D " + serial + " is now ready to record data"); }