| Description | Hierarchy | Fields | Methods | Properties |
type TBatterySensor = class(TSensor)
Class implementing a simple battery sensor. TBatterySensor implements a sensor that provides a way to monitor an energy source (see TEnergySource). The definition of the sensor should be placed in the robot definition file, within the definition of the body (see TRobot.Body). In Table 1 an example definition is shown where the sensor is connected to an energy source with the name "Battery".
Table 1: Example definition of a battery (energy source).
|
object MyBatterySensor:
TBatterySensor CorrespondingBatteryName = 'Battery' end |
![]() |
constructor CreateAndSet(Sensor: TSensor); override; |
![]() |
function Copy: TSensor; override; |
![]() |
procedure LoadFromDefinition(ObjDef: TObjectDefinition); override; |
![]() |
procedure MapBattery(Battery: TEnergySource); |
![]() |
procedure Reset; override; |
![]() |
procedure UpdateReading(Arena: TArena); override; |
![]() |
constructor CreateAndSet(Sensor: TSensor); override; |
Copy constructor. The copy constructor copies everything except the reference to the monitored energy source which is set by calling MapBattery.
![]() |
function Copy: TSensor; override; |
Creates a copy by calling the copy constructor CreateAndSet.
![]() |
procedure LoadFromDefinition(ObjDef: TObjectDefinition); override; |
Loads the properties from the definition file.
![]() |
procedure MapBattery(Battery: TEnergySource); |
Sets the reference to the monitored energy source. This procedure is called automatically during the initialization of the robot's body (see TBody.Initialize). The user is not required to call this procedure explicitly.
![]() |
procedure Reset; override; |
This procedure is currently empty since there are no variables in this class that needs to be reset. It is called automatically in TBody.Reset.
![]() |
procedure UpdateReading(Arena: TArena); override; |
Updates the current reading by calling TEnergySource.Level.
![]() |
property CorrespondingBattery: TEnergySource; |
![]() |
property CorrespondingBatteryName: string; |
![]() |
property CorrespondingBattery: TEnergySource; |
Reference to the energy source that is being monitored.
![]() |
property CorrespondingBatteryName: string; |
Name of the energy source that is being monitored.