def _init_sit_modbus_registers(self, a_slave_address): """ Initializes self._sit_modbus_registers """ assert self.valid_slave_address( a_slave_address), 'invalid a_slave_address:{}'.format( a_slave_address) l_reg_list = OrderedDict() SitUtils.od_extend( l_reg_list, RegisterTypeInt16u( 'GHI', 'Total irradiation on the external irradiation sensor/pyranometer (W/m2)', 0x00, a_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Int16u', an_is_metadata=False)) #SitUtils.od_extend(l_reg_list, RegisterTypeInt16u('GHIDev', 'Solar radiation deviation (0~1800)', 0x52, a_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Int16u', an_is_metadata=False)) #SitUtils.od_extend(l_reg_list, RegisterTypeInt32u('WDigIo', 'Active power setpoint Digital I/O', 31235, l_slave_address, SitModbusRegister.ACCESS_MODE_R, '%', an_is_metadata=False, a_post_set_value_call=self.sma_fix2)) self.append_modbus_registers(l_reg_list) # self.add_cc_only_sit_modbus_registers(1) # self.add_common_sit_modbus_registers(2) self.invariants()
def _init_sit_modbus_registers(self, a_slave_address): """ Initializes self._sit_modbus_registers """ assert len(self._sit_modbus_registers) == 0 l_reg_list = OrderedDict() l_slave_address = a_slave_address self._add_common_registers(l_reg_list, l_slave_address) SitUtils.od_extend( l_reg_list, RegisterTypeInt16uScaleFactor('A', 'AC Current sum of all inverters', 40188, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'A', a_scale_factor=40192)) self.append_modbus_registers(l_reg_list) #error self.add_modbus_register('ID', 'Model ID (ID): 120 = Sunspec nameplate model', 40238, SitModbusRegister.REGISTER_TYPE_INT_16_U, SitModbusRegister.ACCESS_MODE_R, 'uint16') #error self.add_modbus_register('VArPct_Mod', 'Mode of the percentile reactive power limitation: 1 = in % of WMax', 40365, SitModbusRegister.REGISTER_TYPE_ENUM_16, SitModbusRegister.ACCESS_MODE_R, 'enum16') #self.add_modbus_register('VArPct_Ena', 'Control of the percentile reactive power limitation,(SMA: Qext): 1 = activated', 40365, SitModbusRegister.REGISTER_TYPE_ENUM_16, SitModbusRegister.ACCESS_MODE_RW, 'enum16') self.invariants()
def add_common_sit_modbus_registers(self, a_slave_address): """ COMMON REGISTERS to ClusterController and Inverters """ super().add_common_sit_modbus_registers(a_slave_address) l_reg_list = OrderedDict() l_slave_address = a_slave_address #PARAMETERS UNIT_ID = 2 (p.26 of doc) SitUtils.od_extend(l_reg_list, RegisterTypeInt32u('EvtNr', '30213: For error description refere to SMA register address 30247; 30247: Description of the event message, see the documentation of the product', 30247, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'enum', an_is_metadata=False)) #SitUtils.od_extend(l_reg_list, RegisterTypeInt32u('EvtNr', '30213: For error description refere to SMA register address 30247; 30247: Description of the event message, see the documentation of the product', 30247, SitModbusRegister.ACCESS_MODE_R, 'enum', an_is_metadata=False, a_slave_address=a_slave_address)) self.append_modbus_registers(l_reg_list)
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 _W_event(self, a_sit_modbus_register): """ Called by modbus_device.call_sit_modbus_registers_events() """ self._logger.debug('_W_event-> register:{}'.format(a_sit_modbus_register.out_short())) l_short_desc = 'W' l_min_val = self.MIN_W_FOR_RAISE_EVENT_GENERATION l_val = a_sit_modbus_register.value l_sit_dt = SitDateTime() if a_sit_modbus_register.short_description == l_short_desc: l_start_time = time(8, 30) l_end_time = time(16, 30) l_is_day, l_valid_time = l_sit_dt.time_is_between(datetime.now().time(), l_start_time, l_end_time) # l_is_between_sunrise_sunset = l_sit_dt.now_is_into_sunrise_sunset_from_conf(self._sit_json_conf) # # self._logger.debug('read_sit_modbus_register-> l_is_day:{} l_valid_time:{} l_is_between_sunrise_sunset:{}'.format(l_is_day, l_valid_time, l_is_between_sunrise_sunset)) l_msg = '_W_event-> register_index:{} value ({}) '.format(a_sit_modbus_register.register_index, l_val) l_msg += ' between {} and {}'.format(l_start_time, l_end_time) self._logger.info('_W_event-> DEVICE IS GENERATING {} kW'.format(l_val)) if ( l_valid_time and l_val <= l_min_val): l_msg = '_W_event-> register_index:{} value ({} <= {}), valid_time:{}'.format(a_sit_modbus_register.register_index, l_val, l_min_val, l_valid_time) self._logger.warning(l_msg) # Create Dir l_dir = '/tmp/solarity_events' if not os.path.exists(l_dir): os.makedirs(l_dir) l_file = self.__class__.__name__ + '_event_{}_register_{}_slave_{}'.format(datetime.now().strftime("%Y%m%d_%H"), a_sit_modbus_register.register_index, a_sit_modbus_register.slave_address) l_file_abs_path = l_dir + '/' + l_file if not os.path.exists(l_file_abs_path): self._logger.info('_W_event-> Event not sent, sending email file:{}'.format(l_file_abs_path)) # SEND MAIL l_subject = 'event with failure on $(hostname) slave:' + str(a_sit_modbus_register.slave_address) + ' $(date +%Y%m%d_%H%M%S) W val:(' + str(l_val) + ' <= ' + str(l_min_val) + ')W ' l_body = ['event in slave:{} with failure on $(hostname) $(date +%Y%m%d_%H%M%S) review file {}'.format(a_sit_modbus_register.slave_address, self.csv_file_path(a_sit_modbus_register.slave_address))] l_body.append(' Between {} and {}'.format(l_start_time, l_end_time)) l_body.append('Register->out:{}'.format(a_sit_modbus_register.out_human_readable(a_with_description=self._args.long))) l_subject, l_body = self._setted_parts(l_subject, l_body) SitUtils.send_mail(self.events_mail_receivers(), l_subject, l_body, [self.csv_file_path(a_sit_modbus_register.slave_address)]) os.mknod(l_file_abs_path) else: self._logger.warning('_W_event-> Event already sent, not sending email file:{}'.format(l_file_abs_path)) else: l_msg = '_W_event-> Event not raised register_index:{} value ({} > {}), valid_time:{}'.format(a_sit_modbus_register.register_index, l_val, l_min_val, l_valid_time) self._logger.debug(l_msg)
def out_human_readable(self, an_item_prefix='', a_with_description=False): l_res = '' assert self.short_description is not None assert self.value_unit is not None l_val = self.value if l_val is None: l_val = 'None' elif isinstance(l_val, int) or isinstance(l_val, float): from sit_utils import SitUtils l_val = SitUtils.format_number_human_readable(l_val, 2) if a_with_description: l_tmp = '({}/{}) '.format(self.register_index, self.slave_address) l_tmp += self.description l_desc = ' {:<55}'.format(l_tmp) else: l_desc = '' l_res += an_item_prefix + '{:<23}'.format( self.short_description) + '{:<5}'.format('=') + '{:<25}'.format( l_val) + '{:<10}'.format(self.value_unit) + l_desc return l_res
def local_offset_hours(self): """ returns local offset in hours ex. Chile -3 or -4 """ l_res = 0 l_cmd = 'date +%z' try: l_code, l_stdout, l_stderr = SitUtils.system_call(l_cmd) l_res = int(l_stdout) l_res = l_res / 100 except Exception as l_e: self._logger.error('localOffsetHours error'.format(l_e)) raise l_e assert l_res <= -3, 'local_offset_hours->invalid_l_res:{}'.format( l_res) self._logger.debug('localOffsetHours-> cmd_res:{} res:{}'.format( l_stdout, l_res)) return l_res return l_res
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
def add_inverter_modbus_registers(self, a_slave_address, an_inverter_index): """ INVERTERS see p.20 of documentation """ assert an_inverter_index >= 1, 'inverter index >= 1: {}'.format(an_inverter_index) l_initial_register_address = 51000 l_base_address = l_initial_register_address + (25 * (an_inverter_index - 1)) l_reg_list = OrderedDict() l_slave_address = a_slave_address self._logger.info('add_inverter_modbus_registers-> Base address: {}'.format(l_base_address)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32s(SitConstants.SS_REG_SHORT_ABB_AC_POWER, 'Active power for inverter nr: {}'.format(an_inverter_index), l_base_address, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'W', an_is_metadata=False, an_event=SitModbusRegisterEvent(self._W_event))) SitUtils.od_extend(l_reg_list, RegisterTypeInt16u(SitConstants.SS_REG_SHORT_ABB_STATUS_OPERATING_STATE, 'Status for inverter nr: {}'.format(an_inverter_index), l_base_address + 9, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'deg celcius', an_is_metadata=False)) SitUtils.od_extend(l_reg_list, RegisterTypeInt16s(SitConstants.SS_REG_SHORT_ABB_TEMP_CAB, 'Cabinet temperatore for inverter nr: {}'.format(an_inverter_index), l_base_address + 11, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'deg celcius', an_is_metadata=False)) self.append_modbus_registers(l_reg_list)
def _add_common_registers(self, a_reg_list, a_slave_address): """ adds to a_reg_list """ l_reg_list = a_reg_list l_slave_address = a_slave_address SitUtils.od_extend( l_reg_list, RegisterTypeString16('Mn', 'Manufacturer', 40005, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'String16', an_is_metadata=True)) SitUtils.od_extend( l_reg_list, RegisterTypeString16('Md', 'Model (Md): SMA Inverter Manager', 40021, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'String16', an_is_metadata=True)) SitUtils.od_extend( l_reg_list, RegisterTypeString8('Opt', 'Options (Opt): Inverter Manager name', 40037, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'String8', an_is_metadata=True)) SitUtils.od_extend( l_reg_list, RegisterTypeString8( 'Vr', 'Version (Vr): Version number of the installed firmware', 40045, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'String8', an_is_metadata=True)) SitUtils.od_extend( l_reg_list, RegisterTypeString16( 'SN', 'Serial number (SN) of the device that uses the Modbus unit ID', 40053, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'String16', an_is_metadata=True)) SitUtils.od_extend( l_reg_list, RegisterTypeInt16uScaleFactor( 'PPVphAB', 'Voltage, line conductor L1 to L2, in V V_SF (40199) : average value of all inverters', 40193, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'V', a_scale_factor=40199)) SitUtils.od_extend( l_reg_list, RegisterTypeInt16uScaleFactor( 'PPVphBC', 'Voltage, line conductor L2 to L3, in V V_SF (40199) : average value of all inverters', 40194, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'V', a_scale_factor=40199)) SitUtils.od_extend( l_reg_list, RegisterTypeInt16uScaleFactor( 'PPVphCA', 'Voltage, line conductor L3 to L1, in V V_SF (40199) : average value of all inverters', 40195, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'V', a_scale_factor=40199)) SitUtils.od_extend( l_reg_list, RegisterTypeInt16uScaleFactor( 'PPVphA', 'Voltage, line conductor L1 to N (PPVphA), in V-V_SF (40199): average value of all inverters', 40196, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'V', a_scale_factor=40199)) SitUtils.od_extend( l_reg_list, RegisterTypeInt16uScaleFactor( 'PPVphB', 'Voltage, line conductor L1 to N (PPVphB), in V-V_SF (40199): average value of all inverters', 40197, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'V', a_scale_factor=40199)) SitUtils.od_extend( l_reg_list, RegisterTypeInt16uScaleFactor( 'PPVphC', 'Voltage, line conductor L1 to N (PPVphC), in V-V_SF (40199): average value of all inverters', 40198, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'V', a_scale_factor=40199)) SitUtils.od_extend( l_reg_list, RegisterTypeInt16uScaleFactor( 'W', 'Active power (W), in W-W_SF (40201): sum of all inverters', 40200, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'W', a_scale_factor=40192, an_event=SitModbusRegisterEvent(self._W_event), a_post_set_value_call=self.w_fix)) SitUtils.od_extend( l_reg_list, RegisterTypeInt32uScaleFactor( 'WH', 'Total yield (WH), in Wh WH_SF (40212): sum of all inverters', 40210, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'WH', a_scale_factor=40212)) SitUtils.od_extend( l_reg_list, RegisterTypeInt16uScaleFactor( 'TmpCab', 'Internal temperature, in °C Tmp_SF (40223): average value of all inverters', 40219, l_slave_address, SitModbusRegister.ACCESS_MODE_R, '°C', a_scale_factor=40223))
def _init_sit_modbus_registers(self, a_slave_address): """ Initializes self._sit_modbus_registers """ l_reg_list = OrderedDict() l_slave_address = a_slave_address self._add_common_registers(l_reg_list, l_slave_address) SitUtils.od_extend( l_reg_list, RegisterTypeInt16u('ID', 'Model ID (ID): 120 = Sunspec nameplate model', 40238, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'uint16', an_is_metadata=True)) SitUtils.od_extend( l_reg_list, RegisterTypeInt16uScaleFactor('AC_A', 'AC Current sum of all inverters', 40188, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'A', a_scale_factor=40192)) SitUtils.od_extend( l_reg_list, RegisterTypeInt16u( 'VArPct_Mod', 'Mode of the percentile reactive power limitation: 1 = in % of WMax', 40365, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'enum16')) SitUtils.od_extend( l_reg_list, RegisterTypeInt16u( 'VArPct_Ena', 'Control of the percentile reactive power limitation,(SMA: Qext): 1 = activated', 40365, l_slave_address, SitModbusRegister.ACCESS_MODE_RW, 'enum16')) SitUtils.od_extend( l_reg_list, RegisterTypeInt16u('WMaxLim_Ena', 'Limiting (0 Deactivate, 1 activated):', 40353, l_slave_address, SitModbusRegister.ACCESS_MODE_RW, 'enum16')) SitUtils.od_extend( l_reg_list, RegisterTypeInt16uScaleFactor( 'WMaxLimPct', 'Set power to default value, in % of WMax-WMaxLimPct_SF', 40349, l_slave_address, SitModbusRegister.ACCESS_MODE_RW, 'uint16', a_scale_factor=40367)) SitUtils.od_extend( l_reg_list, RegisterTypeInt16uScaleFactor( 'VRef', 'Voltage at the PCC (VRef), in V VRef_SF (40289)', 40269, l_slave_address, SitModbusRegister.ACCESS_MODE_RW, 'uint16', 40289)) SitUtils.od_extend( l_reg_list, RegisterTypeInt16uScaleFactor( 'VMax', 'Set value for maximum voltage (VMax), in V VMinMax_SF', 40271, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'uint16', a_scale_factor=40291)) self.append_modbus_registers(l_reg_list) self.invariants()
def add_cc_only_sit_modbus_registers(self, a_slave_address): """ Registers particular to cluster controller """ assert self.valid_slave_address(a_slave_address), 'invalid a_slave_address:{}'.format(a_slave_address) assert a_slave_address == 2, 'add_cc_only_sit_modbus_registers->for this part slave_address should be =2 and is:{}'.format(a_slave_address) l_reg_list = OrderedDict() l_slave_address = a_slave_address #PARAMETERS UNIT_ID = 2 (p.26 of doc) SitUtils.od_extend(l_reg_list, RegisterTypeInt32u('WDigIo', 'Active power setpoint Digital I/O', 31235, l_slave_address, SitModbusRegister.ACCESS_MODE_R, '%', an_is_metadata=False, a_post_set_value_call=self.sma_fix2)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32u('WAnalog', 'Active power setpoint Analog', 31237, l_slave_address, SitModbusRegister.ACCESS_MODE_R, '%', an_is_metadata=False, a_post_set_value_call=self.sma_fix2)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32u('WSetPoint', 'Active power setpoint in %s', 31239, l_slave_address, SitModbusRegister.ACCESS_MODE_R, '%', an_is_metadata=False, a_post_set_value_call=self.sma_fix2)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('WSetPointDirMar', 'Active power setpoint in %s Specification Modbus Direct marketing', 31241, l_slave_address, SitModbusRegister.ACCESS_MODE_R, '%', an_is_metadata=False, a_post_set_value_call=self.sma_fix2)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32u('ResSetPoint', 'Resulting setpoint (minimum value definition of all specifications)', 31243, l_slave_address, SitModbusRegister.ACCESS_MODE_R, '%', an_is_metadata=False, a_post_set_value_call=self.sma_fix2)) #Strange SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('WExport', 'Current utility grid export active power P in W (actual value of the active power fed in at the grid-connection point; measured with an external measuring device).', 31249, l_slave_address, SitModbusRegister.ACCESS_MODE_R, '%', an_is_metadata=False)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('VArExport', 'Current utility grid export reactive power Q in VAr (actual value of the reactive power fed in at the grid- connection point; measured with an external measuring device).', 31251, l_slave_address, SitModbusRegister.ACCESS_MODE_R, '%', an_is_metadata=False)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('AC_1', 'Analog current input 1 (mA)', 34637, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'mA', an_is_metadata=False, a_post_set_value_call=self.sma_fix2)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('AC_2', 'Analog current input 2 (mA)', 34639, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'mA', an_is_metadata=False, a_post_set_value_call=self.sma_fix2)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('AC_3', 'Analog current input 3 (mA)', 34641, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'mA', an_is_metadata=False, a_post_set_value_call=self.sma_fix2)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('AC_4', 'Analog current input 4 (mA)', 34643, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'mA', an_is_metadata=False, a_post_set_value_call=self.sma_fix2)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('InDCV_1', 'Analog voltage input 1 (V)', 34645, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'V', an_is_metadata=False, a_post_set_value_call=self.sma_fix2)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('InDCV_2', 'Analog voltage input 2 (V)', 34647, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'V', an_is_metadata=False, a_post_set_value_call=self.sma_fix2)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('InDCV_3', 'Analog voltage input 3 (V)', 34649, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'V', an_is_metadata=False, a_post_set_value_call=self.sma_fix2)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('InDCV_4', 'Analog voltage input 4 (V)', 34651, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'V', an_is_metadata=False, a_post_set_value_call=self.sma_fix2)) SitUtils.od_extend(l_reg_list, RegisterTypeInt16s('WSetPointDirTotal', 'Direct marketer: Active power setpoint P, in % of the maximum active power (PMAX) of the PV plant. -100-0=Load|0=No active power|0-100 generator', 40493, l_slave_address, SitModbusRegister.ACCESS_MODE_R, '%', an_is_metadata=False, a_post_set_value_call=self.sma_fix2)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32u('WSetPointMan', 'Active power setpoint (manual specification)', 41167, l_slave_address, SitModbusRegister.ACCESS_MODE_R, '%', an_is_metadata=False, a_post_set_value_call=self.sma_fix2)) # IRRADIATIONS # not working on sanbe, getting max_int, SitUtils.od_extend(l_reg_list, RegisterTypeInt32u('IrradiationSurfaceTot', 'Total irradiation on the sensor surface (W/m2)', 34613, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'W/m2', an_is_metadata=False)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32u('GHI', 'Total irradiation on the external irradiation sensor/pyranometer (W/m2)', 34623, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'W/m2', an_is_metadata=False)) self.append_modbus_registers(l_reg_list)
def add_common_sit_modbus_registers(self, a_slave_address): """ Common devices registers """ assert self.valid_slave_address(a_slave_address), 'invalid a_slave_address:{}'.format(a_slave_address) assert a_slave_address == 1 or a_slave_address >= 3, 'Dont ask for slave_address 2, the add_cc_only_sit_modbus_registers is done for that! addr:{}'.format(a_slave_address) l_reg_list = OrderedDict() l_slave_address = a_slave_address # CLUSTER AND INVERTERS SitUtils.od_extend(l_reg_list, RegisterTypeInt32u('Vr', 'Version number of the SMA Modbus profile', 30001, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Int32u', an_is_metadata=True)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32u('ID', 'SUSy ID (of the Cluster Controller)', 30003, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Int32u', an_is_metadata=True)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32u('SN', 'Serial number (of the Cluster Controller)', 30005, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Int32u', an_is_metadata=True)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('NewData', 'Modbus data change: meter value is increased by the Cluster Controller if new data is available.', 30007, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Int32u', an_is_metadata=False)) SitUtils.od_extend(l_reg_list, RegisterTypeSmaCCDeviceClass('DeviceClass', 'Device Class', 30051, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Enum', an_is_metadata=True)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('W', 'Current active power on all line conductors (W), accumulated values of the inverters', 30775, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'W', an_is_metadata=False, an_event=SitModbusRegisterEvent(self._W_event))) SitUtils.od_extend(l_reg_list, RegisterTypeInt64u('Wh', 'Total energy fed in across all line conductors, in Wh (accumulated values of the inverters) System param', 30513, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Wh', an_is_metadata=False)) SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('VAr', 'Reactive power on all line conductors (var), accumulated values of the inverters', 30805, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'VAr', an_is_metadata=False)) SitUtils.od_extend(l_reg_list, RegisterTypeInt64u('TotWhDay', 'Energy fed in on current day across all line conductors, in Wh (accumulated values of the inverters)', 30517, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Wh', an_is_metadata=False)) self.append_modbus_registers(l_reg_list)
def add_common_sit_modbus_registers(self, a_slave_address): """ Common devices registers """ assert self.valid_slave_address( a_slave_address), 'invalid a_slave_address:{}'.format( a_slave_address) assert a_slave_address == 1 or a_slave_address >= 3, 'Dont ask for slave_address 2, the add_cc_only_sit_modbus_registers is done for that! addr:{}'.format( a_slave_address) l_reg_list = OrderedDict() l_slave_address = a_slave_address SitUtils.od_extend( l_reg_list, RegisterTypeStringVar(SitConstants.SS_REG_SHORT_ABB_SERIAL_NUMBER, 'ESN', 40713, 10, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'W', an_is_metadata=True)) SitUtils.od_extend( l_reg_list, RegisterTypeInt32s(SitConstants.SS_REG_SHORT_ABB_AC_POWER, 'Total active output power of all inverters', 40525, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'W', an_is_metadata=False, an_event=SitModbusRegisterEvent(self._W_event))) SitUtils.od_extend( l_reg_list, RegisterTypeInt32s( SitConstants.SS_REG_SHORT_ABB_AC_S_REACTIVE_POWER, 'Reactive power', 40544, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'kVar', an_is_metadata=False)) # Active power control # SitUtils.od_extend(l_reg_list, RegisterTypeInt16u(SitConstants.SS_REG_SHORT_ABB_STATUS_OPERATING_STATE, 'Plant Status 1=Unlimited/2Limited/3Idle/4Fault/5Communication_interrupt', 40543, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Enum', an_is_metadata=False)) # Not working on tranque sante and maristas santamaria SitUtils.od_extend( l_reg_list, RegisterTypeInt16u('PlantSt2', 'Plant Status 2 0=ildle/1=on-grid/...', 40566, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Enum', an_is_metadata=False)) SitUtils.od_extend( l_reg_list, RegisterTypeInt16u('ActPwrCtlMode', 'Active power control mode 0=no limit/other...', 40737, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Enum', an_is_metadata=False)) #Meter # UNABLE TO READ IT SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('WMeter', 'Active power of meter', 32278, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'W', an_is_metadata=False)) #Huawei specials SitUtils.od_extend( l_reg_list, RegisterTypeInt32s( SitConstants.SS_REG_SHORT_EXTRA_HUAWEI_ACT_POWER_ADJ, 'Active Power adjustment', 40426, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Int', an_is_metadata=False)) SitUtils.od_extend( l_reg_list, RegisterTypeInt16u( SitConstants.SS_REG_SHORT_EXTRA_HUAWEI_ACT_POWER_ADJ_PCT, 'Active Power adjustment percentage', 40428, l_slave_address, SitModbusRegister.ACCESS_MODE_R, '%', an_is_metadata=False)) SitUtils.od_extend( l_reg_list, RegisterTypeInt32u( 'LifeTimeKWHOut', 'Equals the total energy yield generatedby all inverters.', 40560, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'UInt', an_is_metadata=False)) SitUtils.od_extend( l_reg_list, RegisterTypeInt32u( 'TodaykWhOutput', 'Equals daily energy yield generated byall inverters.', 40562, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'UInt', an_is_metadata=False)) #SitUtils.od_extend(l_reg_list, RegisterTypeStrVar('Mn', 'Model', 30000, 15, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'String15', an_is_metadata=True)) # CLUSTER AND INVERTERS # SitUtils.od_extend(l_reg_list, RegisterTypeInt32u('Vr', 'Version number of the SMA Modbus profile', 30001, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Int32u', an_is_metadata=True)) # # SitUtils.od_extend(l_reg_list, RegisterTypeInt32u('ID', 'SUSy ID (of the Cluster Controller)', 30003, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Int32u', an_is_metadata=True)) # SitUtils.od_extend(l_reg_list, RegisterTypeInt32u('SN', 'Serial number (of the Cluster Controller)', 30005, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Int32u', an_is_metadata=True)) # SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('NewData', 'Modbus data change: meter value is increased by the Cluster Controller if new data is available.', 30007, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Int32u', an_is_metadata=False)) # SitUtils.od_extend(l_reg_list, RegisterTypeSmaCCDeviceClass('DeviceClass', 'Device Class', 30051, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Enum', an_is_metadata=True)) # # SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('W', 'Current active power on all line conductors (W), accumulated values of the inverters', 30775, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'W', an_is_metadata=False, an_event=SitModbusRegisterEvent(self._W_event))) # SitUtils.od_extend(l_reg_list, RegisterTypeInt64u('Wh', 'Total energy fed in across all line conductors, in Wh (accumulated values of the inverters) System param', 30513, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Wh', an_is_metadata=False)) # SitUtils.od_extend(l_reg_list, RegisterTypeInt32s('VAr', 'Reactive power on all line conductors (var), accumulated values of the inverters', 30805, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'VAr', an_is_metadata=False)) # SitUtils.od_extend(l_reg_list, RegisterTypeInt64u('TotWhDay', 'Energy fed in on current day across all line conductors, in Wh (accumulated values of the inverters)', 30517, l_slave_address, SitModbusRegister.ACCESS_MODE_R, 'Wh', an_is_metadata=False)) # self.append_modbus_registers(l_reg_list)