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);
        }
Example #2
0
        // 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);
        }
Example #3
0
        // 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);
            }
        }
Example #4
0
 // perform the 2nd stage setup that requires YoctoAPI object
 protected void init(YQt hwd)
 {
     if (hwd == null)
     {
         return;
     }
     base.init(hwd);
     InternalStuff.log("registering Qt callback");
     _func.registerValueCallback(valueChangeCallback);
 }
Example #5
0
        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);
        }
Example #6
0
        /**
         * <summary>
         *   Enumerates all functions of type Qt available on the devices
         *   currently reachable by the library, and returns their unique hardware ID.
         * <para>
         *   Each of these IDs can be provided as argument to the method
         *   <c>YQt.FindQt</c> to obtain an object that can control the
         *   corresponding device.
         * </para>
         * </summary>
         * <returns>
         *   an array of strings, each string containing the unique hardwareId
         *   of a device function currently connected.
         * </returns>
         */
        public static new string[] GetSimilarFunctions()
        {
            List <string> res = new List <string>();
            YQt           it  = YQt.FirstQt();

            while (it != null)
            {
                res.Add(it.get_hardwareId());
                it = it.nextQt();
            }
            return(res.ToArray());
        }
    /**
     * <summary>
     *   Retrieves a quaternion component for a given identifier.
     * <para>
     *   The identifier can be specified using several formats:
     * </para>
     * <para>
     * </para>
     * <para>
     *   - FunctionLogicalName
     * </para>
     * <para>
     *   - ModuleSerialNumber.FunctionIdentifier
     * </para>
     * <para>
     *   - ModuleSerialNumber.FunctionLogicalName
     * </para>
     * <para>
     *   - ModuleLogicalName.FunctionIdentifier
     * </para>
     * <para>
     *   - ModuleLogicalName.FunctionLogicalName
     * </para>
     * <para>
     * </para>
     * <para>
     *   This function does not require that the quaternion component is online at the time
     *   it is invoked. The returned object is nevertheless valid.
     *   Use the method <c>YQt.isOnline()</c> to test if the quaternion component is
     *   indeed online at a given time. In case of ambiguity when looking for
     *   a quaternion component by logical name, no error is notified: the first instance
     *   found is returned. The search is performed first by hardware name,
     *   then by logical name.
     * </para>
     * </summary>
     * <param name="func">
     *   a string that uniquely characterizes the quaternion component
     * </param>
     * <returns>
     *   a <c>YQt</c> object allowing you to drive the quaternion component.
     * </returns>
     */
    public static YQt FindQt(string func)
    {
        YQt obj;

        obj = (YQt)YFunction._FindFromCache("Qt", func);
        if (obj == null)
        {
            obj = new YQt(func);
            YFunction._AddToCache("Qt", func, obj);
        }
        return(obj);
    }
    protected static void yInternalGyroCallback(YQt obj, String value)
    {
        YGyro gyro = (YGyro)obj.get_userData();

        if (gyro == null)
        {
            return;
        }
        string tmp       = obj.get_functionId().Substring(2);
        int    idx       = Convert.ToInt32(tmp);
        double dbl_value = Convert.ToDouble(value);

        gyro._invokeGyroCallbacks(idx, dbl_value);
    }
    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");
        }
Example #11
0
 // perform the initial setup that may be done without a YoctoAPI object (hwd can be null)
 internal override void base_init(YFunction hwd, string instantiationName)
 {
     _func = (YQt)hwd;
     base.base_init(hwd, instantiationName);
 }
Example #12
0
        // property cache
        //--- (end of YQt definitions)

        //--- (YQt implementation)
        internal YQtProxy(YQt hwd, string instantiationName) : base(hwd, instantiationName)
        {
            InternalStuff.log("Qt " + instantiationName + " instantiation");
            base_init(hwd, instantiationName);
        }
 /**
  * <summary>
  *   Retrieves a quaternion component for a given identifier.
  * <para>
  *   The identifier can be specified using several formats:
  * </para>
  * <para>
  * </para>
  * <para>
  *   - FunctionLogicalName
  * </para>
  * <para>
  *   - ModuleSerialNumber.FunctionIdentifier
  * </para>
  * <para>
  *   - ModuleSerialNumber.FunctionLogicalName
  * </para>
  * <para>
  *   - ModuleLogicalName.FunctionIdentifier
  * </para>
  * <para>
  *   - ModuleLogicalName.FunctionLogicalName
  * </para>
  * <para>
  * </para>
  * <para>
  *   This function does not require that the quaternion component is online at the time
  *   it is invoked. The returned object is nevertheless valid.
  *   Use the method <c>YQt.isOnline()</c> to test if the quaternion component is
  *   indeed online at a given time. In case of ambiguity when looking for
  *   a quaternion component by logical name, no error is notified: the first instance
  *   found is returned. The search is performed first by hardware name,
  *   then by logical name.
  * </para>
  * </summary>
  * <param name="func">
  *   a string that uniquely characterizes the quaternion component
  * </param>
  * <returns>
  *   a <c>YQt</c> object allowing you to drive the quaternion component.
  * </returns>
  */
 public static YQt FindQt(string func)
 {
     YQt obj;
     obj = (YQt) YFunction._FindFromCache("Qt", func);
     if (obj == null) {
         obj = new YQt(func);
         YFunction._AddToCache("Qt", func, obj);
     }
     return obj;
 }
 protected static void yInternalGyroCallback(YQt obj, String value)
 {
     YGyro gyro = (YGyro)obj.get_userData();
     if (gyro == null)
     {
         return;
     }
     string tmp = obj.get_functionId().Substring(2);
     int idx = Convert.ToInt32(tmp);
     double dbl_value = Convert.ToDouble(value);
     gyro._invokeGyroCallbacks(idx, dbl_value);
 }
    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;
    }