This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
syntax improvements and sanity checks
- Loading branch information
Showing
48 changed files
with
761 additions
and
565 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/com/team766/framework3/MechanismWithStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.team766.framework3; | ||
|
||
import com.team766.logging.LoggerExceptionUtils; | ||
import java.util.NoSuchElementException; | ||
|
||
public abstract class MechanismWithStatus<S extends Record & Status> extends Mechanism { | ||
private S status = null; | ||
|
||
public final S getStatus() { | ||
if (status == null) { | ||
throw new NoSuchElementException(getName() + " has not published a status yet"); | ||
} | ||
return status; | ||
} | ||
|
||
@Override | ||
/* package */ void periodicInternal() { | ||
try { | ||
status = reportStatus(); | ||
StatusBus.getInstance().publishStatus(status); | ||
} catch (Exception ex) { | ||
ex.printStackTrace(); | ||
LoggerExceptionUtils.logException(ex); | ||
return; | ||
} | ||
super.periodicInternal(); | ||
} | ||
|
||
protected abstract S reportStatus(); | ||
} |
Oops, something went wrong.