Skip to content
Snippets Groups Projects
Commit 30ce09e9 authored by Robin Mueller's avatar Robin Mueller
Browse files

gui testingf continued

parent 8a6a8b3f
No related branches found
No related tags found
No related merge requests found
......@@ -57,6 +57,7 @@ import atexit
import queue
import unittest
import logging
from multiprocessing import Process
from test import OBSW_PusServiceTest
from config import OBSW_Config as g
......@@ -69,7 +70,8 @@ from utility.OBSW_ArgParser import parseInputArguments
from utility.OBSW_TmTcPrinter import TmtcPrinter
from comIF.OBSW_Ethernet_ComIF import EthernetComIF
from comIF.OBSW_Serial_ComIF import SerialComIF
from gui.OBSW_TmtcGUI import TmtcGUI
from gui.OBSW_TmtcGUI import TmTcGUI
from gui.OBSW_BackendTest import TmTcBackend
from utility.OBSW_ExitHandler import keyboardInterruptHandler
......@@ -79,8 +81,14 @@ def main():
tmtcPrinter = TmtcPrinter(g.displayMode, g.printToFile, True)
communicationInterface = 0
if g.modeId == "GUIMode":
GUI = TmtcGUI()
GUI.open()
backend = TmTcBackend()
backend.start()
GUI = TmTcGUI()
GUI.start()
backend.join()
GUI.join()
print("Both processes have closed")
exit()
else:
communicationInterface = setCommunicationInterface(tmtcPrinter)
atexit.register(keyboardInterruptHandler, comInterface=communicationInterface)
......
File moved
from multiprocessing.connection import Listener
from multiprocessing import Process
address = ('localhost', 6000) # family is deduced to be 'AF_INET'
listener = Listener(address, authkey=None)
......@@ -7,7 +8,6 @@ print('connection accepted from' + str(listener.last_accepted))
while True:
msg = conn.recv()
# do something with msg
print("I received something")
if msg == 'close':
conn.close()
break
......
from multiprocessing.connection import Listener
from multiprocessing import Process
import logging
class TmTcBackend(Process):
def __init__(self):
super(TmTcBackend, self).__init__()
self.address = ('localhost', 6000) # family is deduced to be 'AF_INET'
self.listener = Listener(self.address, authkey=None)
self.conn = 0
def run(self):
self.listen()
def listen(self):
self.conn = self.listener.accept()
print('connection accepted from' + str(self.listener.last_accepted))
while True:
msg = self.conn.recv()
# do something with msg
if msg == 'test':
print("Hallo Welt !")
elif msg == 'close':
try:
self.conn.close()
break
except OSError:
logging.exception("Error: ")
self.listener.close()
......@@ -13,8 +13,10 @@
@author:
R. Mueller
"""
from tkinter import Tk
import tkinter as tk
from multiprocessing.connection import Client
from multiprocessing import Process
import time
# A first simple version has drop down menus to chose all necessary options
......@@ -24,16 +26,31 @@ from multiprocessing.connection import Client
# A third button to perform a keyboard interrupt should be implemented
# include a really nice source badge and make it large !
# plan this on paper first...
class TmtcGUI:
class TmTcGUI(Process):
def __init__(self):
self.window = Tk()
super(TmTcGUI, self).__init__()
self.root = None
self.address = ('localhost', 6000)
self.conn = Client(self.address, authkey=None)
self.counter = 0
def run(self):
self.open()
def open(self):
self.window.title("Hallo Welt")
self.window.mainloop()
self.conn.send("close")
self.root = tk.Tk("Hallo Welt !")
self.root.title("Hallo Welt")
while True:
self.conn.send("test")
self.root.update()
time.sleep(2)
self.counter = self.counter + 1
if self.counter == 3:
self.conn.send("close")
self.conn.close()
break
# self.window.mainloop()
def close(self):
self.window.quit()
pass
# self.window.quit()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment