Class FaultCode
- java.lang.Object
-
- com.lightningrobotics.common.fault.FaultCode
-
public class FaultCode extends java.lang.Object
Error codes for robot and means to log them
-
-
Constructor Summary
Constructors Constructor Description FaultCode()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
dummyLightOn()
static void
eachCode(java.util.function.BiConsumer<LightningFaultCodes.Code,java.lang.Boolean> fn)
Runs the given function on each code.static java.util.Map<java.lang.String,java.lang.Object>
getModel()
Gets a model of the faults and their states as well as the timestampstatic void
init()
Push each fault code to the dashboardstatic void
setNetworkTableEntry(LightningFaultCodes.Code code, edu.wpi.first.networktables.NetworkTableEntry nte)
Links aLightningFaultCodes.Code
with aNetworkTableEntry
static java.lang.String
toJSONString()
Gets all the faults as a JSON Stringstatic void
update()
Updates theNetworkTableEntry
for eachLightningFaultCodes.Code
.static void
write(LightningFaultCodes.Code code)
Writes the given fault codestatic void
write(LightningFaultCodes.Code code, java.lang.String msg)
Writes the fault code, effectively logging that it has been detected in a log file and the system error stream.
-
-
-
Method Detail
-
setNetworkTableEntry
public static void setNetworkTableEntry(LightningFaultCodes.Code code, edu.wpi.first.networktables.NetworkTableEntry nte)
Links aLightningFaultCodes.Code
with aNetworkTableEntry
- Parameters:
code
- TheLightningFaultCodes.Code
that needs to be linked with an NT entrynte
- TheNetworkTableEntry
to link the fault to
-
init
public static void init()
Push each fault code to the dashboard
-
write
public static void write(LightningFaultCodes.Code code)
Writes the given fault code- Parameters:
code
- TheLightningFaultCodes.Code
to be written
-
update
public static void update()
Updates theNetworkTableEntry
for eachLightningFaultCodes.Code
.
-
eachCode
public static void eachCode(java.util.function.BiConsumer<LightningFaultCodes.Code,java.lang.Boolean> fn)
Runs the given function on each code.- Parameters:
fn
- TheBiConsumer
function to perform on each code. The function should take a code and state (true or false) as parameters.
-
write
public static void write(LightningFaultCodes.Code code, java.lang.String msg)
Writes the fault code, effectively logging that it has been detected in a log file and the system error stream. Perupdate()
, they will be updated automatically onShuffleboard
- Parameters:
code
- TheLightningFaultCodes.Code
to be writtenmsg
- The message to write to the log file
-
dummyLightOn
public boolean dummyLightOn()
-
toJSONString
public static java.lang.String toJSONString()
Gets all the faults as a JSON String- Returns:
- The faults in JSON format
-
getModel
public static java.util.Map<java.lang.String,java.lang.Object> getModel()
Gets a model of the faults and their states as well as the timestamp- Returns:
- The model of faults
-
-