diff --git a/Ccs/ccs_function_lib.py b/Ccs/ccs_function_lib.py index 98dacdb67fe16fe3570b6c1ab6602f7097544f60..765f24e1a1fc03dc5f78f40687dec756b0c2ecd7 100644 --- a/Ccs/ccs_function_lib.py +++ b/Ccs/ccs_function_lib.py @@ -2649,6 +2649,37 @@ def get_tc_list(ccf_descr=None): return cmd_dict +def get_tc_calibration_and_parameters(ccf_descr=None): + + if ccf_descr is None: + calibrations = scoped_session_idb.execute('SELECT ccf_cname, ccf_descr, cdf_pname, cpc_descr, cpc_categ, cpc_ptc, ' + 'cpc_pfc, prv_minval, prv_maxval, pas_altxt, pas_alval ' + 'FROM ccf LEFT JOIN cdf ON ccf.ccf_cname=cdf.cdf_cname ' + 'LEFT JOIN cpc ON cdf.cdf_pname=cpc.cpc_pname ' + 'LEFT JOIN prv ON cpc.cpc_prfref=prv.prv_numbr ' + 'LEFT JOIN pas ON cpc.cpc_pafref=pas.pas_numbr ' + 'WHERE cpc_descr IS NOT NULL').fetchall() + + else: + calibrations = scoped_session_idb.execute('SELECT ccf_cname, ccf_descr, cdf_pname, cpc_descr, cpc_categ, cpc_ptc, ' + 'cpc_pfc, prv_minval, prv_maxval, pas_altxt, pas_alval ' + 'FROM ccf LEFT JOIN cdf ON ccf.ccf_cname=cdf.cdf_cname ' + 'LEFT JOIN cpc ON cdf.cdf_pname=cpc.cpc_pname ' + 'LEFT JOIN prv ON cpc.cpc_prfref=prv.prv_numbr ' + 'LEFT JOIN pas ON cpc.cpc_pafref=pas.pas_numbr ' + 'WHERE cpc_descr IS NOT NULL ' + 'WHERE ccf_descr="{}"'.format(ccf_descr)).fetchall() + + scoped_session_idb.close() + + calibrations_dict = {} + + for row in calibrations: + calibrations_dict.setdefault(row[0:5], []).append(row[5:11]) + + + return calibrations_dict + def make_tc_template(ccf_descr, pool_name='LIVE', preamble='cfl.Tcsend_DB', options='', comment=True): try: diff --git a/Tst/confignator/Makefile b/Tst/confignator/Makefile index 16dbb7e7a9b16416789982ec1461e9d871f4fe05..52c50f191f26d98bf2f7a0015e7b0dff8004be88 100644 --- a/Tst/confignator/Makefile +++ b/Tst/confignator/Makefile @@ -9,7 +9,7 @@ DIST_DIR = $(CURDIR)/dist .PHONY: build clean-build install uninstall reinstall build-doc clean-doc-build all open-doc -all: clean build install set-log-file-path build-doc open-doc +all: clean build install build-doc open-doc doc: clean-doc-build build-doc diff --git a/Tst/log_viewer/log_viewer.cfg b/Tst/log_viewer/log_viewer.cfg index 97b978c471bfceb4c90dc8a5d608884815b5bc7b..d08fc6126e15e58803fa27edae90649abdfec0bf 100644 --- a/Tst/log_viewer/log_viewer.cfg +++ b/Tst/log_viewer/log_viewer.cfg @@ -27,5 +27,5 @@ thread = False threadname = False [log-viewer-history] -last-folder = ${logging:log-dir}/tst/data_model +last-folder = /home/sebastian/CCS/Tst/logs_test_runs diff --git a/Tst/tst/tc_management.py b/Tst/tst/tc_management.py new file mode 100644 index 0000000000000000000000000000000000000000..e8c4a937f8a4cd7ed22857923165fa8bf6a9be0a --- /dev/null +++ b/Tst/tst/tc_management.py @@ -0,0 +1,258 @@ +#!/usr/bin/env python3 +import gi + +gi.require_version("Gtk", "3.0") +gi.require_version("GtkSource", "3.0") +from gi.repository import Gtk, GtkSource +import confignator +import sys +sys.path.append(confignator.get_option('paths', 'ccs')) +import ccs_function_lib as cfl + + +tc_type = None + + + +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): + + + # read_in_list_of_variables = list(dictionary_of_variables.keys()) + + cpc_descr = [] + + for key in dictionary_of_variables: + if tc_type in key: + cpc_descr.append(key[3]) + cpc_descr = [[list_element] for list_element in cpc_descr] + return cpc_descr + + +def get_calibrations(tc_type, cpc_descr): + treeview_tuple_list = [] + for key in dictionary_of_variables: + if tc_type in key and cpc_descr in key: + for counter in dictionary_of_variables[key]: + + + prv_minval = counter[2] + prv_maxval = counter[3] + pas_altxt = counter[4] + pas_alval = counter[5] + + if prv_minval == None: + prv_minval = "None" + if prv_maxval == None: + prv_maxval = "None" + if pas_altxt == None: + pas_altxt = "None" + 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 + + + + + +descr_list = [] +calibrations_list = [] +minval_list = [] +maxval_list = [] +altxt_list = [] +alval_list = [] + + + +class CommandDescriptionBox(Gtk.Box): + def __init__(self): + + Gtk.Box.__init__(self) + self.set_orientation(Gtk.Orientation.HORIZONTAL) + + + # first treeview for commands + self.descr_liststore = Gtk.ListStore(str) + for descr_ref in descr_list: + self.descr_liststore.append(list(descr_ref)) + self.current_filter_descr = None + + # Creating filter, feeding it with liststore model + self.descr_filter = self.descr_liststore.filter_new() + # setting the filter function + self.descr_filter.set_visible_func(self.descr_filter_func) + + self.treeview = Gtk.TreeView(model=self.descr_filter) + + + for i, column_title in enumerate( + [1] + ): + renderer = Gtk.CellRendererText() + column = Gtk.TreeViewColumn(column_title, renderer, text=i) + column.colnr = i + self.treeview.append_column(column) + + + # item selection + # self.treeview.connect("button-press-event", self.on_cell_clicked) + self.selected_row = self.treeview.get_selection() + self.selected_row.connect("changed", self.item_selected) + + + self.scrollable_treelist = Gtk.ScrolledWindow() + self.scrollable_treelist.set_vexpand(True) + self.pack_start(self.scrollable_treelist, True, True, 0) + + self.scrollable_treelist.add(self.treeview) + + + + # second treeview for calibrations + self.cal_liststore = Gtk.ListStore(str, str, str, str) + for cal_ref in calibrations_list: + self.cal_liststore.append(list(cal_ref)) + self.current_filter_descr = None + + # Creating filter, feeding it with liststore model + self.cal_filter = self.cal_liststore.filter_new() + # setting the filter function + self.cal_filter.set_visible_func(self.cal_filter_func) + + self.cal_treeview = Gtk.TreeView(model=self.descr_filter) + + for i, column_title in enumerate( + ["prv_minval", "prv_maxval", "pas_altxt", "pas_alval"] + ): + 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.pack_start(self.scrollable_calibrations_treelist, True, True, 0) + + self.scrollable_calibrations_treelist.add(self.cal_treeview) + + + + + + def descr_filter_func(self, model, iter, data): + if ( + self.current_filter_descr is None + or self.current_filter_descr == "None" + ): + return True + else: + return model[iter][2] == self.current_filter_descr + + + def item_selected(self, selection): + model, row = selection.get_selected() + if row is not None: + # print("item_selected") + # 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() + + + + + + def refresh_descr_treeview(self): + self.descr_liststore.clear() + self.descr_liststore = Gtk.ListStore(str) + for descr_ref in descr_list: + self.descr_liststore.append(tuple(descr_ref)) + self.treeview.set_model(self.descr_liststore) + + + def cal_filter_func(self, model, iter, data): + if ( + self.current_filter_descr is None + or self.current_filter_descr == "None" + ): + return True + else: + return model[iter][2] == self.current_filter_descr + + def refresh_cal_treeview(self): + self.cal_liststore = Gtk.ListStore(str, str, str, str) + + if calibrations_list == [] or calibrations_list == [[]]: + pass + else: + for cal_ref in calibrations_list[0]: + self.cal_liststore.append(list(cal_ref)) + + + # self.cal_treeview.set_model(self.cal_liststore) + + + self.cal_treeview.set_model(self.cal_liststore) + + + + + + + + + + # self.show_all() \ No newline at end of file diff --git a/Tst/tst/tst.cfg b/Tst/tst/tst.cfg index 79b320baccfa7b3affd79cc2255add483c46f3a6..2ba810c761cee4e646d6d9c3b05317d31095daa1 100644 --- a/Tst/tst/tst.cfg +++ b/Tst/tst/tst.cfg @@ -13,11 +13,11 @@ test_run = ${paths:tst}/logs_test_runs/ [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 = ${paths:tst}/test_specs +last-folder = /home/sebastian/CCS/Tst/test_specs diff --git a/Tst/tst/tst.py b/Tst/tst/tst.py index 162836ae71fa3182ec3c794f2fba03782506eb44..4795105fafaef9bd412965db3c01d4cb06fac4af 100755 --- a/Tst/tst/tst.py +++ b/Tst/tst/tst.py @@ -21,6 +21,7 @@ import codeblockreuse import connect_apps import dbus import toolbox +import tc_management as tcm # creating lists for type and subtype to get rid of duplicate entries, for TC List @@ -315,10 +316,10 @@ class TstAppWindow(Gtk.ApplicationWindow): self.feature_area.append_page(child=self.log_view, tab_label=self.label_widget_log_view) # command list tab - self.tc_table = TCTableClass() - self.label_widget_tc_table = Gtk.Label() - self.label_widget_tc_table.set_text('TC Table') - self.feature_area.append_page(child=self.tc_table, tab_label=self.label_widget_tc_table) + self.tcm = TCTableClass() + self.label_widget_tcm = Gtk.Label() + self.label_widget_tcm.set_text('TC Table') + self.feature_area.append_page(child=self.tcm, tab_label=self.label_widget_tcm) self.box.pack_start(self.work_desk, True, True, 0) @@ -799,6 +800,9 @@ class TCTableClass(Gtk.Grid): self.command_entry.set_placeholder_text("<Command Variables>") self.attach_next_to(self.command_entry, self.scrollable_treelist, Gtk.PositionType.BOTTOM, 8, 1) + self.variable_box = tcm.CommandDescriptionBox() + self.attach_next_to(self.variable_box, self.command_entry, Gtk.PositionType.BOTTOM, 8, 5) + self.show_all() def on_type_combo_changed(self, combo): @@ -821,13 +825,18 @@ class TCTableClass(Gtk.Grid): if row is not None: descr = model[row][2] self.command_entry.set_text(cfl.make_tc_template(descr, comment=False)) + tcm.tc_type = descr + cpc_descr = tcm.get_cpc_descr(tcm.tc_type) + tcm.descr_list.clear() + tcm.descr_list = cpc_descr + self.variable_box.refresh_descr_treeview() + tcm.calibrations_list.clear() + self.variable_box.refresh_cal_treeview() else: pass def telecommand_filter_func(self, model, iter, data): - placeholder1 = 0 - placeholder2 = 0 if ( self.current_filter_telecommand is None or self.current_filter_telecommand == "None" diff --git a/egse.cfg b/egse.cfg index 71f499679fc126efc1943ef1d95321629e917c63..89776870182010c3d463c3603bb4f4e70a66a134 100644 --- a/egse.cfg +++ b/egse.cfg @@ -2,14 +2,14 @@ base = ${confignator-paths:basic-path} tst = ${base}/Tst ccs = ${base}/Ccs -obsw = /home/marko/space/smile/OBSW/implementation +obsw = /home/sebastian/OBSW/implementation crplm = ${obsw}/CrPlm/build/pc ia = ${obsw}/CrIa/build/pc start-simulator-log = ${logging:log-dir}/simulators/sim.log [database] -user = egse -password = weltraummuell +user = sebastian +password = Ego,ich1 [logging] log-dir = ${paths:base}/logs