Class FaultCode
- java.lang.Object
-
- com.lightningrobotics.common.fault.FaultCode
-
public class FaultCode extends java.lang.ObjectError 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 booleandummyLightOn()static voideachCode(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 voidinit()Push each fault code to the dashboardstatic voidsetNetworkTableEntry(LightningFaultCodes.Code code, edu.wpi.first.networktables.NetworkTableEntry nte)Links aLightningFaultCodes.Codewith aNetworkTableEntrystatic java.lang.StringtoJSONString()Gets all the faults as a JSON Stringstatic voidupdate()Updates theNetworkTableEntryfor eachLightningFaultCodes.Code.static voidwrite(LightningFaultCodes.Code code)Writes the given fault codestatic voidwrite(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.Codewith aNetworkTableEntry- Parameters:
code- TheLightningFaultCodes.Codethat needs to be linked with an NT entrynte- TheNetworkTableEntryto 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.Codeto be written
-
update
public static void update()
Updates theNetworkTableEntryfor 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- TheBiConsumerfunction 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.Codeto 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
-
-