Skip to content
Snippets Groups Projects
Commit 10243f78 authored by Sebastian's avatar Sebastian
Browse files

adden verification functionalities and verification tab

changed some typing errors
parent 5ec4cf5d
Branches
No related tags found
No related merge requests found
......@@ -53,7 +53,7 @@ class MessageListener(dbus.service.Object):
try:
self.win.set_title(str(project) + ': ' + str(self.win.get_title()) + ' ' + str(counting-1))
except:
# Looks like a odd title name but is reshaped in pus_datapool.py
# Looks like an odd title name but is reshaped in pus_datapool.py
self.win.windowname = str(project) + ': @ ' + str(counting-1)
###
......
......
......@@ -2655,6 +2655,21 @@ def source_to_srec(data, outfile, memaddr=0x40180000, header=None, bytes_per_lin
print('Data written to file: "{}"'.format(outfile))
"""
Test Function to get tm and tc from database tm
"""
def get_acute_tm_tc(description=None):
if description is None:
test = scoped_session_idb.execute("SELECT * FROM smile_data_storage.tm "
"WHERE smile_data_storage.tm.pool_id = 40;").fetchall()
else:
test = scoped_session_idb.execute("SELECT * FROM smile_data_storage.tm "
"WHERE smile_data_storage.tm.pool_id = 40;").fetchall()
"""
Test function ends
"""
def get_tc_list(ccf_descr=None):
......
......
import os
import json
import struct
import threading
import subprocess
import time
import sys
import dbus
import dbus.service
from dbus.mainloop.glib import DBusGMainLoop
import DBus_Basic
import ccs_function_lib as cfl
from typing import NamedTuple
import confignator
import gi
import matplotlib
matplotlib.use('Gtk3Cairo')
# from sqlalchemy.sql.expression import func, distinct
from sqlalchemy.orm import load_only
from database.tm_db import DbTelemetryPool, DbTelemetry, RMapTelemetry, FEEDataTelemetry, scoped_session_maker
import importlib
from confignator import config
check_cfg = config.get_config(file_path=confignator.get_option('config-files', 'ccs'))
def type_comparison(comparison_data):
pool_rows = cfl.get_pool_rows("PLM")
st_list = []
sst_list = []
x = 0
header_counter = 0
while header_counter < 2:
x += 1
entry = pool_rows.all()[-x]
if entry.data.hex() == comparison_data:
st_list.append(entry.stc)
sst_list.append(entry.sst)
# print("ST Entry_" + str(x) + ": ", entry.stc)
# print("SST Entry_" + str(x) + ": ", entry.sst)
# print("Timestamp entry_" + str(x) + ": ", entry.timestamp)
header_counter += 1
st_list_reverse = [st_list[1], st_list[0]]
sst_list_reverse = [sst_list[1], sst_list[0]]
if sst_list_reverse == [1, 7]:
print("Verification successful")
else:
print("Verification unsuccessful")
return False
verification_running = True
print("RUNNING!!")
while verification_running == True:
# while running the script checks the last three entries of the database and keeps them up to date
# to recognize a tc it checks the time
pool_rows = cfl.get_pool_rows("PLM")
system_time = time.clock_gettime(0)
entry_1_data = pool_rows.all()[-1]
# entry_2_data = pool_rows.all()[-2]
# entry_3_data = pool_rows.all()[-3]
time_1 = entry_1_data.timestamp
# time_2 = entry_2_data.timestamp
# time_3 = entry_3_data.timestamp
# in this script the number 1 after a variable name always refers to data from the last entry
# number 2 refers to second last entry, number 3 to third last entry and so on
# this part triggers as soon as a tc has arrived in the database
if time_1 == "":
first_raw_digits = "" # this string will contain the first bytes of raw data
telecommand = entry_1_data
telecommand_time = telecommand.timestamp
telecommand_raw = telecommand.raw.hex()
# telecommand_data = telecommand.data.hex()
# Variable to generate new telecommand timestamp, other than telecommand_time
telecommand_verification_timestamp = time.clock_gettime(0)
verification_time = telecommand_verification_timestamp + 2
for i in telecommand_raw:
first_raw_digits += str(i)
if len(first_raw_digits) > 7:
break
# print("After Loop telecommand_first_digits: ", first_raw_digits)
while system_time < verification_time and system_time != verification_time:
system_time = time.clock_gettime(0)
if system_time >= verification_time:
verification_running = type_comparison(first_raw_digits)
......@@ -5,6 +5,7 @@ import gi
gi.require_version("Gtk", "3.0")
gi.require_version("GtkSource", "3.0")
from gi.repository import Gtk, Gdk, GtkSource
from gi.repository.GdkPixbuf import Pixbuf
import confignator
import sys
sys.path.append(confignator.get_option('paths', 'ccs'))
......@@ -117,11 +118,14 @@ class TcTable(Gtk.Grid):
for telecommand_ref in list_of_commands:
self.telecommand_liststore.append(list(telecommand_ref))
self.current_filter_telecommand = None
self.current_filter_longdescr = None
self.current_filter_descr = None
# Creating the filter, feeding it with the liststore model
self.telecommand_filter = self.telecommand_liststore.filter_new()
# setting the filter function
self.telecommand_filter.set_visible_func(self.telecommand_filter_func)
# self.telecommand_filter.set_visible_func(self.search_filter_func)
# Create ListStores for the ComboBoxes
self.type_liststore = Gtk.ListStore(int)
......@@ -142,6 +146,23 @@ class TcTable(Gtk.Grid):
self.clear_button, self.type_combo, Gtk.PositionType.RIGHT, 1, 1
)
"""
self.search_entry = Gtk.Entry()
self.search_entry.set_placeholder_text("<search>")
self.attach_next_to(
self.search_entry, self.clear_button, Gtk.PositionType.RIGHT, 1, 1
)
self.search_button = Gtk.ToolButton()
self.search_button.set_icon_name("search")
self.search_button.set_tooltip_text("Search")
self.search_button.connect("clicked", self.on_search)
self.attach_next_to(
self.search_button, self.search_entry, 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.telecommand_filter))
for i, column_title in enumerate(
......@@ -181,6 +202,7 @@ class TcTable(Gtk.Grid):
self.show_all()
def on_type_combo_changed(self, combo):
combo_iter = combo.get_active_iter()
if combo_iter is not None:
......@@ -195,6 +217,7 @@ class TcTable(Gtk.Grid):
self.current_filter_telecommand = None
self.telecommand_filter.refilter()
def item_selected(self, selection):
model, row = selection.get_selected()
if row is not None:
......@@ -213,8 +236,9 @@ class TcTable(Gtk.Grid):
else:
pass
def telecommand_filter_func(self, model, iter, data):
def telecommand_filter_func(self, model, iter, data):
# print("test telecommand filter")
if (
self.current_filter_telecommand is None
or self.current_filter_telecommand == "None"
......@@ -223,15 +247,41 @@ class TcTable(Gtk.Grid):
else:
return model[iter][0] == self.current_filter_telecommand
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, add_parcfg=True), -1)
def on_drag_begin(self, *args):
pass
def on_search(self, *args):
data_from_search_entry = self.search_entry.get_text()
self.telecommand_filter = self.telecommand_liststore.filter_new()
# setting the filter function
self.telecommand_filter.set_visible_func(self.search_filter_func)
self.telecommand_filter.refilter()
print(data_from_search_entry)
print("search started")
def search_filter_func(self, model, iter, data):
print("test search filter")
if (
self.current_filter_longdescr is None
or self.current_filter_longdescr == "None"
):
return True
else:
return model[iter][3] == self.current_filter_longdescr
class CommandDescriptionBox(Gtk.Box):
......
......
......@@ -14,11 +14,11 @@ output-file-path = ${paths:tst}/logs_test_runs/output_files/
[tst-preferences]
show-json-view = True
main-window-height = 1090
main-window-height = 1043
main-window-width = 1920
paned-position = 953
paned-position = 919
paned-position-codeblockreuse = 520
[tst-history]
last-folder = /home/marko/space/smile/OBSW/Documentation/testspec/tst
last-folder = /home/sebastian/OBSW/Documentation/testspec/tst
......@@ -24,6 +24,7 @@ import toolbox
import tc_management as tcm
import tm_management as tmm
import data_pool_tab as dpt
import verification_tab as vt
import json_to_barescript
import json_to_csv
......@@ -355,6 +356,12 @@ class TstAppWindow(Gtk.ApplicationWindow):
self.label_widget_data_pool.set_text('Data Pool')
self.feature_area.append_page(child=self.data_pool_tab, tab_label=self.label_widget_data_pool)
# verification tab
self.verification_tab = vt.VerificationTable()
self.label_widget_verification = Gtk.Label()
self.label_widget_verification.set_text("Verification")
self.feature_area.append_page(child=self.verification_tab, tab_label=self.label_widget_verification)
self.box.pack_start(self.work_desk, True, True, 0)
......
......
# !/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
from gi.repository.GdkPixbuf import Pixbuf
import confignator
import sys
sys.path.append(confignator.get_option('paths', 'ccs'))
import ccs_function_lib as cfl
import s2k_partypes as s2k
verification_list = [
("Verification", 1, 7),
("Other Verification", 0, 0)
]
class VerificationTable(Gtk.Grid):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.set_size_request(500,500)
self.grid = Gtk.Grid()
self.grid.set_column_homogeneous(True)
self.grid.set_row_homogeneous(True)
self.add(self.grid)
# Creating ListStore model
self.verification_liststore = Gtk.ListStore(str, int, int)
for verification_ref in verification_list:
self. verification_liststore.append(list(verification_ref))
self.current_filter_verification = None
# Creating filter, feeding it with liststore model
self.verification_filter = self.verification_liststore.filter_new()
# setting the filter function
self.verification_filter.set_visible_func(self.verification_filter_func)
# Creating treeview
self.treeview = Gtk.TreeView(model=self.verification_filter)
for i, column_title in enumerate(
["Verification", "ST", "SST"]
):
renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn(column_title, renderer, text=i)
self.treeview.append_column(column)
# setting up layout
self.scrollable_treelist = Gtk.ScrolledWindow()
self.scrollable_treelist.set_vexpand(True)
self.grid.attach(self.scrollable_treelist, 0, 0, 8, 10)
self.scrollable_treelist.add(self.treeview)
self.show_all()
def verification_filter_func(self, model, iter, data):
if(
self.current_filter_verification is None
or self.current_filter_verification == "None"
):
return True
else:
return model[iter][2] == self.current_filter_verification
\ No newline at end of file
......@@ -8,8 +8,8 @@ ia = ${obsw}/CrIa/build/pc
start-simulator-log = ${logging:log-dir}/simulators/sim.log
[database]
user = egse
password = xrayvision
user = sebastian
password = Ego,ich1
host = 127.0.0.1
[logging]
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment