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
540ed898
Commit
540ed898
authored
4 years ago
by
Robin.Mueller
Browse files
Options
Downloads
Patches
Plain Diff
backend improved a bit
parent
4d2b3a3e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/tmtc_backend.py
+33
-15
33 additions, 15 deletions
core/tmtc_backend.py
core/tmtc_frontend.py
+1
-1
1 addition, 1 deletion
core/tmtc_frontend.py
with
34 additions
and
16 deletions
core/tmtc_backend.py
+
33
−
15
View file @
540ed898
...
@@ -32,7 +32,7 @@ class TmTcHandler:
...
@@ -32,7 +32,7 @@ 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
=
g
.
ModeList
.
ListenerMode
):
def
__init__
(
self
,
init_mode
:
ModeList
=
ModeList
.
ListenerMode
):
self
.
mode
=
init_mode
self
.
mode
=
init_mode
self
.
com_if
=
g
.
G_COM_IF
self
.
com_if
=
g
.
G_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
...
@@ -44,6 +44,19 @@ class TmTcHandler:
...
@@ -44,6 +44,19 @@ class TmTcHandler:
self
.
single_command_package
:
Tuple
[
bytearray
,
Union
[
None
,
PusTcInfo
]]
=
bytearray
(),
None
self
.
single_command_package
:
Tuple
[
bytearray
,
Union
[
None
,
PusTcInfo
]]
=
bytearray
(),
None
def
set_one_shot_or_loop_handling
(
self
,
enable
:
bool
):
"""
Specify whether the perform_operation() call will only handle one action depending
on the mode or keep listening for replies after handling an operation.
"""
self
.
one_shot_operation
=
enable
def
set_mode
(
self
,
mode
:
ModeList
):
"""
Set the mode which will determine what perform_operation does.
"""
self
.
mode
=
mode
@staticmethod
@staticmethod
def
prepare_tmtc_handler_start
(
init_mode
:
ModeList
=
g
.
ModeList
.
ListenerMode
):
def
prepare_tmtc_handler_start
(
init_mode
:
ModeList
=
g
.
ModeList
.
ListenerMode
):
tmtc_handler
=
TmTcHandler
(
init_mode
)
tmtc_handler
=
TmTcHandler
(
init_mode
)
...
@@ -56,6 +69,10 @@ class TmTcHandler:
...
@@ -56,6 +69,10 @@ class TmTcHandler:
executed_handler
.
perform_operation
()
executed_handler
.
perform_operation
()
def
initialize
(
self
):
def
initialize
(
self
):
"""
Perform initialization steps which might be necessary after class construction.
This has to be called at some point before using the class!
"""
self
.
tmtc_printer
=
TmTcPrinter
(
g
.
G_DISPLAY_MODE
,
g
.
G_PRINT_TO_FILE
,
True
)
self
.
tmtc_printer
=
TmTcPrinter
(
g
.
G_DISPLAY_MODE
,
g
.
G_PRINT_TO_FILE
,
True
)
self
.
communication_interface
=
set_communication_interface
(
self
.
tmtc_printer
)
self
.
communication_interface
=
set_communication_interface
(
self
.
tmtc_printer
)
self
.
tm_listener
=
TmListener
(
self
.
tm_listener
=
TmListener
(
...
@@ -74,7 +91,7 @@ class TmTcHandler:
...
@@ -74,7 +91,7 @@ class TmTcHandler:
Periodic operation
Periodic operation
"""
"""
try
:
try
:
self
.
core_operation
(
self
.
one_shot_operation
)
self
.
__
core_operation
(
self
.
one_shot_operation
)
except
KeyboardInterrupt
:
except
KeyboardInterrupt
:
LOGGER
.
info
(
"
Closing TMTC client.
"
)
LOGGER
.
info
(
"
Closing TMTC client.
"
)
sys
.
exit
()
sys
.
exit
()
...
@@ -83,19 +100,7 @@ class TmTcHandler:
...
@@ -83,19 +100,7 @@ class TmTcHandler:
LOGGER
.
info
(
"
Closing TMTC client.
"
)
LOGGER
.
info
(
"
Closing TMTC client.
"
)
sys
.
exit
()
sys
.
exit
()
def
core_operation
(
self
,
one_shot
):
def
__handle_action
(
self
):
if
not
one_shot
:
while
True
:
self
.
handle_action
()
if
self
.
mode
==
g
.
ModeList
.
Idle
:
LOGGER
.
info
(
"
TMTC Client in idle mode
"
)
time
.
sleep
(
5
)
elif
self
.
mode
==
g
.
ModeList
.
ListenerMode
:
time
.
sleep
(
1
)
else
:
self
.
handle_action
()
def
handle_action
(
self
):
"""
"""
Command handling.
Command handling.
"""
"""
...
@@ -167,6 +172,19 @@ class TmTcHandler:
...
@@ -167,6 +172,19 @@ class TmTcHandler:
logging
.
error
(
"
Unknown Mode, Configuration error !
"
)
logging
.
error
(
"
Unknown Mode, Configuration error !
"
)
sys
.
exit
()
sys
.
exit
()
def
__core_operation
(
self
,
one_shot
):
if
not
one_shot
:
while
True
:
self
.
__handle_action
()
if
self
.
mode
==
g
.
ModeList
.
Idle
:
LOGGER
.
info
(
"
TMTC Client in idle mode
"
)
time
.
sleep
(
5
)
elif
self
.
mode
==
g
.
ModeList
.
ListenerMode
:
time
.
sleep
(
1
)
else
:
self
.
__handle_action
()
def
prompt_mode
(
self
):
def
prompt_mode
(
self
):
next_mode
=
input
(
"
Please enter next mode (enter h for list of modes):
"
)
next_mode
=
input
(
"
Please enter next mode (enter h for list of modes):
"
)
if
next_mode
==
'
h
'
:
if
next_mode
==
'
h
'
:
...
...
This diff is collapsed.
Click to expand it.
core/tmtc_frontend.py
+
1
−
1
View file @
540ed898
...
@@ -99,7 +99,7 @@ class TmTcFrontend:
...
@@ -99,7 +99,7 @@ class TmTcFrontend:
LOGGER
.
info
(
"
start tmtc_handler.handle_action
"
)
LOGGER
.
info
(
"
start tmtc_handler.handle_action
"
)
self
.
is_busy
=
True
self
.
is_busy
=
True
self
.
set_send_buttons
(
False
)
self
.
set_send_buttons
(
False
)
self
.
tmtc_handler
.
handle_action
()
self
.
tmtc_handler
.
__
handle_action
()
self
.
is_busy
=
False
self
.
is_busy
=
False
self
.
set_send_buttons
(
True
)
self
.
set_send_buttons
(
True
)
LOGGER
.
info
(
"
finished tmtc_handler.handle_action
"
)
LOGGER
.
info
(
"
finished tmtc_handler.handle_action
"
)
...
...
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