Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SRC OBDH TMTC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Robin Mueller
SRC OBDH TMTC
Commits
3c8c3ba3
Commit
3c8c3ba3
authored
4 years ago
by
Robin Mueller
Browse files
Options
Downloads
Patches
Plain Diff
improved architecture
parent
9642b180
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
config/obsw_com_config.py
+0
-3
0 additions, 3 deletions
config/obsw_com_config.py
core/tmtc_backend.py
+29
-12
29 additions, 12 deletions
core/tmtc_backend.py
core/tmtc_client_core.py
+5
-13
5 additions, 13 deletions
core/tmtc_client_core.py
tmtc_core
+1
-1
1 addition, 1 deletion
tmtc_core
with
35 additions
and
29 deletions
config/obsw_com_config.py
+
0
−
3
View file @
3c8c3ba3
...
@@ -49,9 +49,6 @@ def set_communication_interface(tmtc_printer: TmTcPrinter) -> Union[Communicatio
...
@@ -49,9 +49,6 @@ def set_communication_interface(tmtc_printer: TmTcPrinter) -> Union[Communicatio
g
.
G_SERIAL_DLE_MAX_QUEUE_LEN
,
g
.
G_SERIAL_DLE_MAX_FRAME_SIZE
,
serial_timeout
)
g
.
G_SERIAL_DLE_MAX_QUEUE_LEN
,
g
.
G_SERIAL_DLE_MAX_FRAME_SIZE
,
serial_timeout
)
else
:
else
:
communication_interface
=
DummyComIF
(
tmtc_printer
=
tmtc_printer
)
communication_interface
=
DummyComIF
(
tmtc_printer
=
tmtc_printer
)
if
not
communication_interface
.
valid
:
LOGGER
.
warning
(
"
Invalid communication interface!
"
)
sys
.
exit
()
communication_interface
.
initialize
()
communication_interface
.
initialize
()
return
communication_interface
return
communication_interface
except
(
IOError
,
OSError
):
except
(
IOError
,
OSError
):
...
...
This diff is collapsed.
Click to expand it.
core/tmtc_backend.py
+
29
−
12
View file @
3c8c3ba3
...
@@ -7,7 +7,7 @@ from collections import deque
...
@@ -7,7 +7,7 @@ from collections import deque
from
typing
import
Tuple
,
Union
from
typing
import
Tuple
,
Union
from
config
import
obsw_config
as
g
from
config
import
obsw_config
as
g
from
config.obsw_definitions
import
ModeList
from
config.obsw_definitions
import
ModeList
,
ComInterfaces
from
config.obsw_user_code
import
command_preparation_hook
from
config.obsw_user_code
import
command_preparation_hook
from
tmtc_core.utility.obsw_logger
import
get_logger
from
tmtc_core.utility.obsw_logger
import
get_logger
...
@@ -32,15 +32,17 @@ class TmTcHandler:
...
@@ -32,15 +32,17 @@ class TmTcHandler:
This is the primary class which handles TMTC reception. This can be seen as the backend
This is the primary class which handles TMTC reception. This can be seen as the backend
in case a GUI or front-end is implemented.
in case a GUI or front-end is implemented.
"""
"""
def
__init__
(
self
,
init_mode
:
ModeList
=
ModeList
.
ListenerMode
):
def
__init__
(
self
,
init_com_if
:
ComInterfaces
=
ComInterfaces
.
Dummy
,
init_mode
:
ModeList
=
ModeList
.
ListenerMode
):
self
.
mode
=
init_mode
self
.
mode
=
init_mode
self
.
com_if
=
g
.
G_COM_IF
self
.
com_if
=
init_com_if
# This flag could be used later to command the TMTC Client with a front-end
# This flag could be used later to command the TMTC Client with a front-end
self
.
one_shot_operation
=
True
self
.
one_shot_operation
=
True
self
.
tmtc_printer
:
Union
[
None
,
TmTcPrinter
]
=
None
self
.
tmtc_printer
:
Union
[
None
,
TmTcPrinter
]
=
None
self
.
communication_interface
:
Union
[
None
,
CommunicationInterface
]
=
None
self
.
communication_interface
:
Union
[
None
,
CommunicationInterface
]
=
None
self
.
tm_listener
:
Union
[
None
,
TmListener
]
=
None
self
.
tm_listener
:
Union
[
None
,
TmListener
]
=
None
self
.
exit_on_com_if_init_failure
=
True
self
.
single_command_package
:
Tuple
[
bytearray
,
Union
[
None
,
PusTcInfo
]]
=
bytearray
(),
None
self
.
single_command_package
:
Tuple
[
bytearray
,
Union
[
None
,
PusTcInfo
]]
=
bytearray
(),
None
...
@@ -57,16 +59,24 @@ class TmTcHandler:
...
@@ -57,16 +59,24 @@ class TmTcHandler:
"""
"""
self
.
mode
=
mode
self
.
mode
=
mode
def
set_com_if
(
self
,
com_if
:
ComInterfaces
):
self
.
com_if
=
com_if
@staticmethod
@staticmethod
def
prepare_tmtc_handler_start
(
init_mode
:
ModeList
=
g
.
ModeList
.
ListenerMode
):
def
prepare_tmtc_handler_start
(
tmtc_handler
=
TmTcHandler
(
init_mode
)
init_com_if
:
ComInterfaces
=
ComInterfaces
.
Dummy
,
init_mode
:
ModeList
=
g
.
ModeList
.
ListenerMode
):
tmtc_handler
=
TmTcHandler
(
init_com_if
,
init_mode
)
tmtc_task
=
Process
(
target
=
TmTcHandler
.
start_handler
,
args
=
(
tmtc_handler
,
))
tmtc_task
=
Process
(
target
=
TmTcHandler
.
start_handler
,
args
=
(
tmtc_handler
,
))
return
tmtc_task
return
tmtc_task
@staticmethod
@staticmethod
def
start_handler
(
executed_handler
):
def
start_handler
(
executed_handler
):
if
not
isinstance
(
executed_handler
,
TmTcHandler
):
LOGGER
.
error
(
"
Unexpected argument, should be TmTcHandler!
"
)
sys
.
exit
(
1
)
executed_handler
.
initialize
()
executed_handler
.
initialize
()
executed_handler
.
perform_operation
()
executed_handler
.
start
()
def
initialize
(
self
):
def
initialize
(
self
):
"""
"""
...
@@ -79,12 +89,19 @@ class TmTcHandler:
...
@@ -79,12 +89,19 @@ class TmTcHandler:
com_interface
=
self
.
communication_interface
,
tm_timeout
=
g
.
G_TM_TIMEOUT
,
com_interface
=
self
.
communication_interface
,
tm_timeout
=
g
.
G_TM_TIMEOUT
,
tc_timeout_factor
=
g
.
G_TC_SEND_TIMEOUT_FACTOR
tc_timeout_factor
=
g
.
G_TC_SEND_TIMEOUT_FACTOR
)
)
if
self
.
communication_interface
.
valid
:
atexit
.
register
(
keyboard_interrupt_handler
,
com_interface
=
self
.
communication_interface
)
def
start
(
self
):
try
:
self
.
communication_interface
.
open
()
self
.
tm_listener
.
start
()
self
.
tm_listener
.
start
()
e
lse
:
e
xcept
IOError
:
LOGGER
.
info
(
"
No c
ommunication
i
nterface
set for now
"
)
LOGGER
.
error
(
"
C
ommunication
I
nterface
could not be opened!
"
)
LOGGER
.
info
(
"
TM listener will not be started
"
)
LOGGER
.
info
(
"
TM listener will not be started
"
)
atexit
.
register
(
keyboard_interrupt_handler
,
com_interface
=
self
.
communication_interface
)
if
self
.
exit_on_com_if_init_failure
:
LOGGER
.
error
(
"
Closing TMTC commander..
"
)
sys
.
exit
(
1
)
self
.
perform_operation
()
def
perform_operation
(
self
):
def
perform_operation
(
self
):
"""
"""
...
@@ -117,12 +134,12 @@ class TmTcHandler:
...
@@ -117,12 +134,12 @@ class TmTcHandler:
if
self
.
single_command_package
is
None
:
if
self
.
single_command_package
is
None
:
pus_packet_tuple
=
command_preparation
()
pus_packet_tuple
=
command_preparation
()
else
:
else
:
LOGGER
.
info
(
"
s
end pack
ag
e from
gui
"
)
LOGGER
.
info
(
"
S
end
ing single
packe
t
from
GUI..
"
)
pus_packet_tuple
=
self
.
single_command_package
pus_packet_tuple
=
self
.
single_command_package
sender_and_receiver
=
SingleCommandSenderReceiver
(
sender_and_receiver
=
SingleCommandSenderReceiver
(
com_interface
=
self
.
communication_interface
,
tmtc_printer
=
self
.
tmtc_printer
,
com_interface
=
self
.
communication_interface
,
tmtc_printer
=
self
.
tmtc_printer
,
tm_listener
=
self
.
tm_listener
)
tm_listener
=
self
.
tm_listener
)
LOGGER
.
info
(
"
Performing single command operation
"
)
LOGGER
.
info
(
"
Performing single command operation
..
"
)
sender_and_receiver
.
send_single_tc_and_receive_tm
(
pus_packet_tuple
=
pus_packet_tuple
)
sender_and_receiver
.
send_single_tc_and_receive_tm
(
pus_packet_tuple
=
pus_packet_tuple
)
self
.
mode
=
g
.
ModeList
.
PromptMode
self
.
mode
=
g
.
ModeList
.
PromptMode
...
...
This diff is collapsed.
Click to expand it.
core/tmtc_client_core.py
+
5
−
13
View file @
3c8c3ba3
...
@@ -55,29 +55,21 @@ def run_tmtc_client(use_gui: bool):
...
@@ -55,29 +55,21 @@ def run_tmtc_client(use_gui: bool):
LOGGER
.
info
(
"
Setting global variables
"
)
LOGGER
.
info
(
"
Setting global variables
"
)
set_globals
(
args
)
set_globals
(
args
)
LOGGER
.
info
(
"
Starting TMTC Handler
"
)
LOGGER
.
info
(
"
Starting TMTC Handler
..
"
)
tmtc_frontend_task
=
Process
# Currently does not work, problems with QEMU / Asyncio
if
not
use_gui
:
if
not
use_gui
:
tmtc_handler
=
TmTcHandler
(
g
.
G_MODE_ID
)
# The global variables are set by the argument parser.
tmtc_handler
=
TmTcHandler
(
g
.
G_COM_IF
,
g
.
G_MODE_ID
)
tmtc_handler
.
set_one_shot_or_loop_handling
(
g
.
G_LISTENER_AFTER_OP
)
tmtc_handler
.
set_one_shot_or_loop_handling
(
g
.
G_LISTENER_AFTER_OP
)
tmtc_handler
.
initialize
()
tmtc_handler
.
initialize
()
tmtc_handler
.
perform_operation
()
tmtc_handler
.
start
()
else
:
else
:
app
=
QApplication
([
"
TMTC Commander
"
])
app
=
QApplication
([
"
TMTC Commander
"
])
tmtc_gui
=
TmTcFrontend
()
tmtc_gui
=
TmTcFrontend
()
tmtc_gui
.
start_ui
()
tmtc_gui
.
start_ui
()
sys
.
exit
(
app
.
exec_
())
sys
.
exit
(
app
.
exec_
())
# tmtc_handler_task = TmTcHandler.prepare_tmtc_handler_start()
# tmtc_frontend = TmTcFrontend()
# tmtc_frontend_task = tmtc_frontend.prepare_start(tmtc_frontend)
# tmtc_frontend_task.start()
# tmtc_handler_task.start()
# tmtc_handler_task.join()
# tmtc_frontend_task.join()
This diff is collapsed.
Click to expand it.
tmtc_core
@
2a12f362
Compare
1f4f33f9
...
2a12f362
Subproject commit
1f4f33f92ae5b6abe92e89dedf7041ebdee4b63c
Subproject commit
2a12f3621780fb5df5a9fcd30b936e8d1ad991c7
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment