Esempio n. 1
0
        // Datalogger buttons handling
        private void DataLoggerButton_Click(object sender, EventArgs e)
        {
            YSensor s = getSelectedSensor();

            if (s != null)
            {
                YModule     m   = s.get_module(); // get the module harboring the sensor
                YDataLogger dtl = YDataLogger.FindDataLogger(m.get_serialNumber() + ".dataLogger");
                if (dtl.isOnline())
                {
                    if (sender == RecordButton)
                    {
                        dtl.set_recording(YDataLogger.RECORDING_ON);
                    }
                    if (sender == PauseButton)
                    {
                        dtl.set_recording(YDataLogger.RECORDING_OFF);
                    }
                    if (sender == DeleteButton)
                    {
                        dtl.set_recording(YDataLogger.RECORDING_OFF);
                        MessageBox.Show("clear");
                        dtl.forgetAllDataStreams();
                        clearGraph();
                    }
                }
            }
            refreshDatloggerButton(s);
        }
Esempio n. 2
0
 // update the datalogger control buttons
 private void refreshDatloggerButton(YSensor s)
 {
     if (s != null)
     {
         YModule     m   = s.get_module(); // get the module harboring the sensor
         YDataLogger dtl = YDataLogger.FindDataLogger(m.get_serialNumber() + ".dataLogger");
         if (dtl.isOnline())
         {
             if (dtl.get_recording() == YDataLogger.RECORDING_ON)
             {
                 RecordButton.Enabled = false;
                 PauseButton.Enabled  = true;
                 DeleteButton.Enabled = false;
                 return;
             }
             else
             {
                 RecordButton.Enabled = true;
                 PauseButton.Enabled  = false;
                 DeleteButton.Enabled = true;
                 return;
             }
         }
     }
     RecordButton.Enabled = false;
     PauseButton.Enabled  = false;
     DeleteButton.Enabled = false;
 }
        public static YDataLoggerProxy FindDataLogger(string name)
        {
            // cases to handle:
            // name =""  no matching unknwn
            // name =""  unknown exists
            // name != "" no  matching unknown
            // name !="" unknown exists
            YDataLogger      func = null;
            YDataLoggerProxy res  = (YDataLoggerProxy)YFunctionProxy.FindSimilarUnknownFunction("YDataLoggerProxy");

            if (name == "")
            {
                if (res != null)
                {
                    return(res);
                }
                res = (YDataLoggerProxy)YFunctionProxy.FindSimilarKnownFunction("YDataLoggerProxy");
                if (res != null)
                {
                    return(res);
                }
                func = YDataLogger.FirstDataLogger();
                if (func != null)
                {
                    name = func.get_hardwareId();
                    if (func.get_userData() != null)
                    {
                        return((YDataLoggerProxy)func.get_userData());
                    }
                }
            }
            else
            {
                // allow to get datalogger from the name of any function
                int p = name.IndexOf(".");
                if (p > 0)
                {
                    name = name.Substring(0, p) + ".dataLogger";
                }
                func = YDataLogger.FindDataLogger(name);
                if (func.get_userData() != null)
                {
                    return((YDataLoggerProxy)func.get_userData());
                }
            }
            if (res == null)
            {
                res = new YDataLoggerProxy(func, name);
            }
            if (func != null)
            {
                res.linkToHardware(name);
                if (func.isOnline())
                {
                    res.arrival();
                }
            }
            return(res);
        }
        // link the instance to a real YoctoAPI object
        internal override void linkToHardware(string hwdName)
        {
            YDataLogger hwd = YDataLogger.FindDataLogger(hwdName);

            // first redo base_init to update all _func pointers
            base_init(hwd, hwdName);
            // then setup Yocto-API pointers and callbacks
            init(hwd);
        }
 // perform the 2nd stage setup that requires YoctoAPI object
 protected void init(YDataLogger hwd)
 {
     if (hwd == null)
     {
         return;
     }
     base.init(hwd);
     InternalStuff.log("registering DataLogger callback");
     _func.registerValueCallback(valueChangeCallback);
 }
        public void reloadConfig(YModule Source)
        {
            _name       = _sourceSensor.get_friendlyName();;
            _serial     = _sourceSensor.get_module().get_module().get_serialNumber();
            _unit       = _sourceSensor.get_unit();
            _datalogger = YDataLogger.FindDataLogger(_serial + ".dataLogger");
            _tempSensor = YTemperature.FindTemperature(_serial + ".temperature");
            string tt = _sourceSensor.get_hardwareId().Replace("weighScale", "genericSensor");

            _genSensor = YGenericSensor.FindGenericSensor(tt);
        }
