rccn-gen 1.2.0__py3-none-any.whl → 1.3.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.
rccn_gen/utils.py CHANGED
@@ -98,6 +98,8 @@ def engineering_bit_number(raw_bit_number):
98
98
  while 2**power < raw_bit_number:
99
99
  power += 1
100
100
  bit_number = 2**power
101
+ if bit_number < 8:
102
+ bit_number = 8
101
103
  return (bit_number)
102
104
 
103
105
  def get_data_type(parent_classes):
@@ -190,6 +192,24 @@ def rust_type_definition(pymdb_data_instance, parent_name="MyStruct"):
190
192
  definition_text[1] += insert
191
193
  definition_text[1] += "}\n\n"
192
194
  definition_text[1] += append
195
+
196
+ elif data_type == 'FloatDataType':
197
+ if pymdb_data_instance.encoding is None or pymdb_data_instance.encoding.bits is None:
198
+ raw_bit_number = 32
199
+ print("RCCN-Warning: No encoding for "+base_type+" "+pymdb_data_instance.name+" found. Using 32 as default for raw bit number.")
200
+ else:
201
+ raw_bit_number = pymdb_data_instance.encoding.bits
202
+ raw_bit_number_str = str(raw_bit_number)
203
+ if raw_bit_number == 32:
204
+ eng_bit_number = 32
205
+ elif raw_bit_number == 64:
206
+ eng_bit_number = 64
207
+ else:
208
+ print("RCCN-Warning: Given raw bit number for "+base_type+" \'"+pymdb_data_instance.name+"\' is not equal to 32 or 64. A engineering bit number of 64 will be used.")
209
+ eng_bit_number = 64
210
+ eng_bit_number_str = str(eng_bit_number)
211
+ definition_text[0] += "\t#[bits("+raw_bit_number_str+")]\n"
212
+ definition_text[0] += ("\tpub "+sc_instance_name+": f"+eng_bit_number_str+",\n")
193
213
  else:
194
214
  definition_text = ["\t// Please implement datatype "+data_type+" here.\n", ""]
195
215
  return definition_text
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rccn_gen
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Summary: A python based generator for RACCOON OS source files in Rust from yamcs-pymdb config files.
5
5
  Project-URL: Homepage, https://gitlab.com/rccn/pymdb_code_generation
6
6
  Project-URL: Issues, https://gitlab.com/rccn/pymdb_code_generation/issues
@@ -29,10 +29,11 @@ To see whats new, see the [CHANGELOG](CHANGELOG.md).
29
29
  ## Using the Generator
