diff --git a/Ccs/ccs_function_lib.py b/Ccs/ccs_function_lib.py index e7a65c1fd69506b3fc0387c29778cf591bc6aeaa..a2020f9b3872fd654dbefe9990d3f6e36f9870b1 100644 --- a/Ccs/ccs_function_lib.py +++ b/Ccs/ccs_function_lib.py @@ -2688,6 +2688,27 @@ def get_tc_calibration_and_parameters(ccf_descr=None): return calibrations_dict +def get_tm_id(ccf_descr=None): + if ccf_descr is None: + tms = scoped_session_idb.execute('SELECT pid_type, pid_stype, pid_apid, pid_pi1_val, pid_descr ' + 'FROM pid ').fetchall() + + else: + tms = scoped_session_idb.execute('SELECT pid_type, pid_stype, pid_apid, pid_pi1_val, pid_descr ' + 'FROM pid ' + 'WHERE ccf_descr="{}"'.format(ccf_descr)).fetchall() + + scoped_session_idb.close() + + tms_dict = {} + + for row in tms: + tms_dict.setdefault(row[0:6]) + + + return tms_dict + + def make_tc_template(ccf_descr, pool_name='LIVE', preamble='cfl.Tcsend_DB', options='', comment=True, add_parcfg=False): try: diff --git a/Tst/tst/tc_management.py b/Tst/tst/tc_management.py index d861cdc22fa785ab965f1b1c83cca816a5947bc5..2dd7a542bf849806fa9abc9bd4d8f2b0586e826a 100644 --- a/Tst/tst/tc_management.py +++ b/Tst/tst/tc_management.py @@ -9,7 +9,10 @@ import confignator import sys sys.path.append(confignator.get_option('paths', 'ccs')) import ccs_function_lib as cfl -import tc_management as tcm +import s2k_partypes as s2k + + + tc_type = None @@ -22,10 +25,7 @@ subtype_list = [] descr_list = [] calibrations_list = [] -minval_list = [] -maxval_list = [] -altxt_list = [] -alval_list = [] + for command in read_in_list_of_commands: @@ -45,56 +45,11 @@ subtype_list.sort() -def get_variables(tc_type): - pas_numbr = "" - pas_altxt = "" - pas_alval = "" - prv_numbr = "" - prv_minval = "" - prv_maxval = "" - - for key in dictionary_of_commands: - # print(key) - if tc_type in key: - for value_list in dictionary_of_commands[key]: - - pas_numbr += str(value_list[3]) + " " - pas_altxt += str(value_list[4]) + " " - pas_alval += str(value_list[5]) + " " - prv_numbr += str(value_list[6]) + " " - prv_minval += str(value_list[7]) + " " - prv_maxval += str(value_list[8]) + " " - # print(value_list[0]) - - pas_numbr_list = list(pas_numbr.split(" ")) - pas_numbr_list.pop() - pas_altxt_list = list(pas_altxt.split(" ")) - pas_altxt_list.pop() - pas_alval_list = list(pas_alval.split(" ")) - pas_alval_list.pop() - prv_numbr_list = list(prv_numbr.split(" ")) - prv_numbr_list.pop() - prv_minval_list = list(prv_minval.split(" ")) - prv_minval_list.pop() - prv_maxval_list = list(prv_maxval.split(" ")) - prv_maxval_list.pop() - - # print("pas_numbr: ", pas_numbr_list) - # print("pas_altxt: ", pas_altxt_list) - # print("pas_alval: ", pas_alval_list) - # print("prv_numbr: ", prv_numbr_list) - # print("prv_minval: ", prv_minval_list) - # print("prv_maxval: ", prv_maxval_list) - - return pas_numbr_list, pas_altxt_list, pas_alval_list, prv_numbr_list, prv_minval_list, prv_maxval_list - - -# print(get_variables("SASW LoadCmd")) - dictionary_of_variables = cfl.get_tc_calibration_and_parameters() + def get_cpc_descr(tc_type): @@ -115,12 +70,17 @@ def get_calibrations(tc_type, cpc_descr): if tc_type in key and cpc_descr in key: for counter in dictionary_of_variables[key]: - + cpc_ptc = counter[0] + cpc_pfc = counter[1] prv_minval = counter[2] prv_maxval = counter[3] pas_altxt = counter[4] pas_alval = counter[5] + if cpc_ptc == None: + cpc_ptc = "None" + if cpc_pfc == None: + cpc_pfc = "None" if prv_minval == None: prv_minval = "None" if prv_maxval == None: @@ -130,25 +90,18 @@ def get_calibrations(tc_type, cpc_descr): if pas_alval == None: pas_alval = "None" - treeview_tuple = tuple([prv_minval, prv_maxval, pas_altxt, pas_alval]) - treeview_tuple_list.append(treeview_tuple) - return treeview_tuple_list - - - + if cpc_ptc == "None": + data_type = "None" + pass + else: + data_type = s2k.ptt[cpc_ptc][cpc_pfc] + treeview_tuple = tuple([prv_minval, prv_maxval, pas_altxt, pas_alval, data_type]) + treeview_tuple_list.append(treeview_tuple) + return treeview_tuple_list -""" -Gesamtbild bestehend aus TcTable und CommandDescriptionBox hier einfügen -""" - -class TcBox(Gtk.Box): - pass -""" -TcTable hier einfügen -""" @@ -233,7 +186,6 @@ class TcTable(Gtk.Grid): if combo_iter is not None: model = combo.get_model() number = model[combo_iter][0] - # print(number) self.current_filter_telecommand = int(number) self.telecommand_filter.refilter() @@ -287,6 +239,9 @@ class CommandDescriptionBox(Gtk.Box): Gtk.Box.__init__(self) self.set_orientation(Gtk.Orientation.HORIZONTAL) + self.set_vexpand(True) + # self.set_hexpand(False) + # first treeview for commands @@ -319,15 +274,16 @@ class CommandDescriptionBox(Gtk.Box): self.scrollable_treelist = Gtk.ScrolledWindow() - self.scrollable_treelist.set_vexpand(True) - self.pack_start(self.scrollable_treelist, True, True, 0) + # self.scrollable_treelist.set_vexpand(True) + # self.scrollable_treelist.set_hexpand(20) + self.pack_start(self.scrollable_treelist, True, True, 5) self.scrollable_treelist.add(self.descr_treeview) # second treeview for calibrations - self.cal_liststore = Gtk.ListStore(str, str, str, str) + self.cal_liststore = Gtk.ListStore(str, str, str, str, str) for cal_ref in calibrations_list: self.cal_liststore.append(list(cal_ref)) self.current_filter_descr = None @@ -340,15 +296,16 @@ class CommandDescriptionBox(Gtk.Box): self.cal_treeview = Gtk.TreeView(model=self.descr_filter) for i, column_title in enumerate( - ["prv_minval", "prv_maxval", "pas_altxt", "pas_alval"] + ["prv_minval", "prv_maxval", "pas_altxt", "pas_alval", "data-type"] ): calibrations_renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(column_title, calibrations_renderer, text=i) column.colnumbr = i self.cal_treeview.append_column(column) + self.scrollable_calibrations_treelist = Gtk.ScrolledWindow() - self.scrollable_calibrations_treelist.set_vexpand(True) + # self.scrollable_calibrations_treelist.set_vexpand(True) self.pack_start(self.scrollable_calibrations_treelist, True, True, 0) self.scrollable_calibrations_treelist.add(self.cal_treeview) @@ -374,7 +331,6 @@ class CommandDescriptionBox(Gtk.Box): # print(model[row][0]) calibrations_list.clear() calibrations_list.append(get_calibrations(tc_type, model[row][0])) - # calibrations_list = get_calibrations(tc_type, model[row][0]) self.refresh_cal_treeview() @@ -400,7 +356,7 @@ class CommandDescriptionBox(Gtk.Box): def refresh_cal_treeview(self): - self.cal_liststore = Gtk.ListStore(str, str, str, str) + self.cal_liststore = Gtk.ListStore(str, str, str, str, str) if calibrations_list == [] or calibrations_list == [[]]: pass @@ -414,12 +370,3 @@ class CommandDescriptionBox(Gtk.Box): self.cal_treeview.set_model(self.cal_liststore) - - - - - - - - - # self.show_all() \ No newline at end of file diff --git a/Tst/tst/tm_management.py b/Tst/tst/tm_management.py new file mode 100644 index 0000000000000000000000000000000000000000..0ab3f865406ad057a9655aa5315e96e341cc0678 --- /dev/null +++ b/Tst/tst/tm_management.py @@ -0,0 +1,182 @@ +#!/usr/bin/env python3 +import gi + + +gi.require_version("Gtk", "3.0") +gi.require_version("GtkSource", "3.0") +from gi.repository import Gtk, Gdk, GtkSource +import confignator +import sys +sys.path.append(confignator.get_option('paths', 'ccs')) +import ccs_function_lib as cfl + + +dictionary_of_tms = cfl.get_tm_id() + + +tm_list = list(dictionary_of_tms.keys()) + + + + + + + + + + + + + + + + + + +tc_type = None + + +dictionary_of_commands = cfl.get_tc_list() +read_in_list_of_commands = list(dictionary_of_commands.keys()) +list_of_commands = [] +type_list = [] +subtype_list = [] + +descr_list = [] +calibrations_list = [] +minval_list = [] +maxval_list = [] +altxt_list = [] +alval_list = [] + + +for command in read_in_list_of_commands: + command = list(command) + del command[0] + myorder = [2, 3, 0, 1] + command = [command[i] for i in myorder] + command[0] = int(command[0]) + command[1] = int(command[1]) + list_of_commands.append(command) + if command[0] not in type_list: + type_list.append(command[0]) + + +type_list.sort() +subtype_list.sort() + + + + + + +class TmTable(Gtk.Grid): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + self.set_size_request(500,500) + + self.telemetry_liststore = Gtk.ListStore(int, int, int, int, str) + for telemetry_ref in tm_list: + self.telemetry_liststore.append(list(telemetry_ref)) + self.current_filter_telemetry = None + + # Creating the filter, feeding it with the liststore model + self.telemetry_filter = self.telemetry_liststore.filter_new() + # setting the filter function + self.telemetry_filter.set_visible_func(self.telemetry_filter_func) + + # Create ListStores for the ComboBoxes + self.type_liststore = Gtk.ListStore(int) + for type_ref in type_list: + self.type_liststore.append([type_ref, ]) + # self.current_filter_type = None + + self.type_combo = Gtk.ComboBox.new_with_model(self.type_liststore) + self.type_combo.connect("changed", self.on_type_combo_changed) + renderer_text = Gtk.CellRendererText() + self.type_combo.pack_start(renderer_text, True) + self.type_combo.add_attribute(renderer_text, "text", 0) + self.attach(self.type_combo, 0, 0, 1, 1) + + self.clear_button = Gtk.Button(label="Clear") + self.clear_button.connect("clicked", self.on_clear_button_clicked) + self.attach_next_to( + self.clear_button, self.type_combo, Gtk.PositionType.RIGHT, 1, 1 + ) + + # creating the treeview, making it use the filter a model, adding columns + self.treeview = Gtk.TreeView.new_with_model(Gtk.TreeModelSort(self.telemetry_filter)) + for i, column_title in enumerate( + ["#TYPE", "SUBTYPE", "APID", "PI1_VALUE", "PID DESCR"] + ): + renderer = Gtk.CellRendererText() + column = Gtk.TreeViewColumn(column_title, renderer, text=i) + column.set_sort_column_id(i) + self.treeview.append_column(column) + + # Handle selection + self.selected_row = self.treeview.get_selection() + self.selected_row.connect("changed", self.item_selected) + + # setting up layout, treeview in scrollwindow + self.scrollable_treelist = Gtk.ScrolledWindow() + self.scrollable_treelist.set_vexpand(True) + self.scrollable_treelist.set_hexpand(True) + self.attach(self.scrollable_treelist, 0, 1, 8, 10) + + self.scrollable_treelist.add(self.treeview) + + self.command_entry = Gtk.Entry() + self.command_entry.set_placeholder_text("<Command Variables>") + self.attach_next_to(self.command_entry, self.scrollable_treelist, Gtk.PositionType.BOTTOM, 8, 1) + + + # Set up Drag and Drop + self.treeview.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, [], Gdk.DragAction.COPY) + self.treeview.drag_source_set_target_list(None) + self.treeview.drag_source_add_text_targets() + + self.treeview.connect("drag-data-get", self.on_drag_data_get) + self.treeview.connect("drag-begin", self.on_drag_begin) + + self.show_all() + + def on_type_combo_changed(self, combo): + combo_iter = combo.get_active_iter() + if combo_iter is not None: + model = combo.get_model() + number = model[combo_iter][0] + # print(number) + self.current_filter_telecommand = int(number) + + self.telecommand_filter.refilter() + + + def on_clear_button_clicked(self, widget): + self.current_filter_telecommand = None + self.telecommand_filter.refilter() + + def item_selected(self, selection): + pass + + + + + def telemetry_filter_func(self, model, iter, data): + + if ( + self.current_filter_telemetry is None + or self.current_filter_telemetry == "None" + ): + return True + else: + return model[iter][0] == self.current_filter_telemetry + + def on_drag_data_get(self, treeview, drag_context, selection_data, info, time, *args): + treeselection = treeview.get_selection() + model, my_iter = treeselection.get_selected() + selection_data.set_text(cfl.make_tc_template(descr, comment=False), -1) + + def on_drag_begin(self, *args): + pass diff --git a/Tst/tst/tst.cfg b/Tst/tst/tst.cfg index b88eb8010000323790bb23685a4c381b20c08e48..12ad269abae8c2ceb61015e90d67da7fc73d5d5b 100644 --- a/Tst/tst/tst.cfg +++ b/Tst/tst/tst.cfg @@ -14,11 +14,11 @@ output-file-path = ${paths:tst}/logs_test_runs/output_files/ [tst-preferences] show-json-view = True -main-window-height = 1025 -main-window-width = 1581 -paned-position = 960 +main-window-height = 1016 +main-window-width = 1848 +paned-position = 919 paned-position-codeblockreuse = 520 [tst-history] -last-folder = /data/home/moeslinged94/smile/CCS/Tst/test_specs +last-folder = /home/sebastian/CCS/Tst/test_specs diff --git a/Tst/tst/tst.py b/Tst/tst/tst.py index 42be742bc957b2f5b26ccff8f07a910b3c2779fc..f60c33624590e4e2031f97ad8298f6acf89d08ef 100755 --- a/Tst/tst/tst.py +++ b/Tst/tst/tst.py @@ -4,16 +4,13 @@ import os import logging import time import gi - gi.require_version('Gtk', '3.0') gi.require_version('GtkSource', '3.0') from gi.repository import Gtk, Gdk, Gio, GtkSource, GLib import confignator import sys - sys.path.append(confignator.get_option('paths', 'ccs')) import ccs_function_lib as cfl - cfl.add_tst_import_paths() import view import data_model @@ -25,11 +22,18 @@ import connect_apps import dbus import toolbox import tc_management as tcm +import tm_management as tmm + import json_to_barescript import json_to_csv import spec_to_json # creating lists for type and subtype to get rid of duplicate entries, for TC List + + + + + path_icon = os.path.join(os.path.dirname(__file__), 'style/tst.svg') menu_xml = os.path.join(os.path.dirname(__file__), 'app_menu.xml') css_file = os.path.join(os.path.dirname(__file__), 'style/style.css') @@ -180,6 +184,7 @@ class TestInstance: def filename(self, value): self._filename = value + class TstAppWindow(Gtk.ApplicationWindow): def __init__(self, logger=logger, *args, **kwargs): @@ -248,6 +253,10 @@ class TstAppWindow(Gtk.ApplicationWindow): self.btn_save.set_icon_name('document-save') self.btn_save.set_tooltip_text('Save') self.btn_save.connect('clicked', self.on_save) + self.btn_show_model_viewer = Gtk.ToolButton() + self.btn_show_model_viewer.set_icon_name('accessories-dictionary-symbolic') + self.btn_show_model_viewer.set_tooltip_text('Show/hide model viewer') + self.btn_show_model_viewer.connect('clicked', self.model_viewer_toggle_hide) self.btn_generate_products = Gtk.ToolButton() self.btn_generate_products.set_label('Generate scripts') # self.btn_generate_products.set_icon_name('printer-printing-symbolic') @@ -267,6 +276,7 @@ class TstAppWindow(Gtk.ApplicationWindow): self.toolbar.insert(self.btn_new_file, 0) self.toolbar.insert(self.btn_open_file, 1) self.toolbar.insert(self.btn_save, 2) + # self.toolbar.insert(self.btn_show_model_viewer, 2) self.toolbar.insert(self.btn_generate_products, 3) self.toolbar.insert(self.btn_start_ccs_editor, 4) self.toolbar.insert(self.btn_open_progress_view, 5) @@ -309,6 +319,13 @@ class TstAppWindow(Gtk.ApplicationWindow): self.label_widget_tcm.set_text('TC Table') self.feature_area.append_page(child=self.tcm, tab_label=self.label_widget_tcm) + # telemetry list tab + self.telemetry = tmm.TmTable() + self.label_widget_telemetry = Gtk.Label() + self.label_widget_telemetry.set_text('TM Table') + self.feature_area.append_page(child=self.telemetry, tab_label=self.label_widget_telemetry) + + """ self.tcm = TCTableClass() self.label_widget_tcm = Gtk.Label() @@ -316,6 +333,8 @@ class TstAppWindow(Gtk.ApplicationWindow): self.feature_area.append_page(child=self.tcm, tab_label=self.label_widget_tcm) """ + + self.box.pack_start(self.work_desk, True, True, 0) # # panes for the step grid an so on diff --git a/egse.cfg b/egse.cfg index c16ad820571cc3cd697e19dbd483c85f152b5815..25729df34d8207422596480bc2d21b0478718c47 100644 --- a/egse.cfg +++ b/egse.cfg @@ -2,14 +2,14 @@ base = ${confignator-paths:basic-path} tst = ${base}/Tst ccs = ${base}/Ccs -obsw = /home/dominik/smile/OBSW/implementation +obsw = /home/OBSW/implementation crplm = ${obsw}/CrPlm/build/pc ia = ${obsw}/CrIa/build/pc start-simulator-log = ${logging:log-dir}/simulators/sim.log [database] -user = smile -password = letssmile +user = sebastian +password = Ego,ich1 [logging] log-dir = ${paths:base}/logs