Top Banner
36

Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.

Jan 15, 2016

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 2: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.

Windows® Sensor and Location Platform

Page 3: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 4: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 5: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.

This is a partial diagram of the Sensor and Location Platform, showing only sensor-related

parts

This is a partial diagram of the Sensor and Location Platform, showing only sensor-related

parts

Page 6: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 7: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 8: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 9: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 10: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.

#include <sensorsapi.h>#include <sensors.h>

HRESULT hr;CComPtr<ISensorManager> pSensorManager;

pSensorManager.CoCreateInstance(CLSID_SensorManager);

CComPtr<ISensorCollection> pALSCollection;CComPtr<ISensor> pALSSensor;

// Get all the ALS sensors on the systempSensorManager->GetSensorsByType(SENSOR_TYPE_AMBIENT_LIGHT, &pALSCollection);

hr = pSensorManager->RequestPermissions(0, // Owner window pALSCollection, // Collection of sensors requiring permissionsTRUE); // Modal flag

if(SUCCEEDED(hr)){ pALSCollection->GetAt(0, &pALSSensor);}

#include <sensorsapi.h>#include <sensors.h>

HRESULT hr;CComPtr<ISensorManager> pSensorManager;

pSensorManager.CoCreateInstance(CLSID_SensorManager);

CComPtr<ISensorCollection> pALSCollection;CComPtr<ISensor> pALSSensor;

// Get all the ALS sensors on the systempSensorManager->GetSensorsByType(SENSOR_TYPE_AMBIENT_LIGHT, &pALSCollection);

hr = pSensorManager->RequestPermissions(0, // Owner window pALSCollection, // Collection of sensors requiring permissionsTRUE); // Modal flag

if(SUCCEEDED(hr)){ pALSCollection->GetAt(0, &pALSSensor);}

Page 11: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.

STDMETHODIMP CALSEventSink::OnDataUpdated(ISensor* pSensor, ISensorDataReport* pNewData)

{PROPVARIANT lightLevel; PropVariantInit(&lightLevel);

// Get the sensor reading from the ISensorDataReport objectpNewData->GetSensorValue(SENSOR_DATA_TYPE_LIGHT_LEVEL_LUX, &lightLevel);

// Extract the float value from the PROPVARIANT objectfloat luxValue = V_FLOAT(lightLevel);

// Normalize the light sensor datadouble lightNormalized = ::pow(luxValue, 0.4) / 100.0;

// Handle UI changes based on the normalized LUX data // which ranges from 0.0 - 1.0 for a lux range of// 0 lux to 100,000 lux, this method represents such a // handler that would be implemented in your application

UpdateUI(lightNormalized);

PropVariantClear(&lightLevel);return S_OK;

}

STDMETHODIMP CALSEventSink::OnDataUpdated(ISensor* pSensor, ISensorDataReport* pNewData)

{PROPVARIANT lightLevel; PropVariantInit(&lightLevel);

// Get the sensor reading from the ISensorDataReport objectpNewData->GetSensorValue(SENSOR_DATA_TYPE_LIGHT_LEVEL_LUX, &lightLevel);

// Extract the float value from the PROPVARIANT objectfloat luxValue = V_FLOAT(lightLevel);

// Normalize the light sensor datadouble lightNormalized = ::pow(luxValue, 0.4) / 100.0;

// Handle UI changes based on the normalized LUX data // which ranges from 0.0 - 1.0 for a lux range of// 0 lux to 100,000 lux, this method represents such a // handler that would be implemented in your application

UpdateUI(lightNormalized);

PropVariantClear(&lightLevel);return S_OK;

}

Page 12: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 13: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.

ISensorEvents

Page 14: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 15: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 16: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.

Accelerometer3D[] sensors = SensorManager.GetSensorsByType<Accelerometer3D>();Accelerometer3D a3dSensor = null;if (sensors.Length > 0){ a3dSensor = sensors[0]; SensorManager.RequestPermission(IntPtr.Zero, true, a3dSensor);}

Accelerometer3D[] sensors = SensorManager.GetSensorsByType<Accelerometer3D>();Accelerometer3D a3dSensor = null;if (sensors.Length > 0){ a3dSensor = sensors[0]; SensorManager.RequestPermission(IntPtr.Zero, true, a3dSensor);}

Page 17: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.

a3dSensor.DataUpdated += OnDataUpdated;

void OnDataUpdated(Sensor sensor, SensorDataReport dataReport){ Accelerometer3DReport a3dReport = (Accelerometer3DReport)dataReport; Console.WriteLine("X: {0} Y: {1} Z: {2}", a3dReport.AxisX_G, a3dReport.AxisY_G, a3dReport.AxisZ_G); }

a3dSensor.DataUpdated += OnDataUpdated;

void OnDataUpdated(Sensor sensor, SensorDataReport dataReport){ Accelerometer3DReport a3dReport = (Accelerometer3DReport)dataReport; Console.WriteLine("X: {0} Y: {1} Z: {2}", a3dReport.AxisX_G, a3dReport.AxisY_G, a3dReport.AxisZ_G); }

Page 18: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 19: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 20: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 21: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 22: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 23: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 24: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 25: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 26: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 27: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.

LOCATION_REPORT_STATUS enumeration:LOCATION_REPORT_STATUS enumeration:

Page 28: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.

Used to set default location (just like the Control Panel applet does) or specifically get the default locationUsed to set default location (just like the Control Panel applet does) or specifically get the default location

Page 29: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 30: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.

HRESULT hr;IID civicReportIID = IID_ICivicAddressReport;

CComPtr<ILocation> pLocation;CComPtr<ILocationReport> pReport;

hr = pLocation.CoCreateInstance(CLSID_Location);hr = pLocation->RequestPermissions(0, &civicReportIID, 1, TRUE);hr = pLocation->GetReport(civicReportIID, &pReport);

CComPtr<ICivicAddressReport> pCivicAddressReport;pReport.QueryInterface<ICivicAddressReport>(&pCivicAddressReport);

BSTR str;hr = pCivicAddressReport->GetCountryRegion(&str);_tprintf(_T("Country/region: %s\n"), str);SysFreeString(str);

HRESULT hr;IID civicReportIID = IID_ICivicAddressReport;

CComPtr<ILocation> pLocation;CComPtr<ILocationReport> pReport;

hr = pLocation.CoCreateInstance(CLSID_Location);hr = pLocation->RequestPermissions(0, &civicReportIID, 1, TRUE);hr = pLocation->GetReport(civicReportIID, &pReport);

CComPtr<ICivicAddressReport> pCivicAddressReport;pReport.QueryInterface<ICivicAddressReport>(&pCivicAddressReport);

BSTR str;hr = pCivicAddressReport->GetCountryRegion(&str);_tprintf(_T("Country/region: %s\n"), str);SysFreeString(str);

Page 31: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 32: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 33: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.

var provider = new CivicAddressLocationProvider(10000);

LocationProvider.RequestPermissions(IntPtr.Zero, true, provider);

var report = (CivicAddressLocationReport) provider.GetReport();

Console.WriteLine("Country/region: “,report.CountryOrRegion);

var provider = new CivicAddressLocationProvider(10000);

LocationProvider.RequestPermissions(IntPtr.Zero, true, provider);

var report = (CivicAddressLocationReport) provider.GetReport();

Console.WriteLine("Country/region: “,report.CountryOrRegion);

Page 34: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.

var provider = new CivicAddressLocationProvider(10000); LocationProvider.RequestPermissions(IntPtr.Zero, true, provider);

provider.LocationChanged += (LocationProvider prov, LocationReport newLoc) => { var civicLocReport = (CivicAddressLocationReport)

newLoc; Console.WriteLine("Country/region: ", civicLocReport.CountryOrRegion); };

var provider = new CivicAddressLocationProvider(10000); LocationProvider.RequestPermissions(IntPtr.Zero, true, provider);

provider.LocationChanged += (LocationProvider prov, LocationReport newLoc) => { var civicLocReport = (CivicAddressLocationReport)

newLoc; Console.WriteLine("Country/region: ", civicLocReport.CountryOrRegion); };

Page 35: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.
Page 36: Windows ® Sensor and Location Platform This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts.

© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after

the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.