class MissionActionsHandler(object): def __init__(self, config): self.filename = config.csettings[ 'configs_path'] + '/' + config.csettings['last_auv_config_xml'] logger.debug("Reading Mission Actions XML...") self.configParser = XMLConfigParser(self.filename) def get_actions(self): """ Get a list of action from xml structure configuration :return: return a list of actions from a xml structure configuration """ # get misison actions mission_actions = self.configParser.first_match( self.configParser.root, "mission_actions") # all actions actions = self.configParser.all_matches(mission_actions, "action") return actions def get_name_from_param(self, param): """ Get name from 'param'""" return self.configParser.first_match(param, "param_name").text def get_type_from_param(self, param): """ Get type from 'param'""" return self.configParser.first_match(param, "param_type").text
def __init__(self, config): config_check_xml = ConfigCheckXML(config) if not config_check_xml.exists(): config_check_xml.exec_() # last auv config xml self.configParser = XMLConfigParser( config.csettings['configs_path'] + '/' + config.csettings['last_auv_config_xml'])
class CheckListHandler(object): def __init__(self, config): self.filename = config.csettings[ 'configs_path'] + '/' + config.csettings['last_auv_config_xml'] self.configParser = XMLConfigParser(self.filename) def get_check_lists(self): """ Get check_lists :return: return all lists from check_lists """ chk_lists = self.configParser.first_match(self.configParser.root, "check_lists") # all check_list in check_lists lists = self.configParser.all_matches(chk_lists, "check_list") return lists def get_items_from_checklist(self, checklist_name): """ Get all items from a check_list with name 'checklist_name' :param checklist_name: name of the check_list :return: return a list of items from a check_list with name 'checklist_name' """ chk_lists = self.configParser.first_match(self.configParser.root, "check_lists") # get specific check_list by attribute chk_name xml_check_list = self.configParser.first_match( chk_lists, "check_list[@id='" + checklist_name + "']") # all check_list items check_items = self.configParser.all_matches(xml_check_list, "check_item") return check_items def get_description_from_item(self, item): """ Get description field from 'item' :param item: item is a check_item from xml structure configuration :return: return description field from 'item' """ description = self.configParser.first_match(item, "description") return description def get_check_topics_from_item(self, item): """ Get check_topics from 'item' :param item: item is a check_item from xml structure configuration :return: return a list of check_topics from 'item' """ check_topics = self.configParser.all_matches(item, "check_topic") return check_topics def get_check_actions_from_item(self, item): """ Get check_actions from 'item' :param item: item is a check_item from xml structure configuration :return: return a list of check_actions from 'item' """ check_actions = self.configParser.all_matches(item, "check_action") return check_actions
class VehicleInfoHandler(object): def __init__(self, config): config_check_xml = ConfigCheckXML(config) if not config_check_xml.exists(): config_check_xml.exec_() # last auv config xml self.configParser = XMLConfigParser( config.csettings['configs_path'] + '/' + config.csettings['last_auv_config_xml']) def read_configuration(self): # get Vehicle Info xml_vehicle_info = self.configParser.first_match( self.configParser.root, "vehicle_info") return xml_vehicle_info def write(self): self.configParser.write()
class VehicleDataHandler(object): def __init__(self, config): self.filename = config.csettings['configs_path'] + '/' + config.csettings['last_auv_config_xml'] self.configParser = XMLConfigParser(self.filename) def read_topics(self): # get Vehicle Data topics xml_vehicle_data_topics = self.configParser.first_match(self.configParser.root, "vehicle_data_topics") return xml_vehicle_data_topics def read_services(self): # get Vehicle Data services xml_vehicle_data_services = self.configParser.first_match(self.configParser.root, "vehicle_data_services") return xml_vehicle_data_services def read_launch_list(self): # get Launch list xml_launch_list = self.configParser.first_match(self.configParser.root, "launch_list") return xml_launch_list
def __init__(self, config): self.filename = config.csettings[ 'configs_path'] + '/' + config.csettings['last_auv_config_xml'] self.configParser = XMLConfigParser(self.filename)
def read_configuration(self): logger.debug("Reading ros_params XML...") config_parser = XMLConfigParser(self.filename) # get ros_params ros_params = config_parser.first_match(config_parser.root, "ros_params") # all sections in ros_params sections = config_parser.all_matches(ros_params, "section") # initialize empty list of sections section_list = list() # fill section values by reading xml and corresponding param values in the param server for section in sections: sect = Section() logger.debug("section.tag") for value in section: # description if value.tag == 'description': logger.debug(" {} {}".format(value.tag, value.text)) sect.set_description(value.text) # param if value.tag == 'param': logger.debug(" {}".format(value.tag)) desc = config_parser.first_match(value, "description").text param = Param(desc) field = config_parser.first_match(value, "field") if field is not None: f_name = config_parser.first_match( field, "field_name").text f_type = config_parser.first_match( field, "field_type").text param.set_field(f_name, f_type) else: field_array = config_parser.first_match( value, "field_array") f_name = config_parser.first_match( field_array, "field_array_name").text f_type = config_parser.first_match( field_array, "field_array_type").text f_size = config_parser.first_match( field_array, "field_array_size").text param.set_field_array(f_name, f_type, f_size) p_value = cola2_interface.get_ros_param( self.ip, self.port, self.vehicle_namespace + f_name)['value'] param.set_value(p_value) logger.debug(" {}".format(desc)) logger.debug(" {}".format(f_name)) logger.debug(" {}".format(p_value)) logger.debug(" {}".format(f_type)) sect.add_param(param) # action_id if value.tag == 'action_id': logger.debug(" {} {}".format(value.tag, value.text)) sect.set_action_id(value.text) section_list.append(sect) return section_list
def __init__(self, config): self.filename = config.csettings[ 'configs_path'] + '/' + config.csettings['last_auv_config_xml'] logger.debug("Reading Mission Actions XML...") self.configParser = XMLConfigParser(self.filename)