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


Python BinaryPayloadDecoder.decode_32bit_float方法代码示例

本文整理汇总了Python中pymodbus.payload.BinaryPayloadDecoder.decode_32bit_float方法的典型用法代码示例。如果您正苦于以下问题:Python BinaryPayloadDecoder.decode_32bit_float方法的具体用法?Python BinaryPayloadDecoder.decode_32bit_float怎么用?Python BinaryPayloadDecoder.decode_32bit_float使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymodbus.payload.BinaryPayloadDecoder的用法示例。


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

示例1: testBigEndianPayloadDecoder

# 需要导入模块: from pymodbus.payload import BinaryPayloadDecoder [as 别名]
# 或者: from pymodbus.payload.BinaryPayloadDecoder import decode_32bit_float [as 别名]
 def testBigEndianPayloadDecoder(self):
     ''' Test basic bit message encoding/decoding '''
     decoder = BinaryPayloadDecoder(self.big_endian_payload, endian=Endian.Big)
     self.assertEqual(1,      decoder.decode_8bit_uint())
     self.assertEqual(2,      decoder.decode_16bit_uint())
     self.assertEqual(3,      decoder.decode_32bit_uint())
     self.assertEqual(4,      decoder.decode_64bit_uint())
     self.assertEqual(-1,     decoder.decode_8bit_int())
     self.assertEqual(-2,     decoder.decode_16bit_int())
     self.assertEqual(-3,     decoder.decode_32bit_int())
     self.assertEqual(-4,     decoder.decode_64bit_int())
     self.assertEqual(1.25,   decoder.decode_32bit_float())
     self.assertEqual(6.25,   decoder.decode_64bit_float())
     self.assertEqual(b'test', decoder.decode_string(4))
     self.assertEqual(self.bitstring, decoder.decode_bits())
开发者ID:semyont,项目名称:pymodbus,代码行数:17,代码来源:test_payload.py

示例2: testLittleEndianPayloadDecoder

# 需要导入模块: from pymodbus.payload import BinaryPayloadDecoder [as 别名]
# 或者: from pymodbus.payload.BinaryPayloadDecoder import decode_32bit_float [as 别名]
 def testLittleEndianPayloadDecoder(self):
     """ Test basic bit message encoding/decoding """
     decoder = BinaryPayloadDecoder(self.little_endian_payload, endian=Endian.Little)
     self.assertEqual(1, decoder.decode_8bit_uint())
     self.assertEqual(2, decoder.decode_16bit_uint())
     self.assertEqual(3, decoder.decode_32bit_uint())
     self.assertEqual(4, decoder.decode_64bit_uint())
     self.assertEqual(-1, decoder.decode_8bit_int())
     self.assertEqual(-2, decoder.decode_16bit_int())
     self.assertEqual(-3, decoder.decode_32bit_int())
     self.assertEqual(-4, decoder.decode_64bit_int())
     self.assertEqual(1.25, decoder.decode_32bit_float())
     self.assertEqual(6.25, decoder.decode_64bit_float())
     self.assertEqual("test", decoder.decode_string(4))
     self.assertEqual(self.bitstring, decoder.decode_bits())
开发者ID:4rc4n4,项目名称:pymodbus,代码行数:17,代码来源:test_payload.py

示例3: testLittleEndianPayloadDecoder

# 需要导入模块: from pymodbus.payload import BinaryPayloadDecoder [as 别名]
# 或者: from pymodbus.payload.BinaryPayloadDecoder import decode_32bit_float [as 别名]
 def testLittleEndianPayloadDecoder(self):
     """ Test basic bit message encoding/decoding """
     decoder = BinaryPayloadDecoder(self.little_endian_payload, 
                                    byteorder=Endian.Little,
                                    wordorder=Endian.Little)
     self.assertEqual(1,      decoder.decode_8bit_uint())
     self.assertEqual(2,      decoder.decode_16bit_uint())
     self.assertEqual(3,      decoder.decode_32bit_uint())
     self.assertEqual(4,      decoder.decode_64bit_uint())
     self.assertEqual(-1,     decoder.decode_8bit_int())
     self.assertEqual(-2,     decoder.decode_16bit_int())
     self.assertEqual(-3,     decoder.decode_32bit_int())
     self.assertEqual(-4,     decoder.decode_64bit_int())
     self.assertEqual(1.25,   decoder.decode_32bit_float())
     self.assertEqual(6.25,   decoder.decode_64bit_float())
     self.assertEqual(None,   decoder.skip_bytes(2))
     self.assertEqual('test', decoder.decode_string(4).decode())
     self.assertEqual(self.bitstring, decoder.decode_bits())
开发者ID:bashwork,项目名称:pymodbus,代码行数:20,代码来源:test_payload.py


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