Twomag Api
This module holds the API for the 2Mag device.
ATTRIBUTE | DESCRIPTION |
---|---|
READ_FORMAT |
The read format for the device
TYPE:
|
WRITE_FORMAT |
The write format for the device
TYPE:
|
Data |
The data type for the device
TYPE:
|
CLASS | DESCRIPTION |
---|---|
TwoMagDevice |
Class for the 2Mag device |
Documentation last updated: 2025-02-22
TwoMagDevice
TwoMagDevice(
port: str | None = None,
baudrate: int = 9600,
timeout: int = 1,
*,
init_timeout: int = 5,
data_type: NamedTuple = Data,
read_format: str = READ_FORMAT,
write_format: str = WRITE_FORMAT,
simulation: bool = False,
verbose: bool = False,
**kwargs,
)
Bases: SerialDevice
Class for the 2Mag device
ATTRIBUTE | DESCRIPTION |
---|---|
address |
The address of the device
TYPE:
|
version |
The version of the device
TYPE:
|
mode |
The mode of the device
TYPE:
|
speed |
The speed of the device in RPM
TYPE:
|
power |
The power of the device in percentage
TYPE:
|
connection_details |
connection details for the device
TYPE:
|
device |
device object that communicates with physical tool
TYPE:
|
flags |
flags for the class
TYPE:
|
is_busy |
whether the device is busy
TYPE:
|
is_connected |
whether the device is connected
TYPE:
|
verbose |
verbosity of class
TYPE:
|
METHOD | DESCRIPTION |
---|---|
connect |
connect to the device |
disconnect |
disconnect from the device |
execute |
execute task |
resetFlags |
reset all flags to class attribute _default_flags |
run |
alias for execute() |
shutdown |
shutdown procedure for tool |
getPower |
get the power of the device |
getSpeed |
get the speed of the device |
getStatus |
get the status of the device |
setDefault |
set the device to default |
setPower |
set the power of the device |
setSpeed |
set the speed of the device |
start |
start the device |
stop |
stop the device |
Initialize the 2Mag device
PARAMETER | DESCRIPTION |
---|---|
port
|
The port to which the device is connected. Defaults to None.
TYPE:
|
baudrate
|
The baudrate of the device. Defaults to 9600.
TYPE:
|
timeout
|
The timeout for the device. Defaults to 1.
TYPE:
|
init_timeout
|
The timeout for initialization. Defaults to 5.
TYPE:
|
data_type
|
The data type for the device. Defaults to Data.
TYPE:
|
read_format
|
The read format for the device. Defaults to READ_FORMAT.
TYPE:
|
write_format
|
The write format for the device. Defaults to WRITE_FORMAT.
TYPE:
|
simulation
|
Whether to simulate the device. Defaults to False.
TYPE:
|
verbose
|
Whether to print out debug information. Defaults to False.
TYPE:
|
getPower
Get the power of the device
RETURNS | DESCRIPTION |
---|---|
int
|
The power of the device in percentage
TYPE:
|
getSpeed
Get the speed of the device
RETURNS | DESCRIPTION |
---|---|
int
|
The speed of the device in RPM
TYPE:
|
getStatus
Get the status of the device
RETURNS | DESCRIPTION |
---|---|
tuple[str, str]
|
tuple[str,str]: The version and mode of the device |
query
query(
data: Any,
multi_out: bool = False,
*,
timeout: int | float = 0.3,
format_in: str | None = None,
format_out: str | None = None,
data_type: NamedTuple | None = None,
timestamp: bool = False,
**kwargs,
) -> Any
Query the device
PARAMETER | DESCRIPTION |
---|---|
data
|
The data to query
TYPE:
|
multi_out
|
Whether to return multiple outputs. Defaults to False.
TYPE:
|
timeout
|
The timeout for the query. Defaults to 0.3.
TYPE:
|
format_in
|
The format of the input. Defaults to None.
TYPE:
|
format_out
|
The format of the output. Defaults to None.
TYPE:
|
data_type
|
The data type of the output. Defaults to None.
TYPE:
|
timestamp
|
Whether to timestamp the query. Defaults to False.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Any
|
The output of the query
TYPE:
|
setAddress
Set the address of the device
PARAMETER | DESCRIPTION |
---|---|
address
|
The address to set the device to
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
Whether the address was set
TYPE:
|
setDefault
Set the device to default
RETURNS | DESCRIPTION |
---|---|
bool
|
Whether the device was set to default
TYPE:
|
setPower
Set the power of the device
PARAMETER | DESCRIPTION |
---|---|
power
|
The power to set the device to in percentage
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
int
|
The power of the device in percentage
TYPE:
|
setSpeed
Set the speed of the device
PARAMETER | DESCRIPTION |
---|---|
speed
|
The speed to set the device to in RPM
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
int
|
The speed of the device in RPM
TYPE:
|
start
Start the device
RETURNS | DESCRIPTION |
---|---|
bool
|
Whether the device was started
TYPE:
|