@@ -127,9 +127,22 @@ public MainWindow()
127127 AddSimpleEntryListener ( CommandoDashNT . GetSubTable ( "SensorData" ) . GetEntry ( "isCentric" ) , new Action ( ( ) =>
128128 IsCentricSB . IsActive = CommandoDashNT . GetSubTable ( "SensorData" ) . GetEntry ( "isCentric" ) . GetBoolean ( true ) ) ) ;
129129
130+ //Update Index Spot 1
131+ AddSimpleEntryListener ( CommandoDashNT . GetSubTable ( "SensorData" ) . GetEntry ( "indexSpot1HasCargo" ) , new Action ( ( ) => updateIndexSpot1 ( ) ) ) ;
132+
133+ //Update Index Spot 2
134+ AddSimpleEntryListener ( CommandoDashNT . GetSubTable ( "SensorData" ) . GetEntry ( "indexSpot2HasCargo" ) , new Action ( ( ) => updateIndexSpot2 ( ) ) ) ;
135+
136+ //Update Intake Spot
137+ AddSimpleEntryListener ( CommandoDashNT . GetSubTable ( "SensorData" ) . GetEntry ( "intakeSpotHasCargo" ) , new Action ( ( ) => updateIntakeSpot ( ) ) ) ;
138+
130139 //AutoLayouts
140+
141+ //Update Robot Field2d position
131142 AddSimpleEntryListener ( ntInst . GetTable ( "SmartDashboard" ) . GetSubTable ( "Field" ) . GetEntry ( "Robot" ) , new Action ( ( ) => updateRobotPosition ( ) ) ) ;
132143
144+ //Update Cargo Field2d position
145+ AddSimpleEntryListener ( ntInst . GetTable ( "SmartDashboard" ) . GetSubTable ( "Field" ) . GetEntry ( "SeenCargo" ) , new Action ( ( ) => updateCargoPosition ( ) ) ) ;
133146 }
134147
135148 public void defaultStates ( )
@@ -252,6 +265,18 @@ private void alliance_Update()
252265 HoundSeesTargetSB . ActiveBrush = ( Brush ) this . Resources [ "HoundRedHounding" ] ;
253266 HoundSeesTargetSB . InactiveBrush = ( Brush ) this . Resources [ "HoundRedDefault" ] ;
254267 HoundSeesTargetSB . BorderBrush = ( Brush ) this . Resources [ "HoundRedBorder" ] ;
268+
269+ FieldCargo . ImageSource = new BitmapImage ( new Uri ( "Images/Red_Cargo.png" , UriKind . Relative ) ) ;
270+ FieldImageScale . ScaleX = - 1 ;
271+ FieldImageScale . ScaleY = 1 ;
272+
273+ IndexCargo1Image . Source = new BitmapImage ( new Uri ( "Images/Red_Cargo.png" , UriKind . Relative ) ) ;
274+ IndexCargo2Image . Source = new BitmapImage ( new Uri ( "Images/Red_Cargo.png" , UriKind . Relative ) ) ;
275+ IntakeCargoImage . Source = new BitmapImage ( new Uri ( "Images/Red_Cargo.png" , UriKind . Relative ) ) ;
276+
277+ IndexSpot1SB . ActiveBrush = ( Brush ) this . Resources [ "IndexRedEnabled" ] ;
278+ IndexSpot2SB . ActiveBrush = ( Brush ) this . Resources [ "IndexRedEnabled" ] ;
279+ IntakeSpotSB . ActiveBrush = ( Brush ) this . Resources [ "IndexRedEnabled" ] ;
255280 } else
256281 {
257282 HoundHoundingTargetSB . ActiveBrush = ( Brush ) this . Resources [ "HoundBlueHounding" ] ;
@@ -260,6 +285,18 @@ private void alliance_Update()
260285 HoundSeesTargetSB . ActiveBrush = ( Brush ) this . Resources [ "HoundBlueHounding" ] ;
261286 HoundSeesTargetSB . InactiveBrush = ( Brush ) this . Resources [ "HoundBlueDefault" ] ;
262287 HoundSeesTargetSB . BorderBrush = ( Brush ) this . Resources [ "HoundBlueBorder" ] ;
288+
289+ FieldCargo . ImageSource = new BitmapImage ( new Uri ( "Images/Blue_Cargo.png" , UriKind . Relative ) ) ;
290+ FieldImageScale . ScaleX = 1 ;
291+ FieldImageScale . ScaleY = - 1 ;
292+
293+ IndexCargo1Image . Source = new BitmapImage ( new Uri ( "Images/Blue_Cargo.png" , UriKind . Relative ) ) ;
294+ IndexCargo2Image . Source = new BitmapImage ( new Uri ( "Images/Blue_Cargo.png" , UriKind . Relative ) ) ;
295+ IntakeCargoImage . Source = new BitmapImage ( new Uri ( "Images/Blue_Cargo.png" , UriKind . Relative ) ) ;
296+
297+ IndexSpot1SB . ActiveBrush = ( Brush ) this . Resources [ "IndexBlueEnabled" ] ;
298+ IndexSpot2SB . ActiveBrush = ( Brush ) this . Resources [ "IndexBlueEnabled" ] ;
299+ IntakeSpotSB . ActiveBrush = ( Brush ) this . Resources [ "IndexBlueEnabled" ] ;
263300 }
264301
265302 }
@@ -343,7 +380,60 @@ private void updateRobotPosition()
343380 RobotXText . Text = Math . Round ( robotXMeters , 4 ) . ToString ( ) + "m" ;
344381 RobotYText . Text = Math . Round ( robotYMeters , 4 ) . ToString ( ) + "m" ;
345382 RobotRText . Text = Math . Round ( robotRDegrees , 4 ) . ToString ( ) + "°" ;
383+ }
384+
385+ private void updateCargoPosition ( )
386+ {
387+ Thickness cargoMargin = CargoRectangle . Margin ;
388+ double cargoXMeters = ntInst . GetTable ( "SmartDashboard" ) . GetSubTable ( "Field" ) . GetEntry ( "SeenCargo" ) . GetDoubleArray ( new double [ 3 ] { 0 , 0 , 0 } ) [ 0 ] ;
389+ double cargoYMeters = ntInst . GetTable ( "SmartDashboard" ) . GetSubTable ( "Field" ) . GetEntry ( "SeenCargo" ) . GetDoubleArray ( new double [ 3 ] { 0 , 0 , 0 } ) [ 1 ] ;
390+ cargoMargin . Left = ( cargoXMeters * ( Field . Width / 16.4592 ) ) - 15 ;
391+ cargoMargin . Top = ( cargoYMeters * ( Field . Height / 8.2296 ) ) - 15 ;
392+ CargoRectangle . Margin = cargoMargin ;
393+
394+ CargoXText . Text = Math . Round ( cargoXMeters , 4 ) . ToString ( ) + "m" ;
395+ CargoYText . Text = Math . Round ( cargoYMeters , 4 ) . ToString ( ) + "m" ;
396+ }
397+
398+ private void updateIndexSpot1 ( )
399+ {
400+ Boolean spotHasCargo = CommandoDashNT . GetSubTable ( "SensorData" ) . GetEntry ( "indexSpot1HasCargo" ) . GetBoolean ( false ) ;
401+ if ( spotHasCargo )
402+ {
403+ IndexCargo1Image . Visibility = Visibility . Visible ;
404+ } else
405+ {
406+ IndexCargo1Image . Visibility = Visibility . Hidden ;
407+ }
408+ IndexSpot1SB . IsActive = spotHasCargo ;
409+ }
410+
411+ private void updateIndexSpot2 ( )
412+ {
413+ Boolean spotHasCargo = CommandoDashNT . GetSubTable ( "SensorData" ) . GetEntry ( "indexSpot2HasCargo" ) . GetBoolean ( false ) ;
414+ if ( spotHasCargo )
415+ {
416+ IndexCargo2Image . Visibility = Visibility . Visible ;
417+ }
418+ else
419+ {
420+ IndexCargo2Image . Visibility = Visibility . Hidden ;
421+ }
422+ IndexSpot2SB . IsActive = spotHasCargo ;
423+ }
346424
425+ private void updateIntakeSpot ( )
426+ {
427+ Boolean spotHasCargo = CommandoDashNT . GetSubTable ( "SensorData" ) . GetEntry ( "intakeSpotHasCargo" ) . GetBoolean ( false ) ;
428+ if ( spotHasCargo )
429+ {
430+ IntakeCargoImage . Visibility = Visibility . Visible ;
431+ }
432+ else
433+ {
434+ IntakeCargoImage . Visibility = Visibility . Hidden ;
435+ }
436+ IntakeSpotSB . IsActive = spotHasCargo ;
347437 }
348438
349439
0 commit comments