예제 #1
0
    def __init__(self, port, addr):
        self.addr = addr  # 485地址
        self.switch_mode = 0  # 干接点模式 1:长触模式,0:短触模式
        self.switch_status = [0, 0, 0]  # 干接点状态
        self.relay_status = [0, 0, 0]  # 继电器状态
        self.id = []
        self.baudrate = int(cf.get("serial", "baudrate"))
        self.bytesize = int(cf.get("serial", "bytesize"))
        self.parity = int(cf.get("serial", "parity"))
        self.stop = int(cf.get("serial", "stop"))

        ModbusWindows.__init__(self,
                               PORT=port,
                               BAUDR=BAUD_LIST[self.baudrate - 1],
                               BSIZE=BYTE_LIST[self.bytesize - 1],
                               PAR=PARITY_LIST[self.parity - 1],
                               BSTOP=STOP_LIST[self.stop - 1],
                               TIMEOUT=1000)
예제 #2
0
파일: ICS.py 프로젝트: gm06120219/ics_tools
    def __init__(self, port, addr):
        self.addr = addr  # 485地址
        self.switch_mode = 0  # 干接点模式 1:长触模式,0:短触模式
        self.switch_status = [0, 0, 0]  # 干接点状态
        self.relay_status = [0, 0, 0]  # 继电器状态
        self.id = []
        self.baudrate = int(cf.get("serial", "baudrate"))
        self.bytesize = int(cf.get("serial", "bytesize"))
        self.parity = int(cf.get("serial", "parity"))
        self.stop = int(cf.get("serial", "stop"))

        ModbusWindows.__init__(
            self,
            PORT=port,
            BAUDR=BAUD_LIST[self.baudrate - 1],
            BSIZE=BYTE_LIST[self.bytesize - 1],
            PAR=PARITY_LIST[self.parity - 1],
            BSTOP=STOP_LIST[self.stop - 1],
            TIMEOUT=1000,
        )
예제 #3
0
 def read(self, length):
     read_raw = ModbusWindows.read(self, length)
     return list(unpack('B' * len(read_raw), str(bytearray(read_raw))))
예제 #4
0
 def write(self, cmd):
     ModbusWindows.write(self, List2Ascii(cmd))
예제 #5
0
파일: ICS.py 프로젝트: gm06120219/ics_tools
 def read(self, length):
     read_raw = ModbusWindows.read(self, length)
     return list(unpack("B" * len(read_raw), str(bytearray(read_raw))))
예제 #6
0
파일: ICS.py 프로젝트: gm06120219/ics_tools
 def write(self, cmd):
     ModbusWindows.write(self, List2Ascii(cmd))