Skip to content

Commit

Permalink
Updating SensorExplorer to version 2.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
saredd committed Sep 5, 2024
1 parent ca189c5 commit 1e03fab
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 88 deletions.
1 change: 1 addition & 0 deletions sensors/Tools/SensorExplorer/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public static class Constants
public static readonly string[] HumanPresenceSensorPropertyTitles = new string[] {
"IsPresent",
"IsEngaged",
"IsOnlookerPresent",
"Distance (mm)"
};

Expand Down
2 changes: 1 addition & 1 deletion sensors/Tools/SensorExplorer/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="Microsoft.SensorExplorer" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="2.7.0.0" />
<Identity Name="Microsoft.SensorExplorer" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="2.8.0.0" />
<mp:PhoneIdentity PhoneProductId="6fc3f92f-5e15-4c38-ac82-1232213dee4c" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>SensorExplorer</DisplayName>
Expand Down
1 change: 0 additions & 1 deletion sensors/Tools/SensorExplorer/PeriodicTimer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ static class PeriodicTimer
{
private static CoreDispatcher cd = Window.Current.CoreWindow.Dispatcher;
private static ThreadPoolTimer periodicTimerSensorDisplay = null;
private static ThreadPoolTimer periodicTimerMALTScenario1 = null;
private static ThreadPoolTimer periodicTimerMALTScenario2 = null;
private static ThreadPoolTimer periodicTimerDEO = null;
private static ThreadPoolTimer periodicTimerDistance = null;
Expand Down
9 changes: 8 additions & 1 deletion sensors/Tools/SensorExplorer/Sensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ static class Sensor
public static List<HumanPresenceSensor> HumanPresenceSensorList;
public static List<DeviceInformation> HumanPresenceSensorDeviceInfo;
public static List<string[]> HumanPresenceSensorPLD;
public static List<int[]> HumanPresenceSensorCapabilities;
public static List<Inclinometer> InclinometerList;
public static List<DeviceInformation> InclinometerDeviceInfo;
public static List<string[]> InclinometerPLD;
Expand Down Expand Up @@ -476,6 +477,7 @@ private static void InitializeLists()
HumanPresenceSensorList= new List<HumanPresenceSensor>();
HumanPresenceSensorDeviceInfo = new List<DeviceInformation>();
HumanPresenceSensorPLD = new List<string[]>();
HumanPresenceSensorCapabilities = new List<int[]>();
InclinometerList = new List<Inclinometer>();
InclinometerDeviceInfo = new List<DeviceInformation>();
InclinometerPLD = new List<string[]>();
Expand Down Expand Up @@ -842,6 +844,9 @@ public static async Task<bool> GetDefault(bool getPLD)
{
HumanPresenceSensorPLD.Add(pldInfo);
}

int[] capabilities = { humanPresenceSensor.IsPresenceSupported ? 1 : 0, humanPresenceSensor.IsEngagementSupported ? 1 : 0, humanPresenceSensor.MaxDetectablePersons };
HumanPresenceSensorCapabilities.Add(capabilities);
}
}
}
Expand Down Expand Up @@ -1867,6 +1872,7 @@ private static async void EnableHumanPresenceSensor(int index, int totalIndex)
var deviceProperties = await GetProperties(HumanPresenceSensorDeviceInfo[index]);
SensorData[totalIndex].AddProperty(deviceId, 0, 0, -1.00f, 0, deviceProperties);
SensorData[totalIndex].AddPLDProperty(HumanPresenceSensorPLD[index]);
SensorData[totalIndex].AddPresenceCapabilities(HumanPresenceSensorCapabilities[index]);
HumanPresenceSensorList[index].ReadingChanged += HumanPresenceSensorReadingChanged;
}
catch { }
Expand All @@ -1888,7 +1894,8 @@ private async static void HumanPresenceSensorReadingChanged(object sender, Human
if (SensorData[CurrentId].SensorType == HUMANPRESENCESENSOR)
{
HumanPresenceSensorReading reading = e.Reading;
if (SensorData[CurrentId].AddReading(reading.Timestamp.UtcDateTime, new double[] { Convert.ToDouble(reading.Engagement), Convert.ToDouble(reading.Presence), Convert.ToDouble(reading.DistanceInMillimeters) }))

if (SensorData[CurrentId].AddReading(reading.Timestamp.UtcDateTime, new double[] { Convert.ToDouble(reading.Engagement), Convert.ToDouble(reading.Presence), Convert.ToDouble(reading.OnlookerPresence), Convert.ToDouble(reading.DistanceInMillimeters) }))
{
await cd.RunAsync(CoreDispatcherPriority.Normal, () =>
{
Expand Down
14 changes: 14 additions & 0 deletions sensors/Tools/SensorExplorer/SensorData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public Reading(DateTime timestamp, double[] value)
public uint ReportLatency = 0;
public float LightSensorThreshold = -1.00f;

public bool PresenceSupported = false;
public bool EngagementSupported = false;
public int MaxDetectablePersons = 1;

public SensorData(int sensorType, int totalIndex, string[] property)
{
SensorType = sensorType;
Expand Down Expand Up @@ -116,6 +120,16 @@ public void AddPLDProperty(string[] PLD)
}
}

public void AddPresenceCapabilities(int[] capabilities)
{
if (null != capabilities)
{
PresenceSupported = (capabilities[0] != 0);
EngagementSupported = (capabilities[1] != 0);
MaxDetectablePersons = capabilities[2];
}
}

public void UpdateReportInterval(uint reportInterval)
{
if (reportInterval != ReportInterval)
Expand Down
83 changes: 63 additions & 20 deletions sensors/Tools/SensorExplorer/SensorDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ class SensorDisplay
"HumanPresenceDetectionType",
"Device ID",
};
private string[] presenceCapabilities = new string[]
{
"PresenceSupported",
"EngagementSupported",
"MaxDetectablePersons",
};
private StackPanel stackPanelBottom = new StackPanel() { Orientation = Orientation.Horizontal };
private StackPanel stackPanelBottomData = new StackPanel() { Orientation = Orientation.Horizontal };
private StackPanel stackPanelBottomRightCol = new StackPanel() { Orientation = Orientation.Vertical };
Expand Down Expand Up @@ -124,6 +130,15 @@ class SensorDisplay
private TextBlock[] textBlockPLDName;
private TextBlock[] textBlockPLDValue;

// Presence Capabilities
private Expander expanderPresenceCap = new Expander() { Header = "Presence Capabilities" };
private ScrollViewer scrollViewerPresenceCap = new ScrollViewer() { HorizontalScrollBarVisibility = ScrollBarVisibility.Visible, VerticalScrollBarVisibility = ScrollBarVisibility.Visible };
private StackPanel stackPanelPresenceCap = new StackPanel() { Orientation = Orientation.Horizontal, Margin = new Thickness(20) };
private StackPanel stackPanelPresenceCapName = new StackPanel() { Orientation = Orientation.Vertical, Margin = new Thickness(10, 10, 0, 10) };
private StackPanel stackPanelPresenceCapValue = new StackPanel() { Orientation = Orientation.Vertical, Margin = new Thickness(10) };
private TextBlock[] textBlockPresenceCapName;
private TextBlock[] textBlockPresenceCapValue;

public SensorDisplay(int sensorType, int index, int totalIndex, int minValue, int maxValue, int scale, Color[] color)
{
SensorType = sensorType;
Expand All @@ -139,6 +154,9 @@ public SensorDisplay(int sensorType, int index, int totalIndex, int minValue, in
expanderPLD.Content = scrollViewerPLD;
scrollViewerPLD.Content = stackPanelPLD;

expanderPresenceCap.Content = scrollViewerPresenceCap;
scrollViewerPresenceCap.Content = stackPanelPresenceCap;

for (int i = 0; i <= scale; i++)
{
if (sensorType == Sensor.ACTIVITYSENSOR)
Expand Down Expand Up @@ -258,6 +276,11 @@ public SensorDisplay(int sensorType, int index, int totalIndex, int minValue, in
stackPanelMaxValue.Children.Add(textBlockMaxValue[i]);
}

if (sensorType == Sensor.HUMANPRESENCESENSOR)
{
stackPanelExpander.Children.Add(expanderPresenceCap);
}

stackPanelExpander.Children.Add(expanderProperty);
stackPanelExpander.Children.Add(expanderPLD);
stackPanelBottom.Children.Add(stackPanelExpander);
Expand Down Expand Up @@ -343,6 +366,20 @@ public SensorDisplay(int sensorType, int index, int totalIndex, int minValue, in
stackPanelPLD.Children.Add(stackPanelPLDName);
stackPanelPLD.Children.Add(stackPanelPLDValue);

textBlockPresenceCapName = new TextBlock[presenceCapabilities.Length];
textBlockPresenceCapValue = new TextBlock[textBlockPresenceCapName.Length];

for (int i = 0; i < presenceCapabilities.Length; i++)
{
textBlockPresenceCapName[i] = new TextBlock() { Text = presenceCapabilities[i], HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center };
textBlockPresenceCapValue[i] = new TextBlock() { Text = (i == 0 ? "\r\n" : "") + " -", HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center };
stackPanelPresenceCapName.Children.Add(textBlockPresenceCapName[i]);
stackPanelPresenceCapValue.Children.Add(textBlockPresenceCapValue[i]);
}

stackPanelPresenceCap.Children.Add(stackPanelPresenceCapName);
stackPanelPresenceCap.Children.Add(stackPanelPresenceCapValue);

StackPanelSensor.Children.Add(StackPanelTop);
StackPanelSensor.Children.Add(canvasSensor);
StackPanelSensor.Children.Add(stackPanelBottom);
Expand Down Expand Up @@ -370,6 +407,7 @@ public void SetWidth(double width, double height)
canvasSensor.Width = width * 0.7;
scrollViewerProperty.MaxWidth = width * 0.5;
scrollViewerPLD.MaxWidth = width * 0.5;
scrollViewerPresenceCap.MaxWidth = width * 0.5;
}

private void SetFontSize(double fontSize)
Expand All @@ -394,6 +432,12 @@ private void SetFontSize(double fontSize)
textBlockPLDValue[i].FontSize = fontSize;
}

for (int i = 0; i < textBlockPresenceCapName.Length; i++)
{
textBlockPresenceCapName[i].FontSize = fontSize;
textBlockPresenceCapValue[i].FontSize = fontSize;
}

TextBlock textBlock = new TextBlock() { Text = "00000000", FontSize = fontSize };
textBlock.Measure(new Size(200, 200)); // Assuming 200x200 is max size of textblock
canvasSensor.Margin = new Thickness(textBlock.DesiredSize.Width, textBlock.DesiredSize.Height, 0, textBlock.DesiredSize.Height * 2);
Expand All @@ -406,6 +450,7 @@ public void SetHeight(double height)
canvasSensor.Width = height;
scrollViewerProperty.MaxHeight = height;
scrollViewerPLD.MaxHeight = height;
scrollViewerPresenceCap.MaxHeight = height;
}

public void EnableSensor()
Expand Down Expand Up @@ -469,6 +514,13 @@ public void UpdatePLDProperty(SensorData sensorData)
textBlockPLDValue[14].Text = (sensorData.PanelVisible == null) ? "null" : sensorData.PanelVisible;
}

public void UpdatePresenceCapabilities(SensorData sensorData)
{
textBlockPresenceCapValue[0].Text = sensorData.PresenceSupported ? " Yes" : " No";
textBlockPresenceCapValue[1].Text = sensorData.EngagementSupported ? " Yes" : " No";
textBlockPresenceCapValue[2].Text = sensorData.MaxDetectablePersons.ToString();
}

public void UpdateText(SensorData sensorData)
{
try
Expand All @@ -478,6 +530,7 @@ public void UpdateText(SensorData sensorData)
{
UpdateProperty(sensorData);
UpdatePLDProperty(sensorData);
UpdatePresenceCapabilities(sensorData);
}

if (StackPanelSensor.Visibility == Visibility.Visible)
Expand Down Expand Up @@ -614,26 +667,9 @@ public void UpdateText(SensorData sensorData)
}
else if (sensorData.SensorType == Sensor.HUMANPRESENCESENSOR && sensorData.Property[i] == "IsEngaged")
{
UInt32 engagement = 0;
const UInt32 engagementCapable = 0x02;

try
{
engagement = (UInt32)Sensor.HumanPresenceSensorDeviceInfo[index].Properties[Constants.Properties["PKEY_Sensor_Proximity_SensorCapabilities"]];
}
catch {
engagement = 0;
}

if ((engagement & engagementCapable) != 0)
{
HumanEngagement engagedEnum = (HumanEngagement)sensorData.Readings[index].Value[0];
textBlockValue[i].Text = string.Format(" {0}", engagedEnum);
}
else
{
textBlockValue[i].Text = string.Format(" {0}", "Not Supported");
}
HumanEngagement engagedEnum = (HumanEngagement)sensorData.Readings[index].Value[0];
textBlockValue[i].Text = string.Format(" {0}", engagedEnum);

textBlockMinValue[i].Text = "";
textBlockMaxValue[i].Text = "";
}
Expand All @@ -644,6 +680,13 @@ public void UpdateText(SensorData sensorData)
textBlockMinValue[i].Text = "";
textBlockMaxValue[i].Text = "";
}
else if (sensorData.SensorType == Sensor.HUMANPRESENCESENSOR && sensorData.Property[i] == "IsOnlookerPresent")
{
HumanPresence onlookerEnum = (HumanPresence)sensorData.Readings[index].Value[2];
textBlockValue[i].Text = string.Format(" {0}", onlookerEnum);
textBlockMinValue[i].Text = "";
textBlockMaxValue[i].Text = "";
}
else if (sensorData.SensorType == Sensor.ACTIVITYSENSOR)
{
if (sensorData.Readings[index].Value[i] == Sensor.ACTIVITYNONE)
Expand Down
61 changes: 31 additions & 30 deletions sensors/Tools/SensorExplorer/SensorExplorer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<AssemblyName>SensorExplorer</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.22598.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.22598.0</TargetPlatformMinVersion>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.26100.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.26100.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Expand All @@ -22,7 +22,7 @@
</NuGetPackageImportStamp>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxBundle>Always</AppxBundle>
<AppxBundlePlatforms>x86|x64|arm</AppxBundlePlatforms>
<AppxBundlePlatforms>x86|x64|arm64</AppxBundlePlatforms>
<PackageCertificateThumbprint>
</PackageCertificateThumbprint>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
Expand Down Expand Up @@ -59,31 +59,6 @@
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
Expand Down Expand Up @@ -290,15 +265,41 @@
<Choose>
<When Condition="'$(Platform)' == 'x64'" />
<When Condition="'$(Platform)' == 'x86'" />
<When Condition="'$(Platform)' == 'ARM'" />
<When Condition="'$(Platform)' == 'ARM64'" />
</Choose>
<Target Name="SensorWrappersInclusion" AfterTargets="ResolveNuGetPackageAssets">
<PropertyGroup Condition="'$(PkgSensorWrappers_x64)' != '' or '$(PkgSensorWrappers_x86)' != '' or '$(PkgSensorWrappers_ARM)' != ''">
<PropertyGroup Condition="'$(PkgSensorWrappers_x64)' != '' or '$(PkgSensorWrappers_x86)' != '' or '$(PkgSensorWrappers_ARM64)' != ''">
<DefineConstants>$(DefineConstants);SENSORWRAPPERS</DefineConstants>
</PropertyGroup>
</Target>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn>;2008</NoWarn>
<NoStdLib>true</NoStdLib>
<DebugType>full</DebugType>
<PlatformTarget>ARM64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'">
<OutputPath>bin\ARM64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<NoStdLib>true</NoStdLib>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
</Project>
Loading

0 comments on commit 1e03fab

Please sign in to comment.