py-eb-model 1.0.0__py3-none-any.whl → 1.1.4__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.
- eb_model/__init__.py +2 -1
- eb_model/cli/os_xdm_2_xls_cli.py +21 -12
- eb_model/cli/pref_system_importer_cli.py +94 -0
- py_eb_model/cli/os_xdm_2_xls_cli.py → eb_model/cli/rte_xdm_2_xls_cli.py +18 -9
- eb_model/models/__init__.py +2 -0
- eb_model/models/abstract.py +86 -13
- eb_model/models/eb_doc.py +55 -27
- eb_model/models/eclipse_project.py +8 -0
- eb_model/models/importer_xdm.py +115 -0
- eb_model/models/os_xdm.py +898 -99
- eb_model/models/rte_xdm.py +604 -0
- eb_model/parser/__init__.py +3 -0
- eb_model/parser/eb_parser.py +92 -39
- eb_model/parser/eb_parser_factory.py +29 -0
- eb_model/parser/os_xdm_parser.py +171 -28
- eb_model/parser/pref_xdm_parser.py +36 -0
- eb_model/parser/rte_xdm_parser.py +95 -0
- eb_model/reporter/excel_reporter/abstract.py +11 -11
- eb_model/reporter/excel_reporter/os_xdm.py +109 -12
- eb_model/reporter/excel_reporter/rte_xdm.py +87 -0
- eb_model/tests/models/test_eb_model.py +19 -1
- eb_model/tests/models/test_importer_xdm.py +61 -0
- eb_model/writer/__init__.py +2 -0
- eb_model/writer/project_writer.py +71 -0
- eb_model/writer/text_writer.py +28 -0
- py_eb_model-1.1.4.dist-info/METADATA +200 -0
- py_eb_model-1.1.4.dist-info/RECORD +38 -0
- py_eb_model-1.1.4.dist-info/entry_points.txt +5 -0
- py_eb_model/__init__.py +0 -3
- py_eb_model/cli/__init__.py +0 -0
- py_eb_model/models/__init__.py +0 -3
- py_eb_model/models/abstract.py +0 -66
- py_eb_model/models/eb_doc.py +0 -52
- py_eb_model/models/os_xdm.py +0 -220
- py_eb_model/parser/__init__.py +0 -1
- py_eb_model/parser/eb_parser.py +0 -147
- py_eb_model/parser/os_xdm_parser.py +0 -43
- py_eb_model/reporter/__init__.py +0 -1
- py_eb_model/reporter/excel_reporter/__init__.py +0 -0
- py_eb_model/reporter/excel_reporter/abstract.py +0 -43
- py_eb_model/reporter/excel_reporter/os_xdm.py +0 -44
- py_eb_model/reporter/markdown.py +0 -40
- py_eb_model-1.0.0.dist-info/METADATA +0 -16
- py_eb_model-1.0.0.dist-info/RECORD +0 -40
- py_eb_model-1.0.0.dist-info/entry_points.txt +0 -3
- {py_eb_model-1.0.0.dist-info → py_eb_model-1.1.4.dist-info}/LICENSE +0 -0
- {py_eb_model-1.0.0.dist-info → py_eb_model-1.1.4.dist-info}/WHEEL +0 -0
- {py_eb_model-1.0.0.dist-info → py_eb_model-1.1.4.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,8 @@
|
|
1
|
+
import re
|
2
|
+
from openpyxl.styles import Alignment
|
1
3
|
from ...models.eb_doc import EBModel
|
2
|
-
from .abstract import ExcelReporter
|
4
|
+
from ...reporter.excel_reporter.abstract import ExcelReporter
|
5
|
+
|
3
6
|
|
4
7
|
class OsXdmXlsWriter(ExcelReporter):
|
5
8
|
def __init__(self) -> None:
|
@@ -8,37 +11,131 @@ class OsXdmXlsWriter(ExcelReporter):
|
|
8
11
|
def write_os_tasks(self, doc: EBModel):
|
9
12
|
sheet = self.wb.create_sheet("OsTask", 0)
|
10
13
|
|
11
|
-
title_row = [
|
14
|
+
title_row = [
|
15
|
+
"Name", "OsApplication", "OsTaskActivation", "OsTaskPriority", "OsTaskAutostart",
|
16
|
+
"OsTaskSchedule", "OsStacksize", "OsTaskType", "OsResourceRef"]
|
12
17
|
self.write_title_row(sheet, title_row)
|
13
18
|
|
14
19
|
row = 2
|
15
20
|
for os_task in doc.getOs().getOsTaskList():
|
16
21
|
self.write_cell(sheet, row, 1, os_task.getName())
|
17
|
-
|
18
|
-
self.write_cell(sheet, row,
|
19
|
-
self.write_cell(sheet, row,
|
20
|
-
self.write_cell(sheet, row,
|
22
|
+
os_app = doc.getOs().getOsTaskOsApplication(os_task.getName())
|
23
|
+
self.write_cell(sheet, row, 2, os_app.getName())
|
24
|
+
self.write_cell(sheet, row, 3, os_task.getOsTaskActivation())
|
25
|
+
self.write_cell(sheet, row, 4, os_task.getOsTaskPriority())
|
26
|
+
self.write_cell(sheet, row, 5, os_task.isOsTaskAutostart())
|
27
|
+
|
28
|
+
self.write_cell(sheet, row, 6, os_task.getOsTaskSchedule())
|
29
|
+
self.write_cell(sheet, row, 7, os_task.getOsStacksize())
|
30
|
+
self.write_cell(sheet, row, 8, os_task.getOsTaskType())
|
31
|
+
resources = []
|
32
|
+
for resource_ref in os_task.getOsTaskResourceRefList():
|
33
|
+
m = re.match(r"Rte_\w+", resource_ref.getValue())
|
34
|
+
if m:
|
35
|
+
resources.append(resource_ref.getValue())
|
36
|
+
total_resources = len(resources)
|
37
|
+
if total_resources > 10:
|
38
|
+
cell = self.write_cell(sheet, row, 9, "Total: %d OsResources" % (total_resources))
|
39
|
+
else:
|
40
|
+
cell = self.write_cell(sheet, row, 9, "\n".join(resources))
|
41
|
+
if total_resources > 1 and total_resources < 10:
|
42
|
+
cell.alignment = Alignment(wrapText=True)
|
21
43
|
row += 1
|
22
44
|
|
45
|
+
self.logger.debug("Write OsTask <%s>" % os_task.getName())
|
46
|
+
|
23
47
|
self.auto_width(sheet)
|
24
48
|
|
25
49
|
def write_os_isrs(self, doc: EBModel):
|
26
|
-
sheet = self.wb.create_sheet("OsIsr",
|
50
|
+
sheet = self.wb.create_sheet("OsIsr", 1)
|
27
51
|
|
28
|
-
title_row = ["Name", "OsIsrCategory", "OsStacksize"]
|
52
|
+
title_row = ["Name", "OsApplication", "OsIsrCategory", "OsStacksize", "OsIsrPriority", "OsIsrVector"]
|
29
53
|
self.write_title_row(sheet, title_row)
|
30
54
|
|
31
55
|
row = 2
|
32
56
|
for os_isr in doc.getOs().getOsIsrList():
|
33
57
|
self.write_cell(sheet, row, 1, os_isr.getName())
|
34
|
-
|
35
|
-
|
58
|
+
os_app = doc.getOs().getOsIsrOsApplication(os_isr.getName())
|
59
|
+
if os_app is not None:
|
60
|
+
self.write_cell(sheet, row, 2, os_app.getName())
|
61
|
+
self.write_cell(sheet, row, 3, os_isr.getOsIsrCategory())
|
62
|
+
self.write_cell(sheet, row, 4, os_isr.getOsStacksize())
|
63
|
+
self.write_cell(sheet, row, 5, os_isr.getOsIsrPriority())
|
64
|
+
self.write_cell(sheet, row, 6, os_isr.getOsIsrVector())
|
36
65
|
row += 1
|
37
66
|
|
67
|
+
self.logger.debug("Write OsIsr <%s>" % os_isr.getName())
|
68
|
+
|
38
69
|
self.auto_width(sheet)
|
39
70
|
|
40
|
-
def
|
41
|
-
self.
|
71
|
+
def write_os_schedule_tables(self, doc: EBModel):
|
72
|
+
sheet = self.wb.create_sheet("OsScheduleTable", 2)
|
73
|
+
|
74
|
+
title_row = ["Name", "Duration", "Repeating", "OsCount"]
|
75
|
+
self.write_title_row(sheet, title_row)
|
76
|
+
|
77
|
+
row = 2
|
78
|
+
for os_schedule_table in doc.getOs().getOsScheduleTableList():
|
79
|
+
self.write_cell(sheet, row, 1, os_schedule_table.getName())
|
80
|
+
self.write_cell(sheet, row, 2, os_schedule_table.getOsScheduleTableDuration())
|
81
|
+
self.write_cell(sheet, row, 3, os_schedule_table.getOsScheduleTableRepeating())
|
82
|
+
self.write_cell(sheet, row, 4, os_schedule_table.getOsScheduleTableCounterRef().getShortName())
|
83
|
+
row += 1
|
84
|
+
|
85
|
+
self.logger.debug("Write OsScheduleTable <%s>" % os_schedule_table.getName())
|
86
|
+
|
87
|
+
self.auto_width(sheet)
|
88
|
+
|
89
|
+
def write_os_counters(self, doc: EBModel):
|
90
|
+
sheet = self.wb.create_sheet("OsCounter", 3)
|
91
|
+
|
92
|
+
title_row = ["Name", "MaxAllowedValue", "MinCycle", "TicksPerBase", "Type", "SecondsPerTick"]
|
93
|
+
self.write_title_row(sheet, title_row)
|
94
|
+
|
95
|
+
row = 2
|
96
|
+
for os_counter in doc.getOs().getOsCounterList():
|
97
|
+
self.write_cell(sheet, row, 1, os_counter.getName())
|
98
|
+
self.write_cell(sheet, row, 2, os_counter.getOsCounterMaxAllowedValue())
|
99
|
+
self.write_cell(sheet, row, 3, os_counter.getOsCounterMinCycle())
|
100
|
+
self.write_cell(sheet, row, 4, os_counter.getOsCounterTicksPerBase())
|
101
|
+
self.write_cell(sheet, row, 5, os_counter.getOsCounterType())
|
102
|
+
self.write_cell(sheet, row, 6, os_counter.getOsSecondsPerTick())
|
103
|
+
row += 1
|
104
|
+
|
105
|
+
self.logger.debug("Write OsScheduleTable <%s>" % os_counter.getName())
|
106
|
+
|
107
|
+
self.auto_width(sheet)
|
108
|
+
|
109
|
+
def write_expiry_points(self, doc: EBModel):
|
110
|
+
sheet = self.wb.create_sheet("OsScheduleTableExpiryPoint", 4)
|
111
|
+
|
112
|
+
title_row = ["ExpiryPoint", "OsScheduleTable", "OsCounter" "Offset (ms)", "Task"]
|
113
|
+
self.write_title_row(sheet, title_row)
|
114
|
+
|
115
|
+
row = 2
|
116
|
+
for table in doc.getOs().getOsScheduleTableList():
|
117
|
+
expiry_point_list = sorted(table.getOsScheduleTableExpiryPointList(),
|
118
|
+
key=lambda o: o.getOsScheduleTblExpPointOffset())
|
119
|
+
for expiry_point in expiry_point_list:
|
120
|
+
self.write_cell(sheet, row, 1, expiry_point.getName())
|
121
|
+
self.write_cell(sheet, row, 2, table.getName())
|
122
|
+
self.write_cell(sheet, row, 3, table.getOsScheduleTableCounterRef().getShortName())
|
123
|
+
self.write_cell(sheet, row, 4, expiry_point.getOsScheduleTblExpPointOffset())
|
124
|
+
self.write_cell(sheet, row, 5, len(expiry_point.getOsScheduleTableTaskActivationList()))
|
125
|
+
row += 1
|
126
|
+
|
127
|
+
self.logger.debug("Write OsScheduleTable <%s>" % table.getName())
|
128
|
+
|
129
|
+
self.auto_width(sheet)
|
130
|
+
|
131
|
+
def write(self, filename, doc: EBModel, options={"skip_os_task": False}):
|
132
|
+
self.logger.info("Writing <%s>" % filename)
|
133
|
+
|
134
|
+
if not options['skip_os_task']:
|
135
|
+
self.write_os_tasks(doc)
|
42
136
|
self.write_os_isrs(doc)
|
137
|
+
self.write_os_schedule_tables(doc)
|
138
|
+
self.write_os_counters(doc)
|
139
|
+
self.write_expiry_points(doc)
|
43
140
|
|
44
141
|
self.save(filename)
|
@@ -0,0 +1,87 @@
|
|
1
|
+
from ...models.rte_xdm import RteBswEventToTaskMapping, RteBswModuleInstance, RteEventToTaskMapping, RteSwComponentInstance
|
2
|
+
from ...models.eb_doc import EBModel
|
3
|
+
from .abstract import ExcelReporter
|
4
|
+
|
5
|
+
class RteXdmXlsWriter(ExcelReporter):
|
6
|
+
def __init__(self) -> None:
|
7
|
+
super().__init__()
|
8
|
+
|
9
|
+
def write_os_tasks(self, doc: EBModel):
|
10
|
+
sheet = self.wb.create_sheet("OsTask", 0)
|
11
|
+
|
12
|
+
title_row = ["Name", "OsTaskActivation", "OsTaskPriority", "OsTaskSchedule", "OsStacksize"]
|
13
|
+
self.write_title_row(sheet, title_row)
|
14
|
+
|
15
|
+
row = 2
|
16
|
+
for os_task in doc.getOs().getOsTaskList():
|
17
|
+
self.write_cell(sheet, row, 1, os_task.getName())
|
18
|
+
self.write_cell(sheet, row, 2, os_task.getOsTaskActivation())
|
19
|
+
self.write_cell(sheet, row, 3, os_task.getOsTaskPriority())
|
20
|
+
self.write_cell(sheet, row, 4, os_task.getOsTaskSchedule())
|
21
|
+
self.write_cell(sheet, row, 5, os_task.getOsStacksize())
|
22
|
+
row += 1
|
23
|
+
|
24
|
+
self.auto_width(sheet)
|
25
|
+
|
26
|
+
def write_os_isrs(self, doc: EBModel):
|
27
|
+
sheet = self.wb.create_sheet("OsIsr", 0)
|
28
|
+
|
29
|
+
title_row = ["Name", "OsIsrCategory", "OsStacksize"]
|
30
|
+
self.write_title_row(sheet, title_row)
|
31
|
+
|
32
|
+
row = 2
|
33
|
+
for os_isr in doc.getOs().getOsIsrList():
|
34
|
+
self.write_cell(sheet, row, 1, os_isr.getName())
|
35
|
+
self.write_cell(sheet, row, 2, os_isr.getOsIsrCategory())
|
36
|
+
self.write_cell(sheet, row, 3, os_isr.getOsStacksize())
|
37
|
+
row += 1
|
38
|
+
|
39
|
+
self.auto_width(sheet)
|
40
|
+
|
41
|
+
def write(self, filename, doc: EBModel):
|
42
|
+
self.logger.info("Writing <%s>" % filename)
|
43
|
+
self.write_os_tasks(doc)
|
44
|
+
self.write_os_isrs(doc)
|
45
|
+
|
46
|
+
self.save(filename)
|
47
|
+
|
48
|
+
class RteRunnableEntityXlsWriter(ExcelReporter):
|
49
|
+
def __init__(self) -> None:
|
50
|
+
super().__init__()
|
51
|
+
|
52
|
+
def write_mapped_events(self, doc: EBModel):
|
53
|
+
sheet = self.wb.create_sheet("Event Mapping", 0)
|
54
|
+
|
55
|
+
title_row = ["OsTask", "Event", "Event Type", "Executable Entity", "Instance", "Position", "Offset"]
|
56
|
+
self.write_title_row(sheet, title_row)
|
57
|
+
|
58
|
+
row = 2
|
59
|
+
for os_task, mappings in doc.getRte().getMappedEvents().items():
|
60
|
+
for mapping in sorted(mappings, key = lambda a:a.getRtePositionInTask()):
|
61
|
+
self.write_cell(sheet, row, 1, os_task)
|
62
|
+
if isinstance(mapping, RteBswEventToTaskMapping):
|
63
|
+
self.logger.debug("Write Mapping %s" % mapping.getName())
|
64
|
+
instance = mapping.getRteBswModuleInstance()
|
65
|
+
self.write_cell(sheet, row, 2, mapping.getRteBswEventRefs().getShortName())
|
66
|
+
self.write_cell(sheet, row, 5, instance.getRteBswImplementationRef().getValue())
|
67
|
+
self.write_cell(sheet, row, 6, mapping.getRteBswPositionInTask())
|
68
|
+
self.write_cell(sheet, row, 7, mapping.getRteBswActivationOffset())
|
69
|
+
elif isinstance(mapping, RteEventToTaskMapping):
|
70
|
+
self.logger.debug("Write Mapping %s" % mapping.getName())
|
71
|
+
instance = mapping.getRteSwComponentInstance()
|
72
|
+
self.write_cell(sheet, row, 2, mapping.getRteEventRef().getShortName())
|
73
|
+
self.write_cell(sheet, row, 5, instance.getRteSoftwareComponentInstanceRef().getValue())
|
74
|
+
self.write_cell(sheet, row, 6, mapping.getRtePositionInTask())
|
75
|
+
self.write_cell(sheet, row, 7, mapping.getRteActivationOffset())
|
76
|
+
else:
|
77
|
+
raise NotImplementedError("Invalid Rte Event To Task Mapping <%s>" % type(mapping))
|
78
|
+
|
79
|
+
row += 1
|
80
|
+
|
81
|
+
self.auto_width(sheet)
|
82
|
+
|
83
|
+
def write(self, filename, doc: EBModel):
|
84
|
+
self.logger.info("Writing <%s>" % filename)
|
85
|
+
self.write_mapped_events(doc)
|
86
|
+
|
87
|
+
self.save(filename)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import pytest
|
2
|
-
from ...models.eb_doc import EBModel
|
2
|
+
from ...models.eb_doc import EBModel, PreferenceModel
|
3
3
|
|
4
4
|
class TestEBModel:
|
5
5
|
|
@@ -23,3 +23,21 @@ class TestEBModel:
|
|
23
23
|
document = EBModel.getInstance()
|
24
24
|
os = document.getOs()
|
25
25
|
assert (os.getFullName() == "/Os/Os")
|
26
|
+
|
27
|
+
def test_ebmodel_get_rte(self):
|
28
|
+
document = EBModel.getInstance()
|
29
|
+
rte = document.getRte()
|
30
|
+
assert (rte.getFullName() == "/Rte/Rte")
|
31
|
+
|
32
|
+
class TestPreferenceModel:
|
33
|
+
|
34
|
+
def test_mode_get_system_description_importer(self):
|
35
|
+
document = PreferenceModel.getInstance()
|
36
|
+
importer = document.getSystemDescriptionImporter()
|
37
|
+
assert (importer.getFullName() == "/ImporterExporterAdditions/SystemDescriptionImporters")
|
38
|
+
|
39
|
+
importer = document.find("/ImporterExporterAdditions/SystemDescriptionImporters")
|
40
|
+
assert (importer.getFullName() == "/ImporterExporterAdditions/SystemDescriptionImporters")
|
41
|
+
|
42
|
+
importer = document.getSystemDescriptionImporter()
|
43
|
+
assert (importer.getFullName() == "/ImporterExporterAdditions/SystemDescriptionImporters")
|
@@ -0,0 +1,61 @@
|
|
1
|
+
|
2
|
+
from ...models.eb_doc import PreferenceModel
|
3
|
+
from ...models.importer_xdm import SystemDescriptionImporter
|
4
|
+
|
5
|
+
|
6
|
+
class TestSystemDescriptionImporter:
|
7
|
+
|
8
|
+
def test_get_parsed_input_files(self):
|
9
|
+
document = PreferenceModel.getInstance()
|
10
|
+
importer = document.getSystemDescriptionImporter()
|
11
|
+
importer.addInputFile("${env_var:TRESOS_OUTPUT_DIR}\**\*.arxml")
|
12
|
+
input_files = importer.getParsedInputFiles({"env_var:TRESOS_OUTPUT_DIR": "c:/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd", "base_path": None})
|
13
|
+
|
14
|
+
assert(len(input_files) == 1)
|
15
|
+
assert(input_files[0] == "c:/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd\\**\\*.arxml")
|
16
|
+
document = PreferenceModel.getInstance()
|
17
|
+
importer = document.getSystemDescriptionImporter()
|
18
|
+
path_segments = importer.getAllPaths("../../EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd")
|
19
|
+
assert(len(path_segments) == 7)
|
20
|
+
assert(path_segments[0] == "EB")
|
21
|
+
assert(path_segments[1] == "EB/ACG-8_8_8_WIN32X86")
|
22
|
+
assert(path_segments[2] == "EB/ACG-8_8_8_WIN32X86/workspace")
|
23
|
+
assert(path_segments[6] == "EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd")
|
24
|
+
|
25
|
+
def test_get_links(self):
|
26
|
+
document = PreferenceModel.getInstance()
|
27
|
+
importer = document.getSystemDescriptionImporter()
|
28
|
+
file_list = []
|
29
|
+
file_list.append("../../EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd/Atomics_Bswmd.arxml")
|
30
|
+
file_list.append("../../EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd/BswM.arxml")
|
31
|
+
file_list.append("../../EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd/Atomics_Bswmd.arxml")
|
32
|
+
|
33
|
+
links = importer.getLinks(file_list)
|
34
|
+
assert(len(links) == 9)
|
35
|
+
assert(links[0].name == "EB")
|
36
|
+
assert(links[0].type == 2)
|
37
|
+
assert(links[0].locationURI == "virtual:/virtual")
|
38
|
+
|
39
|
+
assert(links[1].name == "EB/ACG-8_8_8_WIN32X86")
|
40
|
+
assert(links[1].type == 2)
|
41
|
+
assert(links[1].locationURI == "virtual:/virtual")
|
42
|
+
|
43
|
+
assert(links[2].name == "EB/ACG-8_8_8_WIN32X86/workspace")
|
44
|
+
assert(links[2].type == 2)
|
45
|
+
assert(links[2].locationURI == "virtual:/virtual")
|
46
|
+
|
47
|
+
assert(links[3].name == "EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte")
|
48
|
+
assert(links[3].type == 2)
|
49
|
+
assert(links[3].locationURI == "virtual:/virtual")
|
50
|
+
|
51
|
+
assert(links[6].name == "EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd")
|
52
|
+
assert(links[6].type == 2)
|
53
|
+
assert(links[6].locationURI == "virtual:/virtual")
|
54
|
+
|
55
|
+
assert(links[7].name == "EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd/Atomics_Bswmd.arxml")
|
56
|
+
assert(links[7].type == 1)
|
57
|
+
assert(links[7].locationURI == "PARENT-2-PROJECT_LOC/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd/Atomics_Bswmd.arxml")
|
58
|
+
|
59
|
+
assert(links[8].name == "EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd/BswM.arxml")
|
60
|
+
assert(links[8].type == 1)
|
61
|
+
assert(links[8].locationURI == "PARENT-2-PROJECT_LOC/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd/BswM.arxml")
|
@@ -0,0 +1,71 @@
|
|
1
|
+
from typing import List
|
2
|
+
from xml.dom import minidom
|
3
|
+
import xml.etree.ElementTree as ET
|
4
|
+
import logging
|
5
|
+
import os
|
6
|
+
|
7
|
+
from ..models.eclipse_project import Link
|
8
|
+
from ..models.importer_xdm import SystemDescriptionImporter
|
9
|
+
|
10
|
+
class EclipseProjectWriter:
|
11
|
+
def __init__(self):
|
12
|
+
self.logger = logging.getLogger()
|
13
|
+
|
14
|
+
def write_element(self, element: ET.Element, key: str, content: str) -> ET.Element:
|
15
|
+
child_element = ET.SubElement(element, key)
|
16
|
+
child_element.text = str(content)
|
17
|
+
|
18
|
+
return child_element
|
19
|
+
|
20
|
+
def write(self, links: List[Link]):
|
21
|
+
pass
|
22
|
+
|
23
|
+
class ABProjectWriter(EclipseProjectWriter):
|
24
|
+
def __init__(self):
|
25
|
+
super().__init__()
|
26
|
+
|
27
|
+
def _write_link(self, element: ET.Element, link: Link):
|
28
|
+
child_element = ET.SubElement(element, "link")
|
29
|
+
self.write_element(child_element, "name", link.name)
|
30
|
+
self.write_element(child_element, "type", link.type)
|
31
|
+
self.write_element(child_element, "locationURI", link.locationURI)
|
32
|
+
|
33
|
+
def _write_links(self, element: ET.Element, links: List[Link]):
|
34
|
+
child_element = ET.SubElement(element, "linkedResources")
|
35
|
+
for link in links:
|
36
|
+
self._write_link(child_element, link)
|
37
|
+
|
38
|
+
self.logger.info("Total <%d> Links are written." % len(links))
|
39
|
+
|
40
|
+
|
41
|
+
def _write_file_head(self, element: ET.Element, project: str):
|
42
|
+
if project is not None:
|
43
|
+
self.write_element(element, "name", project)
|
44
|
+
else:
|
45
|
+
self.write_element(element, "name", "project")
|
46
|
+
|
47
|
+
self.write_element(element, "comment", "")
|
48
|
+
self.write_element(element, "projects", "")
|
49
|
+
self.write_element(element, "buildSpec", "")
|
50
|
+
child_element = ET.SubElement(element, "natures")
|
51
|
+
self.write_element(child_element, "nature", "org.artop.aal.workspace.autosarnature")
|
52
|
+
|
53
|
+
def write(self, filename: str, project: str, links: List[Link]):
|
54
|
+
root = ET.Element("projectDescription")
|
55
|
+
|
56
|
+
self._write_file_head(root, project)
|
57
|
+
self._write_links(root, links)
|
58
|
+
|
59
|
+
xml = ET.tostring(root, encoding = "UTF-8", xml_declaration = True, short_empty_elements = False)
|
60
|
+
|
61
|
+
dom = minidom.parseString(xml.decode())
|
62
|
+
xml = dom.toprettyxml(indent = " ", encoding = "UTF-8")
|
63
|
+
|
64
|
+
with open(filename, "w", encoding="utf-8") as f_out:
|
65
|
+
f_out.write(xml.decode())
|
66
|
+
|
67
|
+
def writer_import_files(self, filename: str, importer: SystemDescriptionImporter, params = {'base_path': None, 'wildcard': None, "project": None}):
|
68
|
+
self.logger.info("Generate AB project <%s>" % filename)
|
69
|
+
file_list = sorted(importer.getParsedInputFiles(params))
|
70
|
+
links = importer.getLinks(file_list)
|
71
|
+
self.write(filename, params['project'], links)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import logging
|
2
|
+
from typing import List
|
3
|
+
|
4
|
+
from ..models.eb_doc import SystemDescriptionImporter
|
5
|
+
|
6
|
+
class TextWriter:
|
7
|
+
def __init__(self):
|
8
|
+
self.logger = logging.getLogger()
|
9
|
+
|
10
|
+
def write(self, filename: str, lines: List[str]):
|
11
|
+
with open(filename, "w") as f_out:
|
12
|
+
for line in lines:
|
13
|
+
f_out.write("%s\n" % line)
|
14
|
+
|
15
|
+
class TextPreferenceModelWriter(TextWriter):
|
16
|
+
def __init__(self):
|
17
|
+
super().__init__()
|
18
|
+
|
19
|
+
def writer_import_files(self, filename: str, importer: SystemDescriptionImporter, params = {'base_path': None, 'wildcard': None, "tresos_output_base_dir": None}):
|
20
|
+
self.logger.info("Generate import files list <%s>" % filename)
|
21
|
+
lines = []
|
22
|
+
for file in sorted(importer.getParsedInputFiles(params)):
|
23
|
+
if file in lines:
|
24
|
+
self.logger.warning("file <%s> is duplicated." % file)
|
25
|
+
else:
|
26
|
+
lines.append(file)
|
27
|
+
|
28
|
+
self.write(filename, lines)
|
@@ -0,0 +1,200 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: py-eb-model
|
3
|
+
Version: 1.1.4
|
4
|
+
Summary: The parser for EB XDM file
|
5
|
+
Home-page: UNKNOWN
|
6
|
+
Author: melodypapa
|
7
|
+
Author-email: melodypapa@outlook.com
|
8
|
+
License: proprietary
|
9
|
+
Keywords: EB Tresos XDM
|
10
|
+
Platform: UNKNOWN
|
11
|
+
Classifier: Development Status :: 1 - Planning
|
12
|
+
Classifier: Environment :: Console
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
15
|
+
Classifier: Operating System :: OS Independent
|
16
|
+
Description-Content-Type: text/markdown
|
17
|
+
Requires-Dist: openpyxl
|
18
|
+
Provides-Extra: pytest
|
19
|
+
Requires-Dist: pytest-cov ; extra == 'pytest'
|
20
|
+
|
21
|
+
# 1. py-eb-model
|
22
|
+
|
23
|
+
1. The python parser engine for EB Tresos Xdm file.
|
24
|
+
2. To support EB Tresos data model with python.
|
25
|
+
|
26
|
+
# 2. How to create the distribution and upload to pypi
|
27
|
+
|
28
|
+
1. Run `python setup.py bdist_wheel` to generate distribution
|
29
|
+
2. Run `twine check dist/*` to check the validation of distribution
|
30
|
+
3. Run `twine upload dist/*` to upload to pypi repository
|
31
|
+
4. Check the website https://pypi.org/project/armodel/ to find out it works or not
|
32
|
+
|
33
|
+
And more details can be found at https://packaging.python.org/
|
34
|
+
|
35
|
+
# 3. CLI
|
36
|
+
|
37
|
+
## 3.1. os-task-xlsx
|
38
|
+
|
39
|
+
Extract the Os Task information from os.xdm and then report all to Excel file.
|
40
|
+
|
41
|
+
```bash
|
42
|
+
os-xdm-xlsx data/Os.xdm data/Os.xlsx
|
43
|
+
```
|
44
|
+
|
45
|
+
**Result:**
|
46
|
+
|
47
|
+
1. OsIsrs
|
48
|
+
|
49
|
+

|
50
|
+
|
51
|
+
1. OsTasks
|
52
|
+
|
53
|
+

|
54
|
+
|
55
|
+
3. OsScheduleTable
|
56
|
+
|
57
|
+

|
58
|
+
|
59
|
+
4. OsCounter
|
60
|
+
|
61
|
+

|
62
|
+
|
63
|
+
## 3.2. rte-task-xls
|
64
|
+
|
65
|
+
Extract the Rte Configuration information from rte.xdm and then report all to Excel file.
|
66
|
+
|
67
|
+
1. Export the Rte Configuration information to excel file
|
68
|
+
|
69
|
+
```bash
|
70
|
+
rte-xdm-xlsx data/Rte.xdm data/Rte.xlsx
|
71
|
+
```
|
72
|
+
|
73
|
+
2. Export the Runnable Entities information to excel file
|
74
|
+
|
75
|
+
```bash
|
76
|
+
rte-xdm-xlsx -r data/Rte.xdm data/Os.xdm data/Runnable.xlsx
|
77
|
+
```
|
78
|
+
|
79
|
+
## 3.3. PrefSystemImporter
|
80
|
+
|
81
|
+
Read the EB preference XDM and generate the ARXML file list into text file or create the AUTOSAR builder project file.
|
82
|
+
|
83
|
+
```bash
|
84
|
+
$ pref-system-importer.exe -h
|
85
|
+
usage: pref-system-importer [-h] [-v] [--file-list] [--ab-project] [--base-path BASE_PATH] [--TRESOS_OUTPUT_BASE_DIR TRESOS_OUTPUT_BASE_DIR] [--project PROJECT] INPUTS [INPUTS ...] OUTPUT
|
86
|
+
|
87
|
+
positional arguments:
|
88
|
+
INPUTS The path of perf_imp_xxx.xdm.
|
89
|
+
OUTPUT The path of output file.
|
90
|
+
|
91
|
+
optional arguments:
|
92
|
+
-h, --help show this help message and exit
|
93
|
+
-v, --verbose print debug information.
|
94
|
+
--file-list generate the file list (Default)
|
95
|
+
--ab-project generate the AUTOSAR builder project
|
96
|
+
--base-path BASE_PATH
|
97
|
+
base Path for EB tresos
|
98
|
+
--env ENV [ENV ...] specify the environment variable
|
99
|
+
--project PROJECT specify the project name
|
100
|
+
```
|
101
|
+
### 3.3.1. Configuration
|
102
|
+
|
103
|
+
**h, help**
|
104
|
+
> Show the usage information
|
105
|
+
|
106
|
+
**-v, --verbose**
|
107
|
+
> Print the extra debug information during execution.
|
108
|
+
|
109
|
+
**--file-list or --ab-project**
|
110
|
+
> Generate ARXML file list text file or AUTOSAR builder project.
|
111
|
+
|
112
|
+
**--base-path**
|
113
|
+
> Base path for the EB tresos project. **For example**: c:/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte
|
114
|
+
>
|
115
|
+
> If the base path is specified, all input preference XDM configuration files will be based on this BasePath, which can solve the problem of the input preference configuration file name being too long.
|
116
|
+
|
117
|
+
**--project**
|
118
|
+
|
119
|
+
> The project name will be generate in the AUTOSAR build project.
|
120
|
+
>
|
121
|
+
> It is meaningless if you choose to generate ARXML file list text file.
|
122
|
+
|
123
|
+
**--env**
|
124
|
+
|
125
|
+
> Replace the variable definition of ${env_var:xxx} which is defined in the EB preference XDM file.
|
126
|
+
|
127
|
+
### 3.3.2. Example
|
128
|
+
|
129
|
+
**To generate the ARXML file list:**
|
130
|
+
|
131
|
+
* Base path: c:/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte
|
132
|
+
* INPUT:
|
133
|
+
* c:/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/.prefs/pref_imp_exp_Imp_System.xdm
|
134
|
+
* OUTPUT: output.lst
|
135
|
+
|
136
|
+
```bash
|
137
|
+
PrefSystemImporter --base-path c:/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte .prefs/pref_imp_exp_Imp_System.xdm output.lst
|
138
|
+
```
|
139
|
+
|
140
|
+
**To generate the AUTOSAR builder project:**
|
141
|
+
|
142
|
+
All ARXML files in the .project file will use relative path names, so it is recommended to run PrefSystemImporter in the directory where the .project is located.
|
143
|
+
|
144
|
+
* Base Path: c:/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte
|
145
|
+
* INPUTs:
|
146
|
+
* c:/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/.prefs/pref_imp_exp_Bswm_rte.xdm
|
147
|
+
* c:/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/.prefs/pref_imp_exp_Imp_System.xdm
|
148
|
+
* OUTPUT
|
149
|
+
* c:/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/ab_project/.project
|
150
|
+
* Project Name: SimpleDemoRte
|
151
|
+
|
152
|
+
```bash
|
153
|
+
cd c:/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/ab_project
|
154
|
+
PrefSystemImporter --base-path c:/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte --ab-project --project SimpleDemoRte .prefs/pref_imp_exp_Bswm_rte.xdm .prefs/pref_imp_exp_Imp_System.xdm .project
|
155
|
+
```
|
156
|
+
|
157
|
+
# 4. Change History
|
158
|
+
|
159
|
+
**Version 0.8.0**
|
160
|
+
|
161
|
+
1. Create the basic model for EB xdm. (Issue #1)
|
162
|
+
2. Support to extract the Os Tasks/Isrs from EB xdm and store them in the excel files. (Issue #1)
|
163
|
+
|
164
|
+
**Version 1.0.1**
|
165
|
+
|
166
|
+
1. Change the attribute to start with lowercase
|
167
|
+
2. *read_ref_value* and *read_optional_ref_value* method returns EcucRefType.
|
168
|
+
3. Read the OsScheduleTable and export to excel
|
169
|
+
4. Read the OsCounter and export to excel
|
170
|
+
|
171
|
+
**Version 1.0.2**
|
172
|
+
|
173
|
+
1. Fix the setOsAlarmCallbackName bug
|
174
|
+
|
175
|
+
**Version 1.0.3**
|
176
|
+
|
177
|
+
1. Generate the System import file list based on EB preference Xdm.
|
178
|
+
2. Add the support to read OsTaskAutostart element.
|
179
|
+
3. Add the support to read OsTaskType element.
|
180
|
+
|
181
|
+
**Version 1.1.1**
|
182
|
+
|
183
|
+
1. Add the support to append SystemMod/EcuExtract.arxml into list automatically for PrefSystemImporter.
|
184
|
+
|
185
|
+
**Version 1.1.2**
|
186
|
+
|
187
|
+
1. Read the OsAppTaskRef from OsApplication.
|
188
|
+
|
189
|
+
**Version 1.1.3**
|
190
|
+
|
191
|
+
1. Support to read Isr Priority and Vector for R52+ core.
|
192
|
+
2. Export the Isr Priority and Vector to Excel.
|
193
|
+
3. Read the OsAppResourceRef, OsAppIsrRef from OsApplication.
|
194
|
+
|
195
|
+
**Version 1.1.4**
|
196
|
+
|
197
|
+
1. Fix the incorrect attribute of osTaskAutostart.
|
198
|
+
2. Add the isOsTaskAutostart method to get the enabled flag of osTaskAutostart.
|
199
|
+
3. Add the flake8 change rules.
|
200
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
eb_model/__init__.py,sha256=oMw5xoAS-lHLxufQSlBIXhGZZMcPmwGFA3PYpTwaQTU,92
|
2
|
+
eb_model/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
eb_model/cli/os_xdm_2_xls_cli.py,sha256=zUnxJ4uHWRSjMmpSK5hXRAzVt-_YGEyiMXrexnJSk6g,1970
|
4
|
+
eb_model/cli/pref_system_importer_cli.py,sha256=Cra-rVpgxruLLyWHRdYAgbwfcHVPV2L8Jk6ck0v4lJU,3361
|
5
|
+
eb_model/cli/rte_xdm_2_xls_cli.py,sha256=83uzE2Vk0h267gWxF9mnWN3Bh69RJpYyKULFXpxTByY,2127
|
6
|
+
eb_model/models/__init__.py,sha256=7_WxCwRdVavLbPzepHWNar3O-rOxhLwmVYWd2pqm2kI,124
|
7
|
+
eb_model/models/abstract.py,sha256=uavSXSfKeM2JvOLmpBh43WlYLQ5fCk_F99tf9YVHDkU,3833
|
8
|
+
eb_model/models/eb_doc.py,sha256=uVV8Bh7fJtaILRVIGmQW3XnK29uam0tEhphKN3P-MKU,2575
|
9
|
+
eb_model/models/eclipse_project.py,sha256=W6ovTd3SMnlmWm_efVBZqTUGQebF0hJocsTqMlQ7_XQ,169
|
10
|
+
eb_model/models/importer_xdm.py,sha256=B2Vqw5nkmzFgaGSpZlmTVFWZ88rTMqD8Iryytg4kUnk,4249
|
11
|
+
eb_model/models/os_xdm.py,sha256=lpUibY_qJ1hSLjS_j6d0UoQd4jJWWUF9jaMISA91wdo,33755
|
12
|
+
eb_model/models/rte_xdm.py,sha256=otYbFuIKsFl0Jlqm18fRqroTi1fUEGw2HPhGZb7sAQ0,21060
|
13
|
+
eb_model/parser/__init__.py,sha256=7VOmPr4dng_TrOyDZFu2_s3r0BJZQGiOUxALMY8EnqI,170
|
14
|
+
eb_model/parser/eb_parser.py,sha256=_5sUl2pMt1SchHvrLOhU2axqa3FmKTWElSB79taz0O4,8188
|
15
|
+
eb_model/parser/eb_parser_factory.py,sha256=zqsqq52uImU4-WcS5dvHfhM95hiEPAGRtNzVik8i8wc,971
|
16
|
+
eb_model/parser/os_xdm_parser.py,sha256=folWFp-4HdxIBmEzrBW4LA3ZQRAYygI30sZbks6rOnQ,10510
|
17
|
+
eb_model/parser/pref_xdm_parser.py,sha256=EjfR4vrnjRVLw_7wyPmMYlBj6lPXZbBZMEdWlYPj3uI,1539
|
18
|
+
eb_model/parser/rte_xdm_parser.py,sha256=plUue0c4ejreE9w71_mT0JNzGSClf30cXhfC2NalrII,5471
|
19
|
+
eb_model/reporter/__init__.py,sha256=H8D_23UwJi1Ph6yjBfZhxWVbu9ci5_O4471gqXGiZCM,36
|
20
|
+
eb_model/reporter/markdown.py,sha256=NhcJOFQ_BVbkgGe66uAT7KUPIchWU4kfVMtMLQtbK-w,1647
|
21
|
+
eb_model/reporter/excel_reporter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
|
+
eb_model/reporter/excel_reporter/abstract.py,sha256=PfIoiKNKy1eRJBABln7rADkSdwWzS03Vs03jBYM-_5Y,1622
|
23
|
+
eb_model/reporter/excel_reporter/os_xdm.py,sha256=MG6-6qi7Dh1XXv4CR2I-iQpOvypso0dlfXt_ZQ3lO7I,6406
|
24
|
+
eb_model/reporter/excel_reporter/rte_xdm.py,sha256=OHuVPUV7xCdDzxELyXi766YJ6GejTHrzPrlAUBqexIw,3937
|
25
|
+
eb_model/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
26
|
+
eb_model/tests/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
|
+
eb_model/tests/models/test_eb_model.py,sha256=3fpIHhzQlf9KZjm4fZxcSTT4Zio6YhTrcn9UBvlhOfo,1632
|
28
|
+
eb_model/tests/models/test_ecuc_container.py,sha256=lZmtXwPMz9T52WFduTgFy16fO2agjSW-Rl2cVypM86s,722
|
29
|
+
eb_model/tests/models/test_importer_xdm.py,sha256=F80kO77jeyfCkLPRgRLjEj3UPcrACimR5LhBhFgX_m4,3372
|
30
|
+
eb_model/writer/__init__.py,sha256=CXvQAsNV1OvYClkHdKCG7Q300OVBzcl2TmoD68MyQOs,95
|
31
|
+
eb_model/writer/project_writer.py,sha256=9BQU1CJAktVxFvQk89Pj4IbizTJXnlQidt4eX_CIFXU,2800
|
32
|
+
eb_model/writer/text_writer.py,sha256=7d4_PUTJk5Y6S_EQflAH3ACDnUw9VwJzP90GFDh0n0I,991
|
33
|
+
py_eb_model-1.1.4.dist-info/LICENSE,sha256=I52rGS7W1IwAmYCUfqTpDaSHoFAdt7grcNiBhk-Z3eI,1088
|
34
|
+
py_eb_model-1.1.4.dist-info/METADATA,sha256=dUriywto0TN8xJ-oWR-6ecZooharZ2ug4Ra5_N14w4U,6314
|
35
|
+
py_eb_model-1.1.4.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
36
|
+
py_eb_model-1.1.4.dist-info/entry_points.txt,sha256=yDLH9wnJ5Fp7ImgyFRSnr3mU6nvaenuKZnbe2rgs8Mk,183
|
37
|
+
py_eb_model-1.1.4.dist-info/top_level.txt,sha256=DGBNh6YW_x4RF_UoLKW3cKqb2SLnmfuEIZlkTewR66A,9
|
38
|
+
py_eb_model-1.1.4.dist-info/RECORD,,
|