def __init__(self, a_slave_address=DEFAULT_SLAVE_ADDRESS, a_port=ClusterController.DEFAULT_MODBUS_PORT, an_ip_address=None): """ slave_address priority to commandline arguments """ assert self.valid_slave_address(a_slave_address), 'init invalid slave address' try: self.init_arg_parse() l_slave_address = a_slave_address if (hasattr(self._args, 'slave_address') and self._args.slave_address): self._slave_addresses_list = SitUtils.args_to_list(self._args.slave_address) assert self.valid_slave_address_list(self._slave_addresses_list), 'Given script arguments are not valid, or could not be parsed' assert self.valid_ip(self._args.host_ip), 'valid ip address:{}'.format(self._args.host_ip) super().__init__(l_slave_address, a_port=a_port, an_ip_address=self._args.host_ip) self._logger = SitLogger().new_logger(self.__class__.__name__, self._args.host_mac) self.invariants() #self._logger.debug('init->' + self.out()) except OSError as l_e: self._logger.warning("init-> OSError, probably rollingfileAppender" % (l_e)) if e.errno != errno.ENOENT: raise l_e except Exception as l_e: print('Error in init: %s' % (l_e)) raise l_e
def __init__(self, a_slave_address=DEFAULT_SLAVE_ADDRESS, a_port=DEFAULT_MODBUS_PORT, an_ip_address=None): assert self.valid_slave_address(a_slave_address), 'invalid a_slave_address:{}'.format(a_slave_address) try: self.init_arg_parse() assert self.valid_slave_address(a_slave_address), 'a_slave_address parameter invalid:{}'.format(l_slave_address) l_slave_address = a_slave_address if __name__ == '__main__': if (hasattr(self._args, 'slave_address') and self._args.slave_address): l_slave_address = self._args.slave_address super().__init__(l_slave_address, self.DEFAULT_TARGET_MODE, a_port=self.DEFAULT_MODBUS_PORT, an_ip_address=self._args.host_ip) self._inverter_indexes_list = SitUtils.args_to_list(self._args.inverter_index) self._logger = SitLogger().new_logger(self.__class__.__name__, self._args.host_mac) self.invariants() #self._logger.debug('init->' + self.out()) except OSError as l_e: self._logger.warning("init-> OSError, probably rollingfileAppender" % (l_e)) if e.errno != errno.ENOENT: raise l_e except Exception as l_e: print('Error in init: %s' % (l_e)) raise l_e