Package me.autobot.lib.robot
Class Device
java.lang.Object
me.autobot.lib.robot.Device
- All Implemented Interfaces:
Logger
Some sort of device that can be attached to a robot.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Called to emergency stop the device.static void
Emergency stops all devices.void
Enable simulation mode for the device.double
Get the current of the device (if applicable).protected Robot
Get the parent of the device.Returns the properties of the device.double
getProperty
(String key) Get a property of the device.double
Get the voltage of the device (if applicable).boolean
Check if the device is in simulation mode.static void
registerDevice
(Device device) Registers a device.void
Set the parent of the device, i.e what robot the device is attached to.void
setProperty
(String key, double value) Sets a property of the device.
-
Field Details
-
devices
List of all devices.
-
-
Constructor Details
-
Device
public Device()Creates a new device.
-
-
Method Details
-
registerDevice
Registers a device.- Parameters:
device
- The device to register.
-
emergencyStopAll
public static void emergencyStopAll()Emergency stops all devices. Used in emergencies. -
setProperty
Sets a property of the device.- Parameters:
key
- The key of the property.value
- The value of the property.
-
getProperties
Returns the properties of the device.- Returns:
- The properties of the device.
-
getProperty
Get a property of the device.- Parameters:
key
- The key of the property.- Returns:
- The value of the property.
-
getVoltage
public double getVoltage()Get the voltage of the device (if applicable).- Returns:
- The voltage of the device.
-
getCurrent
public double getCurrent()Get the current of the device (if applicable).- Returns:
- The current of the device.
-
emergencyStop
public void emergencyStop()Called to emergency stop the device. This means: stop all motors, turn off all LEDs, etc. Literally stop everything. -
setParent
Set the parent of the device, i.e what robot the device is attached to.- Parameters:
parent
- The parent of the device.
-
enableSimulation
public void enableSimulation()Enable simulation mode for the device. -
inSimulation
public boolean inSimulation()Check if the device is in simulation mode.- Returns:
- true if the device is in simulation mode.
-
getParent
Get the parent of the device.- Returns:
- The parent of the device.
-