@@ -377,6 +377,7 @@ def startCompetition(self) -> None:
377377
378378 def endCompetition (self ) -> None :
379379 self .__done = True
380+ self ._automodes .endCompetition ()
380381
381382 def autonomous (self ) -> None :
382383 """
@@ -434,9 +435,17 @@ def _disabled(self) -> None:
434435 self .onException (forceReport = True )
435436 watchdog .addEpoch ("disabledInit()" )
436437
438+ refreshData = wpilib .DriverStation .refreshData
439+ DSControlWord = wpilib .DSControlWord
440+
437441 with NotifierDelay (self .control_loop_wait_time ) as delay :
438- while not self .__done and self .isDisabled ():
439- if ds_attached != self .__is_ds_attached ():
442+ while not self .__done :
443+ refreshData ()
444+ cw = DSControlWord ()
445+ if cw .isEnabled ():
446+ break
447+
448+ if ds_attached != cw .isDSAttached ():
440449 ds_attached = not ds_attached
441450 self .__nt_put_is_ds_attached (ds_attached )
442451
@@ -484,9 +493,15 @@ def _operatorControl(self) -> None:
484493 watchdog .addEpoch ("teleopInit()" )
485494
486495 observe = hal .observeUserProgramTeleop
496+ refreshData = wpilib .DriverStation .refreshData
497+ isTeleopEnabled = wpilib .DriverStation .isTeleopEnabled
487498
488499 with NotifierDelay (self .control_loop_wait_time ) as delay :
489- while not self .__done and self .isTeleopEnabled ():
500+ while not self .__done :
501+ refreshData ()
502+ if not isTeleopEnabled ():
503+ break
504+
490505 observe ()
491506 try :
492507 self .teleopPeriodic ()
@@ -526,8 +541,16 @@ def _test(self) -> None:
526541 self .onException (forceReport = True )
527542 watchdog .addEpoch ("testInit()" )
528543
544+ refreshData = wpilib .DriverStation .refreshData
545+ DSControlWord = wpilib .DSControlWord
546+
529547 with NotifierDelay (self .control_loop_wait_time ) as delay :
530- while not self .__done and self .isTest () and self .isEnabled ():
548+ while not self .__done :
549+ refreshData ()
550+ cw = DSControlWord ()
551+ if not (cw .isTest () and cw .isEnabled ()):
552+ break
553+
531554 hal .observeUserProgramTest ()
532555 try :
533556 self .testPeriodic ()
0 commit comments