Exemplo n.º 1
0
        /// <summary>
        /// Creates a data report instance appropirate for the sensor.
        /// </summary>
        /// <param name="report">Underlying data report COM object.</param>
        /// <param name="sensor">Sensor COM object.</param>
        /// <returns></returns>
        internal SensorDataReport GetDataReport(ISensorDataReport report, ISensor sensor)
        {
            SensorDataReport sdr = CreateReport();

            sdr.InitializeReport(report, this);
            return(sdr);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Handler for any event. Fires the <see cref="EventReceived"/> event.
 /// </summary>
 /// <param name="sensor">COM sensor object for which this event was fired.</param>
 /// <param name="eventID">Event GUID.</param>
 /// <param name="newData">COM data report object.</param>
 void ISensorEvents.OnEvent(ISensor sensor, Guid eventID, ISensorDataReport newData)
 {
     if (EventReceived != null)
     {
         SensorDataReport sdr = GetDataReport(newData, sensor);
         EventReceived(this, eventID, sdr);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Handler of the data updated event. Fires the <see cref="DataUpdated"/> event.
 /// Creates an appropriate data report object.
 /// </summary>
 /// <param name="sensor">COM sensor object for which this event was fired.</param>
 /// <param name="newData">COM data report object.</param>
 void ISensorEvents.OnDataUpdated(ISensor sensor, ISensorDataReport newData)
 {
     _lastReport = newData;
     if (DataUpdated != null)
     {
         SensorDataReport sdr = GetDataReport(newData, sensor);
         DataUpdated(this, sdr);
     }
 }
Exemplo n.º 4
0
 void sensor_DataUpdated(Windows7.Sensors.Sensor sensor, Windows7.Sensors.SensorDataReport dataReport)
 {
     if (sensor != this._sensor)
     {
         return;
     }
     CommonDataUpdated(dataReport);   // traitement des données communes à tous les capteurs
     SpecificDataUpdated(dataReport); // traitement des données spécifique à un capteurs particulier
     this.DataTimestamp = dataReport.Timestamp;
 }
Exemplo n.º 5
0
        protected override void SpecificDataUpdated(Windows7.Sensors.SensorDataReport dataReport)
        {
            double lux = Math.Round((float)dataReport.GetDataField(SensorPropertyKeys.SENSOR_DATA_TYPE_LIGHT_LUX), DecimalPrecision);

            if (resetCalibrate)
            {
                LuxMinimum     = lux;
                LuxMaximum     = lux;
                resetCalibrate = false;
            }

            this.Lux = lux;

            if (LuxDataUpdated != null)
            {
                LuxDataUpdated(this, lux);
            }
        }
        protected override void SpecificDataUpdated(Windows7.Sensors.SensorDataReport dataReport)
        {
            double x = Math.Round((float)dataReport.GetDataField(SensorPropertyKeys.SENSOR_DATA_TYPE_ACCELERATION_X_G), DecimalPrecision);
            double y = Math.Round((float)dataReport.GetDataField(SensorPropertyKeys.SENSOR_DATA_TYPE_ACCELERATION_Y_G), DecimalPrecision);
            double z = Math.Round((float)dataReport.GetDataField(SensorPropertyKeys.SENSOR_DATA_TYPE_ACCELERATION_Z_G), DecimalPrecision);

            if (x < AccelerationXMinimum)
            {
                AccelerationXMinimum = x;
            }
            if (x > AccelerationXMaximum)
            {
                AccelerationXMaximum = x;
            }


            if (y < AccelerationYMinimum)
            {
                AccelerationYMinimum = y;
            }
            if (y > AccelerationYMaximum)
            {
                AccelerationYMaximum = y;
            }


            if (z < AccelerationZMinimum)
            {
                AccelerationZMinimum = z;
            }
            if (z > AccelerationZMaximum)
            {
                AccelerationZMaximum = z;
            }

            this.AccelerationX = x;
            this.AccelerationY = y;
            this.AccelerationZ = z;

            if (AccelerationDataUpdated != null)
            {
                AccelerationDataUpdated(this, x, y, z);
            }
        }
Exemplo n.º 7
0
 void sensor_EventReceived(Windows7.Sensors.Sensor sensor, Guid eventID, Windows7.Sensors.SensorDataReport dataReport)
 {
     //throw new NotImplementedException();
 }