class Tp54_in: """ #54 Four dry contact inputs """ def __init__(self, slot, host=None): """ コンストラクタ """ self.slot = slot self.comm = GPIO self.host = host def start(self, callback_recv): """ 開始処理 """ self.tcp_client = TcpClient(callback_recv) self.tcp_client.connect_by_conf_recv(self.host, self.slot, self.comm) def wait_for_recv(self): """ データ受信待ち """ self.tcp_client.recv()
class TpcButton: """ TP Button """ def __init__(self, host=None): """ コンストラクタ """ self.slot = "S00" self.comm = TP_BUTTON self.host = host def start(self, callback_recv): """ 開始処理 """ self.tcp_client = TcpClient(callback_recv) self.tcp_client.connect_by_conf_recv(self.host, self.slot, self.comm) def wait_for_recv(self): """ データ受信待ち """ self.tcp_client.recv()
class Tp00_in: """ #00 direct I/O lines """ def __init__(self, slot, comm, host=None): """ コンストラクタ """ self.slot = slot self.comm = comm self.host = host def start(self, callback_recv): """ 開始処理 """ self.tcp_client = TcpClient(callback_recv) self.tcp_client.connect_by_conf_recv(self.host, self.slot, self.comm) def wait_for_recv(self): """ データ受信待ち """ self.tcp_client.recv()
class Tp01_in: """ #01 Four-line RS232 port """ def __init__(self, slot, host=None): """ コンストラクタ """ self.slot = slot self.comm = Serial self.host = host def start(self, callback_recv): """ 開始処理 """ self.tcp_client = TcpClient(callback_recv) self.tcp_client.connect_by_conf_recv(self.host, self.slot, self.comm) def wait_for_recv(self): """ データ受信待ち """ self.tcp_client.recv()
class Tp31_in: """ #31 PIC coprocessor """ def __init__(self, slot, host=None): """ コンストラクタ """ self.slot = slot self.comm = GPIO self.host = host def start(self, callback_recv): """ 開始処理 """ self.tcp_client = TcpClient(callback_recv) self.tcp_client.connect_by_conf_recv(self.host, self.slot, self.comm) def wait_for_recv(self): """ データ受信待ち """ self.tcp_client.recv()
class Tp00_in: """ #00 direct I/O lines """ def __init__(self, slot, comm, host=None, target_line=['A', 'B', 'C', 'D']): """ コンストラクタ """ self.slot = slot self.comm = comm self.host = host # GPIOのみ有効(対象となるライン) self.target_line = target_line def start(self, callback_recv): """ 開始処理 """ self.callback_recv = callback_recv self.tcp_client = TcpClient(self.__callback_recv) self.tcp_client.connect_by_conf_recv(self.host, self.slot, self.comm) def wait_for_recv(self): """ データ受信待ち """ self.tcp_client.recv() def __callback_recv(self, recv_data): """ データ受信イベント """ if self.comm == GPIO: # GPIOの場合、監視対象のラインかチェック result_data = json.loads(recv_data.decode()) if result_data['line'] in self.target_line: # 含むときだけコールバックを呼ぶ self.handler(self.callback_recv, recv_data) else: self.handler(self.callback_recv, recv_data) def handler(self, func, *args): """ ハンドラー """ return func(*args)