pnpq.apt package#
Submodules#
pnpq.apt.connection module#
- class pnpq.apt.connection.AptConnection(*, serial_number: str, baudrate: int = 115200, bytesize: int = 8, exclusive: bool = True, parity: str = 'N', rtscts: bool = True, stopbits: int = 1, timeout: None | int = None, rx_dispatcher_thread_lock: _thread.lock = <factory>, rx_dispatcher_subscribers: dict[int, queue.Queue[pnpq.apt.protocol.AptMessage]] = <factory>, rx_dispatcher_subscribers_lock: _thread.lock = <factory>, tx_connection_lock: _thread.lock = <factory>, tx_ordered_sender_awaiting_reply: threading.Event = <factory>, tx_ordered_sender_queue: queue.Queue[typing.Tuple[pnpq.apt.protocol.AptMessage, typing.Optional[typing.Callable[[pnpq.apt.protocol.AptMessage], bool]], None | queue.Queue[pnpq.apt.protocol.AptMessage]]] = <factory>, tx_ordered_sender_thread_lock: _thread.lock = <factory>, stop_event: threading.Event = <factory>)#
Bases:
object
- Parameters:
serial_number (str)
baudrate (int)
bytesize (int)
exclusive (bool)
parity (str)
rtscts (bool)
stopbits (int)
timeout (None | int)
rx_dispatcher_thread_lock (lock)
rx_dispatcher_subscribers (dict[int, Queue[AptMessage]])
rx_dispatcher_subscribers_lock (lock)
tx_connection_lock (lock)
tx_ordered_sender_awaiting_reply (Event)
tx_ordered_sender_queue (Queue[Tuple[AptMessage, None | Callable[[AptMessage], bool], None | Queue[AptMessage]]])
tx_ordered_sender_thread_lock (lock)
stop_event (Event)
- baudrate: int = 115200#
- bytesize: int = 8#
- close()#
- Return type:
None
- connection: Serial#
- exclusive: bool = True#
- is_closed()#
- Return type:
bool
- log = <BoundLoggerLazyProxy(logger=None, wrapper_class=None, processors=None, context_class=None, initial_values={}, logger_factory_args=())>#
- open()#
- Return type:
None
- parity: str = 'N'#
- rtscts: bool = True#
- rx_dispatch()#
- Return type:
None
- rx_dispatcher_subscribers: dict[int, Queue[AptMessage]]#
- rx_dispatcher_subscribers_lock: lock#
- rx_dispatcher_thread: Thread#
- rx_dispatcher_thread_lock: lock#
- rx_subscribe()#
- Return type:
Iterator[Queue[AptMessage]]
- send_message_expect_reply(message, match_reply)#
Send a message and block until an expected reply is received.
message: AptMessage - The message to send
match_reply: Callable - A function that returns True if a received message should be recognized as a reply to this message, and False otherwise.
- Parameters:
message (AptMessage)
match_reply (Callable[[AptMessage], bool])
- Return type:
- send_message_no_reply(message)#
Send a message and return immediately, without waiting for any reply.
- Parameters:
message (AptMessage)
- Return type:
None
- send_message_unordered(message)#
Send a message as soon as the connection lock will allow, bypassing the message queue. This allows us to poll for status messages while the main message thread is blocked waiting for a reply.
- Parameters:
message (AptMessage)
- Return type:
None
- serial_number: str#
- stop_event: Event#
- stopbits: int = 1#
- timeout: None | int = None#
- tx_connection_lock: lock#
- tx_ordered_send()#
- Return type:
None
- tx_ordered_sender_awaiting_reply: Event#
- tx_ordered_sender_queue: Queue[Tuple[AptMessage, None | Callable[[AptMessage], bool], None | Queue[AptMessage]]]#
- tx_ordered_sender_thread: Thread#
- tx_ordered_sender_thread_lock: lock#
pnpq.apt.protocol module#
- class pnpq.apt.protocol.ATS(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
StrEnum
ATS = Apt To Struct
Map Python struct format strings to the names used by the APT documentation. Unfortunately, those names are not used consistently.
- BYTE = 'b'#
- CHAR = 'c'#
- CHAR_N = 's'#
- DWORD = 'I'#
- LONG = 'i'#
- SHORT = 'h'#
- U_BYTE = 'B'#
- WORD = 'H'#
- class pnpq.apt.protocol.Address(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
int
,Enum
- BAY_0 = 33#
- BAY_1 = 34#
- BAY_2 = 35#
- BAY_3 = 36#
- BAY_4 = 37#
- BAY_5 = 38#
- BAY_6 = 39#
- BAY_7 = 40#
- BAY_8 = 41#
- BAY_9 = 42#
- GENERIC_USB = 80#
- HOST_CONTROLLER = 1#
- RACK_CONTROLLER = 17#
- class pnpq.apt.protocol.AptMessage(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address)#
Bases:
ABC
- abstract property destination_serialization: int#
- abstract classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
Self
- message_id: ClassVar[AptMessageId]#
- abstract to_bytes()#
- Return type:
bytes
- class pnpq.apt.protocol.AptMessageForStreamParsing(*, message_id, data_length)#
Bases:
object
This is used to parse streams of incoming messages and understand if they are header-only or data-attached messages. Note that it does NOT implement the AptMessage abstract base class.
- Parameters:
message_id (int)
data_length (int)
- data_length: int#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
Self
- header_struct: ClassVar[Struct] = Struct('<HH2B')#
- message_id: int#
- class pnpq.apt.protocol.AptMessageHeaderOnly(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address)#
Bases:
AptMessage
- property destination_serialization: int#
- class pnpq.apt.protocol.AptMessageHeaderOnlyChanEnableState(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, enable_state: pnpq.apt.protocol.EnableState)#
Bases:
AptMessageHeaderOnly
- Parameters:
destination (Address)
source (Address)
chan_ident (ChanIdent)
enable_state (EnableState)
- enable_state: EnableState#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
Self
- message_struct: ClassVar[Struct] = Struct('<H2B2B')#
- to_bytes()#
- Return type:
bytes
- class pnpq.apt.protocol.AptMessageHeaderOnlyChanIdent(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnly
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
Self
- message_struct: ClassVar[Struct] = Struct('<HBc2B')#
- param2: bytes = b'\x00'#
- to_bytes()#
- Return type:
bytes
- class pnpq.apt.protocol.AptMessageHeaderOnlyNoParams(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, param1: bytes = b'\x00', param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnly
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
Self
- message_struct: ClassVar[Struct] = Struct('<H2c2B')#
- param1: bytes = b'\x00'#
- param2: bytes = b'\x00'#
- to_bytes()#
- Return type:
bytes
- class pnpq.apt.protocol.AptMessageId(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
int
,Enum
- MGMSG_HW_DISCONNECT = 2#
- MGMSG_HW_GET_INFO = 6#
- MGMSG_HW_REQ_INFO = 5#
- MGMSG_HW_START_UPDATEMSGS = 17#
- MGMSG_HW_STOP_UPDATEMSGS = 18#
- MGMSG_MOD_GET_CHANENABLESTATE = 530#
- MGMSG_MOD_IDENTIFY = 547#
- MGMSG_MOD_REQ_CHANENABLESTATE = 529#
- MGMSG_MOD_SET_CHANENABLESTATE = 528#
- MGMSG_MOT_ACK_USTATUSUPDATE = 1170#
- MGMSG_MOT_GET_HOMEPARAMS = 1090#
- MGMSG_MOT_GET_JOGPARAMS = 1048#
- MGMSG_MOT_GET_POSCOUNTER = 1042#
- MGMSG_MOT_GET_STATUSUPDATE = 1153#
- MGMSG_MOT_GET_USTATUSUPDATE = 1169#
- MGMSG_MOT_GET_VELPARAMS = 1045#
- MGMSG_MOT_MOVE_ABSOLUTE = 1107#
- MGMSG_MOT_MOVE_COMPLETED = 1124#
- MGMSG_MOT_MOVE_HOME = 1091#
- MGMSG_MOT_MOVE_HOMED = 1092#
- MGMSG_MOT_MOVE_JOG = 1130#
- MGMSG_MOT_MOVE_STOP = 1125#
- MGMSG_MOT_MOVE_STOPPED = 1126#
- MGMSG_MOT_REQ_HOMEPARAMS = 1089#
- MGMSG_MOT_REQ_JOGPARAMS = 1047#
- MGMSG_MOT_REQ_POSCOUNTER = 1041#
- MGMSG_MOT_REQ_STATUSUPDATE = 1152#
- MGMSG_MOT_REQ_USTATUSUPDATE = 1168#
- MGMSG_MOT_REQ_VELPARAMS = 1044#
- MGMSG_MOT_RESUME_ENDOFMOVEMSGS = 1132#
- MGMSG_MOT_SET_EEPROMPARAMS = 1209#
- MGMSG_MOT_SET_HOMEPARAMS = 1088#
- MGMSG_MOT_SET_JOGPARAMS = 1046#
- MGMSG_MOT_SET_POSCOUNTER = 1040#
- MGMSG_MOT_SET_VELPARAMS = 1043#
- MGMSG_POL_GET_PARAMS = 1330#
- MGMSG_POL_REQ_PARAMS = 1329#
- MGMSG_POL_SET_PARAMS = 1328#
- MGMSG_RESTOREFACTORYSETTINGS = 1670#
- class pnpq.apt.protocol.AptMessageWithData(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address)#
Bases:
AptMessage
- property destination_serialization: int#
- header_struct_str: ClassVar[str] = '<HH2B'#
- class pnpq.apt.protocol.AptMessageWithDataMotorStatus(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, position: int, velocity: int, motor_current: pint.registry.Quantity, status: pnpq.apt.protocol.UStatus)#
Bases:
AptMessageWithData
- Parameters:
- data_length: ClassVar[int] = 14#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
Self
- message_struct: ClassVar[Struct] = Struct('<HH2BHihhI')#
- motor_current: Quantity#
- position: int#
- to_bytes()#
- Return type:
bytes
- velocity: int#
- class pnpq.apt.protocol.AptMessageWithDataPolParams(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, unused: int = 0, velocity: int, home_position: int, jog_step_1: int, jog_step_2: int, jog_step_3: int)#
Bases:
AptMessageWithData
- Parameters:
- data_length: ClassVar[int] = 12#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
Self
- home_position: int#
- jog_step_1: int#
- jog_step_2: int#
- jog_step_3: int#
- message_struct: ClassVar[Struct] = Struct('<HH2B6H')#
- to_bytes()#
- Return type:
bytes
- unused: int = 0#
- velocity: int#
- class pnpq.apt.protocol.AptMessageWithDataPosition(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, position: int)#
Bases:
AptMessageWithData
- data_length: ClassVar[int] = 6#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
Self
- message_struct: ClassVar[Struct] = Struct('<HH2BHi')#
- position: int#
- to_bytes()#
- Return type:
bytes
- class pnpq.apt.protocol.AptMessageWithDataVelParams(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, minimum_velocity: int, acceleration: int, maximum_velocity: int)#
Bases:
AptMessageWithData
- Parameters:
- acceleration: int#
- data_length: ClassVar[int] = 14#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
Self
- maximum_velocity: int#
- message_struct: ClassVar[Struct] = Struct('<HH2BHiii')#
- minimum_velocity: int#
- to_bytes()#
- Return type:
bytes
- class pnpq.apt.protocol.AptMessageWithHomeParams(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, home_direction: pnpq.apt.protocol.HomeDirection, limit_switch: pnpq.apt.protocol.LimitSwitch, home_velocity: int, offset_distance: int)#
Bases:
AptMessageWithData
- Parameters:
destination (Address)
source (Address)
chan_ident (ChanIdent)
home_direction (HomeDirection)
limit_switch (LimitSwitch)
home_velocity (int)
offset_distance (int)
- data_length: ClassVar[int] = 14#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
Self
- home_direction: HomeDirection#
- home_velocity: int#
- limit_switch: LimitSwitch#
- message_struct: ClassVar[Struct] = Struct('<HH2B3H2i')#
- offset_distance: int#
- to_bytes()#
- Return type:
bytes
- class pnpq.apt.protocol.AptMessageWithJogParams(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, jog_mode: pnpq.apt.protocol.JogMode, jog_step_size: int, jog_minimum_velocity: int, jog_acceleration: int, jog_maximum_velocity: int, jog_stop_mode: pnpq.apt.protocol.StopMode)#
Bases:
AptMessageWithData
- Parameters:
- data_length: ClassVar[int] = 22#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
Self
- jog_acceleration: int#
- jog_maximum_velocity: int#
- jog_minimum_velocity: int#
- jog_step_size: int#
- message_struct: ClassVar[Struct] = Struct('<HH2B2H4iH')#
- to_bytes()#
- Return type:
bytes
- class pnpq.apt.protocol.AptMessage_MGMSG_HW_DISCONNECT(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, param1: bytes = b'\x00', param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyNoParams
- message_id: ClassVar[AptMessageId] = 2#
- class pnpq.apt.protocol.AptMessage_MGMSG_HW_GET_INFO(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, firmware_version: pnpq.apt.protocol.FirmwareVersion, hardware_type: pnpq.apt.protocol.HardwareType, hardware_version: int, internal_use: bytes, model_number: str, modification_state: int, number_of_channels: int, serial_number: int)#
Bases:
AptMessageWithData
- Parameters:
destination (Address)
source (Address)
firmware_version (FirmwareVersion)
hardware_type (HardwareType)
hardware_version (int)
internal_use (bytes)
model_number (str)
modification_state (int)
number_of_channels (int)
serial_number (int)
- data_length: ClassVar[int] = 84#
- firmware_version: FirmwareVersion#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
- hardware_type: HardwareType#
- hardware_version: int#
- internal_use: bytes#
- message_id: ClassVar[AptMessageId] = 6#
- message_struct: ClassVar[Struct] = Struct('<HH2Bi8sH4B60s3H')#
- model_number: str#
- modification_state: int#
- number_of_channels: int#
- serial_number: int#
- to_bytes()#
- Return type:
bytes
- class pnpq.apt.protocol.AptMessage_MGMSG_HW_REQ_INFO(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, param1: bytes = b'\x00', param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyNoParams
- message_id: ClassVar[AptMessageId] = 5#
- class pnpq.apt.protocol.AptMessage_MGMSG_HW_START_UPDATEMSGS(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, param1: bytes = b'\x00', param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyNoParams
- message_id: ClassVar[AptMessageId] = 17#
- class pnpq.apt.protocol.AptMessage_MGMSG_HW_STOP_UPDATEMSGS(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, param1: bytes = b'\x00', param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyNoParams
- message_id: ClassVar[AptMessageId] = 18#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOD_GET_CHANENABLESTATE(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, enable_state: pnpq.apt.protocol.EnableState)#
Bases:
AptMessageHeaderOnlyChanEnableState
- Parameters:
destination (Address)
source (Address)
chan_ident (ChanIdent)
enable_state (EnableState)
- message_id: ClassVar[AptMessageId] = 530#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOD_IDENTIFY(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyChanIdent
- message_id: ClassVar[AptMessageId] = 547#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOD_REQ_CHANENABLESTATE(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyChanIdent
- message_id: ClassVar[AptMessageId] = 529#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOD_SET_CHANENABLESTATE(*, destination, source, chan_ident, enable_state)#
Bases:
AptMessageHeaderOnlyChanEnableState
Sets the state of the motor channels to enabled or disabled. The official APT specification and the message itself are designed in a way that suggests this operates on one channel ID at a time; however, in reality, on the MPC320 motorized polarization controller, the
chan_ident
field is actually a bitmask.In other words, at least on the MPC devices,
enable_state
should always be set toEnableState.CHANNEL_ENABLED
, and the presence of a1
or0
in the appropriate position inchan_ident
should be used to indicate if that channel should be enabled or disabled.- Parameters:
chan_ident (ChanIdent) – A bitmask indicating which channels should be enabled. See the class documentation for more information.
enable_state (EnableState) – Should always be set to
EnableState.CHANNEL_ENABLED
. See the class documentation for more information.destination (Address)
source (Address)
- message_id: ClassVar[AptMessageId] = 528#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_ACK_USTATUSUPDATE(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, param1: bytes = b'\x00', param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyNoParams
- message_id: ClassVar[AptMessageId] = 1170#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_GET_HOMEPARAMS(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, home_direction: pnpq.apt.protocol.HomeDirection, limit_switch: pnpq.apt.protocol.LimitSwitch, home_velocity: int, offset_distance: int)#
Bases:
AptMessageWithHomeParams
- Parameters:
destination (Address)
source (Address)
chan_ident (ChanIdent)
home_direction (HomeDirection)
limit_switch (LimitSwitch)
home_velocity (int)
offset_distance (int)
- message_id: ClassVar[AptMessageId] = 1090#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_GET_JOGPARAMS(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, jog_mode: pnpq.apt.protocol.JogMode, jog_step_size: int, jog_minimum_velocity: int, jog_acceleration: int, jog_maximum_velocity: int, jog_stop_mode: pnpq.apt.protocol.StopMode)#
Bases:
AptMessageWithJogParams
- Parameters:
- message_id: ClassVar[AptMessageId] = 1048#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_GET_POSCOUNTER(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, position: int)#
Bases:
AptMessageWithDataPosition
- message_id: ClassVar[AptMessageId] = 1042#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_GET_STATUSUPDATE(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, position: int, enc_count: int, status: pnpq.apt.protocol.Status)#
Bases:
AptMessageWithData
- Parameters:
- data_length: ClassVar[int] = 14#
- enc_count: int#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
Self
- message_id: ClassVar[AptMessageId] = 1153#
- message_struct: ClassVar[Struct] = Struct('<HH2BHiiI')#
- position: int#
- to_bytes()#
- Return type:
bytes
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_GET_USTATUSUPDATE(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, position: int, velocity: int, motor_current: pint.registry.Quantity, status: pnpq.apt.protocol.UStatus)#
Bases:
AptMessageWithDataMotorStatus
- Parameters:
- message_id: ClassVar[AptMessageId] = 1169#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_GET_VELPARAMS(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, minimum_velocity: int, acceleration: int, maximum_velocity: int)#
Bases:
AptMessageWithDataVelParams
- Parameters:
- message_id: ClassVar[AptMessageId] = 1045#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_MOVE_ABSOLUTE(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, absolute_distance: int)#
Bases:
AptMessageWithData
- absolute_distance: int#
- data_length: ClassVar[int] = 6#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
- message_id: ClassVar[AptMessageId] = 1107#
- message_struct: ClassVar[Struct] = Struct('<HH2BHi')#
- to_bytes()#
- Return type:
bytes
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_MOVE_COMPLETED(*, destination, source)#
Bases:
AptMessage
Note that the APT documentation indicates that this should be followed by a full USTATUS data packet. So, two separate methods will be defined. One for the full 20 byte message, and another for the 6 byte message.
- data_length: ClassVar[int]#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_MOVE_COMPLETED_20_BYTES(*, destination, source, chan_ident, position, velocity, motor_current, status)#
Bases:
AptMessageWithDataMotorStatus
,AptMessage_MGMSG_MOT_MOVE_COMPLETED
For the K10CR1 and KBD101, a full USTATUS data packet follows the main move completed message, so this message is used.
- Parameters:
- data_length: ClassVar[int] = 14#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
Self
- message_id: ClassVar[AptMessageId] = 1124#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_MOVE_COMPLETED_6_BYTES(*, destination, source, chan_ident, param2=b'\x00')#
Bases:
AptMessageHeaderOnlyChanIdent
,AptMessage_MGMSG_MOT_MOVE_COMPLETED
For the MPC320, no data packet follows the main move completed message, so this message is used.
- data_length: ClassVar[int] = 0#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
Self
- message_id: ClassVar[AptMessageId] = 1124#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_MOVE_HOME(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyChanIdent
- message_id: ClassVar[AptMessageId] = 1091#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_MOVE_HOMED(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyChanIdent
- message_id: ClassVar[AptMessageId] = 1092#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_MOVE_JOG(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, jog_direction: pnpq.apt.protocol.JogDirection)#
Bases:
AptMessageHeaderOnly
- Parameters:
destination (Address)
source (Address)
chan_ident (ChanIdent)
jog_direction (JogDirection)
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
- jog_direction: JogDirection#
- message_id: ClassVar[AptMessageId] = 1130#
- message_struct: ClassVar[Struct] = Struct('<H2B2B')#
- to_bytes()#
- Return type:
bytes
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_MOVE_STOP(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, stop_mode: pnpq.apt.protocol.StopMode)#
Bases:
AptMessageHeaderOnly
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
- message_id: ClassVar[AptMessageId] = 1125#
- message_struct: ClassVar[Struct] = Struct('<H2B2B')#
- to_bytes()#
- Return type:
bytes
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_MOVE_STOPPED(*, destination, source)#
Bases:
AptMessage
Note that the APT documentation indicates that this should be followed by a full USTATUS data packet. So, two separate methods will be defined. One for the full 20 byte message, and another for the 6 byte message.
- data_length: ClassVar[int]#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_MOVE_STOPPED_20_BYTES(*, destination, source, chan_ident, position, velocity, motor_current, status)#
Bases:
AptMessageWithDataMotorStatus
,AptMessage_MGMSG_MOT_MOVE_STOPPED
For the K10CR1 and KBD101, a full USTATUS data packet follows the main move completed message, so this message is used.
- Parameters:
- data_length: ClassVar[int] = 14#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
Self
- message_id: ClassVar[AptMessageId] = 1126#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_MOVE_STOPPED_6_BYTES(*, destination, source, chan_ident, param2=b'\x00')#
Bases:
AptMessageHeaderOnlyChanIdent
,AptMessage_MGMSG_MOT_MOVE_STOPPED
For the MPC320, no data packet follows the main move completed message, so this message is used.
- data_length: ClassVar[int] = 0#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
Self
- message_id: ClassVar[AptMessageId] = 1126#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_REQ_HOMEPARAMS(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyChanIdent
- message_id: ClassVar[AptMessageId] = 1089#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_REQ_JOGPARAMS(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyChanIdent
- message_id: ClassVar[AptMessageId] = 1047#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_REQ_POSCOUNTER(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyChanIdent
- message_id: ClassVar[AptMessageId] = 1041#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_REQ_STATUSUPDATE(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyChanIdent
- message_id: ClassVar[AptMessageId] = 1152#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_REQ_USTATUSUPDATE(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyChanIdent
- message_id: ClassVar[AptMessageId] = 1168#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_REQ_VELPARAMS(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyChanIdent
- message_id: ClassVar[AptMessageId] = 1044#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_RESUME_ENDOFMOVEMSGS(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, param1: bytes = b'\x00', param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyNoParams
- message_id: ClassVar[AptMessageId] = 1132#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_SET_EEPROMPARAMS(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, message_id_to_save: pnpq.apt.protocol.AptMessageId)#
Bases:
AptMessageWithData
- Parameters:
destination (Address)
source (Address)
chan_ident (ChanIdent)
message_id_to_save (AptMessageId)
- data_length: ClassVar[int] = 4#
- classmethod from_bytes(raw)#
- Parameters:
raw (bytes)
- Return type:
- message_id: ClassVar[AptMessageId] = 1209#
- message_id_to_save: AptMessageId#
- message_struct: ClassVar[Struct] = Struct('<HH2BHH')#
- to_bytes()#
- Return type:
bytes
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_SET_HOMEPARAMS(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, home_direction: pnpq.apt.protocol.HomeDirection, limit_switch: pnpq.apt.protocol.LimitSwitch, home_velocity: int, offset_distance: int)#
Bases:
AptMessageWithHomeParams
- Parameters:
destination (Address)
source (Address)
chan_ident (ChanIdent)
home_direction (HomeDirection)
limit_switch (LimitSwitch)
home_velocity (int)
offset_distance (int)
- message_id: ClassVar[AptMessageId] = 1088#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_SET_JOGPARAMS(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, jog_mode: pnpq.apt.protocol.JogMode, jog_step_size: int, jog_minimum_velocity: int, jog_acceleration: int, jog_maximum_velocity: int, jog_stop_mode: pnpq.apt.protocol.StopMode)#
Bases:
AptMessageWithJogParams
- Parameters:
- message_id: ClassVar[AptMessageId] = 1046#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_SET_POSCOUNTER(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, position: int)#
Bases:
AptMessageWithDataPosition
- message_id: ClassVar[AptMessageId] = 1040#
- class pnpq.apt.protocol.AptMessage_MGMSG_MOT_SET_VELPARAMS(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, chan_ident: pnpq.apt.protocol.ChanIdent, minimum_velocity: int, acceleration: int, maximum_velocity: int)#
Bases:
AptMessageWithDataVelParams
- Parameters:
- message_id: ClassVar[AptMessageId] = 1043#
- class pnpq.apt.protocol.AptMessage_MGMSG_POL_GET_PARAMS(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, unused: int = 0, velocity: int, home_position: int, jog_step_1: int, jog_step_2: int, jog_step_3: int)#
Bases:
AptMessageWithDataPolParams
- Parameters:
- message_id: ClassVar[AptMessageId] = 1330#
- class pnpq.apt.protocol.AptMessage_MGMSG_POL_REQ_PARAMS(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, param1: bytes = b'\x00', param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyNoParams
- message_id: ClassVar[AptMessageId] = 1329#
- class pnpq.apt.protocol.AptMessage_MGMSG_POL_SET_PARAMS(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, unused: int = 0, velocity: int, home_position: int, jog_step_1: int, jog_step_2: int, jog_step_3: int)#
Bases:
AptMessageWithDataPolParams
- Parameters:
- message_id: ClassVar[AptMessageId] = 1328#
- class pnpq.apt.protocol.AptMessage_MGMSG_RESTOREFACTORYSETTINGS(*, destination: pnpq.apt.protocol.Address, source: pnpq.apt.protocol.Address, param1: bytes = b'\x00', param2: bytes = b'\x00')#
Bases:
AptMessageHeaderOnlyNoParams
- message_id: ClassVar[AptMessageId] = 1670#
- class pnpq.apt.protocol.ChanIdent(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
IntFlag
Used in IDENTIFY and CHANENABLESTATE commands.
- CHANNEL_1 = 1#
- CHANNEL_2 = 2#
- CHANNEL_3 = 4#
- CHANNEL_4 = 8#
- class pnpq.apt.protocol.EnableState(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
int
,Enum
Used in CHANENABLESTATE commands.
- CHANNEL_DISABLED = 2#
- CHANNEL_ENABLED = 1#
- classmethod from_bool(toggle)#
- Parameters:
toggle (bool)
- Return type:
- class pnpq.apt.protocol.FirmwareVersion(*, major_revision, interim_revision, minor_revision, unused=0)#
Bases:
object
Used in MGMSG_HW_GET_INFO.
Judging by the order in the documentation, “interim revision” comes betwen major and minor.
On the other hand, judging by the example in the documentation, this is intended to be read as a 3-byte unsigned integer. It’s unclear which representation is correct.
- Parameters:
major_revision (int)
interim_revision (int)
minor_revision (int)
unused (int)
- interim_revision: int#
- major_revision: int#
- minor_revision: int#
- unused: int = 0#
- class pnpq.apt.protocol.HardwareType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
IntFlag
Used in MGMSG_HW_GET_INFO. This is marked as a Flag because we expect to receive unknown values. It is not actually a bit-mappable flag.
- BRUSHLESS_DC_CONTROLLER = 44#
- MULTI_CHANNEL_CONTROLLER_MOTHERBOARD = 45#
- class pnpq.apt.protocol.HomeDirection(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
int
,Enum
Used in MSMSG_MOT_SET_HOMEPARAMS, MSMSG_MOT_GET_HOMEPARAMS.
- FORWARD = 1#
- FORWARD_0 = 0#
- REVERSE = 2#
- class pnpq.apt.protocol.JogDirection(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
int
,Enum
Used in MSMSG_MOT_MOVE_JOG.
- FORWARD = 1#
- REVERSE = 2#
- class pnpq.apt.protocol.JogMode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
int
,Enum
Used in MGMSG_MOT_SET_JOGPARAMS.
- CONTINUOUS = 1#
- SINGLE_STEP = 2#
- class pnpq.apt.protocol.LimitSwitch(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
int
,Enum
The limit switch associated with the home position. Used in MSMSG_MOT_SET_HOMEPARAMS, MSMSG_MOT_GET_HOMEPARAMS.
- HARDWARE_FORWARD = 4#
- HARDWARE_REVERSE = 1#
- NULL = 0#
- class pnpq.apt.protocol.Status(*, CWHARDLIMIT=False, CCWHARDLIMIT=False, CWSOFTLIMIT=False, CCWSOFTLIMIT=False, INMOTIONCW=False, INMOTIONCCW=False, JOGGINGCW=False, JOGGINGCCW=False, CONNECTED=False, HOMING=False, HOMED=False, INTERLOCK=False)#
Bases:
object
Dataclass-based representation of StatusBits to enable more legible output formats such as JSON.
- Parameters:
CWHARDLIMIT (bool)
CCWHARDLIMIT (bool)
CWSOFTLIMIT (bool)
CCWSOFTLIMIT (bool)
INMOTIONCW (bool)
INMOTIONCCW (bool)
JOGGINGCW (bool)
JOGGINGCCW (bool)
CONNECTED (bool)
HOMING (bool)
HOMED (bool)
INTERLOCK (bool)
- CCWHARDLIMIT: bool = False#
- CCWSOFTLIMIT: bool = False#
- CONNECTED: bool = False#
- CWHARDLIMIT: bool = False#
- CWSOFTLIMIT: bool = False#
- HOMED: bool = False#
- HOMING: bool = False#
- INMOTIONCCW: bool = False#
- INMOTIONCW: bool = False#
- INTERLOCK: bool = False#
- JOGGINGCCW: bool = False#
- JOGGINGCW: bool = False#
- classmethod from_bits(bits)#
- Parameters:
bits (StatusBits)
- Return type:
Self
- to_bits()#
- Return type:
- class pnpq.apt.protocol.StatusBits(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
IntFlag
Bitmask used in MGMSG_MOT_GET_STATUSUPDATE to indicate motor conditions. In the official documentation, these values are not given clear, parseable names. However, nearly all of them correspond to values defined for the slightly different
MGMSG_MOT_GET_USTATUSUPDATE
command that do have clear names; we re-use those names here.- CCWHARDLIMIT = 2#
- CCWSOFTLIMIT = 8#
- CONNECTED = 256#
- CWHARDLIMIT = 1#
- CWSOFTLIMIT = 4#
- HOMED = 1024#
- HOMING = 512#
- INMOTIONCCW = 32#
- INMOTIONCW = 16#
- INTERLOCK = 4096#
- JOGGINGCCW = 128#
- JOGGINGCW = 64#
- class pnpq.apt.protocol.StopMode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
int
,Enum
Used in MSMSG_MOT_MOVE_STOP, MGMSG_MOT_SET_JOGPARAMS
- CONTROLLED = 2#
- IMMEDIATE = 1#
- class pnpq.apt.protocol.UStatus(*, CWHARDLIMIT=False, CCWHARDLIMIT=False, CWSOFTLIMIT=False, CCWSOFTLIMIT=False, INMOTIONCW=False, INMOTIONCCW=False, JOGGINGCW=False, JOGGINGCCW=False, CONNECTED=False, HOMING=False, HOMED=False, INITILIZING=False, TRACKING=False, SETTLED=False, POSITIONERROR=False, INSTRERROR=False, INTERLOCK=False, OVERTEMP=False, BUSVOLTFAULT=False, COMMUTATIONERROR=False, DIGIP1=False, DIGIP2=False, DIGIP3=False, DIGIP4=False, OVERLOAD=False, ENCODERFAULT=False, OVERCURRENT=False, BUSCURRENTFAULT=False, POWEROK=False, ACTIVE=False, ERROR=False, ENABLED=False)#
Bases:
object
Dataclass-based representation of UStatusBits to enable more legible output formats such as JSON.
- Parameters:
CWHARDLIMIT (bool)
CCWHARDLIMIT (bool)
CWSOFTLIMIT (bool)
CCWSOFTLIMIT (bool)
INMOTIONCW (bool)
INMOTIONCCW (bool)
JOGGINGCW (bool)
JOGGINGCCW (bool)
CONNECTED (bool)
HOMING (bool)
HOMED (bool)
INITILIZING (bool)
TRACKING (bool)
SETTLED (bool)
POSITIONERROR (bool)
INSTRERROR (bool)
INTERLOCK (bool)
OVERTEMP (bool)
BUSVOLTFAULT (bool)
COMMUTATIONERROR (bool)
DIGIP1 (bool)
DIGIP2 (bool)
DIGIP3 (bool)
DIGIP4 (bool)
OVERLOAD (bool)
ENCODERFAULT (bool)
OVERCURRENT (bool)
BUSCURRENTFAULT (bool)
POWEROK (bool)
ACTIVE (bool)
ERROR (bool)
ENABLED (bool)
- ACTIVE: bool = False#
- BUSCURRENTFAULT: bool = False#
- BUSVOLTFAULT: bool = False#
- CCWHARDLIMIT: bool = False#
- CCWSOFTLIMIT: bool = False#
- COMMUTATIONERROR: bool = False#
- CONNECTED: bool = False#
- CWHARDLIMIT: bool = False#
- CWSOFTLIMIT: bool = False#
- DIGIP1: bool = False#
- DIGIP2: bool = False#
- DIGIP3: bool = False#
- DIGIP4: bool = False#
- ENABLED: bool = False#
- ENCODERFAULT: bool = False#
- ERROR: bool = False#
- HOMED: bool = False#
- HOMING: bool = False#
- INITILIZING: bool = False#
- INMOTIONCCW: bool = False#
- INMOTIONCW: bool = False#
- INSTRERROR: bool = False#
- INTERLOCK: bool = False#
- JOGGINGCCW: bool = False#
- JOGGINGCW: bool = False#
- OVERCURRENT: bool = False#
- OVERLOAD: bool = False#
- OVERTEMP: bool = False#
- POSITIONERROR: bool = False#
- POWEROK: bool = False#
- SETTLED: bool = False#
- TRACKING: bool = False#
- classmethod from_bits(bits)#
- Parameters:
bits (UStatusBits)
- Return type:
Self
- to_bits()#
- Return type:
- class pnpq.apt.protocol.UStatusBits(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
IntFlag
Bitmask used in MGMSG_MOT_GET_USTATUSUPDATE to indicate motor conditions. In the official documentation, all of these names have P_MOT_SB prepended to them.
All spelling errors (e.g. “INITILIZING”) are from the official documentation.
- ACTIVE = 536870912#
- BUSCURRENTFAULT = 134217728#
- BUSVOLTFAULT = 262144#
- CCWHARDLIMIT = 2#
- CCWSOFTLIMIT = 8#
- COMMUTATIONERROR = 524288#
- CONNECTED = 256#
- CWHARDLIMIT = 1#
- CWSOFTLIMIT = 4#
- DIGIP1 = 1048576#
- DIGIP2 = 2097152#
- DIGIP3 = 4194304#
- DIGIP4 = 8388608#
- ENABLED = 2147483648#
- ENCODERFAULT = 33554432#
- ERROR = 1073741824#
- HOMED = 1024#
- HOMING = 512#
- INITILIZING = 2048#
- INMOTIONCCW = 32#
- INMOTIONCW = 16#
- INSTRERROR = 32768#
- INTERLOCK = 65536#
- JOGGINGCCW = 128#
- JOGGINGCW = 64#
- OVERCURRENT = 67108864#
- OVERLOAD = 16777216#
- OVERTEMP = 131072#
- POSITIONERROR = 16384#
- POWEROK = 268435456#
- SETTLED = 8192#
- TRACKING = 4096#