当前位置: 首页>>代码示例>>Python>>正文


Python meterbus.load函数代码示例

本文整理汇总了Python中meterbus.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了load函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

    def setUp(self):
        self.frame = "\x68\x53\x53\x68\x08\x05\x72\x34\x08\x00\x54\x96\x15\x32" \
                     "\x00\xf2\x00\x00\x00\x01\xfd\x1b\x00\x02\xfc\x03\x48\x52" \
                     "\x25\x74\xd4\x11\x22\xfc\x03\x48\x52\x25\x74\xc8\x11\x12" \
                     "\xfc\x03\x48\x52\x25\x74\xb4\x16\x02\x65\xd0\x08\x22\x65" \
                     "\x70\x08\x12\x65\x23\x09\x01\x72\x18\x42\x65\xe4\x08\x82" \
                     "\x01\x65\xdd\x08\x0c\x78\x34\x08\x00\x54\x03\xfd\x0f\x00" \
                     "\x00\x04\x1f\x5d\x16"
        self.frame2 = "\x68\xD8\xD8\x68\x08\x00\x72\x92\x03\x00\x64\x96\x15" \
                      "\x14\x31\x04\x00\x00\x00\x0C\x78\x92\x03\x00\x64\x0D" \
                      "\xFD\x0F\x05\x33\x2E\x36\x2E\x31\x0D\x7C\x03\x79\x65" \
                      "\x6B\x10\x0A\xB3\xED\x14\xCD\x07\x58\xD7\xBA\xDE\x3B" \
                      "\x38\xB2\xE6\x96\x0C\x01\x7C\x03\x6F\x6D\x77\x04\x01" \
                      "\x7C\x03\x65\x73\x77\x00\x02\x7C\x03\x74\x69\x77\x3C" \
                      "\x00\x02\x7C\x03\x73\x69\x77\x3C\x00\x01\x7C\x03\x6D" \
                      "\x69\x77\x01\x02\x7C\x03\x65\x67\x61\xA0\x05\x04\x7C" \
                      "\x03\x66\x69\x77\xFF\xFF\xFF\xFF\x01\x7C\x03\x69\x63" \
                      "\x77\x01\x01\x7C\x03\x6F\x6D\x74\x00\x01\x7C\x03\x66" \
                      "\x64\x74\x03\x01\x7C\x03\x64\x63\x6C\x00\x01\x7C\x03" \
                      "\x6E\x61\x6C\x00\x01\x7C\x03\x65\x6C\x73\x05\x0A\xFD" \
                      "\x16\x00\x00\x04\xFD\x0B\x00\x00\x00\x00\x02\x7C\x03" \
                      "\x61\x66\x77\x00\x00\x01\x7C\x03\x66\x69\x61\x01\x04" \
                      "\x7C\x03\x63\x72\x72\xB3\x02\x00\x00\x01\x7C\x03\x61" \
                      "\x74\x73\x00\x01\x7C\x03\x6D\x61\x63\x00\x01\x7C\x03" \
                      "\x6D\x61\x6D\x00\x01\x7C\x03\x66\x63\x69\x01\x1F\x3A" \
                      "\x16"

        self.frame = meterbus.load(self.frame)
        self.frame2 = meterbus.load(self.frame2)
开发者ID:ganehag,项目名称:pyMeterBus,代码行数:29,代码来源:test_variable_data_record.py

示例2: mbus_probe_secondary_address

def mbus_probe_secondary_address(ser, mask):
    # False -> Collison
    # None -> No reply
    # True -> Single reply
    meterbus.send_select_frame(ser, mask)
    try:
        frame = meterbus.load(meterbus.recv_frame(ser, 1))
    except meterbus.MBusFrameDecodeError as e:
        frame = e.value

    if isinstance(frame, meterbus.TelegramACK):
        meterbus.send_request_frame(ser, meterbus.ADDRESS_NETWORK_LAYER)
        time.sleep(0.5)

        frame = None
        try:
            frame = meterbus.load(
                meterbus.recv_frame(ser))
        except meterbus.MBusFrameDecodeError:
            pass

        if isinstance(frame, meterbus.TelegramLong):
            return True, frame.secondary_address, frame.manufacturer

        return None, None, None

    return frame, None, None
开发者ID:ganehag,项目名称:pyMeterBus,代码行数:27,代码来源:mbus-serial-scan-seconday.py

示例3: do_char_dev

def do_char_dev(args):
    address = None

    try:
        address = int(args.address)
        if not (0 <= address <= 254):
            address = args.address
    except ValueError:
        address = args.address.upper()

    try:
        ibt = meterbus.inter_byte_timeout(args.baudrate)
        with serial.serial_for_url(args.device,
                           args.baudrate, 8, 'E', 1,
                           inter_byte_timeout=ibt,
                           timeout=1) as ser:
            frame = None

            if meterbus.is_primary_address(address):
                ping_address(ser, meterbus.ADDRESS_NETWORK_LAYER, 0)

                meterbus.send_request_frame(ser, address)
                frame = meterbus.load(
                    meterbus.recv_frame(ser, meterbus.FRAME_DATA_LENGTH))

            elif meterbus.is_secondary_address(address):
                meterbus.send_select_frame(ser, address)
                try:
                    frame = meterbus.load(meterbus.recv_frame(ser, 1))
                except meterbus.MBusFrameDecodeError as e:
                    frame = e.value

                assert isinstance(frame, meterbus.TelegramACK)

                frame = None
                # ping_address(ser, meterbus.ADDRESS_NETWORK_LAYER, 0)

                meterbus.send_request_frame(
                    ser, meterbus.ADDRESS_NETWORK_LAYER)

                time.sleep(0.3)

                frame = meterbus.load(
                    meterbus.recv_frame(ser, meterbus.FRAME_DATA_LENGTH))

            if frame is not None:
                print(frame.to_JSON())

    except serial.serialutil.SerialException as e:
        print(e)
