@@ -96,6 +96,12 @@ class SensorDisplay
9696 "HumanPresenceDetectionType" ,
9797 "Device ID" ,
9898 } ;
99+ private string [ ] presenceCapabilities = new string [ ]
100+ {
101+ "PresenceSupported" ,
102+ "EngagementSupported" ,
103+ "MaxDetectablePersons" ,
104+ } ;
99105 private StackPanel stackPanelBottom = new StackPanel ( ) { Orientation = Orientation . Horizontal } ;
100106 private StackPanel stackPanelBottomData = new StackPanel ( ) { Orientation = Orientation . Horizontal } ;
101107 private StackPanel stackPanelBottomRightCol = new StackPanel ( ) { Orientation = Orientation . Vertical } ;
@@ -124,6 +130,15 @@ class SensorDisplay
124130 private TextBlock [ ] textBlockPLDName ;
125131 private TextBlock [ ] textBlockPLDValue ;
126132
133+ // Presence Capabilities
134+ private Expander expanderPresenceCap = new Expander ( ) { Header = "Presence Capabilities" } ;
135+ private ScrollViewer scrollViewerPresenceCap = new ScrollViewer ( ) { HorizontalScrollBarVisibility = ScrollBarVisibility . Visible , VerticalScrollBarVisibility = ScrollBarVisibility . Visible } ;
136+ private StackPanel stackPanelPresenceCap = new StackPanel ( ) { Orientation = Orientation . Horizontal , Margin = new Thickness ( 20 ) } ;
137+ private StackPanel stackPanelPresenceCapName = new StackPanel ( ) { Orientation = Orientation . Vertical , Margin = new Thickness ( 10 , 10 , 0 , 10 ) } ;
138+ private StackPanel stackPanelPresenceCapValue = new StackPanel ( ) { Orientation = Orientation . Vertical , Margin = new Thickness ( 10 ) } ;
139+ private TextBlock [ ] textBlockPresenceCapName ;
140+ private TextBlock [ ] textBlockPresenceCapValue ;
141+
127142 public SensorDisplay ( int sensorType , int index , int totalIndex , int minValue , int maxValue , int scale , Color [ ] color )
128143 {
129144 SensorType = sensorType ;
@@ -139,6 +154,9 @@ public SensorDisplay(int sensorType, int index, int totalIndex, int minValue, in
139154 expanderPLD . Content = scrollViewerPLD ;
140155 scrollViewerPLD . Content = stackPanelPLD ;
141156
157+ expanderPresenceCap . Content = scrollViewerPresenceCap ;
158+ scrollViewerPresenceCap . Content = stackPanelPresenceCap ;
159+
142160 for ( int i = 0 ; i <= scale ; i ++ )
143161 {
144162 if ( sensorType == Sensor . ACTIVITYSENSOR )
@@ -258,6 +276,11 @@ public SensorDisplay(int sensorType, int index, int totalIndex, int minValue, in
258276 stackPanelMaxValue . Children . Add ( textBlockMaxValue [ i ] ) ;
259277 }
260278
279+ if ( sensorType == Sensor . HUMANPRESENCESENSOR )
280+ {
281+ stackPanelExpander . Children . Add ( expanderPresenceCap ) ;
282+ }
283+
261284 stackPanelExpander . Children . Add ( expanderProperty ) ;
262285 stackPanelExpander . Children . Add ( expanderPLD ) ;
263286 stackPanelBottom . Children . Add ( stackPanelExpander ) ;
@@ -343,6 +366,20 @@ public SensorDisplay(int sensorType, int index, int totalIndex, int minValue, in
343366 stackPanelPLD . Children . Add ( stackPanelPLDName ) ;
344367 stackPanelPLD . Children . Add ( stackPanelPLDValue ) ;
345368
369+ textBlockPresenceCapName = new TextBlock [ presenceCapabilities . Length ] ;
370+ textBlockPresenceCapValue = new TextBlock [ textBlockPresenceCapName . Length ] ;
371+
372+ for ( int i = 0 ; i < presenceCapabilities . Length ; i ++ )
373+ {
374+ textBlockPresenceCapName [ i ] = new TextBlock ( ) { Text = presenceCapabilities [ i ] , HorizontalAlignment = HorizontalAlignment . Left , VerticalAlignment = VerticalAlignment . Center } ;
375+ textBlockPresenceCapValue [ i ] = new TextBlock ( ) { Text = ( i == 0 ? "\r \n " : "" ) + " -" , HorizontalAlignment = HorizontalAlignment . Left , VerticalAlignment = VerticalAlignment . Center } ;
376+ stackPanelPresenceCapName . Children . Add ( textBlockPresenceCapName [ i ] ) ;
377+ stackPanelPresenceCapValue . Children . Add ( textBlockPresenceCapValue [ i ] ) ;
378+ }
379+
380+ stackPanelPresenceCap . Children . Add ( stackPanelPresenceCapName ) ;
381+ stackPanelPresenceCap . Children . Add ( stackPanelPresenceCapValue ) ;
382+
346383 StackPanelSensor . Children . Add ( StackPanelTop ) ;
347384 StackPanelSensor . Children . Add ( canvasSensor ) ;
348385 StackPanelSensor . Children . Add ( stackPanelBottom ) ;
@@ -370,6 +407,7 @@ public void SetWidth(double width, double height)
370407 canvasSensor . Width = width * 0.7 ;
371408 scrollViewerProperty . MaxWidth = width * 0.5 ;
372409 scrollViewerPLD . MaxWidth = width * 0.5 ;
410+ scrollViewerPresenceCap . MaxWidth = width * 0.5 ;
373411 }
374412
375413 private void SetFontSize ( double fontSize )
@@ -394,6 +432,12 @@ private void SetFontSize(double fontSize)
394432 textBlockPLDValue [ i ] . FontSize = fontSize ;
395433 }
396434
435+ for ( int i = 0 ; i < textBlockPresenceCapName . Length ; i ++ )
436+ {
437+ textBlockPresenceCapName [ i ] . FontSize = fontSize ;
438+ textBlockPresenceCapValue [ i ] . FontSize = fontSize ;
439+ }
440+
397441 TextBlock textBlock = new TextBlock ( ) { Text = "00000000" , FontSize = fontSize } ;
398442 textBlock . Measure ( new Size ( 200 , 200 ) ) ; // Assuming 200x200 is max size of textblock
399443 canvasSensor . Margin = new Thickness ( textBlock . DesiredSize . Width , textBlock . DesiredSize . Height , 0 , textBlock . DesiredSize . Height * 2 ) ;
@@ -406,6 +450,7 @@ public void SetHeight(double height)
406450 canvasSensor . Width = height ;
407451 scrollViewerProperty . MaxHeight = height ;
408452 scrollViewerPLD . MaxHeight = height ;
453+ scrollViewerPresenceCap . MaxHeight = height ;
409454 }
410455
411456 public void EnableSensor ( )
@@ -469,6 +514,13 @@ public void UpdatePLDProperty(SensorData sensorData)
469514 textBlockPLDValue [ 14 ] . Text = ( sensorData . PanelVisible == null ) ? "null" : sensorData . PanelVisible ;
470515 }
471516
517+ public void UpdatePresenceCapabilities ( SensorData sensorData )
518+ {
519+ textBlockPresenceCapValue [ 0 ] . Text = sensorData . PresenceSupported ? " Yes" : " No" ;
520+ textBlockPresenceCapValue [ 1 ] . Text = sensorData . EngagementSupported ? " Yes" : " No" ;
521+ textBlockPresenceCapValue [ 2 ] . Text = sensorData . MaxDetectablePersons . ToString ( ) ;
522+ }
523+
472524 public void UpdateText ( SensorData sensorData )
473525 {
474526 try
@@ -478,6 +530,7 @@ public void UpdateText(SensorData sensorData)
478530 {
479531 UpdateProperty ( sensorData ) ;
480532 UpdatePLDProperty ( sensorData ) ;
533+ UpdatePresenceCapabilities ( sensorData ) ;
481534 }
482535
483536 if ( StackPanelSensor . Visibility == Visibility . Visible )
@@ -614,26 +667,9 @@ public void UpdateText(SensorData sensorData)
614667 }
615668 else if ( sensorData . SensorType == Sensor . HUMANPRESENCESENSOR && sensorData . Property [ i ] == "IsEngaged" )
616669 {
617- UInt32 engagement = 0 ;
618- const UInt32 engagementCapable = 0x02 ;
619-
620- try
621- {
622- engagement = ( UInt32 ) Sensor . HumanPresenceSensorDeviceInfo [ index ] . Properties [ Constants . Properties [ "PKEY_Sensor_Proximity_SensorCapabilities" ] ] ;
623- }
624- catch {
625- engagement = 0 ;
626- }
627-
628- if ( ( engagement & engagementCapable ) != 0 )
629- {
630- HumanEngagement engagedEnum = ( HumanEngagement ) sensorData . Readings [ index ] . Value [ 0 ] ;
631- textBlockValue [ i ] . Text = string . Format ( " {0}" , engagedEnum ) ;
632- }
633- else
634- {
635- textBlockValue [ i ] . Text = string . Format ( " {0}" , "Not Supported" ) ;
636- }
670+ HumanEngagement engagedEnum = ( HumanEngagement ) sensorData . Readings [ index ] . Value [ 0 ] ;
671+ textBlockValue [ i ] . Text = string . Format ( " {0}" , engagedEnum ) ;
672+
637673 textBlockMinValue [ i ] . Text = "" ;
638674 textBlockMaxValue [ i ] . Text = "" ;
639675 }
@@ -644,6 +680,13 @@ public void UpdateText(SensorData sensorData)
644680 textBlockMinValue [ i ] . Text = "" ;
645681 textBlockMaxValue [ i ] . Text = "" ;
646682 }
683+ else if ( sensorData . SensorType == Sensor . HUMANPRESENCESENSOR && sensorData . Property [ i ] == "IsOnlookerPresent" )
684+ {
685+ HumanPresence onlookerEnum = ( HumanPresence ) sensorData . Readings [ index ] . Value [ 2 ] ;
686+ textBlockValue [ i ] . Text = string . Format ( " {0}" , onlookerEnum ) ;
687+ textBlockMinValue [ i ] . Text = "" ;
688+ textBlockMaxValue [ i ] . Text = "" ;
689+ }
647690 else if ( sensorData . SensorType == Sensor . ACTIVITYSENSOR )
648691 {
649692 if ( sensorData . Readings [ index ] . Value [ i ] == Sensor . ACTIVITYNONE )
0 commit comments