Exemple #1
0
        public void newGenericSensorData(YGenericSensor source, YMeasure data)
        {
            pointXY p = new pointXY()
            {
                x = data.get_endTimeUTC(), y = data.get_averageValue()
            };

            WeightData.Add(p);
            monitor_wData.AddPoint(p);
        }
Exemple #2
0
        public void newTempSensorData(YTemperature source, YMeasure data)
        {
            pointXY p = new pointXY()
            {
                x = data.get_endTimeUTC(), y = data.get_averageValue()
            };

            TempData.Add(p);
            monitor_tData.AddPoint(p);
        }
        public void SensorValuecallback(CustomYSensor source, YMeasure M)
        {
            if (prop == null)
            {
                return;
            }

            if (source == prop.DataSource_source)
            {
                _solidGauge.value = source.isOnline() ? M.get_averageValue() : 0;
            }
        }
Exemple #4
0
        // automatically called on a regular basis with sensor value
        public void newSensorValue(YFunction f, YMeasure m)
        {
            double t = m.get_endTimeUTC();

            chart1.Series[0].Points.AddXY(UnixTimeStampToDateTime(t), m.get_averageValue());
            if (FirstPointDate < 0)
            {
                FirstPointDate = t;
            }
            LastPointDate = t;
            setGraphScale();
        }
 public override int _invokeTimedReportCallback(YMeasure value)
 {
     if (this._timedReportCallbackLatitude != null)
     {
         this._timedReportCallbackLatitude(this, value);
     }
     else
     {
         base._invokeTimedReportCallback(value);
     }
     return(0);
 }
 public override int _invokeTimedReportCallback(YMeasure value)
 {
     if (this._timedReportCallbackMultiCellWeighScale != null)
     {
         this._timedReportCallbackMultiCellWeighScale(this, value);
     }
     else
     {
         base._invokeTimedReportCallback(value);
     }
     return(0);
 }
 public override int _invokeTimedReportCallback(YMeasure value)
 {
     if (this._timedReportCallbackAccelerometer != null)
     {
         this._timedReportCallbackAccelerometer(this, value);
     }
     else
     {
         base._invokeTimedReportCallback(value);
     }
     return(0);
 }
Exemple #8
0
 public override int _invokeTimedReportCallback(YMeasure value)
 {
     if (this._timedReportCallbackQuadratureDecoder != null)
     {
         this._timedReportCallbackQuadratureDecoder(this, value);
     }
     else
     {
         base._invokeTimedReportCallback(value);
     }
     return(0);
 }
 public override int _invokeTimedReportCallback(YMeasure value)
 {
     if (this._timedReportCallbackGenericSensor != null)
     {
         this._timedReportCallbackGenericSensor(this, value);
     }
     else
     {
         base._invokeTimedReportCallback(value);
     }
     return(0);
 }
 public override int _invokeTimedReportCallback(YMeasure value)
 {
     if (this._timedReportCallbackGroundSpeed != null)
     {
         this._timedReportCallbackGroundSpeed(this, value);
     }
     else
     {
         base._invokeTimedReportCallback(value);
     }
     return(0);
 }
        public void SensorValuecallback(CustomYSensor source, YMeasure M)
        {
            if (prop == null)
            {
                return;
            }

            //     if (FirstLiveValue == 0) FirstLiveValue = M.get_endTimeUTC();

            for (int i = 0; i < SeriesCount; i++)
            {
                ChartSerie s = seriesProperties[i];
                if (s.DataSource_source == source)
                {
                    if (!s.DataSource_source.isOnline())
                    {
                        offlineMessages[i] = s.DataSource_source.get_friendlyName() + " is OFFLINE";
                        showOffline[i]     = true;
                        updateOfflinePanel();


                        return;
                    }

                    showOffline[i] = false;
                    updateOfflinePanel();

                    int index = s.DataSource_source.curData.Count - 1;


                    switch (s.DataSource_datatype)
                    {
                    case 1: _cartesianChart.series[i].AddPoint(new pointXY {
                            x = s.DataSource_source.minData[index].DateTime, y = s.DataSource_source.minData[index].Value
                        }); break;

                    case 2: _cartesianChart.series[i].AddPoint(new pointXY {
                            x = s.DataSource_source.maxData[index].DateTime, y = s.DataSource_source.maxData[index].Value
                        }); break;

                    default:
                        _cartesianChart.series[i].AddPoint(new pointXY {
                            x = s.DataSource_source.curData[index].DateTime, y = s.DataSource_source.curData[index].Value
                        }); break;
                    }
                    _cartesianChart.series[i].unit = s.DataSource_source.get_unit();
                }
            }
        }