30
30
  The generator is based on [`pymdb`](https://github.com/yamcs/pymdb) and uses the same structure. Where `pymdb` gives the user freedom in defining systems, subsystems and their respective relations, the definitions for rust code generation is more restricted. For the rust generation, the user is bound to the following classes:
31
31
  - `Application`,
32
- - `Service`, and
33
- - `RCCNCommand`.
32
+ - `Service`,
33
+ - `RCCNCommand`, and
34
+ - `RCCNContainer`.
34
35
 
35
- All classes inherit from pymdb's Subsystem class and extend their functionality. This means that an existing pymdb definition can be used to generate rust code by renaming the respective instances. No functionality for pymdb's XTCE generation will be lost.
36
+ The Application and Service classes inherit from pymdb's Subsystem class and extend their functionality. The RCCNCommand extends the Command class and the RCCNContainer extends the Container class of pymdb. This means that an existing pymdb definition can be used to generate rust code by renaming the respective instances. No functionality for pymdb's XTCE generation will be lost.
36
37
 
37
38
  A root system may be defined for the satellite.
38
39
  ```python
@@ -44,7 +45,7 @@ An application can be defined with the following statement.
44
45
  ```python
45
46
  app = Application(system=root_system, name="ExampleApp", apid=42)
46
47
  ```
47
- It has the obligatory arguments **system**, **name**, **apid** and **export_directory**. After all Applications, Services and RCCNCommands are defined, the rust code generator can be called on the application with `app.generate_rccn_code(export_directory='.')`.
48
+ It has the obligatory arguments **system**, **name** and **apid**. After all Applications, Services and RCCNCommands are defined, the rust code generator can be called on the application with `app.generate_rccn_code(export_directory='.')`.
48
49
 
49
50
  ### Service
50
51
 
@@ -81,7 +82,7 @@ my_command = RCCNCommand(
81
82
  service.add_command(my_command)
82
83
  ```
83
84
 
84
- The only obligatory arguments are **name** and a **subtype assignment**, like shown in the example. The connection to a service can also be achieved with base commands, where every base command must be unique to a service. For example:
85
+ The only obligatory argument is **name**. If the subtype assignment is not given, a value will be chosen automatically. The connection to a service can also be achieved with base commands, where every base command must be unique to a service. For example:
85
86
 
86
87
  ```python
87
88
  base_cmd = RCCNCommand(
@@ -98,6 +99,34 @@ my_command = RCCNCommand(
98
99
  )
99
100
  ```
100
101
 
102
+ ### RCCNContainer
103
+ A container to hold telemetry information can be created with:
104
+ ```python
105
+ my_container = RCCNContainer(
106
+ system=service,
107
+ name='BatteryInformation',
108
+ short_description='This container holds information on battery voltage and current'
109
+ )
110
+ my_container.add_integer_parameter_entry(
111
+ name='BatteryNumber',
112
+ minimum=1,
113
+ maximum=4,
114
+ encoding=IntegerEncoding(bits=3),
115
+ short_description='Number of the battery'
116
+ )
117
+ my_container.add_float_parameter_entry(
118
+ name='Current',
119
+ units='Ampere',
120
+ encoding=FloatEncoding(bits=32),
121
+ short_description='Electric current of the battery.'
122
+ )
123
+ my_container.add_float_parameter_entry(
124
+ name='Voltage',
125
+ units='Volts',
126
+ encoding=FloatEncoding(bits=32),
127
+ short_description='Electric voltage of the battery.'
128
+ )
129
+ ```
101
130
  ## Output
102
131
  From the python configuration, the `main.rs`, `service.rs`, `command.rs`, `mod.rs`, `Cargo.toml` and `telemetry.rs` files are generated and are structured accordingly:
103
132
  - rccn_usr_example_app/
@@ -1,7 +1,7 @@
1
1
  rccn_gen/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
2
2
  rccn_gen/__init__.py,sha256=rBnqIw3uQk-uBbRh9VnungoTRSr2V0Bqos32xFZ44Eo,168
3
- rccn_gen/systems.py,sha256=vGsCyVkwrsFgYqHDL_bPPv8FuX3pIHYUwfIRB5YUWrY,37414
4
- rccn_gen/utils.py,sha256=VKnTC2hrgMyLdneksAifnqEgXO27zLQJ9x5igaF35rE,8269
3
+ rccn_gen/systems.py,sha256=NewVHJVITt3svMBkAigD23Wl3_-srjNBbiMsOqUstg4,83907
4
+ rccn_gen/utils.py,sha256=qcAYBjQ_-YfUQY4QtcRX9ebHoTVXyy7xWb57vpKO6vQ,9314
5
5
  rccn_gen/text_modules/cargo_toml/cargo.txt,sha256=AYjSo3WJE7lhOcJaiNgXP9Y-DXHDIFIt6p42rDTVNVE,427
6
6
  rccn_gen/text_modules/command/command.txt,sha256=8Y-uJilhFLoinftIbn7uKfia9LLMZno2LkoDJ-4Y-9M,345
7
7
  rccn_gen/text_modules/command/command_module_enum.txt,sha256=35sBlAV_CzQw95Uf2dNynrYOxVD2tT2XWfEvS4Zx_KY,121
@@ -14,6 +14,6 @@ rccn_gen/text_modules/mod/mod.txt,sha256=BF8LablBE4ddutdl5m0prvpvLdBRejueVOujkyr
14
14
  rccn_gen/text_modules/service/command_module_match_cmd.txt,sha256=eVGo6ltuerG37rVxpXtL-JYuLyLW4c0i6NXb5g1_U-A,89
15
15
  rccn_gen/text_modules/service/service.txt,sha256=qTxoOD5i7wH4yFiDn13rOJW9hIZyACA8W3m6UABe22U,695
16
16
  rccn_gen/text_modules/telemetry/telemetry.txt,sha256=Re1d3BfpyXT_CEe7jJzLF3MARik0-J-K98K85iPOE40,193
17
- rccn_gen-1.2.0.dist-info/METADATA,sha256=h-4mJGYkmnAxOFD5Pn4ART7ml2VjQPrVdENO2eIVj7s,8967
18
- rccn_gen-1.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
19
- rccn_gen-1.2.0.dist-info/RECORD,,
17
+ rccn_gen-1.3.0.dist-info/METADATA,sha256=EOwcq4lhWocClSHmjO0M12G--1sPtJPfpVHY6ahdPsw,9911
18
+ rccn_gen-1.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
19
+ rccn_gen-1.3.0.dist-info/RECORD,,