Skip to content

Commit

Permalink
prep next major version
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed May 5, 2024
1 parent a56a9bd commit b76e5d9
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 284 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ Starting from v4.0.0, this project adheres to [Semantic Versioning](http://semve

# [unreleased]

# [v8.0.0] 2024-05-03

## Changed

- Renamed `FsfwTmTcPrinter.get_validity_buffer` to `FsfwTmTcPrinter.get_validity_buffer_str`

## Added

- Added `fsfw.tmtc_printer.get_validity_buffer_str` function.

## Removed

- Broken FSFW PUS3 TM unpacket.

# [v8.0.0rc2] 2024-04-23

- Bumped `spacepackets` to release range >=0.24, <0.25.
Expand Down
4 changes: 2 additions & 2 deletions examples/app/tmtcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ def main(): # noqa: C901
else:
post_args_wrapper.set_params_with_prompts(proc_wrapper)
params.apid = EXAMPLE_PUS_APID
if params.tc_params.print_tree:
perform_tree_printout(params.tc_params, hook_obj.get_command_definitions())
if params.cmd_params.print_tree and not params.use_gui:
perform_tree_printout(params.cmd_params, hook_obj.get_command_definitions())
sys.exit(0)
setup_args = SetupWrapper(
hook_obj=hook_obj, setup_params=params, proc_param_wrapper=proc_wrapper
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
name = "tmtccmd"
description = "TMTC Commander Core"
readme = "README.md"
version = "8.0.0rc.2"
version = "8.0.0"
requires-python = ">=3.8"
license = {text = "Apache-2.0 or MIT" }
authors = [
Expand Down
20 changes: 10 additions & 10 deletions tests/config/test_args_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_basic(self):
self.params.backend_params.mode = ""
self.params.backend_params.com_if_id = ""
self.simple_pargs_cli_set()
self.assertEqual(self.params.tc_params.delay, 0)
self.assertEqual(self.params.cmd_params.delay, 0)
self.assertEqual(self.params.backend_params.mode, "")
self.assertEqual(self.params.backend_params.com_if_id, "")
def_params = TreeCommandingParams(None)
Expand All @@ -62,9 +62,9 @@ def test_basic(self):
assign_com_if=False,
)
# Set to default value
self.assertEqual(self.params.tc_params.delay, 4.0)
self.assertEqual(self.params.cmd_params.delay, 4.0)
# Unset
self.assertEqual(self.params.tc_params.apid, 0)
self.assertEqual(self.params.cmd_params.apid, 0)
self.assertEqual(self.params.app_params.use_gui, False)
self.assertEqual(self.params.app_params.use_ansi_colors, True)
self.assertEqual(def_params.cmd_path, "/PING")
Expand All @@ -88,7 +88,7 @@ def test_delay_set(self):
assign_com_if=False,
)
self.assertEqual(def_params.cmd_path, "/PING")
self.assertEqual(self.params.tc_params.delay, 2.0)
self.assertEqual(self.params.cmd_params.delay, 2.0)

def test_cfdp_conversion_basic(self):
self.pargs.source = "hello.txt"
Expand Down Expand Up @@ -147,9 +147,9 @@ def test_tree_printout_conversion_default(self):
def_tmtc_params=def_params,
assign_com_if=False,
)
self.assertTrue(self.params.tc_params.print_tree)
self.assertTrue(self.params.tc_params.tree_print_with_description)
self.assertIsNone(self.params.tc_params.tree_print_max_depth)
self.assertTrue(self.params.cmd_params.print_tree)
self.assertTrue(self.params.cmd_params.tree_print_with_description)
self.assertIsNone(self.params.cmd_params.tree_print_max_depth)

def test_tree_printout_conversion_with_custom_args(self):
self.base_cli_set()
Expand All @@ -163,9 +163,9 @@ def test_tree_printout_conversion_with_custom_args(self):
def_tmtc_params=def_params,
assign_com_if=False,
)
self.assertTrue(self.params.tc_params.print_tree)
self.assertFalse(self.params.tc_params.tree_print_with_description)
self.assertEqual(self.params.tc_params.tree_print_max_depth, 2)
self.assertTrue(self.params.cmd_params.print_tree)
self.assertFalse(self.params.cmd_params.tree_print_with_description)
self.assertEqual(self.params.cmd_params.tree_print_max_depth, 2)

