fprime-gds 3.6.1__py3-none-any.whl → 4.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fprime_gds/common/communication/adapters/ip.py +14 -9
- fprime_gds/common/communication/adapters/uart.py +34 -25
- fprime_gds/common/communication/ccsds/__init__.py +0 -0
- fprime_gds/common/communication/ccsds/apid.py +19 -0
- fprime_gds/common/communication/ccsds/chain.py +106 -0
- fprime_gds/common/communication/ccsds/space_data_link.py +196 -0
- fprime_gds/common/communication/ccsds/space_packet.py +129 -0
- fprime_gds/common/communication/framing.py +27 -32
- fprime_gds/common/decoders/ch_decoder.py +1 -1
- fprime_gds/common/decoders/event_decoder.py +9 -2
- fprime_gds/common/decoders/pkt_decoder.py +1 -1
- fprime_gds/common/distributor/distributor.py +6 -3
- fprime_gds/common/encoders/ch_encoder.py +2 -2
- fprime_gds/common/encoders/cmd_encoder.py +2 -2
- fprime_gds/common/encoders/event_encoder.py +2 -2
- fprime_gds/common/encoders/pkt_encoder.py +2 -2
- fprime_gds/common/encoders/seq_writer.py +2 -2
- fprime_gds/common/fpy/README.md +56 -0
- fprime_gds/common/fpy/SPEC.md +69 -0
- fprime_gds/common/fpy/__init__.py +0 -0
- fprime_gds/common/fpy/bytecode/__init__.py +0 -0
- fprime_gds/common/fpy/bytecode/directives.py +490 -0
- fprime_gds/common/fpy/codegen.py +1687 -0
- fprime_gds/common/fpy/grammar.lark +88 -0
- fprime_gds/common/fpy/main.py +40 -0
- fprime_gds/common/fpy/parser.py +239 -0
- fprime_gds/common/gds_cli/base_commands.py +1 -1
- fprime_gds/common/handlers.py +39 -0
- fprime_gds/common/loaders/fw_type_json_loader.py +54 -0
- fprime_gds/common/loaders/json_loader.py +15 -0
- fprime_gds/common/loaders/pkt_json_loader.py +125 -0
- fprime_gds/common/loaders/prm_json_loader.py +85 -0
- fprime_gds/common/logger/__init__.py +2 -2
- fprime_gds/common/pipeline/dictionaries.py +60 -41
- fprime_gds/common/pipeline/encoding.py +19 -0
- fprime_gds/common/pipeline/histories.py +4 -0
- fprime_gds/common/pipeline/standard.py +16 -2
- fprime_gds/common/templates/cmd_template.py +8 -0
- fprime_gds/common/templates/prm_template.py +81 -0
- fprime_gds/common/testing_fw/api.py +148 -1
- fprime_gds/common/testing_fw/pytest_integration.py +37 -3
- fprime_gds/common/tools/README.md +34 -0
- fprime_gds/common/tools/params.py +246 -0
- fprime_gds/common/utils/config_manager.py +6 -6
- fprime_gds/common/utils/data_desc_type.py +6 -1
- fprime_gds/executables/apps.py +189 -11
- fprime_gds/executables/cli.py +468 -127
- fprime_gds/executables/comm.py +5 -2
- fprime_gds/executables/data_product_writer.py +164 -165
- fprime_gds/executables/fprime_cli.py +3 -3
- fprime_gds/executables/run_deployment.py +13 -5
- fprime_gds/flask/app.py +3 -0
- fprime_gds/flask/resource.py +5 -2
- fprime_gds/flask/static/addons/chart-display/addon.js +8 -3
- fprime_gds/flask/static/js/datastore.js +1 -0
- fprime_gds/flask/static/js/vue-support/channel.js +1 -1
- fprime_gds/flask/static/js/vue-support/event.js +1 -1
- fprime_gds/plugin/definitions.py +86 -8
- fprime_gds/plugin/system.py +172 -58
- {fprime_gds-3.6.1.dist-info → fprime_gds-4.0.0.dist-info}/METADATA +23 -21
- {fprime_gds-3.6.1.dist-info → fprime_gds-4.0.0.dist-info}/RECORD +66 -50
- {fprime_gds-3.6.1.dist-info → fprime_gds-4.0.0.dist-info}/WHEEL +1 -1
- {fprime_gds-3.6.1.dist-info → fprime_gds-4.0.0.dist-info}/entry_points.txt +2 -0
- fprime_gds/common/loaders/ch_py_loader.py +0 -79
- fprime_gds/common/loaders/cmd_py_loader.py +0 -66
- fprime_gds/common/loaders/event_py_loader.py +0 -75
- fprime_gds/common/loaders/python_loader.py +0 -132
- {fprime_gds-3.6.1.dist-info → fprime_gds-4.0.0.dist-info/licenses}/LICENSE.txt +0 -0
- {fprime_gds-3.6.1.dist-info → fprime_gds-4.0.0.dist-info/licenses}/NOTICE.txt +0 -0
- {fprime_gds-3.6.1.dist-info → fprime_gds-4.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,85 @@
|
|
1
|
+
"""
|
2
|
+
prm_json_loader.py:
|
3
|
+
|
4
|
+
Loads flight dictionary (JSON) and returns id and mnemonic based Python dictionaries of params
|
5
|
+
|
6
|
+
@author zimri.leisher
|
7
|
+
"""
|
8
|
+
|
9
|
+
from fprime_gds.common.templates.prm_template import PrmTemplate
|
10
|
+
from fprime_gds.common.loaders.json_loader import JsonLoader
|
11
|
+
from fprime_gds.common.data_types.exceptions import GdsDictionaryParsingException
|
12
|
+
|
13
|
+
|
14
|
+
class PrmJsonLoader(JsonLoader):
|
15
|
+
"""Class to load parameters from json dictionaries"""
|
16
|
+
|
17
|
+
PARAMS_FIELD = "parameters"
|
18
|
+
|
19
|
+
ID = "id"
|
20
|
+
NAME = "name"
|
21
|
+
TYPE = "type"
|
22
|
+
DESC = "annotation"
|
23
|
+
DEFAULT = "default"
|
24
|
+
|
25
|
+
|
26
|
+
def construct_dicts(self, _):
|
27
|
+
"""
|
28
|
+
Constructs and returns python dictionaries keyed on id and name
|
29
|
+
|
30
|
+
Args:
|
31
|
+
_: Unused argument (inherited)
|
32
|
+
Returns:
|
33
|
+
A tuple with two channel dictionaries (python type dict):
|
34
|
+
(id_dict, fqn_name_dict). The keys should be the channels' id and
|
35
|
+
fully qualified name fields respectively and the values should be PrmTemplate
|
36
|
+
objects.
|
37
|
+
"""
|
38
|
+
id_dict = {}
|
39
|
+
fqn_name_dict = {}
|
40
|
+
|
41
|
+
if self.PARAMS_FIELD not in self.json_dict:
|
42
|
+
raise GdsDictionaryParsingException(
|
43
|
+
f"Ground Dictionary missing '{self.PARAMS_FIELD}' field: {str(self.json_file)}"
|
44
|
+
)
|
45
|
+
|
46
|
+
for prm_dict in self.json_dict[self.PARAMS_FIELD]:
|
47
|
+
# Create a channel template object
|
48
|
+
prm_temp = self.construct_template_from_dict(prm_dict)
|
49
|
+
|
50
|
+
id_dict[prm_temp.get_id()] = prm_temp
|
51
|
+
fqn_name_dict[prm_temp.get_full_name()] = prm_temp
|
52
|
+
|
53
|
+
return (
|
54
|
+
dict(sorted(id_dict.items())),
|
55
|
+
dict(sorted(fqn_name_dict.items())),
|
56
|
+
self.get_versions(),
|
57
|
+
)
|
58
|
+
|
59
|
+
def construct_template_from_dict(self, prm_dict: dict) -> PrmTemplate:
|
60
|
+
try:
|
61
|
+
prm_id = prm_dict[self.ID]
|
62
|
+
# The below assignment also raises a ValueError if the name does not contain a '.'
|
63
|
+
qualified_component_name, prm_name = prm_dict[self.NAME].rsplit('.', 1)
|
64
|
+
if not qualified_component_name or not prm_name:
|
65
|
+
raise ValueError()
|
66
|
+
|
67
|
+
type_obj = self.parse_type(prm_dict[self.TYPE])
|
68
|
+
except ValueError as e:
|
69
|
+
raise GdsDictionaryParsingException(
|
70
|
+
f"Parameter dictionary entry malformed, expected name of the form '<QUAL_COMP_NAME>.<PRM_NAME>' in : {str(prm_dict)}"
|
71
|
+
)
|
72
|
+
except KeyError as e:
|
73
|
+
raise GdsDictionaryParsingException(
|
74
|
+
f"{str(e)} key missing from parameter dictionary entry or its associated type in the dictionary: {str(prm_dict)}"
|
75
|
+
)
|
76
|
+
|
77
|
+
prm_default_val = prm_dict.get(self.DEFAULT, None)
|
78
|
+
|
79
|
+
return PrmTemplate(
|
80
|
+
prm_id,
|
81
|
+
prm_name,
|
82
|
+
qualified_component_name,
|
83
|
+
type_obj,
|
84
|
+
prm_default_val
|
85
|
+
)
|
@@ -13,7 +13,7 @@ import sys
|
|
13
13
|
INITIALIZED = False
|
14
14
|
|
15
15
|
|
16
|
-
def configure_py_log(directory=None, filename=sys.argv[0], mirror_to_stdout=False):
|
16
|
+
def configure_py_log(directory=None, filename=sys.argv[0], mirror_to_stdout=False, log_level="INFO"):
|
17
17
|
"""
|
18
18
|
Configure the python logging. If logdir is supplied, our logs will go in that directory as a log file. Otherwise,
|
19
19
|
logs will go to the CLI.
|
@@ -40,6 +40,6 @@ def configure_py_log(directory=None, filename=sys.argv[0], mirror_to_stdout=Fals
|
|
40
40
|
for handler in handlers:
|
41
41
|
handler.setFormatter(formatter)
|
42
42
|
logging.getLogger().addHandler(handler)
|
43
|
-
logging.getLogger().setLevel(
|
43
|
+
logging.getLogger().setLevel(log_level)
|
44
44
|
logging.info("Logging system initialized!")
|
45
45
|
INITIALIZED = True
|
@@ -7,25 +7,22 @@ class called "Dictionaries".
|
|
7
7
|
@author mstarch
|
8
8
|
"""
|
9
9
|
|
10
|
-
import os
|
11
10
|
from pathlib import Path
|
12
11
|
|
13
|
-
import fprime_gds.common.loaders.ch_py_loader
|
14
|
-
import fprime_gds.common.loaders.ch_xml_loader
|
15
|
-
|
16
|
-
# Py Loaders
|
17
|
-
import fprime_gds.common.loaders.cmd_py_loader
|
18
12
|
|
19
13
|
# XML Loaders
|
14
|
+
import fprime_gds.common.loaders.ch_xml_loader
|
20
15
|
import fprime_gds.common.loaders.cmd_xml_loader
|
21
|
-
import fprime_gds.common.loaders.event_py_loader
|
22
16
|
import fprime_gds.common.loaders.event_xml_loader
|
17
|
+
import fprime_gds.common.loaders.fw_type_json_loader
|
18
|
+
import fprime_gds.common.loaders.pkt_json_loader
|
23
19
|
import fprime_gds.common.loaders.pkt_xml_loader
|
20
|
+
|
21
|
+
# JSON Loaders
|
24
22
|
import fprime_gds.common.loaders.ch_json_loader
|
25
23
|
import fprime_gds.common.loaders.cmd_json_loader
|
26
24
|
import fprime_gds.common.loaders.event_json_loader
|
27
25
|
|
28
|
-
|
29
26
|
class Dictionaries:
|
30
27
|
"""
|
31
28
|
Dictionaries class to encapsulate the many different dictionaries used in the system. This includes the following
|
@@ -49,9 +46,11 @@ class Dictionaries:
|
|
49
46
|
self._event_name_dict = None
|
50
47
|
self._channel_name_dict = None
|
51
48
|
self._packet_dict = None
|
49
|
+
self._fw_type_name_dict = None
|
52
50
|
self._versions = None
|
51
|
+
self._metadata = None
|
53
52
|
|
54
|
-
def load_dictionaries(self, dictionary, packet_spec):
|
53
|
+
def load_dictionaries(self, dictionary, packet_spec, packet_set_name):
|
55
54
|
"""
|
56
55
|
Loads the dictionaries based on the dictionary path supplied. Optional packet_spec is allowed to specify the
|
57
56
|
definitions of packets.
|
@@ -59,57 +58,44 @@ class Dictionaries:
|
|
59
58
|
:param dictionary: dictionary path used for loading dictionaries
|
60
59
|
:param packet_spec: specification for packets, or None, for packetized telemetry
|
61
60
|
"""
|
62
|
-
|
63
|
-
if os.path.isdir(dictionary):
|
64
|
-
# Events
|
65
|
-
event_loader = fprime_gds.common.loaders.event_py_loader.EventPyLoader()
|
66
|
-
self._event_id_dict = event_loader.get_id_dict(
|
67
|
-
os.path.join(dictionary, "events")
|
68
|
-
)
|
69
|
-
self._event_name_dict = event_loader.get_name_dict(
|
70
|
-
os.path.join(dictionary, "events")
|
71
|
-
)
|
72
|
-
# Commands
|
73
|
-
command_loader = fprime_gds.common.loaders.cmd_py_loader.CmdPyLoader()
|
74
|
-
self._command_id_dict = command_loader.get_id_dict(
|
75
|
-
os.path.join(dictionary, "commands")
|
76
|
-
)
|
77
|
-
self._command_name_dict = command_loader.get_name_dict(
|
78
|
-
os.path.join(dictionary, "commands")
|
79
|
-
)
|
80
|
-
# Channels
|
81
|
-
channel_loader = fprime_gds.common.loaders.ch_py_loader.ChPyLoader()
|
82
|
-
self._channel_id_dict = channel_loader.get_id_dict(
|
83
|
-
os.path.join(dictionary, "channels")
|
84
|
-
)
|
85
|
-
self._channel_name_dict = channel_loader.get_name_dict(
|
86
|
-
os.path.join(dictionary, "channels")
|
87
|
-
)
|
88
|
-
elif Path(dictionary).is_file() and ".json" in Path(dictionary).suffixes:
|
61
|
+
if Path(dictionary).is_file() and ".json" in Path(dictionary).suffixes:
|
89
62
|
# Events
|
90
63
|
json_event_loader = (
|
91
64
|
fprime_gds.common.loaders.event_json_loader.EventJsonLoader(dictionary)
|
92
65
|
)
|
93
66
|
self._event_name_dict = json_event_loader.get_name_dict(None)
|
94
67
|
self._event_id_dict = json_event_loader.get_id_dict(None)
|
95
|
-
self._versions = json_event_loader.get_versions()
|
96
68
|
# Commands
|
97
69
|
json_command_loader = (
|
98
70
|
fprime_gds.common.loaders.cmd_json_loader.CmdJsonLoader(dictionary)
|
99
71
|
)
|
100
72
|
self._command_name_dict = json_command_loader.get_name_dict(None)
|
101
73
|
self._command_id_dict = json_command_loader.get_id_dict(None)
|
102
|
-
assert (
|
103
|
-
self._versions == json_command_loader.get_versions()
|
104
|
-
), "Version mismatch while loading"
|
105
74
|
# Channels
|
106
75
|
json_channel_loader = fprime_gds.common.loaders.ch_json_loader.ChJsonLoader(
|
107
76
|
dictionary
|
108
77
|
)
|
109
78
|
self._channel_name_dict = json_channel_loader.get_name_dict(None)
|
110
79
|
self._channel_id_dict = json_channel_loader.get_id_dict(None)
|
80
|
+
# Fw Types
|
81
|
+
fw_types_loader = fprime_gds.common.loaders.fw_type_json_loader.FwTypeJsonLoader(
|
82
|
+
dictionary
|
83
|
+
)
|
84
|
+
self._fw_type_name_dict = fw_types_loader.get_name_dict(None)
|
85
|
+
# Metadata
|
86
|
+
self._versions = json_event_loader.get_versions()
|
87
|
+
self._metadata = json_event_loader.get_metadata().copy()
|
88
|
+
self._metadata["dictionary_type"] = "json"
|
89
|
+
# Each loaders should agree on metadata and versions
|
90
|
+
assert (
|
91
|
+
json_command_loader.get_metadata()
|
92
|
+
== json_channel_loader.get_metadata()
|
93
|
+
== json_event_loader.get_metadata()
|
94
|
+
), "Metadata mismatch while loading"
|
111
95
|
assert (
|
112
|
-
|
96
|
+
json_command_loader.get_versions()
|
97
|
+
== json_channel_loader.get_versions()
|
98
|
+
== json_event_loader.get_versions()
|
113
99
|
), "Version mismatch while loading"
|
114
100
|
# XML dictionaries
|
115
101
|
elif Path(dictionary).is_file():
|
@@ -132,6 +118,12 @@ class Dictionaries:
|
|
132
118
|
assert (
|
133
119
|
self._versions == channel_loader.get_versions()
|
134
120
|
), "Version mismatch while loading"
|
121
|
+
# versions are camelCase to match the metadata field of the JSON dictionaries
|
122
|
+
self._metadata = {
|
123
|
+
"frameworkVersion": self._versions[0],
|
124
|
+
"projectVersion": self._versions[1],
|
125
|
+
"dictionary_type": "xml",
|
126
|
+
}
|
135
127
|
else:
|
136
128
|
msg = f"[ERROR] Dictionary '{dictionary}' does not exist."
|
137
129
|
raise Exception(msg)
|
@@ -141,6 +133,20 @@ class Dictionaries:
|
|
141
133
|
self._packet_dict = packet_loader.get_id_dict(
|
142
134
|
packet_spec, self._channel_name_dict
|
143
135
|
)
|
136
|
+
# Otherwise use JSON dictionary to attempt automatic packet loading
|
137
|
+
elif self._metadata["dictionary_type"] == "json":
|
138
|
+
packet_loader = fprime_gds.common.loaders.pkt_json_loader.PktJsonLoader(dictionary)
|
139
|
+
if packet_set_name is None:
|
140
|
+
names = packet_loader.get_packet_set_names(None)
|
141
|
+
if len(names) == 0:
|
142
|
+
self._packet_dict = None
|
143
|
+
return
|
144
|
+
elif len(names) > 1:
|
145
|
+
raise Exception("[ERROR] Multiple packet sets, must set --packet-set-name")
|
146
|
+
packet_set_name = names[0]
|
147
|
+
self._packet_dict = packet_loader.get_id_dict(
|
148
|
+
None, packet_set_name, self._channel_name_dict
|
149
|
+
)
|
144
150
|
else:
|
145
151
|
self._packet_dict = None
|
146
152
|
|
@@ -173,6 +179,11 @@ class Dictionaries:
|
|
173
179
|
def channel_name(self):
|
174
180
|
"""Channel dictionary by name"""
|
175
181
|
return self._channel_name_dict
|
182
|
+
|
183
|
+
@property
|
184
|
+
def fw_type_name(self):
|
185
|
+
"""Fw type name dictionary by name"""
|
186
|
+
return self._fw_type_name_dict
|
176
187
|
|
177
188
|
@property
|
178
189
|
def project_version(self):
|
@@ -184,6 +195,14 @@ class Dictionaries:
|
|
184
195
|
"""Framework version in dictionary"""
|
185
196
|
return self._versions[0]
|
186
197
|
|
198
|
+
@property
|
199
|
+
def metadata(self):
|
200
|
+
"""Dictionary metadata.
|
201
|
+
|
202
|
+
Note: framework_version and project_version are also available as separate properties
|
203
|
+
for legacy reasons. New code should use the metadata property."""
|
204
|
+
return self._metadata
|
205
|
+
|
187
206
|
@property
|
188
207
|
def packet(self):
|
189
208
|
"""Packet dictionary"""
|
@@ -6,6 +6,7 @@ and decoding into a single component that the be composed into the standard pipe
|
|
6
6
|
|
7
7
|
@mstarch
|
8
8
|
"""
|
9
|
+
|
9
10
|
import fprime_gds.common.decoders.ch_decoder
|
10
11
|
import fprime_gds.common.decoders.event_decoder
|
11
12
|
import fprime_gds.common.decoders.file_decoder
|
@@ -130,6 +131,24 @@ class EncodingDecoding:
|
|
130
131
|
"""
|
131
132
|
return self.channel_decoder.deregister(consumer)
|
132
133
|
|
134
|
+
def register_file_consumer(self, consumer):
|
135
|
+
"""
|
136
|
+
Registers a consumer with the file decoder.
|
137
|
+
|
138
|
+
:param consumer: consumer of file packets
|
139
|
+
"""
|
140
|
+
self.file_decoder.register(consumer)
|
141
|
+
|
142
|
+
def remove_file_consumer(self, consumer):
|
143
|
+
"""
|
144
|
+
Removes a consumer from the file decoder. Will raise an error if the history was not
|
145
|
+
previously registered.
|
146
|
+
|
147
|
+
:param consumer: consumer of channels
|
148
|
+
:return: a boolean indicating if the consumer was removed.
|
149
|
+
"""
|
150
|
+
return self.file_decoder.deregister(consumer)
|
151
|
+
|
133
152
|
def register_command_consumer(self, consumer):
|
134
153
|
"""
|
135
154
|
Registers a history with the standard pipeline.
|
@@ -6,6 +6,7 @@ to compose in this code.
|
|
6
6
|
|
7
7
|
@author mstarch
|
8
8
|
"""
|
9
|
+
|
9
10
|
from typing import Type
|
10
11
|
|
11
12
|
from fprime_gds.common.history.history import History
|
@@ -37,6 +38,9 @@ class Histories:
|
|
37
38
|
:param coders: coders object to register histories with
|
38
39
|
"""
|
39
40
|
self.coders = coders
|
41
|
+
# Allow implementation type to disable histories
|
42
|
+
if self._implementation_type is None:
|
43
|
+
return
|
40
44
|
# Create histories, RAM histories for now
|
41
45
|
self.commands = self._implementation_type()
|
42
46
|
self.events = self._implementation_type()
|
@@ -8,6 +8,7 @@ below.
|
|
8
8
|
|
9
9
|
:author: lestarch
|
10
10
|
"""
|
11
|
+
|
11
12
|
import datetime
|
12
13
|
import os.path
|
13
14
|
from pathlib import Path
|
@@ -19,6 +20,7 @@ import fprime_gds.common.data_types.cmd_data
|
|
19
20
|
import fprime_gds.common.distributor.distributor
|
20
21
|
import fprime_gds.common.logger.data_logger
|
21
22
|
from fprime_gds.common.transport import RoutingTag, ThreadedTCPSocketClient
|
23
|
+
from fprime_gds.common.utils.config_manager import ConfigManager
|
22
24
|
|
23
25
|
# Local imports for the sake of composition
|
24
26
|
from . import dictionaries, encoding, files, histories
|
@@ -54,7 +56,13 @@ class StandardPipeline:
|
|
54
56
|
self.__transport_type = ThreadedTCPSocketClient
|
55
57
|
|
56
58
|
def setup(
|
57
|
-
self,
|
59
|
+
self,
|
60
|
+
config: ConfigManager,
|
61
|
+
dictionary,
|
62
|
+
file_store,
|
63
|
+
logging_prefix=None,
|
64
|
+
packet_spec=None,
|
65
|
+
packet_set_name=None,
|
58
66
|
):
|
59
67
|
"""
|
60
68
|
Setup the standard pipeline for moving data from the middleware layer through the GDS layers using the standard
|
@@ -84,7 +92,13 @@ class StandardPipeline:
|
|
84
92
|
self.distributor = fprime_gds.common.distributor.distributor.Distributor(config)
|
85
93
|
self.client_socket = self.__transport_type()
|
86
94
|
# Setup dictionaries encoders and decoders
|
87
|
-
self.dictionaries.load_dictionaries(
|
95
|
+
self.dictionaries.load_dictionaries(
|
96
|
+
self.dictionary_path, packet_spec, packet_set_name
|
97
|
+
)
|
98
|
+
# Update config to use Fw types defined in the JSON dictionary
|
99
|
+
if self.dictionaries.fw_type_name:
|
100
|
+
for fw_type_name, fw_type in self.dictionaries.fw_type_name.items():
|
101
|
+
config.set("types", fw_type_name, fw_type)
|
88
102
|
self.coders.setup_coders(
|
89
103
|
self.dictionaries, self.distributor, self.client_socket, config
|
90
104
|
)
|
@@ -175,3 +175,11 @@ class CmdTemplate(data_template.DataTemplate):
|
|
175
175
|
|
176
176
|
def getArgs(self):
|
177
177
|
return self.get_args()
|
178
|
+
|
179
|
+
def __repr__(self):
|
180
|
+
arg_strs = []
|
181
|
+
for arg in self.arguments:
|
182
|
+
arg_strs.append(arg[0] + ": " + str(arg[2]))
|
183
|
+
|
184
|
+
args_str = ", ".join(arg_strs)
|
185
|
+
return f"CmdTemplate({self.comp_name}.{self.mnemonic}, args: ({args_str}))"
|
@@ -0,0 +1,81 @@
|
|
1
|
+
"""
|
2
|
+
@brief Params Template class
|
3
|
+
|
4
|
+
Instances of this class describe a parameter of a component instance (not
|
5
|
+
including a specific value)
|
6
|
+
|
7
|
+
@date Created January 27, 2025
|
8
|
+
@author Zimri Leisher
|
9
|
+
|
10
|
+
@bug Hopefully none
|
11
|
+
"""
|
12
|
+
|
13
|
+
from fprime.common.models.serialize.type_base import BaseType
|
14
|
+
from fprime.common.models.serialize.type_exceptions import TypeMismatchException
|
15
|
+
|
16
|
+
from . import data_template
|
17
|
+
|
18
|
+
|
19
|
+
class PrmTemplate(data_template.DataTemplate):
|
20
|
+
"""Class for param templates that describe parameters of component instances"""
|
21
|
+
|
22
|
+
def __init__(
|
23
|
+
self,
|
24
|
+
prm_id: int,
|
25
|
+
prm_name: str,
|
26
|
+
comp_name: str,
|
27
|
+
prm_type_obj: BaseType,
|
28
|
+
prm_default_val,
|
29
|
+
):
|
30
|
+
"""
|
31
|
+
Constructor
|
32
|
+
|
33
|
+
Args:
|
34
|
+
prm_id: the id of the parameter
|
35
|
+
prm_name: the name of the parameter
|
36
|
+
comp_name: the name of the component instance owning this parameter
|
37
|
+
prm_type_obj: the instance of BaseType corresponding to the type of this parameter
|
38
|
+
prm_default_val: the default value of this parameter, in raw JSON form
|
39
|
+
"""
|
40
|
+
super().__init__()
|
41
|
+
# Make sure correct types are passed
|
42
|
+
if not isinstance(prm_id, int):
|
43
|
+
raise TypeMismatchException(int, type(prm_id))
|
44
|
+
|
45
|
+
if not isinstance(prm_name, str):
|
46
|
+
raise TypeMismatchException(str, type(prm_name))
|
47
|
+
|
48
|
+
if not isinstance(comp_name, str):
|
49
|
+
raise TypeMismatchException(str, type(comp_name))
|
50
|
+
|
51
|
+
if not issubclass(prm_type_obj, BaseType):
|
52
|
+
raise TypeMismatchException(BaseType, prm_type_obj)
|
53
|
+
|
54
|
+
# prm_default_val is an arbitrary type, likely a primitive or dict
|
55
|
+
|
56
|
+
self.prm_id = prm_id
|
57
|
+
self.prm_name = prm_name
|
58
|
+
self.comp_name = comp_name
|
59
|
+
self.prm_type_obj = prm_type_obj
|
60
|
+
self.prm_default_val = prm_default_val
|
61
|
+
|
62
|
+
def get_full_name(self):
|
63
|
+
"""
|
64
|
+
Get the full name of this param
|
65
|
+
|
66
|
+
Returns:
|
67
|
+
The full name (component.param) for this param
|
68
|
+
"""
|
69
|
+
return f"{self.comp_name}.{self.prm_name}"
|
70
|
+
|
71
|
+
def get_id(self):
|
72
|
+
return self.prm_id
|
73
|
+
|
74
|
+
def get_name(self):
|
75
|
+
return self.prm_name
|
76
|
+
|
77
|
+
def get_comp_name(self):
|
78
|
+
return self.comp_name
|
79
|
+
|
80
|
+
def get_type_obj(self):
|
81
|
+
return self.prm_type_obj
|
@@ -9,6 +9,9 @@ telemetry and dictionaries.
|
|
9
9
|
"""
|
10
10
|
import signal
|
11
11
|
import time
|
12
|
+
from pathlib import Path
|
13
|
+
import shutil
|
14
|
+
import json
|
12
15
|
|
13
16
|
from fprime.common.models.serialize.time_type import TimeType
|
14
17
|
|
@@ -28,15 +31,17 @@ class IntegrationTestAPI(DataHandler):
|
|
28
31
|
|
29
32
|
NOW = "NOW"
|
30
33
|
|
31
|
-
def __init__(self, pipeline, logpath=None, fsw_order=True):
|
34
|
+
def __init__(self, pipeline, deployment_config=None, logpath=None, fsw_order=True):
|
32
35
|
"""
|
33
36
|
Initializes API: constructs and registers test histories.
|
34
37
|
Args:
|
35
38
|
pipeline: a pipeline object providing access to basic GDS functionality
|
39
|
+
deployment_config: path to deployment configuration file
|
36
40
|
logpath: an optional output destination for the api test log
|
37
41
|
fsw_order: a flag to determine whether the API histories will maintain FSW time order.
|
38
42
|
"""
|
39
43
|
self.pipeline = pipeline
|
44
|
+
self.deployment_config = deployment_config
|
40
45
|
|
41
46
|
# these are owned by the GDS and will not be modified by the test API.
|
42
47
|
self.aggregate_command_history = pipeline.histories.commands
|
@@ -63,6 +68,15 @@ class IntegrationTestAPI(DataHandler):
|
|
63
68
|
# Initialize the logger
|
64
69
|
self.logger = TestLogger(logpath) if logpath is not None else None
|
65
70
|
|
71
|
+
# Copy dictionaries and binary file to output directory
|
72
|
+
if logpath is not None:
|
73
|
+
base_dir = Path(self.pipeline.dictionary_path).parents[1]
|
74
|
+
for subdir in ['bin', 'dict']:
|
75
|
+
dir_path = base_dir / subdir
|
76
|
+
if dir_path.is_dir():
|
77
|
+
shutil.copytree(dir_path, Path(logpath) / subdir,
|
78
|
+
dirs_exist_ok=True)
|
79
|
+
|
66
80
|
# A predicate used as a filter to choose which events to log automatically
|
67
81
|
self.event_log_filter = self.get_event_pred()
|
68
82
|
|
@@ -215,6 +229,139 @@ class IntegrationTestAPI(DataHandler):
|
|
215
229
|
"""
|
216
230
|
self.event_log_filter = self.get_event_pred(event, args, severity, time_pred)
|
217
231
|
|
232
|
+
def get_deployment(self):
|
233
|
+
"""
|
234
|
+
Get the deployment of the target using the loaded FSW dictionary.
|
235
|
+
|
236
|
+
Returns:
|
237
|
+
The name of the deployment (str) or None if not found
|
238
|
+
"""
|
239
|
+
dictionary = str(self.pipeline.dictionary_path)
|
240
|
+
|
241
|
+
try:
|
242
|
+
with open(dictionary, 'r') as file:
|
243
|
+
data = json.load(file)
|
244
|
+
return data['metadata'].get("deploymentName")
|
245
|
+
except FileNotFoundError:
|
246
|
+
msg = f"Error: File not found at path: {dictionary}"
|
247
|
+
self.__log(msg, TestLogger.YELLOW)
|
248
|
+
return None
|
249
|
+
except json.JSONDecodeError as e:
|
250
|
+
msg = f"Error decoding JSON: {e}"
|
251
|
+
self.__log(msg, TestLogger.YELLOW)
|
252
|
+
return None
|
253
|
+
except Exception as e:
|
254
|
+
msg = f"An unexpected error occurred: {e} is an unknown key"
|
255
|
+
self.__log(msg, TestLogger.YELLOW)
|
256
|
+
return None
|
257
|
+
|
258
|
+
def wait_for_dataflow(self, count=1, channels=None, start=None, timeout=120):
|
259
|
+
"""
|
260
|
+
Wait for data flow by checking for any telemetry updates within a specified timeout.
|
261
|
+
|
262
|
+
Args:
|
263
|
+
count: either an exact amount (int) or a predicate to specify how many objects to find
|
264
|
+
channels: a channel specifier or list of channel specifiers (mnemonic, ID, or predicate). All will count if None
|
265
|
+
start: an optional index or predicate to specify the earliest item to search
|
266
|
+
timeout: the number of seconds to wait before terminating the search (int)
|
267
|
+
"""
|
268
|
+
if start is None:
|
269
|
+
start = self.get_latest_time()
|
270
|
+
|
271
|
+
history = self.get_telemetry_subhistory()
|
272
|
+
result = self.await_telemetry_count(
|
273
|
+
count, channels=channels, history=history, start=start, timeout=timeout
|
274
|
+
)
|
275
|
+
if not result:
|
276
|
+
msg = f'Failed to detect any data flow for {timeout} s.'
|
277
|
+
self.__log(msg, TestLogger.RED)
|
278
|
+
assert False, msg
|
279
|
+
self.remove_telemetry_subhistory(history)
|
280
|
+
|
281
|
+
def get_config_file_path(self):
|
282
|
+
"""
|
283
|
+
Accessor for IntegrationTestAPI's deployment configuration file.
|
284
|
+
|
285
|
+
Returns:
|
286
|
+
path to user-specified deployment configuration file (str) or None if not defined
|
287
|
+
"""
|
288
|
+
if self.deployment_config:
|
289
|
+
return self.deployment_config
|
290
|
+
else:
|
291
|
+
return None
|
292
|
+
|
293
|
+
def load_config_file(self):
|
294
|
+
"""
|
295
|
+
Load user-specified deployment configuration JSON file.
|
296
|
+
|
297
|
+
Returns:
|
298
|
+
JSON object as a dictionary
|
299
|
+
"""
|
300
|
+
config_file = self.get_config_file_path()
|
301
|
+
|
302
|
+
try:
|
303
|
+
with open(config_file, 'r') as file:
|
304
|
+
result = json.load(file)
|
305
|
+
return result
|
306
|
+
except FileNotFoundError:
|
307
|
+
msg = f"Error: File not found at path {config_file}"
|
308
|
+
self.__log(msg, TestLogger.RED)
|
309
|
+
assert False, msg
|
310
|
+
except json.JSONDecodeError as e:
|
311
|
+
msg = f"Error decoding JSON: {e}"
|
312
|
+
self.__log(msg, TestLogger.RED)
|
313
|
+
assert False, msg
|
314
|
+
except Exception as e:
|
315
|
+
msg = f"An unexpected error occurred: {e}"
|
316
|
+
self.__log(msg, TestLogger.RED)
|
317
|
+
assert False, msg
|
318
|
+
|
319
|
+
def get_mnemonic(self, comp=None, name=None):
|
320
|
+
"""
|
321
|
+
Get deployment mnemonic of specified item from user-specified deployment
|
322
|
+
configuration file.
|
323
|
+
|
324
|
+
Args:
|
325
|
+
comp: qualified name of the component instance (str), i.e. "<component>.<instance>"
|
326
|
+
name: command, channel, or event name (str) [optional]
|
327
|
+
Returns:
|
328
|
+
deployment mnemonic of specified item (str) or native mnemonic (str) if not found
|
329
|
+
"""
|
330
|
+
data = self.load_config_file()
|
331
|
+
|
332
|
+
if data:
|
333
|
+
try:
|
334
|
+
mnemonic = data[comp]
|
335
|
+
return f"{mnemonic}.{name}" if name else f"{mnemonic}"
|
336
|
+
except KeyError:
|
337
|
+
self.__log(f"Error: {comp} not found", TestLogger.YELLOW)
|
338
|
+
return f"{comp}.{name}" if name else f"{comp}"
|
339
|
+
else:
|
340
|
+
return f"{comp}.{name}" if name else f"{comp}"
|
341
|
+
|
342
|
+
def get_prm_db_path(self) -> str:
|
343
|
+
"""
|
344
|
+
Get file path to parameter db from user-specified deployment configuration file.
|
345
|
+
|
346
|
+
Returns:
|
347
|
+
file path to parameter db (str) or None if not found
|
348
|
+
"""
|
349
|
+
data = self.load_config_file()
|
350
|
+
|
351
|
+
if data:
|
352
|
+
try:
|
353
|
+
filepath = data["Svc.PrmDb.filename"]
|
354
|
+
if filepath.startswith('/'):
|
355
|
+
return filepath
|
356
|
+
else:
|
357
|
+
msg = f"Error: {filepath} did not start with a forward slash"
|
358
|
+
self.__log(msg, TestLogger.RED)
|
359
|
+
assert False, msg
|
360
|
+
except KeyError:
|
361
|
+
return None
|
362
|
+
else:
|
363
|
+
return None
|
364
|
+
|
218
365
|
######################################################################################
|
219
366
|
# History Functions
|
220
367
|
######################################################################################
|