mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-30 03:27:33 +08:00
Fix in python supervision (#2210)
Control panel configuration : only search for "conf/control_panel.xml".
This commit is contained in:
committed by
Gautier Hattenberger
parent
4a7983370e
commit
751d9c7fcf
@@ -268,58 +268,16 @@ class Hmi(Widgets.QMainWindow):
|
|||||||
# [Hmi methods] Init HMI methods
|
# [Hmi methods] Init HMI methods
|
||||||
|
|
||||||
def init_hmi_data(self):
|
def init_hmi_data(self):
|
||||||
"""
|
|
||||||
-> Initialization of a 'Data' object with all necessary data from XML
|
|
||||||
files found in the 'CONF_PATH' Paparazzi UAV directory.
|
|
||||||
-> Loading of cache data (last settings used) to restore them.
|
|
||||||
-> Initialization of main HMI widgets with necessary data found.
|
|
||||||
"""
|
|
||||||
init_conf_xml_path()
|
|
||||||
|
|
||||||
# Data object creation implies XML parsing in the parser module :
|
|
||||||
try:
|
try:
|
||||||
self.data = parser.Data(CONF_PATH)
|
self.init_hmi_data_core()
|
||||||
|
|
||||||
# Cache parameters extracted from the cache dictionary :
|
|
||||||
last_geometry = self.data.cache[parser.LAST_GEOMETRY].split(" ")
|
|
||||||
last_x, last_y, last_width, last_height = map(int, last_geometry)
|
|
||||||
self.setGeometry(last_x, last_y, last_width, last_height)
|
|
||||||
|
|
||||||
last_set_name = self.data.cache[parser.LAST_SET]
|
|
||||||
self.current_set = self.data.sets[last_set_name]
|
|
||||||
|
|
||||||
point_symbol_link_to(self.current_set.name)
|
|
||||||
|
|
||||||
last_config_name = self.data.cache[parser.LAST_CONFIG]
|
|
||||||
self.current_config = self.data.configurations[last_config_name]
|
|
||||||
|
|
||||||
last_target_name = self.data.cache[parser.LAST_TARGET]
|
|
||||||
self.current_target = self.current_config.targets[last_target_name]
|
|
||||||
|
|
||||||
self.ui.upload.setEnabled(self.current_target.name
|
|
||||||
not in self.simulation_targets_names)
|
|
||||||
|
|
||||||
last_device_name = self.data.cache[parser.LAST_DEVICE]
|
|
||||||
self.current_device = self.data.devices[last_device_name]
|
|
||||||
|
|
||||||
last_session_name = self.data.cache[parser.LAST_SESSION]
|
|
||||||
self.current_session = self.data.sessions[last_session_name]
|
|
||||||
|
|
||||||
last_log_filters = self.data.cache[parser.LAST_LOG_FILTERS].split(" ")
|
|
||||||
last_level = last_log_filters[0]
|
|
||||||
last_default, last_info, last_warning, last_error =\
|
|
||||||
map(int, last_log_filters[1:])
|
|
||||||
self.current_log_filter = cs.LogFilter(last_level,
|
|
||||||
last_default, last_info,
|
|
||||||
last_warning, last_error)
|
|
||||||
except:
|
except:
|
||||||
" if something goes wrong, delete cache and load again (to be improved)"
|
" if something goes wrong, delete cache and load again (to be improved)"
|
||||||
LOGGER.error("ERROR while load HMI cache"
|
LOGGER.error("ERROR while load HMI cache"
|
||||||
"Original message : '%s'.", sys.exc_info()[0])
|
"Original message : '%s'.", sys.exc_info()[0])
|
||||||
print("HMI error in cache, load default instead")
|
print("HMI error in cache, load default instead")
|
||||||
parser.delete_cache()
|
parser.delete_cache()
|
||||||
self.init_hmi_data()
|
self.init_hmi_data_core()
|
||||||
|
|
||||||
# Run and build Paparazzi versions found by existing program
|
# Run and build Paparazzi versions found by existing program
|
||||||
# './paparazzi_version' and file './var/build_version.txt' :
|
# './paparazzi_version' and file './var/build_version.txt' :
|
||||||
run_version_cmd = env.RUN_VERSION_EXE
|
run_version_cmd = env.RUN_VERSION_EXE
|
||||||
@@ -327,6 +285,50 @@ class Hmi(Widgets.QMainWindow):
|
|||||||
build_version_cmd = " ".join(["cat", env.BUILD_VERSION_FILE])
|
build_version_cmd = " ".join(["cat", env.BUILD_VERSION_FILE])
|
||||||
self.build_version = os.popen(build_version_cmd).readline().strip()
|
self.build_version = os.popen(build_version_cmd).readline().strip()
|
||||||
|
|
||||||
|
def init_hmi_data_core(self):
|
||||||
|
"""
|
||||||
|
-> Initialization of a 'Data' object with all necessary data from XML
|
||||||
|
files found in the 'CONF_PATH' Paparazzi UAV directory.
|
||||||
|
-> Loading of cache data (last settings used) to restore them.
|
||||||
|
-> Initialization of main HMI widgets with necessary data found.
|
||||||
|
"""
|
||||||
|
init_conf_xml_path()
|
||||||
|
self.data = parser.Data(CONF_PATH)
|
||||||
|
|
||||||
|
# Cache parameters extracted from the cache dictionary :
|
||||||
|
last_geometry = self.data.cache[parser.LAST_GEOMETRY].split(" ")
|
||||||
|
last_x, last_y, last_width, last_height = map(int, last_geometry)
|
||||||
|
self.setGeometry(last_x, last_y, last_width, last_height)
|
||||||
|
|
||||||
|
last_set_name = self.data.cache[parser.LAST_SET]
|
||||||
|
self.current_set = self.data.sets[last_set_name]
|
||||||
|
|
||||||
|
point_symbol_link_to(self.current_set.name)
|
||||||
|
|
||||||
|
last_config_name = self.data.cache[parser.LAST_CONFIG]
|
||||||
|
self.current_config = self.data.configurations[last_config_name]
|
||||||
|
|
||||||
|
last_target_name = self.data.cache[parser.LAST_TARGET]
|
||||||
|
self.current_target = self.current_config.targets[last_target_name]
|
||||||
|
|
||||||
|
self.ui.upload.setEnabled(self.current_target.name
|
||||||
|
not in self.simulation_targets_names)
|
||||||
|
|
||||||
|
last_device_name = self.data.cache[parser.LAST_DEVICE]
|
||||||
|
self.current_device = self.data.devices[last_device_name]
|
||||||
|
|
||||||
|
last_session_name = self.data.cache[parser.LAST_SESSION]
|
||||||
|
self.current_session = self.data.sessions[last_session_name]
|
||||||
|
|
||||||
|
last_log_filters = self.data.cache[parser.LAST_LOG_FILTERS].split(" ")
|
||||||
|
last_level = last_log_filters[0]
|
||||||
|
last_default, last_info, last_warning, last_error =\
|
||||||
|
map(int, last_log_filters[1:])
|
||||||
|
self.current_log_filter = cs.LogFilter(last_level,
|
||||||
|
last_default, last_info,
|
||||||
|
last_warning, last_error)
|
||||||
|
|
||||||
|
|
||||||
def init_hmi_widgets(self):
|
def init_hmi_widgets(self):
|
||||||
"""
|
"""
|
||||||
-> Initialization of all the HMI widgets content.
|
-> Initialization of all the HMI widgets content.
|
||||||
|
|||||||
@@ -381,7 +381,15 @@ def load_init_files(conf_path):
|
|||||||
matching with '*conf*.xml', 'control_panel.xml' and 'flash_modes.xml'.
|
matching with '*conf*.xml', 'control_panel.xml' and 'flash_modes.xml'.
|
||||||
-> Show the result of scan if DEBUG mode is on (main.py)
|
-> Show the result of scan if DEBUG mode is on (main.py)
|
||||||
"""
|
"""
|
||||||
conf_files, cp_files, devices_files = [], [], []
|
conf_files, devices_files = [], []
|
||||||
|
cp_file = None
|
||||||
|
|
||||||
|
cp_path = conf_path + "/" + CONTROL_PANEL + XML_EXT
|
||||||
|
if os.path.exists(cp_path):
|
||||||
|
cp_file = cp_path
|
||||||
|
else:
|
||||||
|
raise Exception("%s not found!"% conf_path)
|
||||||
|
|
||||||
for root, dirs, files in os.walk(conf_path):
|
for root, dirs, files in os.walk(conf_path):
|
||||||
for file in files:
|
for file in files:
|
||||||
ext = os.path.splitext(file)[1]
|
ext = os.path.splitext(file)[1]
|
||||||
@@ -392,12 +400,12 @@ def load_init_files(conf_path):
|
|||||||
and xml_file != env.PAPARAZZI_CONF+"/conf.xml":
|
and xml_file != env.PAPARAZZI_CONF+"/conf.xml":
|
||||||
conf_files.append(xml_file)
|
conf_files.append(xml_file)
|
||||||
elif file == CONTROL_PANEL_FILE and "airframes" not in root:
|
elif file == CONTROL_PANEL_FILE and "airframes" not in root:
|
||||||
cp_files.append(xml_file)
|
pass
|
||||||
elif file == DEVICES_FILE:
|
elif file == DEVICES_FILE:
|
||||||
devices_files.append(xml_file)
|
devices_files.append(xml_file)
|
||||||
|
|
||||||
result = "{} startup files found."
|
result = "{} startup files found." # exclude control_panel.xml
|
||||||
files_nb = sum((len(conf_files), len(cp_files), len(devices_files)))
|
files_nb = sum((len(conf_files), len(devices_files)))
|
||||||
info = result.format(files_nb)
|
info = result.format(files_nb)
|
||||||
|
|
||||||
if logging.DEBUG:
|
if logging.DEBUG:
|
||||||
@@ -408,9 +416,8 @@ def load_init_files(conf_path):
|
|||||||
for file in devices_files:
|
for file in devices_files:
|
||||||
LOGGER.debug(file)
|
LOGGER.debug(file)
|
||||||
LOGGER.debug("'control_panel' file(s) :")
|
LOGGER.debug("'control_panel' file(s) :")
|
||||||
for file in cp_files:
|
LOGGER.debug(cp_file)
|
||||||
LOGGER.debug(file)
|
return conf_files, cp_file, devices_files, info
|
||||||
return conf_files, cp_files, devices_files, info
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@@ -812,10 +819,10 @@ class Data(object):
|
|||||||
|
|
||||||
def load_sessions_and_programs(self):
|
def load_sessions_and_programs(self):
|
||||||
LOGGER.info("Loading programs and sessions...")
|
LOGGER.info("Loading programs and sessions...")
|
||||||
if len(self.cp_file) == 1:
|
if self.cp_file is not None:
|
||||||
self.tools, self.sessions, \
|
self.tools, self.sessions, \
|
||||||
load_info = load_sessions_and_programs(self.cp_file[0])
|
load_info = load_sessions_and_programs(self.cp_file)
|
||||||
LOGGER.debug(load_info)
|
LOGGER.debug(load_info)
|
||||||
LOGGER.info("Programs and sessions loaded.\n")
|
LOGGER.info("Programs and sessions loaded.\n")
|
||||||
else:
|
else:
|
||||||
LOGGER.error("ERROR : Multiple '%s' XML files !", CONTROL_PANEL)
|
LOGGER.error("ERROR : control_panel.xml not found!")
|
||||||
|
|||||||
Reference in New Issue
Block a user