def DictBodyVisit(self, obj): """ Defined to generate the body of the Python channel class @parms obj: the instance of the channel model to operation on. """ inst = 0 for id in obj.get_ids(): c = ChannelBody.ChannelBody() if len(obj.get_ids()) > 1: c.name = obj.get_name() + "_%d" % inst else: c.name = obj.get_name() c.id = id c.description = obj.get_comment() c.format_string = obj.get_format_string() c.component = obj.get_component_name() (c.low_red, c.low_orange, c.low_yellow, c.high_yellow, c.high_orange, c.high_red) = obj.get_limits() c.ser_import = None (c.type, c.ser_import, type_name, dontcare) = DictTypeConverter.DictTypeConverter().convert( obj.get_type(), obj.get_size()) # special case for enums and Gse GUI. Needs to convert %d to %s if type_name == "enum": c.format_string = "%s" self._writeTmpl(c, self.__fp[inst], "channelBodyVisit") self.__fp[inst].close() inst += 1
def DictBodyWrite(self, obj, topology_model): """ Defined to generate the body of the Python channel class @parms obj: the instance of the channel model to operation on. """ try: instance_obj_list = topology_model.get_base_id_dict()[ obj.get_component_base_name()] except Exception: PRINT.info( "ERROR: Could not find instance object for component " + obj.get_component_base_name() + ". Check topology model to see if the component was instanced." ) raise for instance_obj in instance_obj_list: c = ChannelBody.ChannelBody() if instance_obj[3].get_dict_short_name() != None: fname = "{}_{}".format(instance_obj[3].get_dict_short_name(), obj.get_name()) elif not topology_model.get_prepend_instance_name() and len( instance_obj_list) == 1: fname = obj.get_name() else: fname = "{}_{}".format(instance_obj[0], obj.get_name()) c.name = fname if len(obj.get_ids()) > 1: raise Exception( "There is more than one event id when creating dictionaries. Check xml of {} or see if multiple explicit IDs exist in the AcConstants.ini file" .format(fname)) try: c.id = hex(instance_obj[1] + int(float(obj.get_ids()[0]))) except: c.id = hex(instance_obj[1] + int(obj.get_ids()[0], 16)) c.description = obj.get_comment() c.format_string = obj.get_format_string() c.component = obj.get_component_name() (c.low_red, c.low_orange, c.low_yellow, c.high_yellow, c.high_orange, c.high_red) = obj.get_limits() c.ser_import = None (c.type, c.ser_import, type_name, dontcare) = DictTypeConverter.DictTypeConverter().convert( obj.get_type(), obj.get_size()) # special case for enums and Gse GUI. Needs to convert %d to %s if type_name == "enum": c.format_string = "%s" self._writeTmpl(c, self.__fp[fname], "channelBodyWrite") self.__fp[fname].close()