sensors

class AbsoluteRotaryEncoder(target: RotatingObject)

Bases: SensorBase

AbsoluteRotaryEncoder object.

Attributes

targetRotatingObject

Target rotating object whose angular position is probed by the sensor.

Methods

get_value()

It gets the angular position of the target rotating object.

get_value(unit: str | None = None) AngularPosition | float | int

It gets the angular position of the target rotating object.

If a unit is set, then it converts the angular position to that unit and returns only the numerical value as float or integer.

Parameters

unitstr, optional

The unit to which convert the target angular position. If specified, it converts the angular position and returns only the numerical value as float or integer, otherwise it returns an AngularPosition. Default is None, so it returns an AngularPosition.

Returns

AngularPosition or float or int

Angular position of the target rotating object.

Raises

TypeError

If unit is not a str.

property target: RotatingObject

Target rotating object whose angular position is probed by the sensor.

Returns

RotatingObject

Target rotating object whose angular position is probed by the sensor.

Raises

TypeError

If target is not an instance of RotatingObject.

class Amperometer(target: MotorBase)

Bases: SensorBase

Amperometer object.

Attributes

targetMotorBase

Target motor object whose electric current is probed by the sensor.

Methods

get_value()

It gets the electric current of the target motor object.

get_value(unit: str | None = None) Current | float | int

It gets the electric current of the target motor object.

If a unit is set, then it converts the electric current to that unit and returns only the numerical value as float or integer.

Parameters

unitstr, optional

The unit to which convert the target electric current. If specified, it converts the electric current and returns only the numerical value as float or integer, otherwise it returns a Current. Default is None, so it returns a Current.

Returns

Current or float`or :py:class:`int

Electric Current of the target motor object.

Raises

TypeError

If unit is not a str.

property target: MotorBase

Target motor object whose electric current is probed by the sensor.

Returns

MotorBase

Target motor object whose electric current is probed by the sensor.

Raises

TypeError

If target is not an instance of MotorBase.

class SensorBase

Bases: ABC

SensorBase object.

Abstract base class for creating sensor objects.

abstract get_value() UnitBase | float | int
abstract property target: RotatingObject
class Tachometer(target: RotatingObject)

Bases: SensorBase

Tachometer object.

Attributes

targetRotatingObject

Target rotating object whose angular speed is probed by the sensor.

Methods

get_value()

It gets the angular speed of the target rotating object.

get_value(unit: str | None = None) AngularSpeed | float | int

It gets the angular speed of the target rotating object.

If a unit is set, then it converts the angular speed to that unit and returns only the numerical value as float or integer.

Parameters

unitstr, optional

The unit to which convert the target angular speed. If specified, it converts the angular speed and returns only the numerical value as float or integer, otherwise it returns an AngularSpeed. Default is None, so it returns an AngularSpeed.

Returns

AngularSpeed or float or int

Angular speed of the target rotating object.

Raises

TypeError

If unit is not a str.

property target: RotatingObject

Target rotating object whose angular speed is probed by the sensor.

Returns

RotatingObject

Target rotating object whose angular speed is probed by the sensor.

Raises

TypeError

If target is not an instance of RotatingObject.

class Timer(start_time: Time, duration: TimeInterval)

Bases: object

Timer object.

Attributes

start_timeTime

Start time after which the timer is active.

durationTimeInterval

Time duration of the timer, starting from start_time

Methods

is_active()

It checks if the simulation current_time is greater than or equal to start_time but lower than or equal to the sum of current_time and duration.

property duration: TimeInterval

Time duration of the timer, starting from start_time.

Returns

TimeInterval

Time duration of the timer, starting from start_time

Raises

TypeError

If duration is not an instance of TimeInterval.

is_active(current_time: Time) bool

It checks if the simulation current_time is greater than or equal to start_time but lower than or equal to the sum of current_time and duration.

Parameters

current_timeTime

Current time of the simulation, to be compared with start_time and duration.

Returns

bool

Whether current_time is greater than or equal to start_time but lower than or equal to the sum of start_time and duration.

Raises

TypeError

If current_time is not an instance of Time.

property start_time: Time

Start time after which the timer is active.

Returns

Time

Start time after which the timer is active.

Raises

TypeError

If start_time is not an instance of Time.