powertrain-build 1.13.1__py3-none-any.whl → 1.13.3.dev3__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.
Files changed (132) hide show
  1. powertrain_build/__init__.py +40 -40
  2. powertrain_build/__main__.py +6 -6
  3. powertrain_build/a2l.py +582 -582
  4. powertrain_build/a2l_merge.py +650 -650
  5. powertrain_build/a2l_templates.py +717 -717
  6. powertrain_build/build.py +985 -985
  7. powertrain_build/build_defs.py +309 -309
  8. powertrain_build/build_proj_config.py +690 -690
  9. powertrain_build/check_interface.py +575 -575
  10. powertrain_build/cli.py +141 -141
  11. powertrain_build/config.py +542 -542
  12. powertrain_build/core.py +395 -395
  13. powertrain_build/core_dummy.py +343 -343
  14. powertrain_build/create_conversion_table.py +73 -73
  15. powertrain_build/dids.py +916 -916
  16. powertrain_build/dummy.py +157 -157
  17. powertrain_build/dummy_spm.py +252 -252
  18. powertrain_build/environmentcheck.py +52 -52
  19. powertrain_build/ext_dbg.py +255 -255
  20. powertrain_build/ext_var.py +327 -327
  21. powertrain_build/feature_configs.py +301 -301
  22. powertrain_build/gen_allsysteminfo.py +227 -227
  23. powertrain_build/gen_label_split.py +449 -449
  24. powertrain_build/handcode_replacer.py +124 -124
  25. powertrain_build/html_report.py +133 -133
  26. powertrain_build/interface/__init__.py +4 -4
  27. powertrain_build/interface/application.py +511 -511
  28. powertrain_build/interface/base.py +500 -500
  29. powertrain_build/interface/csp_api.py +490 -490
  30. powertrain_build/interface/device_proxy.py +677 -677
  31. powertrain_build/interface/ems.py +67 -67
  32. powertrain_build/interface/export_global_vars.py +121 -121
  33. powertrain_build/interface/generate_adapters.py +132 -132
  34. powertrain_build/interface/generate_hi_interface.py +87 -87
  35. powertrain_build/interface/generate_service.py +69 -69
  36. powertrain_build/interface/generate_wrappers.py +147 -147
  37. powertrain_build/interface/generation_utils.py +142 -142
  38. powertrain_build/interface/hal.py +194 -194
  39. powertrain_build/interface/model_yaml_verification.py +348 -348
  40. powertrain_build/interface/service.py +296 -296
  41. powertrain_build/interface/simulink.py +249 -249
  42. powertrain_build/interface/update_call_sources.py +180 -180
  43. powertrain_build/interface/update_model_yaml.py +186 -186
  44. powertrain_build/interface/zone_controller.py +362 -362
  45. powertrain_build/lib/__init__.py +4 -4
  46. powertrain_build/lib/helper_functions.py +127 -127
  47. powertrain_build/lib/logger.py +55 -55
  48. powertrain_build/matlab_scripts/CodeGen/BuildAutomationPyBuild.m +78 -78
  49. powertrain_build/matlab_scripts/CodeGen/Generate_A2L.m +154 -154
  50. powertrain_build/matlab_scripts/CodeGen/generateTLUnit.m +239 -239
  51. powertrain_build/matlab_scripts/CodeGen/getAsilClassification.m +28 -28
  52. powertrain_build/matlab_scripts/CodeGen/modelConfiguredForTL.m +28 -28
  53. powertrain_build/matlab_scripts/CodeGen/moveDefOutports.m +88 -88
  54. powertrain_build/matlab_scripts/CodeGen/parseCalMeasData.m +410 -410
  55. powertrain_build/matlab_scripts/CodeGen/parseCoreIdentifiers.m +139 -139
  56. powertrain_build/matlab_scripts/CodeGen/parseDIDs.m +141 -141
  57. powertrain_build/matlab_scripts/CodeGen/parseInPorts.m +106 -106
  58. powertrain_build/matlab_scripts/CodeGen/parseIncludeConfigs.m +25 -25
  59. powertrain_build/matlab_scripts/CodeGen/parseModelInfo.m +38 -38
  60. powertrain_build/matlab_scripts/CodeGen/parseNVM.m +81 -81
  61. powertrain_build/matlab_scripts/CodeGen/parseOutPorts.m +120 -120
  62. powertrain_build/matlab_scripts/CodeGen/parsePreProcBlks.m +23 -23
  63. powertrain_build/matlab_scripts/CodeGen/struct2JSON.m +128 -128
  64. powertrain_build/matlab_scripts/CodeGen/updateCodeSwConfig.m +31 -31
  65. powertrain_build/matlab_scripts/Init_PyBuild.m +91 -91
  66. powertrain_build/matlab_scripts/__init__.py +2 -2
  67. powertrain_build/matlab_scripts/helperFunctions/Get_Full_Name.m +46 -46
  68. powertrain_build/matlab_scripts/helperFunctions/Get_SrcLines.m +12 -12
  69. powertrain_build/matlab_scripts/helperFunctions/Init_Models.m +78 -78
  70. powertrain_build/matlab_scripts/helperFunctions/Init_Projects.m +67 -67
  71. powertrain_build/matlab_scripts/helperFunctions/Read_Units.m +34 -34
  72. powertrain_build/matlab_scripts/helperFunctions/SetProjectTimeSamples.m +26 -26
  73. powertrain_build/matlab_scripts/helperFunctions/Strip_Suffix.m +16 -16
  74. powertrain_build/matlab_scripts/helperFunctions/followLink.m +118 -118
  75. powertrain_build/matlab_scripts/helperFunctions/getCodeSwitches.m +50 -50
  76. powertrain_build/matlab_scripts/helperFunctions/getConsumerBlocks.m +30 -30
  77. powertrain_build/matlab_scripts/helperFunctions/getDefBlock.m +39 -39
  78. powertrain_build/matlab_scripts/helperFunctions/getDefOutport.m +58 -58
  79. powertrain_build/matlab_scripts/helperFunctions/getDstBlocks.m +19 -19
  80. powertrain_build/matlab_scripts/helperFunctions/getDstLines.m +13 -13
  81. powertrain_build/matlab_scripts/helperFunctions/getInterfaceSignals.m +37 -37
  82. powertrain_build/matlab_scripts/helperFunctions/getName.m +37 -37
  83. powertrain_build/matlab_scripts/helperFunctions/getPath.m +6 -6
  84. powertrain_build/matlab_scripts/helperFunctions/getProperValue.m +21 -21
  85. powertrain_build/matlab_scripts/helperFunctions/getSrcBlocks.m +19 -19
  86. powertrain_build/matlab_scripts/helperFunctions/getSrcLines.m +13 -13
  87. powertrain_build/matlab_scripts/helperFunctions/loadLibraries.m +10 -10
  88. powertrain_build/matlab_scripts/helperFunctions/loadjson.m +6 -6
  89. powertrain_build/matlab_scripts/helperFunctions/modifyEnumStructField.m +21 -21
  90. powertrain_build/matlab_scripts/helperFunctions/removeConfigDuplicates.m +31 -31
  91. powertrain_build/matlab_scripts/helperFunctions/sortSystemByClass.m +26 -26
  92. powertrain_build/matlab_scripts/helperFunctions/tl_getfast.m +89 -89
  93. powertrain_build/matlab_scripts/helperFunctions/topLevelSystem.m +20 -20
  94. powertrain_build/matlab_scripts/helperFunctions/updateModels.m +131 -131
  95. powertrain_build/memory_section.py +224 -224
  96. powertrain_build/nvm_def.py +729 -729
  97. powertrain_build/problem_logger.py +86 -86
  98. powertrain_build/pt_matlab.py +430 -430
  99. powertrain_build/pt_win32.py +144 -144
  100. powertrain_build/replace_compu_tab_ref.py +105 -105
  101. powertrain_build/rte_dummy.py +254 -254
  102. powertrain_build/sched_funcs.py +209 -207
  103. powertrain_build/signal.py +7 -7
  104. powertrain_build/signal_if_html_rep.py +221 -221
  105. powertrain_build/signal_if_html_rep_all.py +302 -302
  106. powertrain_build/signal_incons_html_rep.py +180 -180
  107. powertrain_build/signal_incons_html_rep_all.py +366 -366
  108. powertrain_build/signal_incons_html_rep_base.py +168 -168
  109. powertrain_build/signal_inconsistency_check.py +641 -641
  110. powertrain_build/signal_interfaces.py +864 -864
  111. powertrain_build/templates/Index_SigCheck_All.html +22 -22
  112. powertrain_build/templates/Index_SigIf_All.html +19 -19
  113. powertrain_build/types.py +218 -218
  114. powertrain_build/unit_configs.py +419 -419
  115. powertrain_build/user_defined_types.py +660 -660
  116. powertrain_build/versioncheck.py +66 -66
  117. powertrain_build/wrapper.py +512 -512
  118. powertrain_build/xlrd_csv.py +87 -87
  119. powertrain_build/zone_controller/__init__.py +4 -4
  120. powertrain_build/zone_controller/calibration.py +176 -176
  121. powertrain_build/zone_controller/composition_yaml.py +880 -878
  122. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/METADATA +100 -100
  123. powertrain_build-1.13.3.dev3.dist-info/RECORD +130 -0
  124. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/WHEEL +1 -1
  125. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/licenses/LICENSE +202 -202
  126. powertrain_build-1.13.3.dev3.dist-info/pbr.json +1 -0
  127. powertrain_build-1.13.1.dist-info/RECORD +0 -130
  128. powertrain_build-1.13.1.dist-info/pbr.json +0 -1
  129. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/entry_points.txt +0 -0
  130. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/licenses/AUTHORS +0 -0
  131. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/licenses/NOTICE +0 -0
  132. {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/top_level.txt +0 -0
@@ -1,23 +1,23 @@
1
- <!DOCTYPE html>
2
- <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
3
- <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
4
-
5
- <body class="wy-body-for-nav">
6
-
7
- <a class="icon icon-home"> Signal Consistency Report
8
- </a>
9
- <ul>
10
- <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_intro.html">Introduction</a></li>
11
- <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_GEP3_BEV.html">SigCheckAll GEP3_BEV</a></li>
12
- <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_GEP3_HEP7.html">SigCheckAll GEP3_HEP7</a></li>
13
- <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_GEP3_HRE.html">SigCheckAll GEP3_HRE</a></li>
14
- <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_GEP3_PFI_HEV.html">SigCheckAll GEP3_PFI_HEV</a></li>
15
- <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_GEP3_SPA.html">SigCheckAll GEP3_SPA</a></li>
16
- <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_GEP3_SPA_7DCT.html">SigCheckAll GEP3_SPA_7DCT</a></li>
17
- <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_VED4_GENIII.html">SigCheckAll VED4_GENIII</a></li>
18
- <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_VEP4_GENIII.html">SigCheckAll VEP4_GENIII</a></li>
19
- <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_VEP4_GENIII_LP.html">SigCheckAll VEP4_GENIII_LP</a></li>
20
- <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_ext_signals.html">External Signals</a></li>
21
- </ul>
22
- </body>
1
+ <!DOCTYPE html>
2
+ <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
3
+ <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
4
+
5
+ <body class="wy-body-for-nav">
6
+
7
+ <a class="icon icon-home"> Signal Consistency Report
8
+ </a>
9
+ <ul>
10
+ <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_intro.html">Introduction</a></li>
11
+ <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_GEP3_BEV.html">SigCheckAll GEP3_BEV</a></li>
12
+ <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_GEP3_HEP7.html">SigCheckAll GEP3_HEP7</a></li>
13
+ <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_GEP3_HRE.html">SigCheckAll GEP3_HRE</a></li>
14
+ <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_GEP3_PFI_HEV.html">SigCheckAll GEP3_PFI_HEV</a></li>
15
+ <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_GEP3_SPA.html">SigCheckAll GEP3_SPA</a></li>
16
+ <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_GEP3_SPA_7DCT.html">SigCheckAll GEP3_SPA_7DCT</a></li>
17
+ <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_VED4_GENIII.html">SigCheckAll VED4_GENIII</a></li>
18
+ <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_VEP4_GENIII.html">SigCheckAll VEP4_GENIII</a></li>
19
+ <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_VEP4_GENIII_LP.html">SigCheckAll VEP4_GENIII_LP</a></li>
20
+ <li class="toctree-l1"><a class="reference internal" href="SigCheckAll_ext_signals.html">External Signals</a></li>
21
+ </ul>
22
+ </body>
23
23
  </html>
@@ -1,20 +1,20 @@
1
- <!DOCTYPE html>
2
- <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
3
- <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
4
- <body class="wy-body-for-nav">
5
- <a class="icon icon-home"> Signal Interface Report
6
- </a>
7
- <ul>
8
- <li class="toctree-l1"><a class="reference internal" href="SigIfAll_intro.html">Introduction</a></li>
9
- <li class="toctree-l1"><a class="reference internal" href="SigIfAll_GEP3_BEV.html">SigIfAll GEP3_BEV</a></li>
10
- <li class="toctree-l1"><a class="reference internal" href="SigIfAll_GEP3_HEP7.html">SigIfAll GEP3_HEP7</a></li>
11
- <li class="toctree-l1"><a class="reference internal" href="SigIfAll_GEP3_HRE.html">SigIfAll GEP3_HRE</a></li>
12
- <li class="toctree-l1"><a class="reference internal" href="SigIfAll_GEP3_PFI_HEV.html">SigIfAll GEP3_PFI_HEV</a></li>
13
- <li class="toctree-l1"><a class="reference internal" href="SigIfAll_GEP3_SPA.html">SigIfAll GEP3_SPA</a></li>
14
- <li class="toctree-l1"><a class="reference internal" href="SigIfAll_GEP3_SPA_7DCT.html">SigIfAll GEP3_SPA_7DCT</a></li>
15
- <li class="toctree-l1"><a class="reference internal" href="SigIfAll_VED4_GENIII.html">SigIfAll VED4_GENIII</a></li>
16
- <li class="toctree-l1"><a class="reference internal" href="SigIfAll_VEP4_GENIII.html">SigIfAll VEP4_GENIII</a></li>
17
- <li class="toctree-l1"><a class="reference internal" href="SigIfAll_VEP4_GENIII_LP.html">SigIfAll VEP4_GENIII_LP</a></li>
18
- </ul>
19
- </body>
1
+ <!DOCTYPE html>
2
+ <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
3
+ <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
4
+ <body class="wy-body-for-nav">
5
+ <a class="icon icon-home"> Signal Interface Report
6
+ </a>
7
+ <ul>
8
+ <li class="toctree-l1"><a class="reference internal" href="SigIfAll_intro.html">Introduction</a></li>
9
+ <li class="toctree-l1"><a class="reference internal" href="SigIfAll_GEP3_BEV.html">SigIfAll GEP3_BEV</a></li>
10
+ <li class="toctree-l1"><a class="reference internal" href="SigIfAll_GEP3_HEP7.html">SigIfAll GEP3_HEP7</a></li>
11
+ <li class="toctree-l1"><a class="reference internal" href="SigIfAll_GEP3_HRE.html">SigIfAll GEP3_HRE</a></li>
12
+ <li class="toctree-l1"><a class="reference internal" href="SigIfAll_GEP3_PFI_HEV.html">SigIfAll GEP3_PFI_HEV</a></li>
13
+ <li class="toctree-l1"><a class="reference internal" href="SigIfAll_GEP3_SPA.html">SigIfAll GEP3_SPA</a></li>
14
+ <li class="toctree-l1"><a class="reference internal" href="SigIfAll_GEP3_SPA_7DCT.html">SigIfAll GEP3_SPA_7DCT</a></li>
15
+ <li class="toctree-l1"><a class="reference internal" href="SigIfAll_VED4_GENIII.html">SigIfAll VED4_GENIII</a></li>
16
+ <li class="toctree-l1"><a class="reference internal" href="SigIfAll_VEP4_GENIII.html">SigIfAll VEP4_GENIII</a></li>
17
+ <li class="toctree-l1"><a class="reference internal" href="SigIfAll_VEP4_GENIII_LP.html">SigIfAll VEP4_GENIII_LP</a></li>
18
+ </ul>
19
+ </body>
20
20
  </html>
powertrain_build/types.py CHANGED
@@ -1,218 +1,218 @@
1
- # Copyright 2024 Volvo Car Corporation
2
- # Licensed under Apache 2.0.
3
-
4
- """Common functions and properties for types."""
5
-
6
- TL_TYPES = dict(
7
- Float32=dict(
8
- size=4,
9
- a2l_type='FLOAT32_IEEE',
10
- a2l_range=('-1e38', '1e38')
11
- ),
12
- UInt32=dict(
13
- size=4,
14
- a2l_type='ULONG',
15
- a2l_range=(0, 4294967295)
16
- ),
17
- Int32=dict(
18
- size=4,
19
- a2l_type='SLONG',
20
- a2l_range=(-2147483648, 2147483647)
21
- ),
22
- UInt16=dict(
23
- size=2,
24
- a2l_type='UWORD',
25
- a2l_range=(0, 65535)
26
- ),
27
- Int16=dict(
28
- size=2,
29
- a2l_type='SWORD',
30
- a2l_range=(-32768, 32767)
31
- ),
32
- UInt8=dict(
33
- size=1,
34
- a2l_type='UBYTE',
35
- a2l_range=(0, 255)
36
- ),
37
- Int8=dict(
38
- size=1,
39
- a2l_type='SBYTE',
40
- a2l_range=(-128, 127)
41
- ),
42
- Bool=dict(
43
- size=1,
44
- a2l_type='UBYTE',
45
- a2l_range=(0, 1),
46
- bitmask='0x01'
47
- )
48
- )
49
-
50
- EC_TYPES = dict(
51
- real64_T=dict(
52
- size=8,
53
- a2l_type='FLOAT64_IEEE',
54
- a2l_ranger=('-1.8e308', '1.8e308')
55
- ),
56
- real_T=dict(
57
- size=8,
58
- a2l_type='FLOAT64_IEEE',
59
- a2l_ranger=('-1.8e308', '1.8e308')
60
- ),
61
- time_T=dict(
62
- size=8,
63
- a2l_type='FLOAT64_IEEE',
64
- a2l_ranger=('-1.8e308', '1.8e308')
65
- ),
66
- ulong_T=dict(
67
- size=4,
68
- a2l_type='ULONG',
69
- a2l_range=(0, 4294967295)
70
- ),
71
- real32_T=dict(
72
- size=4,
73
- a2l_type='FLOAT32_IEEE',
74
- a2l_range=('-1e38', '1e38')
75
- ),
76
- uint32_T=dict(
77
- size=4,
78
- a2l_type='ULONG',
79
- a2l_range=(0, 4294967295)
80
- ),
81
- uint_T=dict(
82
- size=4,
83
- a2l_type='ULONG',
84
- a2l_range=(0, 4294967295)
85
- ),
86
- int32_T=dict(
87
- size=4,
88
- a2l_type='SLONG',
89
- a2l_range=(-2147483648, 2147483647)
90
- ),
91
- int_T=dict(
92
- size=4,
93
- a2l_type='SLONG',
94
- a2l_range=(-2147483648, 2147483647)
95
- ),
96
- uint16_T=dict(
97
- size=2,
98
- a2l_type='UWORD',
99
- a2l_range=(0, 65535)
100
- ),
101
- int16_T=dict(
102
- size=2,
103
- a2l_type='SWORD',
104
- a2l_range=(-32768, 32767)
105
- ),
106
- uint8_T=dict(
107
- size=1,
108
- a2l_type='UBYTE',
109
- a2l_range=(0, 255)
110
- ),
111
- int8_T=dict(
112
- size=1,
113
- a2l_type='SBYTE',
114
- a2l_range=(-128, 127)
115
- ),
116
- boolean_T=dict(
117
- size=1,
118
- a2l_type='UBYTE',
119
- a2l_range=(0, 1),
120
- bitmask='0x01'
121
- ),
122
- uchar_T=dict(
123
- size=1,
124
- a2l_type='UBYTE',
125
- a2l_range=(0, 255)
126
- ),
127
- char_T=dict(
128
- size=1,
129
- a2l_type='SBYTE',
130
- a2l_range=(-128, 127)
131
- ),
132
- byte_T=dict(
133
- size=1,
134
- a2l_type='SBYTE',
135
- a2l_range=(-128, 127)
136
- )
137
- )
138
-
139
-
140
- def _validate_c_type(c_type):
141
- """Make sure given c-type is handled."""
142
- if c_type in TL_TYPES:
143
- return TL_TYPES[c_type]
144
- if c_type in EC_TYPES:
145
- return EC_TYPES[c_type]
146
- raise KeyError(f'Invalid data type: {c_type}')
147
-
148
-
149
- def byte_size(c_type):
150
- """Get byte size of a c-type as an int."""
151
- type_dict = _validate_c_type(c_type)
152
- return type_dict['size']
153
-
154
-
155
- def byte_size_string(c_type):
156
- """Get byte size of a c-type as a string."""
157
- return str(byte_size(c_type))
158
-
159
-
160
- def a2l_type(c_type):
161
- """Get a2l-type of a c-type."""
162
- type_dict = _validate_c_type(c_type)
163
- return type_dict['a2l_type']
164
-
165
-
166
- def a2l_range(c_type):
167
- """Get a2l-range of a c-type."""
168
- # TODO: Find out why we default to float32 in a2l.py
169
- # Probably due to vc_dummy.
170
- if c_type == 'float32' or c_type is None:
171
- # TODO Assuming TL for now
172
- return TL_TYPES['Float32']['a2l_range']
173
- type_dict = _validate_c_type(c_type)
174
- return type_dict['a2l_range']
175
-
176
-
177
- def get_bitmask(c_type):
178
- """Get bit mask of a c-type.
179
-
180
- Defaults to None for types other than Bool.
181
- """
182
- type_dict = _validate_c_type(c_type)
183
- return type_dict.get('bitmask')
184
-
185
-
186
- def get_ec_type(tl_type):
187
- """Get equivalent EC type for a given TL type.
188
-
189
- Args:
190
- tl_type (str): TL type
191
-
192
- Returns:
193
- str: EC type
194
- """
195
- tl_ec = dict(
196
- Float32='real32_T',
197
- UInt32='uint32_T',
198
- Int32='int32_T',
199
- UInt16='uint16_T',
200
- Int16='int16_T',
201
- UInt8='uint8_T',
202
- Int8='int8_T',
203
- Bool='boolean_T'
204
- )
205
- return tl_ec[tl_type]
206
-
207
-
208
- def get_float32_types():
209
- """Get all EC types that are equivalent to Float32.
210
-
211
- Returns:
212
- set: EC types
213
- """
214
- float32_types = {'Float32'}
215
- for ec_type, ec_type_def in EC_TYPES.items():
216
- if ec_type_def == TL_TYPES['Float32']:
217
- float32_types.add(ec_type)
218
- return float32_types
1
+ # Copyright 2024 Volvo Car Corporation
2
+ # Licensed under Apache 2.0.
3
+
4
+ """Common functions and properties for types."""
5
+
6
+ TL_TYPES = dict(
7
+ Float32=dict(
8
+ size=4,
9
+ a2l_type='FLOAT32_IEEE',
10
+ a2l_range=('-1e38', '1e38')
11
+ ),
12
+ UInt32=dict(
13
+ size=4,
14
+ a2l_type='ULONG',
15
+ a2l_range=(0, 4294967295)
16
+ ),
17
+ Int32=dict(
18
+ size=4,
19
+ a2l_type='SLONG',
20
+ a2l_range=(-2147483648, 2147483647)
21
+ ),
22
+ UInt16=dict(
23
+ size=2,
24
+ a2l_type='UWORD',
25
+ a2l_range=(0, 65535)
26
+ ),
27
+ Int16=dict(
28
+ size=2,
29
+ a2l_type='SWORD',
30
+ a2l_range=(-32768, 32767)
31
+ ),
32
+ UInt8=dict(
33
+ size=1,
34
+ a2l_type='UBYTE',
35
+ a2l_range=(0, 255)
36
+ ),
37
+ Int8=dict(
38
+ size=1,
39
+ a2l_type='SBYTE',
40
+ a2l_range=(-128, 127)
41
+ ),
42
+ Bool=dict(
43
+ size=1,
44
+ a2l_type='UBYTE',
45
+ a2l_range=(0, 1),
46
+ bitmask='0x01'
47
+ )
48
+ )
49
+
50
+ EC_TYPES = dict(
51
+ real64_T=dict(
52
+ size=8,
53
+ a2l_type='FLOAT64_IEEE',
54
+ a2l_ranger=('-1.8e308', '1.8e308')
55
+ ),
56
+ real_T=dict(
57
+ size=8,
58
+ a2l_type='FLOAT64_IEEE',
59
+ a2l_ranger=('-1.8e308', '1.8e308')
60
+ ),
61
+ time_T=dict(
62
+ size=8,
63
+ a2l_type='FLOAT64_IEEE',
64
+ a2l_ranger=('-1.8e308', '1.8e308')
65
+ ),
66
+ ulong_T=dict(
67
+ size=4,
68
+ a2l_type='ULONG',
69
+ a2l_range=(0, 4294967295)
70
+ ),
71
+ real32_T=dict(
72
+ size=4,
73
+ a2l_type='FLOAT32_IEEE',
74
+ a2l_range=('-1e38', '1e38')
75
+ ),
76
+ uint32_T=dict(
77
+ size=4,
78
+ a2l_type='ULONG',
79
+ a2l_range=(0, 4294967295)
80
+ ),
81
+ uint_T=dict(
82
+ size=4,
83
+ a2l_type='ULONG',
84
+ a2l_range=(0, 4294967295)
85
+ ),
86
+ int32_T=dict(
87
+ size=4,
88
+ a2l_type='SLONG',
89
+ a2l_range=(-2147483648, 2147483647)
90
+ ),
91
+ int_T=dict(
92
+ size=4,
93
+ a2l_type='SLONG',
94
+ a2l_range=(-2147483648, 2147483647)
95
+ ),
96
+ uint16_T=dict(
97
+ size=2,
98
+ a2l_type='UWORD',
99
+ a2l_range=(0, 65535)
100
+ ),
101
+ int16_T=dict(
102
+ size=2,
103
+ a2l_type='SWORD',
104
+ a2l_range=(-32768, 32767)
105
+ ),
106
+ uint8_T=dict(
107
+ size=1,
108
+ a2l_type='UBYTE',
109
+ a2l_range=(0, 255)
110
+ ),
111
+ int8_T=dict(
112
+ size=1,
113
+ a2l_type='SBYTE',
114
+ a2l_range=(-128, 127)
115
+ ),
116
+ boolean_T=dict(
117
+ size=1,
118
+ a2l_type='UBYTE',
119
+ a2l_range=(0, 1),
120
+ bitmask='0x01'
121
+ ),
122
+ uchar_T=dict(
123
+ size=1,
124
+ a2l_type='UBYTE',
125
+ a2l_range=(0, 255)
126
+ ),
127
+ char_T=dict(
128
+ size=1,
129
+ a2l_type='SBYTE',
130
+ a2l_range=(-128, 127)
131
+ ),
132
+ byte_T=dict(
133
+ size=1,
134
+ a2l_type='SBYTE',
135
+ a2l_range=(-128, 127)
136
+ )
137
+ )
138
+
139
+
140
+ def _validate_c_type(c_type):
141
+ """Make sure given c-type is handled."""
142
+ if c_type in TL_TYPES:
143
+ return TL_TYPES[c_type]
144
+ if c_type in EC_TYPES:
145
+ return EC_TYPES[c_type]
146
+ raise KeyError(f'Invalid data type: {c_type}')
147
+
148
+
149
+ def byte_size(c_type):
150
+ """Get byte size of a c-type as an int."""
151
+ type_dict = _validate_c_type(c_type)
152
+ return type_dict['size']
153
+
154
+
155
+ def byte_size_string(c_type):
156
+ """Get byte size of a c-type as a string."""
157
+ return str(byte_size(c_type))
158
+
159
+
160
+ def a2l_type(c_type):
161
+ """Get a2l-type of a c-type."""
162
+ type_dict = _validate_c_type(c_type)
163
+ return type_dict['a2l_type']
164
+
165
+
166
+ def a2l_range(c_type):
167
+ """Get a2l-range of a c-type."""
168
+ # TODO: Find out why we default to float32 in a2l.py
169
+ # Probably due to vc_dummy.
170
+ if c_type == 'float32' or c_type is None:
171
+ # TODO Assuming TL for now
172
+ return TL_TYPES['Float32']['a2l_range']
173
+ type_dict = _validate_c_type(c_type)
174
+ return type_dict['a2l_range']
175
+
176
+
177
+ def get_bitmask(c_type):
178
+ """Get bit mask of a c-type.
179
+
180
+ Defaults to None for types other than Bool.
181
+ """
182
+ type_dict = _validate_c_type(c_type)
183
+ return type_dict.get('bitmask')
184
+
185
+
186
+ def get_ec_type(tl_type):
187
+ """Get equivalent EC type for a given TL type.
188
+
189
+ Args:
190
+ tl_type (str): TL type
191
+
192
+ Returns:
193
+ str: EC type
194
+ """
195
+ tl_ec = dict(
196
+ Float32='real32_T',
197
+ UInt32='uint32_T',
198
+ Int32='int32_T',
199
+ UInt16='uint16_T',
200
+ Int16='int16_T',
201
+ UInt8='uint8_T',
202
+ Int8='int8_T',
203
+ Bool='boolean_T'
204
+ )
205
+ return tl_ec[tl_type]
206
+
207
+
208
+ def get_float32_types():
209
+ """Get all EC types that are equivalent to Float32.
210
+
211
+ Returns:
212
+ set: EC types
213
+ """
214
+ float32_types = {'Float32'}
215
+ for ec_type, ec_type_def in EC_TYPES.items():
216
+ if ec_type_def == TL_TYPES['Float32']:
217
+ float32_types.add(ec_type)
218
+ return float32_types