public override int _invokeTimedReportCallback(YMeasure value)
 {
   if (this._timedReportCallbackLightSensor != null)
   {
     this._timedReportCallbackLightSensor(this, value);
   }
   else
   {
     base._invokeTimedReportCallback(value);
   }
   return 0;
 }
 public override int _invokeTimedReportCallback(YMeasure value)
 {
   if (this._timedReportCallbackTemperature != null)
   {
     this._timedReportCallbackTemperature(this, value);
   }
   else
   {
     base._invokeTimedReportCallback(value);
   }
   return 0;
 }
 public override int _invokeTimedReportCallback(YMeasure value)
 {
   if (this._timedReportCallbackMagnetometer != null)
   {
     this._timedReportCallbackMagnetometer(this, value);
   }
   else
   {
     base._invokeTimedReportCallback(value);
   }
   return 0;
 }
Ejemplo n.º 4
0
 public virtual int _invokeTimedReportCallback(YMeasure value)
 {
   if (this._timedReportCallbackSensor != null)
   {
     this._timedReportCallbackSensor(this, value);
   }
   else
   {
   }
   return 0;
 }
Ejemplo n.º 5
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.NOT_SUPPORTED;
        }

      Nullable<YAPI.TJSONRECORD> node, arr;
      YDataStream stream;
      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, "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);
        if (_startTime > 0 && stream.get_startTimeUTC() + stream.get_duration() <= _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 (stream.isClosed() && stream.get_startTimeUTC() >= this._startTime &&
             (this._endTime == 0 || stream.get_startTimeUTC() + stream.get_duration() <= 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(),
                                stream.get_startTimeUTC() + stream.get_duration(),
                                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
        stream = this._streams[this._streams.Count - 1];
        UInt32 endtime = (UInt32)(stream.get_startTimeUTC() + stream.get_duration());
        UInt32 startTime = (UInt32)(this._streams[0].get_startTimeUTC() - stream.get_dataSamplesIntervalMs() / 1000);
        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();
    }
Ejemplo n.º 6
0
 // 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);
 }
Ejemplo n.º 7
0
    //--- (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();
    }