示例#1
0
 def setUp(self):
     ''' Initializes the test environment '''
     self.context = ModbusSlaveContext(**{
         'di' : ModbusSequentialDataBlock(0, [0]*100),
         'co' : ModbusSequentialDataBlock(0, [0]*100),
         'ir' : ModbusSequentialDataBlock(0, [0]*100),
         'hr' : ModbusSequentialDataBlock(0, [0]*100)})
     self.initialize()
示例#2
0
    def __init__(self, *args, **kwargs):
        ''' Initializes the datastores
        :param kwargs: Each element is a ModbusDataBlock

            'di' - Discrete Inputs initializer
            'co' - Coils initializer
            'hr' - Holding Register initializer
            'ir' - Input Registers iniatializer
        '''
        self.store = {}
        self.store['d'] = kwargs.get('di', ModbusSequentialDataBlock(0, 0))
        self.store['c'] = kwargs.get('co', ModbusSequentialDataBlock(0, 0))
        self.store['i'] = kwargs.get('ir', ModbusSequentialDataBlock(0, 0))
        self.store['h'] = kwargs.get('hr', ModbusSequentialDataBlock(0, 0))
示例#3
0
    def __init__(self, *args, **kwargs):
        ''' Initializes the datastores, defaults to fully populated
        sequential data blocks if none are passed in.

        :param kwargs: Each element is a ModbusDataBlock

            'di' - Discrete Inputs initializer
            'co' - Coils initializer
            'hr' - Holding Register initializer
            'ir' - Input Registers iniatializer
        '''
        self.store = {}
        self.store['d'] = kwargs.get('di', ModbusSequentialDataBlock.create())
        self.store['c'] = kwargs.get('co', ModbusSequentialDataBlock.create())
        self.store['i'] = kwargs.get('ir', ModbusSequentialDataBlock.create())
        self.store['h'] = kwargs.get('hr', ModbusSequentialDataBlock.create())
示例#4
0
    def __init__(self, *args, **kwargs):
        ''' Initializes the datastores, defaults to fully populated
        sequential data blocks if none are passed in.

        :param kwargs: Each element is a ModbusDataBlock

            'di' - Discrete Inputs initializer
            'co' - Coils initializer
            'hr' - Holding Register initializer
            'ir' - Input Registers iniatializer
        '''
        self.store = {}
        self.store['d'] = kwargs.get('di', ModbusSequentialDataBlock.create())
        self.store['c'] = kwargs.get('co', ModbusSequentialDataBlock.create())
        self.store['i'] = kwargs.get('ir', ModbusSequentialDataBlock.create())
        self.store['h'] = kwargs.get('hr', ModbusSequentialDataBlock.create())
示例#5
0
 def register(self, fc, fx, datablock=None):
     """
     Registers a datablock with the slave context
     :param fc: function code (int)
     :param fx: string representation of function code (e.g 'cf' )
     :param datablock: datablock to associate with this function code
     :return:
     """
     self.store[fx] = datablock or ModbusSequentialDataBlock.create()
     self._IModbusSlaveContext__fx_mapper[fc] = fx
示例#6
0
 def register(self, fc, fx, datablock=None):
     """
     Registers a datablock with the slave context
     :param fc: function code (int)
     :param fx: string representation of function code (e.g 'cf' )
     :param datablock: datablock to associate with this function code
     :return:
     """
     self.store[fx] = datablock or ModbusSequentialDataBlock.create()
     self._IModbusSlaveContext__fx_mapper[fc] = fx