Esempio n. 7
0
 public YDataStream(YDataLogger parent, int run, int stamp, long utc, int itv)
 {
     dataLogger  = parent;
     runNo       = run;
     timeStamp   = stamp;
     utcStamp    = utc;
     interval    = itv;
     nRows       = 0;
     nCols       = 0;
     columnNames = new List <string>();
     values      = null;
 }
    /**
     * <summary>
     *   Retrieves a data logger 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 data logger is online at the time
     *   it is invoked. The returned object is nevertheless valid.
     *   Use the method <c>YDataLogger.isOnline()</c> to test if the data logger is
     *   indeed online at a given time. In case of ambiguity when looking for
     *   a data logger 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 data logger
     * </param>
     * <returns>
     *   a <c>YDataLogger</c> object allowing you to drive the data logger.
     * </returns>
     */
    public static YDataLogger FindDataLogger(string func)
    {
        YDataLogger obj;

        obj = (YDataLogger)YFunction._FindFromCache("DataLogger", func);
        if (obj == null)
        {
            obj = new YDataLogger(func);
            YFunction._AddToCache("DataLogger", func, obj);
        }
        return(obj);
    }
        /**
         * <summary>
         *   Enumerates all functions of type DataLogger 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>YDataLogger.FindDataLogger</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>();
            YDataLogger   it  = YDataLogger.FirstDataLogger();

            while (it != null)
            {
                res.Add(it.get_hardwareId());
                it = it.nextDataLogger();
            }
            return(res.ToArray());
        }
Esempio n. 10
0
    //--- (generated code: DataLogger functions)

    /**
     * <summary>
     *   Retrieves a data logger 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 data logger is online at the time
     *   it is invoked. The returned object is nevertheless valid.
     *   Use the method <c>YDataLogger.isOnline()</c> to test if the data logger is
     *   indeed online at a given time. In case of ambiguity when looking for
     *   a data logger 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 data logger
     * </param>
     * <returns>
     *   a <c>YDataLogger</c> object allowing you to drive the data logger.
     * </returns>
     */
    public static YDataLogger FindDataLogger(string func)
    {
        YDataLogger res;

        if (_DataLoggerCache.ContainsKey(func))
        {
            return((YDataLogger)_DataLoggerCache[func]);
        }
        res = new YDataLogger(func);
        _DataLoggerCache.Add(func, res);
        return(res);
    }
