本文整理汇总了Python中pymodbus.pdu.ModbusRequest类的典型用法代码示例。如果您正苦于以下问题:Python ModbusRequest类的具体用法?Python ModbusRequest怎么用?Python ModbusRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ModbusRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, status):
''' Initializes a new instance
:param status: The status response to report
'''
ModbusRequest.__init__(self)
self.status = status
示例2: __init__
def __init__(self, records=None, **kwargs):
''' Initializes a new instance
:param records: The file record requests to be read
'''
ModbusRequest.__init__(self, **kwargs)
self.records = records or []
示例3: __init__
def __init__(self, address, count, **kwargs):
''' Initializes the read request data
:param address: The start address to read from
:param count: The number of bits after 'address' to read
'''
ModbusRequest.__init__(self, **kwargs)
self.address = address
self.count = count
示例4: __init__
def __init__(self, address=None, value=None, **kwargs):
''' Initializes a new instance
:param address: The address to start writing add
:param value: The values to write
'''
ModbusRequest.__init__(self, **kwargs)
self.address = address
self.value = value
示例5: __init__
def __init__(self, address=None, value=None, **kwargs):
''' Initializes a new instance
:param address: The variable address to write
:param value: The value to write at address
'''
ModbusRequest.__init__(self, **kwargs)
self.address = address
self.value = bool(value)
示例6: __init__
def __init__(self, address=None, value=None):
''' Initializes a new instance
:param address: The variable address to write
:param value: The value to write at address
'''
ModbusRequest.__init__(self)
self.address = address
self.value = 0xff00 if value else 0x0000
示例7: __init__
def __init__(self, address, count, **kwargs):
''' Initializes a new instance
:param address: The address to start the read from
:param count: The number of registers to read
'''
ModbusRequest.__init__(self, **kwargs)
self.address = address
self.count = count
示例8: __init__
def __init__(self, read_code=None, object_id=0x00, **kwargs):
''' Initializes a new instance
:param read_code: The device information read code
:param object_id: The object to read from
'''
ModbusRequest.__init__(self, **kwargs)
self.read_code = read_code or DeviceInformation.Basic
self.object_id = object_id
示例9: testInverterFramerEncoding
def testInverterFramerEncoding(self):
old_encode = ModbusRequest.encode
ModbusRequest.encode = lambda self: ''
message = ModbusRequest()
message.unit_id = 0xff
message.function_code = 0x01
expected = '\x0a\xff\x01\x81\x80\x0d'
actual = self.framer.buildPacket(message)
ModbusRequest.encode = old_encode
self.assertEqual(expected, actual)
示例10: __init__
def __init__(self, address=None, count=None):
''' Initializes a new instance
:param address: The address to start writing to
:param count: The number of registers to write to
'''
ModbusRequest.__init__(self)
self.address = address
if count != None and count > 0:
self.registers = [0] * count
else: self.registers = []
示例11: __init__
def __init__(self, address, count, **kwargs):
''' Initializes a new instance
:param address: The address to start the read from
:param count: The number of registers to read
'''
ModbusRequest.__init__(self, **kwargs)
self.address = address
self.count = count
frame_struct = struct.Struct('>HH')
self._unpack = frame_struct.unpack
self._pack = frame_struct.pack
示例12: __init__
def __init__(self, address=None, values=None, **kwargs):
''' Initializes a new instance
:param address: The address to start writing to
:param values: The values to write
'''
ModbusRequest.__init__(self, **kwargs)
self.address = address
self.values = values or []
if not hasattr(values, '__iter__'):
values = [values]
self.count = len(self.values)
self.byte_count = self.count * 2
示例13: __init__
def __init__(self, raddress=None, rcount=None, waddress=None, wcount=None):
''' Initializes a new request message
:param raddress: The address to start reading from
:param rcount: The number of registers to read from address
:param waddress: The address to start writing to
:param wcount: The number of registers to write from address
'''
ModbusRequest.__init__(self)
self.raddress = raddress
self.rcount = rcount
self.waddress = waddress
self.wbyte_count = 0
if wcount != None and wcount > 0:
self.wregisters = [0] * wcount
else: self.wregisters = []
示例14: __init__
def __init__(self, address=None, **kwargs):
ModbusRequest.__init__(self, **kwargs)
self.address = address
self.count = 16
示例15: __init__
def __init__(self, **kwargs):
'''
Base initializer for a diagnostic request
'''
ModbusRequest.__init__(self, **kwargs)
self.message = None