Exemple #12
0
        static void dumpSensor(YSensor sensor)
        {
            string fmt = "dd MMM yyyy hh:mm:ss,fff";

            Console.WriteLine("Using DataLogger of " + sensor.get_friendlyName());
            YDataSet dataset = sensor.get_recordedData(0, 0);

            Console.WriteLine("loading summary... ");
            dataset.loadMore();
            YMeasure summary = dataset.get_summary();
            String   line    =
                String.Format("from {0} to {1} : min={2:0.00}{5} avg={3:0.00}{5}  max={4:0.00}{5}",
                              summary.get_startTimeUTC_asDateTime().ToString(fmt),
                              summary.get_endTimeUTC_asDateTime().ToString(fmt), summary.get_minValue(),
                              summary.get_averageValue(), summary.get_maxValue(), sensor.get_unit());

            Console.WriteLine(line);
            Console.Write("loading details :   0%");
            int progress = 0;

            do
            {
                progress = dataset.loadMore();
                Console.Write(String.Format("\b\b\b\b{0,3:##0}%", progress));
            } while(progress < 100);
            Console.WriteLine("");
            List <YMeasure> details = dataset.get_measures();

            foreach (YMeasure m in details)
            {
                Console.WriteLine(
                    String.Format("from {0} to {1} : min={2:0.00}{5} avg={3:0.00}{5}  max={4:0.00}{5}",
                                  m.get_startTimeUTC_asDateTime().ToString(fmt),
                                  m.get_endTimeUTC_asDateTime().ToString(fmt), m.get_minValue(), m.get_averageValue(),
                                  m.get_maxValue(), sensor.get_unit()));
            }
        }
    /**
     * <summary>
     *   Returns the detailed set of measures for the time interval corresponding
     *   to a given condensed measures previously returned by <c>get_preview()</c>.
     * <para>
     *   The result is provided as a list of YMeasure objects.
     * </para>
     * <para>
     * </para>
     * </summary>
     * <param name="measure">
     *   condensed measure from the list previously returned by
     *   <c>get_preview()</c>.
     * </param>
     * <returns>
     *   a table of records, where each record depicts the
     *   measured values during a time interval
     * </returns>
     * <para>
     *   On failure, throws an exception or returns an empty array.
     * </para>
     */
    public virtual List<YMeasure> get_measuresAt(YMeasure measure)
    {
        long startUtc;
        YDataStream stream;
        List<List<double>> dataRows = new List<List<double>>();
        List<YMeasure> measures = new List<YMeasure>();
        double tim;
        double itv;
        int nCols;
        int minCol;
        int avgCol;
        int maxCol;
        // may throw an exception
        startUtc = (long) Math.Round(measure.get_startTimeUTC());
        stream = null;
        for (int ii = 0; ii < this._streams.Count; ii++) {
            if (this._streams[ii].get_startTimeUTC() == startUtc) {
                stream = this._streams[ii];
            }
            ;;
        }
        if (stream == null) {
            return measures;
        }
        dataRows = stream.get_dataRows();
        if (dataRows.Count == 0) {
            return measures;
        }
        tim = (double) stream.get_startTimeUTC();
        itv = stream.get_dataSamplesInterval();
        if (tim < itv) {
            tim = itv;
        }
        nCols = dataRows[0].Count;
        minCol = 0;
        if (nCols > 2) {
            avgCol = 1;
        } else {
            avgCol = 0;
        }
        if (nCols > 2) {
            maxCol = 2;
        } else {
            maxCol = 0;
        }

        for (int ii = 0; ii < dataRows.Count; ii++) {
            if ((tim >= this._startTime) && ((this._endTime == 0) || (tim <= this._endTime))) {
                measures.Add(new YMeasure(tim - itv, tim, dataRows[ii][minCol], dataRows[ii][avgCol], dataRows[ii][maxCol]));
            }
            tim = tim + itv;;
        }
        return measures;
    }
 public override int _invokeTimedReportCallback(YMeasure value)
 {
     if (this._timedReportCallbackCurrent != null) {
         this._timedReportCallbackCurrent(this, value);
     } else {
         base._invokeTimedReportCallback(value);
     }
     return 0;
 }
 public override int _invokeTimedReportCallback(YMeasure value)
 {
     if (this._timedReportCallbackAccelerometer != null) {
         this._timedReportCallbackAccelerometer(this, value);
     } else {
         base._invokeTimedReportCallback(value);
     }
     return 0;
 }
 async Task sensorTimedReportCallBack(YSensor fct, YMeasure measure)
 {
     Output.Text += await fct.get_hardwareId() + ": " + measure.get_averageValue() + " " + await fct.get_userData() + " (timed report)\n";
 }
 // YDataSet constructor for the new datalogger
 public YDataSet(YFunction parent, string data)
 {
     //--- (generated code: YDataSet attributes initialization)
     //--- (end of generated code: YDataSet attributes initialization)
     this._parent = parent;
     this._startTime = 0;
     this._endTime   = 0;
     this._summary = new YMeasure();
     this._parse(data);
 }
 //--- (end of generated code: YDataSet definitions)
 // YDataSet constructor, when instantiated directly by a function
 public YDataSet(YFunction parent, string functionId, string unit, long startTime, long endTime)
 {
     //--- (generated code: YDataSet attributes initialization)
     //--- (end of generated code: YDataSet attributes initialization)
     this._parent     = parent;
     this._functionId = functionId;
     this._unit       = unit;
     this._startTime  = startTime;
     this._endTime    = endTime;
     this._progress   = -1;
     this._summary = new YMeasure();
 }
 public virtual int _invokeTimedReportCallback(YMeasure value)
 {
     if (this._timedReportCallbackSensor != null) {
         this._timedReportCallbackSensor(this, value);
     } else {
     }
     return 0;
 }
 /**
  * <summary>
  *   Returns the detailed set of measures for the time interval corresponding
  *   to a given condensed measures previously returned by <c>get_preview()</c>.
  * <para>
  *   The result is provided as a list of <c>YMeasure</c> objects.
  * </para>
  * <para>
  * </para>
  * </summary>
  * <param name="measure">
  *   condensed measure from the list previously returned by
  *   <c>get_preview()</c>.
  * </param>
  * <returns>
  *   a table of records, where each record depicts the
  *   measured values during a time interval
  * </returns>
  * <para>
  *   On failure, throws an exception or returns an empty array.
  * </para>
  */
 public virtual YMeasure[] get_measuresAt(YMeasure measure)
 {
     return(_objref.get_measuresAt(measure).ToArray());
 }
 public override int _invokeTimedReportCallback(YMeasure value)
 {
     if (this._timedReportCallbackGenericSensor != null) {
         this._timedReportCallbackGenericSensor(this, value);
     } else {
         base._invokeTimedReportCallback(value);
     }
     return 0;
 }
    protected int _parse(string data)
    {
        YAPI.TJsonParser p;

        if (!YAPI.ExceptionsDisabled)  p= new YAPI.TJsonParser(data, false);
        else try
        {
            p = new YAPI.TJsonParser(data, false);
        }
        catch
        {

            return YAPI.IO_ERROR;
        }

        Nullable<YAPI.TJSONRECORD> node, arr;
        YDataStream stream;
        long streamStartTime;
        long streamEndTime;
        long startTime = 0x7fffffff;
        long endTime = 0;
        double summaryMinVal = Double.MaxValue;
        double summaryMaxVal = -Double.MaxValue;
        double summaryTotalTime = 0;
        double summaryTotalAvg = 0;

        node = p.GetChildNode(null, "id");
        this._functionId = node.Value.svalue;
        node = p.GetChildNode(null, "unit");
        this._unit = node.Value.svalue;
        node = p.GetChildNode(null, "calib");
        if (node != null)
        {
            this._calib = YAPI._decodeFloats(node.Value.svalue);
            this._calib[0] = this._calib[0] / 1000;
        }
        else
        {
            node = p.GetChildNode(null, "cal");
            this._calib = YAPI._decodeWords(node.Value.svalue);
        }
        arr = p.GetChildNode(null, "streams");
        this._streams = new List<YDataStream>();
        this._preview = new List<YMeasure>();
        this._measures = new List<YMeasure>();
        for (int i = 0; i < arr.Value.itemcount; i++)
        {
            stream = _parent._findDataStream(this, arr.Value.items[i].svalue);
            streamStartTime = stream.get_startTimeUTC() - stream.get_dataSamplesIntervalMs() / 1000;
            streamEndTime = stream.get_startTimeUTC() + stream.get_duration();
            if (_startTime > 0 && streamEndTime <= _startTime)
            {
                // this stream is too early, drop it
            }
            else if (_endTime > 0 && stream.get_startTimeUTC() > this._endTime)
            {
                // this stream is too late, drop it
            }
            else
            {
                _streams.Add(stream);
                if (startTime > streamStartTime)
                {
                    startTime = streamStartTime;
                }
                if (endTime < streamEndTime)
                {
                    endTime = streamEndTime;
                }
                if (stream.isClosed() && stream.get_startTimeUTC() >= this._startTime &&
                   (this._endTime == 0 || streamEndTime <= this._endTime))
                {
                    if (summaryMinVal > stream.get_minValue()) {
                        summaryMinVal = stream.get_minValue();
                    }
                    if (summaryMaxVal < stream.get_maxValue()) {
                        summaryMaxVal = stream.get_maxValue();
                    }
                    summaryTotalAvg += stream.get_averageValue() * stream.get_duration();
                    summaryTotalTime += stream.get_duration();

                    YMeasure rec = new YMeasure(
                                        stream.get_startTimeUTC(),
                                        streamEndTime,
                                        stream.get_minValue(),
                                        stream.get_averageValue(),
                                        stream.get_maxValue());
                    this._preview.Add(rec);
                }
            }
        }
        if ((this._streams.Count > 0) && (summaryTotalTime>0))
        {
            // update time boundaries with actual data
            if (this._startTime < startTime)
            {
                this._startTime = startTime;
            }
            if (this._endTime == 0 || this._endTime > endTime)
            {
                this._endTime = endTime;
            }
            this._summary = new YMeasure(
                                        _startTime,
                                        _endTime,
                                        summaryMinVal,
                                        summaryTotalAvg / summaryTotalTime,
                                        summaryMaxVal);
        }
        this._progress = 0;
        return this.get_progress();
    }
Exemple #23
0
 static void sensorTimedReportCallBack(YSensor fct, YMeasure measure)
 {
     Console.WriteLine(fct.get_hardwareId() + ": " + measure.get_averageValue() + " " + fct.get_userData() + " (timed report)");
 }