Exemplo n.º 1
0
 void ISensorEvents.OnDataUpdated(ISensor sensor, ISensorDataReport newData)
 {
     DataReport = SensorReport.FromNativeReport(this, newData);
     if (DataReportChanged != null)
     {
         DataReportChanged.Invoke(this, EventArgs.Empty);
     }
 }
Exemplo n.º 2
0
        internal static SensorReport FromNativeReport(Sensor originator, ISensorDataReport iReport)
        {
            SystemTime systemTimeStamp = new SystemTime();

            iReport.GetTimestamp(out systemTimeStamp);
            FILETIME ftTimeStamp = new FILETIME();

            SensorNativeMethods.SystemTimeToFileTime(ref systemTimeStamp, out ftTimeStamp);
            long     lTimeStamp = (((long)ftTimeStamp.dwHighDateTime) << 32) + (long)ftTimeStamp.dwLowDateTime;
            DateTime timeStamp  = DateTime.FromFileTime(lTimeStamp);

            SensorReport sensorReport = new SensorReport();

            sensorReport.originator = originator;
            sensorReport.timeStamp  = timeStamp;
            sensorReport.sensorData = SensorData.FromNativeReport(originator.internalObject, iReport);

            return(sensorReport);
        }
Exemplo n.º 3
0
        internal HResult InternalUpdateData()
        {
            ISensorDataReport iReport;
            HResult           hr = nativeISensor.GetData(out iReport);

            if (hr == HResult.Ok)
            {
                try
                {
                    DataReport = SensorReport.FromNativeReport(this, iReport);
                    if (DataReportChanged != null)
                    {
                        DataReportChanged.Invoke(this, EventArgs.Empty);
                    }
                }
                finally
                {
                    Marshal.ReleaseComObject(iReport);
                }
            }
            return(hr);
        }