From a0e339570fb6ec4fa4f2b90de5af6d79e3b10577 Mon Sep 17 00:00:00 2001
From: "Robin.Mueller" <robin.mueller.m@gmail.com>
Date: Sat, 31 Oct 2020 02:12:57 +0100
Subject: [PATCH] some more stuff

---
 config/obsw_com_config.py  |  6 +++---
 config/obsw_config.py      | 19 ++++++++++---------
 config/obsw_definitions.py |  2 +-
 core/tmtc_frontend.py      | 12 ++++++------
 4 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/config/obsw_com_config.py b/config/obsw_com_config.py
index 77a4931..0d45593 100644
--- a/config/obsw_com_config.py
+++ b/config/obsw_com_config.py
@@ -25,12 +25,12 @@ def set_communication_interface(tmtc_printer: TmTcPrinter) -> Union[Communicatio
     :return: CommunicationInterface object
     """
     try:
-        if g.G_COM_IF == g.ComIF.Ethernet:
+        if g.G_COM_IF == g.ComInterfaces.Ethernet:
             communication_interface = EthernetComIF(
                 tmtc_printer=tmtc_printer, tm_timeout=g.G_TM_TIMEOUT,
                 tc_timeout_factor=g.G_TC_SEND_TIMEOUT_FACTOR, send_address=g.G_ETHERNET_SEND_ADDRESS,
                 receive_address=g.G_ETHERNET_RECV_ADDRESS)
-        elif g.G_COM_IF == g.ComIF.Serial:
+        elif g.G_COM_IF == g.ComInterfaces.Serial:
             serial_baudrate = g.G_SERIAL_BAUDRATE
             serial_timeout = g.G_SERIAL_TIMEOUT
             communication_interface = SerialComIF(
@@ -39,7 +39,7 @@ def set_communication_interface(tmtc_printer: TmTcPrinter) -> Union[Communicatio
                 ser_com_type=SerialCommunicationType.DLE_ENCODING)
             communication_interface.set_dle_settings(
                 g.G_SERIAL_DLE_MAX_QUEUE_LEN, g.G_SERIAL_DLE_MAX_FRAME_SIZE, serial_timeout)
-        elif g.G_COM_IF == g.ComIF.QEMU:
+        elif g.G_COM_IF == g.ComInterfaces.QEMU:
             serial_timeout = g.G_SERIAL_TIMEOUT
             communication_interface = QEMUComIF(
                 tmtc_printer=tmtc_printer,
diff --git a/config/obsw_config.py b/config/obsw_config.py
index c5b4d38..f5fdb83 100644
--- a/config/obsw_config.py
+++ b/config/obsw_config.py
@@ -10,7 +10,7 @@
 import struct
 import pprint
 import logging
-from config.obsw_definitions import ModeList, ComIF
+from config.obsw_definitions import ModeList, ComInterfaces
 
 """
 Mission/Device specific information.
@@ -74,7 +74,7 @@ G_APID = 0x73
 G_MAX_BINARY_FRAME_LENGTH = 1500
 G_MAX_APP_DATA_LENGTH = G_MAX_BINARY_FRAME_LENGTH - 100
 
-G_COM_IF = 2
+G_COM_IF: ComInterfaces = ComInterfaces.QEMU
 # COM Port for serial communication
 G_COM_PORT = 'COM0'
 G_SERIAL_TIMEOUT = 0.01
@@ -141,14 +141,15 @@ def set_globals(args):
             G_MODE_ID = ModeList.UnitTest
     else:
         G_MODE_ID = ModeList[1]
-    if args.com_if == ComIF.Ethernet.value:
-        G_COM_IF = ComIF.Ethernet
-    elif args.com_if == ComIF.Serial.value:
-        G_COM_IF = ComIF.Serial
-    elif args.com_if == ComIF.QEMU.value:
-        G_COM_IF = ComIF.QEMU
+
+    if args.com_if == ComInterfaces.Ethernet.value:
+        G_COM_IF = ComInterfaces.Ethernet
+    elif args.com_if == ComInterfaces.Serial.value:
+        G_COM_IF = ComInterfaces.Serial
+    elif args.com_if == ComInterfaces.QEMU.value:
+        G_COM_IF = ComInterfaces.QEMU
     else:
-        G_COM_IF = ComIF.Dummy
+        G_COM_IF = ComInterfaces.Dummy
 
     G_SERVICE = str(args.service)
     if G_SERVICE.isdigit():
diff --git a/config/obsw_definitions.py b/config/obsw_definitions.py
index 738119a..3aff148 100644
--- a/config/obsw_definitions.py
+++ b/config/obsw_definitions.py
@@ -17,7 +17,7 @@ class ModeList(enum.Enum):
     PromptMode = 32
 
 
-class ComIF(enum.Enum):
+class ComInterfaces(enum.Enum):
     Dummy = 0
     Serial = 1
     QEMU = 2
diff --git a/core/tmtc_frontend.py b/core/tmtc_frontend.py
index 99e4008..c840731 100644
--- a/core/tmtc_frontend.py
+++ b/core/tmtc_frontend.py
@@ -14,6 +14,7 @@ from core.tmtc_backend import TmTcHandler
 from tmtc_core.tc.obsw_pus_tc_base import PusTelecommand
 from tmtc_core.utility.obsw_logger import get_logger
 from config import obsw_config
+from config.obsw_definitions import ComInterfaces
 import threading
 
 LOGGER = get_logger()
@@ -41,10 +42,10 @@ class TmTcFrontend:
     def __init__(self, tmtc_handler: TmTcHandler):
         self.tmtc_handler = tmtc_handler
         obsw_config.G_SERVICE = 17
-        obsw_config.G_COM_IF = obsw_config.ComIF.QEMU
+        obsw_config.G_COM_IF = obsw_config.ComInterfaces.QEMU
 
     def prepare_start(self) -> Process:
-        return Process(target=self.init_ui)
+        return Process(target=self.start_ui)
 
     def service_index_changed(self, index: int):
         obsw_config.G_SERVICE = self.serviceList[index]
@@ -107,7 +108,7 @@ class TmTcFrontend:
         self.service_test_button.setEnabled(state)
         self.single_command_button.setEnabled(state)
 
-    def init_ui(self):
+    def start_ui(self):
         app = QApplication([])
 
         win = QWidget()
@@ -192,7 +193,7 @@ class TmTcFrontend:
         grid.addWidget(QLabel("COM IF:"), row, 0, 1, 1)
         com_if_comboBox = QComboBox()
         # add all possible ComIFs to the comboBox
-        for comIf in obsw_config.ComIF:
+        for comIf in obsw_config.ComInterfaces:
             com_if_comboBox.addItem(comIf.name)
         com_if_comboBox.setCurrentIndex(obsw_config.G_COM_IF.value)
         com_if_comboBox.currentIndexChanged.connect(com_if_index_changed)
@@ -301,10 +302,9 @@ class SingleCommandTable(QTableWidget):
         self.setItem(0, 2, QTableWidgetItem("20"))
 
 def com_if_index_changed(index: int):
-    obsw_config.G_COM_IF = obsw_config.ComIF(index)
+    obsw_config.G_COM_IF = ComInterfaces(index)
     LOGGER.info("com if updated: " + str(obsw_config.G_COM_IF))
 
-
 def checkbox_console_print(state: int):
     LOGGER.info(["enabled", "disabled"][state == 0] + " console print")
     obsw_config.G_PRINT_TM = state == 0
-- 
GitLab