pm2cd.core package
- class pm2cd.core.Communication(ip_address: str, port: int = 7777, timeout_sec: float = 3.0, encoding: str = 'ascii', logger=None, log_level: str = 'INFO')[source]
Bases:
objectPMシリーズ用のTCP通信層。
TCPソケットの生成、接続、CR+LF単位の送受信、切断までをこのクラス内で 完結させる。
通常運転中に発生し得る通信失敗はログへ原因を記録し、
FalseまたはNoneを返す。コンストラクタ引数の不正など、戻り値では表現できない 呼び出し側の誤りは例外とする。- property encoding
encoding を返す。
- property ip_address
ip_address を返す。
- property port
port を返す。
- property timeout_sec
timeout_sec を返す。
- exception pm2cd.core.CommunicationError[source]
Bases:
MotorControlError通信処理に失敗した場合の例外。
- class pm2cd.core.MotorStatus(motor: int, channel: int, raw: str, remote_local: str, direction: str, ls_status: int, mcc_status: int, position: int, motor_status: str, is_busy: bool, is_driving: bool, is_accelerating: bool, is_decelerating: bool, has_command_error: bool, limit_stop_received: bool, slow_stop_received: bool, emergency_stop_received: bool, rotation_state: int, cw_ls: bool, ccw_ls: bool, hp_ls: bool, hold_off: bool, legacy_status_bits: int)[source]
Bases:
objectSTS?応答中の1軸分の状態を保持する。- ccw_ls: bool
- channel: int
- cw_ls: bool
- direction: str
- emergency_stop_received: bool
- has_command_error: bool
- hold_off: bool
- hp_ls: bool
- is_accelerating: bool
- is_busy: bool
- is_decelerating: bool
- is_driving: bool
- legacy_status_bits: int
- limit_stop_received: bool
- ls_status: int
- mcc_status: int
- motor: int
- motor_status: str
- position: int
- raw: str
- remote_local: str
- rotation_state: int
- slow_stop_received: bool
- exception pm2cd.core.ProtocolError[source]
Bases:
MotorControlError装置応答を解釈できない場合の例外。
Submodules
pm2cd.core.communication_tcp module
- class pm2cd.core.communication_tcp.Communication(ip_address: str, port: int = 7777, timeout_sec: float = 3.0, encoding: str = 'ascii', logger=None, log_level: str = 'INFO')[source]
Bases:
objectPMシリーズ用のTCP通信層。
TCPソケットの生成、接続、CR+LF単位の送受信、切断までをこのクラス内で 完結させる。
通常運転中に発生し得る通信失敗はログへ原因を記録し、
FalseまたはNoneを返す。コンストラクタ引数の不正など、戻り値では表現できない 呼び出し側の誤りは例外とする。- property encoding
encoding を返す。
- property ip_address
ip_address を返す。
- property port
port を返す。
- property timeout_sec
timeout_sec を返す。
pm2cd.core.controller_status module
- class pm2cd.core.controller_status.ControllerStatus(raw: str, remote_local: str, stopped_motor_count: int, is_remote: bool, can_start: bool)[source]
Bases:
objectSTQ?の REMOTE/LOCAL と停止可能数を保持する。- can_start: bool
- is_remote: bool
- raw: str
- remote_local: str
- stopped_motor_count: int
- pm2cd.core.controller_status.parse_controller_status(raw: str) ControllerStatus | None[source]
STQ?応答を解析する。
pm2cd.core.data module
PM2CD / PM2C-06A 固有データ。
pm2cd.core.errors module
- exception pm2cd.core.errors.CommunicationError[source]
Bases:
MotorControlError通信処理に失敗した場合の例外。
- exception pm2cd.core.errors.ProtocolError[source]
Bases:
MotorControlError装置応答を解釈できない場合の例外。
pm2cd.core.home_status module
- class pm2cd.core.home_status.HomeStatus(raw: str, found: bool, found_direction: str, auto_start_direction: str)[source]
Bases:
objectSETHP?xの0XYZ応答を保持する。- auto_start_direction: str
- found: bool
- found_direction: str
- raw: str
- pm2cd.core.home_status.parse_home_status(raw: str) HomeStatus | None[source]
SETHP?x応答を解析する。
pm2cd.core.limit_status module
- class pm2cd.core.limit_status.LimitStatus(motor: int, channel: int, raw: str, hard_status: int, soft_status: int, hard_cw: bool, hard_ccw: bool, hard_hp: bool, soft_cw: bool, soft_ccw: bool)[source]
Bases:
objectHDSTLS?応答中の1軸分のリミット状態を保持する。- channel: int
- property hard: List[bool]
ハードウェアLS現在状態を
[CW, CCW, HP]で返す。
- hard_ccw: bool
- hard_cw: bool
- hard_hp: bool
- hard_status: int
- motor: int
- raw: str
- property soft: List[bool]
ソフトウェアLS現在状態を
[CW, CCW]で返す。
- soft_ccw: bool
- soft_cw: bool
- soft_status: int
- pm2cd.core.limit_status.parse_limit_status_all(raw: str) List[LimitStatus] | None[source]
PM2CD の
HDSTLS?2ch応答abHHSSを解析する。
pm2cd.core.limit_switch_setting module
- class pm2cd.core.limit_switch_setting.LimitSwitchSetting(raw: str, digital_limit_enabled: bool, raw_hp_enabled: bool, raw_ccw_enabled: bool, raw_cw_enabled: bool, hp_nc: bool, raw_ccw_nc: bool, raw_cw_nc: bool)[source]
Bases:
objectSETLS?xのDYYY0yyy応答を保持する。PM□C-06 シリーズでは、書き込み時の HP LS enable は常に 1 であり、 CCW LS の enable / 接点仕様が CW LS にも適用される。 読み出し応答そのものはマニュアル記載どおり
DYYY0yyyとして保持する。- property ccw_enabled: bool
PM□C-06 の実効 CCW LS enable を返す。
- property ccw_nc: bool
PM□C-06 の実効 CCW LS 接点仕様を返す。
- property cw_enabled: bool
PM□C-06 では CCW 設定が適用される CW LS enable を返す。
- property cw_nc: bool
PM□C-06 では CCW 設定が適用される CW LS 接点仕様を返す。
- digital_limit_enabled: bool
- property hp_enabled: bool
PM□C-06 で実効的に常時有効な HP LS enable を返す。
- hp_nc: bool
- raw: str
- raw_ccw_enabled: bool
- raw_ccw_nc: bool
- raw_cw_enabled: bool
- raw_cw_nc: bool
- raw_hp_enabled: bool
- pm2cd.core.limit_switch_setting.parse_limit_switch_setting(raw: str) LimitSwitchSetting | None[source]
SETLS?xのDYYY0yyy応答を解析する。8文字の位置は順に、
D, HP-enable, CCW-enable, CW-enable, 0, HP-contact, CCW-contact, CW-contact。読み出しでは
DYYY0yyyをそのまま解析し、PM□C-06 固有の 実効値への解釈はLimitSwitchSettingの property が担当する。
- pm2cd.core.limit_switch_setting.set_digital_limit(setting: LimitSwitchSetting, enabled: bool) str | None[source]
digital limit enable を変更した PM□C-06 書き込み値を返す。
- pm2cd.core.limit_switch_setting.set_hardware_limit(setting: LimitSwitchSetting, enabled: bool) str | None[source]
CW/CCW hardware LS enable を同時変更した書き込み値を返す。
- pm2cd.core.limit_switch_setting.set_hardware_limit_normally_closed(setting: LimitSwitchSetting, side: str, normally_closed: bool) str | None[source]
hardware LS の接点仕様を変更した PM□C-06 書き込み値を返す。
HP は独立して変更する。CW または CCW を指定した場合は、 PM□C-06 の仕様に従い CCW/CW を同じ接点仕様へ変更する。
pm2cd.core.motor_setting module
- class pm2cd.core.motor_setting.MotorSetting(raw: str, drive_enabled: bool, hold_mode: int, drive_mode: int, output_mode: int)[source]
Bases:
objectSETMT?xのモーター設定を保持する。- drive_enabled: bool
- drive_mode: int
- hold_mode: int
- output_mode: int
- raw: str
- pm2cd.core.motor_setting.parse_motor_setting(raw: str) MotorSetting | None[source]
SETMT?xのABCD応答を解析する。
pm2cd.core.motor_status module
- class pm2cd.core.motor_status.MotorStatus(motor: int, channel: int, raw: str, remote_local: str, direction: str, ls_status: int, mcc_status: int, position: int, motor_status: str, is_busy: bool, is_driving: bool, is_accelerating: bool, is_decelerating: bool, has_command_error: bool, limit_stop_received: bool, slow_stop_received: bool, emergency_stop_received: bool, rotation_state: int, cw_ls: bool, ccw_ls: bool, hp_ls: bool, hold_off: bool, legacy_status_bits: int)[source]
Bases:
objectSTS?応答中の1軸分の状態を保持する。- ccw_ls: bool
- channel: int
- cw_ls: bool
- direction: str
- emergency_stop_received: bool
- has_command_error: bool
- hold_off: bool
- hp_ls: bool
- is_accelerating: bool
- is_busy: bool
- is_decelerating: bool
- is_driving: bool
- legacy_status_bits: int
- limit_stop_received: bool
- ls_status: int
- mcc_status: int
- motor: int
- motor_status: str
- position: int
- raw: str
- remote_local: str
- rotation_state: int
- slow_stop_received: bool
- pm2cd.core.motor_status.parse_motor_status_all(raw: str) List[MotorStatus] | None[source]
PM4C-06A互換の
STS?応答を解析する。