@patch("builtins.print")
def test_tree_printout_0(self, print_mock: MagicMock):
Expand Down
2 changes: 1 addition & 1 deletion tmtccmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def create_default_tmtc_backend(
if setup_wrapper.params.backend_params.listener:
tmtc_backend.keep_listener_mode = True
tmtc_backend.inter_cmd_delay = timedelta(
seconds=setup_wrapper.params.tc_params.delay
seconds=setup_wrapper.params.cmd_params.delay
)
if init_procedure is not None:
tmtc_backend.current_procedure = init_procedure.procedure
Expand Down
42 changes: 21 additions & 21 deletions tmtccmd/config/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,25 @@ class SetupParams:
def __init__(
self,
com_if: Optional[ComInterface] = None,
tc_params: Optional[CommandingParams] = None,
cmd_params: Optional[CommandingParams] = None,
backend_params: Optional[BackendParams] = None,
app_params: Optional[AppParams] = None,
):
self.com_if = com_if
if tc_params is None:
self.tc_params = CommandingParams()
if cmd_params is None:
self.cmd_params = CommandingParams()
if backend_params is None:
self.backend_params = BackendParams()
if app_params is None:
self.app_params = AppParams()

@property
def apid(self):
return self.tc_params.apid
return self.cmd_params.apid

Check warning on line 127 in tmtccmd/config/args.py

View check run for this annotation

Codecov / codecov/patch

tmtccmd/config/args.py#L127

Added line #L127 was not covered by tests

@apid.setter
def apid(self, apid):
self.tc_params.apid = apid
self.cmd_params.apid = apid

Check warning on line 131 in tmtccmd/config/args.py

View check run for this annotation

Codecov / codecov/patch

tmtccmd/config/args.py#L131

Added line #L131 was not covered by tests

@property
def use_gui(self):
Expand Down Expand Up @@ -458,9 +458,9 @@ def args_to_all_params_for_cfdp(
CoreModeList.MULTI_INTERACTIVE_QUEUE_MODE
)
if pargs.delay is None:
params.tc_params.delay = 0.4
params.cmd_params.delay = 0.4

Check warning on line 461 in tmtccmd/config/args.py

View check run for this annotation

Codecov / codecov/patch

tmtccmd/config/args.py#L461

Added line #L461 was not covered by tests
else:
params.tc_params.delay = float(pargs.delay)
params.cmd_params.delay = float(pargs.delay)

Check warning on line 463 in tmtccmd/config/args.py

View check run for this annotation

Codecov / codecov/patch

tmtccmd/config/args.py#L463

Added line #L463 was not covered by tests


def args_to_all_params_tmtc(
Expand Down Expand Up @@ -496,14 +496,14 @@ def args_to_all_params_tmtc(
use_prompts=use_prompts,
assign_com_if=assign_com_if,
)
params.tc_params.print_tree = False
params.cmd_params.print_tree = False
if pargs.print_tree is not None:
params.tc_params.print_tree = True
params.cmd_params.print_tree = True
for arg in pargs.print_tree:
if "b" in arg:
params.tc_params.tree_print_with_description = False
params.cmd_params.tree_print_with_description = False
if arg.isdigit():
params.tc_params.tree_print_max_depth = int(arg)
params.cmd_params.tree_print_max_depth = int(arg)
mode_set_explicitely = False
if pargs.mode is None:
params.mode = CoreModeConverter.get_str(CoreModeList.ONE_QUEUE_MODE)
Expand All @@ -521,14 +521,14 @@ def args_to_all_params_tmtc(
if params.backend_params.mode == CoreModeConverter.get_str(
CoreModeList.ONE_QUEUE_MODE
):
params.tc_params.delay = 4.0
params.cmd_params.delay = 4.0
else:
params.tc_params.delay = 0.0
params.cmd_params.delay = 0.0
else:
params.tc_params.delay = float(pargs.delay)
params.cmd_params.delay = float(pargs.delay)
if (
params.mode != CoreModeConverter.get_str(CoreModeList.LISTENER_MODE)
and not params.tc_params.print_tree
and not params.cmd_params.print_tree
):
determine_cmd_path(
params=params,
Expand All @@ -539,18 +539,18 @@ def args_to_all_params_tmtc(
)


def perform_tree_printout(tc_params: CommandingParams, cmd_def_tree: CmdTreeNode):
if tc_params.tree_print_with_description:
def perform_tree_printout(cmd_params: CommandingParams, cmd_def_tree: CmdTreeNode):
if cmd_params.tree_print_with_description:
info_str = "with full descriptions"
else:
info_str = "without descriptions"
if tc_params.tree_print_max_depth is not None:
info_str += f" and maximum depth {tc_params.tree_print_max_depth}"
if cmd_params.tree_print_max_depth is not None:
info_str += f" and maximum depth {cmd_params.tree_print_max_depth}"
print(f"Printing command tree {info_str}:")
print(
cmd_def_tree.str_for_tree(
tc_params.tree_print_with_description,
tc_params.tree_print_max_depth,
cmd_params.tree_print_with_description,
cmd_params.tree_print_max_depth,
)
)

Expand Down
63 changes: 36 additions & 27 deletions tmtccmd/fsfw/tmtc_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,39 @@ class DisplayMode(enum.Enum):
LONG = enum.auto


def get_validity_buffer_str(validity_buffer: bytes, num_vars: int) -> str:
"""
:param validity_buffer: Validity buffer in bytes format
:param num_vars: Number of variables
:return:
"""
valid_list = []
counter = 0
for _index, byte in enumerate(validity_buffer):
for bit in range(1, 9):
if FsfwTmTcPrinter.bit_extractor(byte, bit) == 1:
valid_list.append(True)
else:
valid_list.append(False)
counter += 1
if counter == num_vars:
break
validity_lists = list(FsfwTmTcPrinter.chunks(n=16, lst=valid_list))
for valid_list in validity_lists:
printout = "Valid: ["
for idx, valid in enumerate(valid_list):
if valid:
printout += "Y"
else:
printout += "N"
if idx < len(valid_list) - 1:
printout += ","
else:
printout += "]"
return printout
return ""


class FsfwTmTcPrinter:
"""This class handles printing to the command line and to files"""

Expand Down Expand Up @@ -120,43 +153,19 @@ def generic_hk_tm_print(
self.file_logger.info(f"{get_current_time_string(True)}: {generic_info}")

def print_validity_buffer(self, validity_buffer: bytes, num_vars: int):
printout = FsfwTmTcPrinter.get_validity_buffer(validity_buffer, num_vars)
printout = FsfwTmTcPrinter.get_validity_buffer_str(validity_buffer, num_vars)
print(printout)
if self.file_logger:
self.file_logger.info(printout)

@staticmethod
def get_validity_buffer(validity_buffer: bytes, num_vars: int) -> str:
def get_validity_buffer_str(validity_buffer: bytes, num_vars: int) -> str:
"""
:param validity_buffer: Validity buffer in bytes format
:param num_vars: Number of variables
:return:
"""
valid_list = []
counter = 0
for index, byte in enumerate(validity_buffer):
for bit in range(1, 9):
if FsfwTmTcPrinter.bit_extractor(byte, bit) == 1:
valid_list.append(True)
else:
valid_list.append(False)
counter += 1
if counter == num_vars:
break
validity_lists = list(FsfwTmTcPrinter.chunks(n=16, lst=valid_list))
for valid_list in validity_lists:
printout = "Valid: ["
for idx, valid in enumerate(valid_list):
if valid:
printout += "Y"
else:
printout += "N"
if idx < len(valid_list) - 1:
printout += ","
else:
printout += "]"
return printout
return ""
return get_validity_buffer_str(validity_buffer, num_vars)

@staticmethod
def generic_action_packet_tm_print(
Expand Down

0 comments on commit b76e5d9

Please sign in to comment.