Esempio n. 11
0
        private void configurePWMInput(YPwmInput pwmInput)
        {
            this.log("Configure PWM Input");

            // Set debounce value to 5 ms
            pwmInput.set_debouncePeriod(5);
            pwmInput.set_pwmReportMode(YPwmInput.PWMREPORTMODE_PWM_PULSECOUNT);
            pwmInput.set_logFrequency("1/m");
            pwmInput.get_module().saveToFlash();
            YDataLogger dataLogger = pwmInput.get_dataLogger();

            dataLogger.set_autoStart(YDataLogger.AUTOSTART_ON);
            dataLogger.set_recording(YDataLogger.RECORDING_ON);
        }
 public YOldDataStream(YDataLogger parent, int run, int stamp, UInt32 utc, int itv)
     : base(parent)
 {
     this._dataLogger     = parent;
     this._runNo          = run;
     this._timeStamp      = stamp;
     this._utcStamp       = utc;
     this._interval       = itv;
     this._samplesPerHour = (int)(3600 / _interval);
     this._isClosed       = true;
     this._minVal         = DATA_INVALID;
     this._avgVal         = DATA_INVALID;
     this._maxVal         = DATA_INVALID;
 }
        private void clearDataLogger(object sender, EventArgs e)
        {
            if (System.Windows.Forms.MessageBox.Show("Do you really want to erase contents of all dataloggers related to this graph?",
                                                     "Erase dataloggers contents?",
                                                     MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            List <YDataLogger> loggers = new List <YDataLogger>();

            for (int i = 0; i < SeriesCount; i++)
            {
                ChartSerie    s      = (ChartSerie)prop.GetType().GetProperty("Graph_series" + i.ToString()).GetValue(prop, null);
                CustomYSensor sensor = s.DataSource_source;
                if (!(sensor is NullYSensor))
                {
                    sensor.stopDataloggerloading();
                    string serial = sensor.get_hardwareId();
                    int    n      = serial.IndexOf(".");
                    serial = serial.Substring(0, n);
                    YDataLogger d = YDataLogger.FindDataLogger(serial + ".dataLogger");
                    if (d.isOnline())
                    {
                        if (loggers.IndexOf(d) < 0)
                        {
                            loggers.Add(d);
                        }
                    }
                }
            }

            for (int i = 0; i < loggers.Count; i++)
            {
                loggers[i].forgetAllDataStreams();
                loggers[i].set_recording(YDataLogger.RECORDING_ON);
            }

            bool tmp = prop.Graph_showRecordedData;

            prop.Graph_showRecordedData = false;
            truncateView();
            prop.Graph_showRecordedData = tmp;
        }
Esempio n. 14
0
        private List <List <double> > GetRecordList(string serial)
        {
            StreamWriter file = new StreamWriter("c:\\tmp\\debug.log");

            YDataLogger     logger = YDataLogger.FindDataLogger(serial + ".dataLogger");
            List <YMeasure> qt_w   = LoadQT(serial + ".qt1");
            List <YMeasure> qt_x   = LoadQT(serial + ".qt2");
            List <YMeasure> qt_y   = LoadQT(serial + ".qt3");
            List <YMeasure> qt_z   = LoadQT(serial + ".qt4");
            int             count  = qt_w.Count;
            double          len    = qt_w[qt_w.Count - 1].get_startTimeUTC() - qt_w[0].get_startTimeUTC();
            double          frame  = len * 30;

            file.WriteLine("nb measure = " + count + " duration:" + len + "s (we should get " + frame + " at 30/s)");


            List <List <double> > angles = new List <List <double> >(count);
            double start = qt_w[0].get_startTimeUTC();

            for (int i = 0; i < count; i++)
            {
                List <double> pos = computeAngles(qt_w[i].get_averageValue(),
                                                  qt_x[i].get_averageValue(),
                                                  qt_y[i].get_averageValue(),
                                                  qt_z[i].get_averageValue(),
                                                  0,
                                                  qt_w[i].get_startTimeUTC() - qt_w[0].get_startTimeUTC()
                                                  );


                angles.Add(pos);
                len = qt_w[i].get_endTimeUTC() - qt_w[i].get_startTimeUTC();
                double abs = qt_w[i].get_startTimeUTC() - start;

                String line = String.Format("{0} -> {1:0.000}s  len{2:0.000} : W={3:0.00} X={4:0.00} Y={5:0.00} Z={6:0.00} => r={7:0.00} p={8:0.00} h={9:0.00}",
                                            i, abs, len, qt_w[i].get_averageValue(), qt_x[i].get_averageValue(), qt_y[i].get_averageValue(), qt_z[i].get_averageValue(), pos[0], pos[1], pos[2]);
                file.WriteLine(line);
                backgroundWorker1.ReportProgress(10 * i / count);
            }
            file.Close();
            return(angles);
        }
Esempio n. 15
0
        private void moduleInventory()
        {
            YModule m, currentmodule;
            string  name;
            int     index;

            comboBox1.Items.Clear();
            currentmodule = null;
            m             = YModule.FirstModule();
            while (m != null)
            {
                if (m.get_productName() == "Yocto-3D")
                {
                    comboBox1.Items.Add(m);
                    //stop the datalogger
                    YDataLogger d = YDataLogger.FindDataLogger(m.get_serialNumber() + ".dataLogger");
                    d.set_recording(YDataLogger.RECORDING_OFF);
                }
                m = m.nextModule();
            }

            if (comboBox1.Items.Count == 0)
            {
                comboBox1.Enabled  = false;
                reset.Enabled      = false;
                loadButton.Enabled = false;
            }
            else
            {
                comboBox1.Enabled  = true;
                reset.Enabled      = true;
                loadButton.Enabled = true;
                index = 0;
                comboBox1.SelectedIndex = index;
            }
        }
Esempio n. 16
0
        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");
        }
 /**
  * <summary>
  *   Retrieves a data logger 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 data logger is online at the time
  *   it is invoked. The returned object is nevertheless valid.
  *   Use the method <c>YDataLogger.isOnline()</c> to test if the data logger is
  *   indeed online at a given time. In case of ambiguity when looking for
  *   a data logger 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 data logger
  * </param>
  * <returns>
  *   a <c>YDataLogger</c> object allowing you to drive the data logger.
  * </returns>
  */
 public static YDataLogger FindDataLogger(string func)
 {
     YDataLogger obj;
     obj = (YDataLogger) YFunction._FindFromCache("DataLogger", func);
     if (obj == null) {
         obj = new YDataLogger(func);
         YFunction._AddToCache("DataLogger", func, obj);
     }
     return obj;
 }
Esempio n. 18
0
 public YDataStream(YDataLogger parent, int run, int stamp, long utc, int itv)
 {
     dataLogger = parent;
     runNo = run;
     timeStamp = stamp;
     utcStamp = utc;
     interval = itv;
     nRows = 0;
     nCols = 0;
     columnNames = new List<string>();
     values = null;
 }
Esempio n. 19
0
 //--- (generated code: DataLogger functions)
 /**
    * <summary>
    *   Retrieves a data logger 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 data logger is online at the time
    *   it is invoked. The returned object is nevertheless valid.
    *   Use the method <c>YDataLogger.isOnline()</c> to test if the data logger is
    *   indeed online at a given time. In case of ambiguity when looking for
    *   a data logger 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 data logger
    * </param>
    * <returns>
    *   a <c>YDataLogger</c> object allowing you to drive the data logger.
    * </returns>
    */
 public static YDataLogger FindDataLogger(string func)
 {
     YDataLogger res;
     if (_DataLoggerCache.ContainsKey(func))
       return (YDataLogger)_DataLoggerCache[func];
     res = new YDataLogger(func);
     _DataLoggerCache.Add(func, res);
     return res;
 }
 // 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 = (YDataLogger)hwd;
     base.base_init(hwd, instantiationName);
 }
 public YOldDataStream(YDataLogger parent, int run, int stamp, UInt32 utc, int itv)
     : base(parent)
 {
     this._dataLogger = parent;
     this._runNo = run;
     this._timeStamp = stamp;
     this._utcStamp = utc;
     this._interval = itv;
     this._samplesPerHour = (int)(3600 / _interval);
     this._isClosed = true;
     this._minVal = DATA_INVALID;
     this._avgVal = DATA_INVALID;
     this._maxVal = DATA_INVALID;
 }
        //--- (end of generated code: YDataLogger definitions)

        //--- (generated code: YDataLogger implementation)
        internal YDataLoggerProxy(YDataLogger hwd, string instantiationName) : base(hwd, instantiationName)
        {
            InternalStuff.log("DataLogger " + instantiationName + " instantiation");
            base_init(hwd, instantiationName);
        }