开发者ID:ganehag,项目名称:pyMeterBus,代码行数:50,代码来源:mbus-serial-request-data.py

示例4: ping_address

def ping_address(ser, address, retries=5):
    for i in range(0, retries + 1):
        meterbus.send_ping_frame(ser, address)
        try:
            frame = meterbus.load(meterbus.recv_frame(ser, 1))
            if isinstance(frame, meterbus.TelegramACK):
                return True
        except meterbus.MBusFrameDecodeError:
            pass

    return False
开发者ID:ganehag,项目名称:pyMeterBus,代码行数:11,代码来源:mbus-serial-request-data-multi-reply.py

示例5: test_ping_frame

    def test_ping_frame(self):
        self.reset()
        meterbus.send_ping_frame(self.master, 0)
        self.assertEqual(self.slave.read(5),
                         b"\x10\x40\x00\x40\x16")

        # Slave sends ACK reply
        self.slave.write(b'\xE5')

        frame_data = meterbus.recv_frame(self.master, 1)
        frame = meterbus.load(frame_data)

        self.assertIsInstance(frame, meterbus.TelegramACK)
开发者ID:ganehag,项目名称:pyMeterBus,代码行数:13,代码来源:test_serial.py

示例6: test_send_select_frame

    def test_send_select_frame(self):
        self.reset()
        meterbus.send_select_frame(self.master,
                                   "00000001DADAFA1B")

        reply = (b"\x68\x0b\x0b\x68\x73\xfd\x52\x01\x00"
                 b"\x00\x00\xda\xda\xfa\x1b\x8c\x16")

        self.assertEqual(self.slave.read(len(reply)), reply)

        # Slave sends ACK reply
        self.slave.write(b'\xE5')

        frame_data = meterbus.recv_frame(self.master, 1)
        frame = meterbus.load(frame_data)

        self.assertIsInstance(frame, meterbus.TelegramACK)
开发者ID:ganehag,项目名称:pyMeterBus,代码行数:17,代码来源:test_serial.py

示例7: test_empty_reply

    def test_empty_reply(self):
        self.reset()
        meterbus.send_ping_frame(self.master,
                                 0)

        self.assertEqual(self.slave.read(5),
                         b"\x10\x40\x00\x40\x16")

        # Slave does not send anything

        frame_data = meterbus.recv_frame(self.master, 1)
        try:
            frame = meterbus.load(frame_data)
        except MBusFrameDecodeError as e:
            frame = e.value

        self.assertEqual(frame, None)
开发者ID:ganehag,项目名称:pyMeterBus,代码行数:17,代码来源:test_serial.py

示例8: test_long_frame

    def test_long_frame(self):
        tele = meterbus.load(self.long_frame)
	self.assertIsInstance(tele, meterbus.TelegramLong)
开发者ID:dcneeme,项目名称:pyMeterBus,代码行数:3,代码来源:frametype_test.py

示例9: test_control_frame

    def test_control_frame(self):
        tele = meterbus.load(self.control_frame)
	self.assertIsInstance(tele, meterbus.TelegramControl)
开发者ID:dcneeme,项目名称:pyMeterBus,代码行数:3,代码来源:frametype_test.py

示例10: test_short_frame

    def test_short_frame(self):
        tele = meterbus.load(self.short_frame)
	self.assertIsInstance(tele, meterbus.TelegramShort)
开发者ID:dcneeme,项目名称:pyMeterBus,代码行数:3,代码来源:frametype_test.py

示例11: test_ack_frame

    def test_ack_frame(self):
        tele = meterbus.load(self.ack_frame)
	self.assertIsInstance(tele, meterbus.TelegramACK)
开发者ID:dcneeme,项目名称:pyMeterBus,代码行数:3,代码来源:frametype_test.py

示例12: test_record6_unit

 def test_record6_unit(self):
     tele = meterbus.load(list(map(ord, self.frame)))
     records = tele.body.bodyPayload.records
     self.assertEqual(records[5].unit, "none")
开发者ID:ganehag,项目名称:pyMeterBus,代码行数:4,代码来源:test_weptech.py

示例13: test_record5_value

 def test_record5_value(self):
     tele = meterbus.load(list(map(ord, self.frame)))
     records = tele.body.bodyPayload.records
     self.assertAlmostEqual(records[4].parsed_value, 53.1, 5)
开发者ID:ganehag,项目名称:pyMeterBus,代码行数:4,代码来源:test_weptech.py

示例14: test_record4_unit

 def test_record4_unit(self):
     tele = meterbus.load(map(ord, self.frame))
     records = tele.body.bodyPayload.records
     self.assertEquals(records[3].unit.name, "C")
开发者ID:dcneeme,项目名称:pyMeterBus,代码行数:4,代码来源:weptech_test.py

示例15: test_record4_value

 def test_record4_value(self):
     tele = meterbus.load(self.frame)
     records = tele.body.bodyPayload.records
     self.assertAlmostEqual(float(records[3].parsed_value), 379716.8, 5)
开发者ID:ganehag,项目名称:pyMeterBus,代码行数:4,代码来源:test_unknown_pl.py


注:本文中的meterbus.load函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。