Пример #1
0
 def run(self):
     conn = self.frmwk.serial_connection
     logger = self.logger
     meter_id = self.options['METERID']
     if not self.frmwk.serial_login():
         logger.warning('meter login failed')
     gen_ctl = C1219GeneralAccess(conn)
     if gen_ctl.id_form == 0:
         logger.info('device id stored in 20 byte string')
         if len(meter_id) > 20:
             self.frmwk.print_error(
                 'METERID length exceeds the allowed 20 bytes')
             return
     else:
         logger.info('device id stored in BCD(10)')
         if len(meter_id) > 10:
             self.frmwk.print_error(
                 'METERID length exceeds the allowed 10 bytes')
             return
     if gen_ctl.set_device_id(meter_id):
         self.frmwk.print_error('Could not set the Meter\'s ID')
     else:
         self.frmwk.print_status(
             'Successfully updated the Meter\'s ID to: ' + meter_id)
     conn.stop()
     return
Пример #2
0
	def run(self):
		conn = self.frmwk.serial_connection
		logger = self.logger
		if not self.frmwk.serial_login():	# don't alert on failed logins
			logger.warning('meter login failed, not all information may be available')
			self.frmwk.print_error('Meter login failed, not all information may be available')
		conn = self.frmwk.serial_connection
		
		try:
			generalCtl = C1219GeneralAccess(conn)
		except C1218ReadTableError:
			self.frmwk.print_error('Could not read the necessary tables')
			return
		conn.stop()
		
		meter_info = {}
		meter_info['Character Encoding'] = generalCtl.char_format
		meter_info['Device Type'] = generalCtl.nameplate_type
		meter_info['C12.19 Version'] =  {0:'Pre-release', 1:'C12.19-1997', 2:'C12.19-2008'}.get(generalCtl.std_version_no) or 'Unknown'
		meter_info['Manufacturer'] = generalCtl.manufacturer
		meter_info['Model'] = generalCtl.ed_model
		meter_info['Hardware Version'] = str(generalCtl.hw_version_no) + '.' + str(generalCtl.hw_revision_no)
		meter_info['Firmware Version'] = str(generalCtl.fw_version_no) + '.' + str(generalCtl.fw_revision_no)
		meter_info['Serial Number'] = generalCtl.mfg_serial_no
		
		if generalCtl.ed_mode != None:
			modes = []
			flags = ['Metering', 'Test Mode', 'Meter Shop Mode', 'Factory']
			for i in range(len(flags)):
				if generalCtl.ed_mode & (2 ** i):
					modes.append(flags[i])
			if len(modes):
				meter_info['Mode Flags'] = ', '.join(modes)
		
		if generalCtl.std_status != None:
			status = []
			flags = ['Unprogrammed', 'Configuration Error', 'Self Check Error', 'RAM Failure', 'ROM Failure', 'Non Volatile Memory Failure', 'Clock Error', 'Measurement Error', 'Low Battery', 'Low Loss Potential', 'Demand Overload', 'Power Failure', 'Tamper Detect', 'Reverse Rotation']
			for i in range(len(flags)):
				if generalCtl.std_status & (2 ** i):
					status.append(flags[i])
			if len(status):
				meter_info['Status Flags'] = ', '.join(status)
		if generalCtl.device_id != None:
			meter_info['Device ID'] = generalCtl.device_id
		
		self.frmwk.print_status('General Information:')
		fmt_string = "    {0:.<38}.{1}"
		keys = meter_info.keys()
		keys.sort()
		for key in keys:
			self.frmwk.print_status(fmt_string.format(key, meter_info[key]))
		return
Пример #3
0
    def run(self):
        conn = self.frmwk.serial_connection

        try:
            general_ctl = C1219GeneralAccess(conn)
        except C1218ReadTableError:
            self.frmwk.print_error('Could not read the necessary tables')
            return

        meter_info = {}
        meter_info['Character Encoding'] = general_ctl.char_format
        meter_info['Device Type'] = general_ctl.nameplate_type
        meter_info['C12.19 Version'] = {
            0: 'Pre-release',
            1: 'C12.19-1997',
            2: 'C12.19-2008'
        }.get(general_ctl.std_version_no) or 'Unknown'
        meter_info['Manufacturer'] = general_ctl.manufacturer
        meter_info['Model'] = general_ctl.ed_model
        meter_info['Hardware Version'] = str(
            general_ctl.hw_version_no) + '.' + str(general_ctl.hw_revision_no)
        meter_info['Firmware Version'] = str(
            general_ctl.fw_version_no) + '.' + str(general_ctl.fw_revision_no)
        meter_info['Serial Number'] = general_ctl.mfg_serial_no

        if general_ctl.ed_mode is not None:
            modes = []
            flags = ['Metering', 'Test Mode', 'Meter Shop Mode', 'Factory']
            for i in range(len(flags)):
                if general_ctl.ed_mode & (2**i):
                    modes.append(flags[i])
            if len(modes):
                meter_info['Mode Flags'] = ', '.join(modes)

        if general_ctl.std_status is not None:
            status = []
            for i, flag in enumerate(STATUS_FLAGS):
                if general_ctl.std_status & (2**i):
                    status.append(flag)
            if len(status):
                meter_info['Status Flags'] = ', '.join(status)
        if general_ctl.device_id is not None:
            meter_info['Device ID'] = general_ctl.device_id

        self.frmwk.print_status('General Information:')
        fmt_string = "    {0:.<38}.{1}"
        keys = sorted(list(meter_info.keys()))
        for key in keys:
            self.frmwk.print_status(fmt_string.format(key, meter_info[key]))