Files
paparazzi/sw/supervision/python/lib/database.py
T
Gautier Hattenberger 9763a70ca9 New paparazzicenter in Python (#1811)
This is the result of a student project to develop a new paparazzi center based on Python/Qt.
See http://wiki.paparazziuav.org/wiki/Paparazzi_Center/Evolutions for the main idea and development process.
It can be tested by running the main paparazzi launcher with the -python option. I more convenient way might be added later.
This PR is mostly a way to not loose this work, and other people are encourage to improve it in many aspects (HMI, functionalities, ...).
2016-07-19 22:52:15 +02:00

162 lines
5.3 KiB
Python

# Paparazzi center utilities
#
# Copyright (C) 2016 ENAC, Florian BITARD (intern student)
#
# This file is part of paparazzi.
#
# paparazzi is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# paparazzi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with paparazzi; see the file COPYING. If not, write to
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
###############################################################################
# [Imports]
###############################################################################
# [Configuration class]
class Configuration(object):
"""Class to define a Configuration (old aircraft) object."""
def __init__(self, name, config_id, airframes, targets):
# Necessary parameters :
self.name = name
self.id = config_id
self.airframes = airframes
# Not necessary parameters :
self.settings = []
self.modules = []
self.flight_plan = []
self.radio = []
self.telemetry = []
self.color = []
self.targets = targets
def __repr__(self):
string = "| name = {!s:<25} | id = {!s:<3} | airframe = {!s:<65} |" + \
"targets = {!s:<250} | color = {!s:<15} | " + \
"radio = {!s:<40} | telemetry = {!s:<45} | " + \
"flight_plan = {!s:<75} | settings = {!s:<265} | " + \
"modules = {!s:<265} |"
format_string = string.format(self.name, self.id, self.airframes,
[_ for _ in self.targets.values()],
self.color, self.radio,
self.telemetry, self.flight_plan,
self.settings, self.modules)
return format_string
###############################################################################
# [Set class]
class Set(object):
"""Class to define a Set (old configuration) object."""
def __init__(self, name):
self.name = name
self.configs_names = []
def __repr__(self):
string = "| name = {!s:<75} | configs_names = {!s:<680} |"
format_string = string.format(self.name, self.configs_names)
return format_string
def is_config_in_set(self, config):
return config.id in self.configs_names
###############################################################################
# [Target class]
class Target(object):
"""Class to define a Target object."""
def __init__(self, name, board, ):
self.name = name
self.board = board
self.subsystems = None
self.defines = None
def __repr__(self):
string = "| name = {!s:<15} | board = {!s:<20} |"
format_string = string.format(self.name, self.board)
return format_string
###############################################################################
# [Device class]
class Device(object):
"""Class to define a Device (old flash mode) object."""
def __init__(self, name, variable_name="", variable_value=""):
self.name = name
self.variable = (variable_name, variable_value)
self.boards_regex = []
def __repr__(self):
string = "| name = {!s:<25} | variable = {!s:<35} | " + \
"boards_regex = {!s:<125} |"
format_string = string.format(self.name, self.variable,
self.boards_regex)
return format_string
###############################################################################
# [Session class]
class Session(object):
"""Class to define a Session object."""
def __init__(self, name, programs):
self.name = name
self.programs = programs
def __repr__(self):
string = "| name = {!s:<30} | programs = {!s:<1300} |"
format_string = string.format(self.name,
[_ for _ in self.programs.values()])
return format_string
###############################################################################
# [Program class]
class Program(object):
"""Class to define a Program (old tool) object."""
def __init__(self, name, command, options):
self.name = name
self.command = command
self.options = options
def __repr__(self):
string = "\t| name = {!s:<30} | command = {!s:<60} | options = {!s:<70} |"
format_string = string.format(self.name, self.command, self.options)
return format_string
###############################################################################
# [Cache class]
class Cache(object):
"""Class to define a Cache (old %gconf) object."""
def __init__(self, last_update_time):
self.last_update = last_update_time
self.main_window_shape = (0, 0)
self.last_set = None
self.last_configuration = None
self.last_target = None
self.last_session = None
self.last_device = None