cannect 1.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.
- cannect/__init__.py +30 -0
- cannect/api/__init__.py +0 -0
- cannect/config.py +114 -0
- cannect/core/__init__.py +0 -0
- cannect/core/ascet/__init__.py +3 -0
- cannect/core/ascet/amd.py +698 -0
- cannect/core/ascet/formula.py +33 -0
- cannect/core/ascet/oid.py +29 -0
- cannect/core/ascet/ws.py +154 -0
- cannect/core/can/__init__.py +2 -0
- cannect/core/can/ascet/__init__.py +3 -0
- cannect/core/can/ascet/_db2code.py +344 -0
- cannect/core/can/ascet/_db2elem.py +399 -0
- cannect/core/can/ascet/comdef.py +256 -0
- cannect/core/can/ascet/comrx.py +139 -0
- cannect/core/can/ascet/diag.py +691 -0
- cannect/core/can/db/__init__.py +4 -0
- cannect/core/can/db/reader.py +148 -0
- cannect/core/can/db/schema.py +269 -0
- cannect/core/can/db/specification/__init__.py +0 -0
- cannect/core/can/db/specification/message.py +230 -0
- cannect/core/can/db/specification/styles.py +81 -0
- cannect/core/can/db/specification/wrapper.py +161 -0
- cannect/core/can/db/vcs.py +104 -0
- cannect/core/can/rule.py +229 -0
- cannect/core/can/testcase/__init__.py +0 -0
- cannect/core/can/testcase/unitcase/__init__.py +0 -0
- cannect/core/can/testcase/unitcase/asw2can.py +48 -0
- cannect/core/can/testcase/unitcase/decode.py +63 -0
- cannect/core/can/testcase/unitcase/diagnosis.py +479 -0
- cannect/core/can/testcase/unitcase/encode.py +60 -0
- cannect/core/ir/__init__.py +2 -0
- cannect/core/ir/changehistory.py +310 -0
- cannect/core/ir/delivereables.py +71 -0
- cannect/core/ir/diff.py +97 -0
- cannect/core/ir/ir.py +581 -0
- cannect/core/ir/sdd.py +148 -0
- cannect/core/mdf.py +66 -0
- cannect/core/subversion.py +136 -0
- cannect/core/testcase/__init__.py +3 -0
- cannect/core/testcase/plotter.py +181 -0
- cannect/core/testcase/style.py +981 -0
- cannect/core/testcase/testcase.py +160 -0
- cannect/core/testcase/unitcase.py +227 -0
- cannect/errors.py +20 -0
- cannect/schema/__init__.py +5 -0
- cannect/schema/candb.py +226 -0
- cannect/schema/datadictionary.py +60 -0
- cannect/utils/__init__.py +3 -0
- cannect/utils/excel.py +29 -0
- cannect/utils/logger.py +81 -0
- cannect/utils/ppt.py +236 -0
- cannect/utils/tools.py +207 -0
- cannect-1.0.0.dist-info/METADATA +214 -0
- cannect-1.0.0.dist-info/RECORD +58 -0
- cannect-1.0.0.dist-info/WHEEL +5 -0
- cannect-1.0.0.dist-info/licenses/LICENSE +21 -0
- cannect-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
from cannect.config import env
|
|
2
|
+
from cannect.core.ascet.amd import Amd
|
|
3
|
+
from cannect.core.can.ascet._db2code import MessageCode
|
|
4
|
+
from cannect.core.can.db.reader import CANDBReader
|
|
5
|
+
from cannect.utils.logger import Logger
|
|
6
|
+
from cannect.utils import tools
|
|
7
|
+
|
|
8
|
+
from typing import Dict
|
|
9
|
+
from pandas import DataFrame
|
|
10
|
+
import os
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ComRx:
|
|
14
|
+
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
db:CANDBReader,
|
|
18
|
+
engine_spec:str,
|
|
19
|
+
base_model:str='',
|
|
20
|
+
):
|
|
21
|
+
exclude_ecus = ["EMS", "CVVD", "MHSG", "NOx"]
|
|
22
|
+
if engine_spec == "ICE":
|
|
23
|
+
exclude_ecus += ["BMS", "LDC"]
|
|
24
|
+
db = db[~db["ECU"].isin(exclude_ecus)]
|
|
25
|
+
if not db.is_developer_mode():
|
|
26
|
+
db = db.to_developer_mode(engine_spec)
|
|
27
|
+
|
|
28
|
+
if base_model:
|
|
29
|
+
name = os.path.basename(base_model).split(".")[0]
|
|
30
|
+
else:
|
|
31
|
+
name = f"ComRx{'_HEV' if engine_spec == 'HEV' else ''}"
|
|
32
|
+
base_model = env.SVN_MODEL / rf'HNB_GASOLINE/_29_CommunicationVehicle/StandardDB/MessageInterface/MessageReceive/{name}/{name}.zip'
|
|
33
|
+
host = name.replace("Rx", "Def")
|
|
34
|
+
|
|
35
|
+
# 공용 속성 생성
|
|
36
|
+
self.db = db
|
|
37
|
+
self.name = name
|
|
38
|
+
|
|
39
|
+
# 각 amd의 IO 생성
|
|
40
|
+
amd = Amd(base_model)
|
|
41
|
+
self.main = amd.main
|
|
42
|
+
self.impl = amd.impl
|
|
43
|
+
self.data = amd.data
|
|
44
|
+
self.spec = spec = amd.spec
|
|
45
|
+
|
|
46
|
+
(env.DOWNLOADS / name).mkdir(parents=True, exist_ok=True)
|
|
47
|
+
self.logger = logger = Logger(env.DOWNLOADS / rf'{name}/log.txt', clean_record=True)
|
|
48
|
+
logger.info(f"%{name} MODEL GENERATION")
|
|
49
|
+
logger.info(f">>> Engine Spec : {engine_spec}")
|
|
50
|
+
logger.info(f">>> Base Model : {tools.path_abbreviate(base_model)}")
|
|
51
|
+
logger.info(f">>> DB Revision : {db.revision}")
|
|
52
|
+
|
|
53
|
+
prev = {
|
|
54
|
+
method.attrib['methodName']: method.find('CodeBlock').text
|
|
55
|
+
for method in list(spec.strictFind('CodeVariant', target="G_HMCEMS").find('MethodBodies'))
|
|
56
|
+
}
|
|
57
|
+
curr = self.code_generation(host)
|
|
58
|
+
self.spec_update(curr)
|
|
59
|
+
|
|
60
|
+
summary_prev = MessageCode.method_contains_message(prev)
|
|
61
|
+
summary_curr = MessageCode.method_contains_message(curr)
|
|
62
|
+
deleted = list(set(summary_prev.index) - set(summary_curr.index))
|
|
63
|
+
added = list(set(summary_curr.index) - set(summary_prev.index))
|
|
64
|
+
desc = DataFrame(
|
|
65
|
+
data={
|
|
66
|
+
("Message", "Total"): [len(summary_prev), len(summary_curr)],
|
|
67
|
+
("Message", "Added"): ["-", len(added)],
|
|
68
|
+
("Message", "Deleted"): [len(deleted), "-"]
|
|
69
|
+
},
|
|
70
|
+
index=['Base Model', ' New Model']
|
|
71
|
+
)
|
|
72
|
+
self.logger.info(">>> Summary\n" + \
|
|
73
|
+
desc.to_string() + '\n' + \
|
|
74
|
+
f'* Added: {", ".join(added)}' + '\n' + \
|
|
75
|
+
f'* Deleted: {", ".join(deleted)}')
|
|
76
|
+
return
|
|
77
|
+
|
|
78
|
+
def code_generation(self, host:str) -> Dict[str, str]:
|
|
79
|
+
context = {}
|
|
80
|
+
for name, obj in self.db.messages.items():
|
|
81
|
+
period = 40 if "E" in obj["Send Type"] else obj["Cycle Time"]
|
|
82
|
+
key = f"_{period}msPreRunPost"
|
|
83
|
+
if not key in context:
|
|
84
|
+
context[key] = ""
|
|
85
|
+
code = MessageCode(obj)
|
|
86
|
+
context[key] += code.to_rx(host)
|
|
87
|
+
|
|
88
|
+
if obj["WakeUp"]:
|
|
89
|
+
key = f"_{period}msWakeUp"
|
|
90
|
+
if not key in context:
|
|
91
|
+
context[key] = ""
|
|
92
|
+
context[key] += code.to_rx(host)
|
|
93
|
+
return context
|
|
94
|
+
|
|
95
|
+
def spec_update(self, curr:Dict[str, str]):
|
|
96
|
+
parent = self.spec.strictFind('CodeVariant', target="G_HMCEMS").find('MethodBodies')
|
|
97
|
+
for method in list(parent):
|
|
98
|
+
name = method.attrib['methodName']
|
|
99
|
+
method.find('CodeBlock').text = curr.get(name, "")
|
|
100
|
+
return
|
|
101
|
+
|
|
102
|
+
def export(self):
|
|
103
|
+
self.main.export_to_downloads()
|
|
104
|
+
self.impl.export_to_downloads()
|
|
105
|
+
self.data.export_to_downloads()
|
|
106
|
+
self.spec.export_to_downloads()
|
|
107
|
+
return
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
if __name__ == "__main__":
|
|
111
|
+
from pandas import set_option
|
|
112
|
+
set_option('display.expand_frame_repr', False)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
db = CANDBReader()
|
|
116
|
+
# db = CANDBReader(env.SVN_CANDB / rf'dev/G-PROJECT_KEFICO-EMS_CANFD_r21676@01.json')
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
engine_spec = "HEV"
|
|
120
|
+
|
|
121
|
+
# DB CUSTOMIZE ------------------------------------------------------
|
|
122
|
+
# db = db[db["Status"] != "TSW"] # TSW 제외
|
|
123
|
+
# db = db[~db["Requirement ID"].isin(["VCDM CR10777888"])] # 특정 CR 제외
|
|
124
|
+
# db = db[~db["Required Date"].isin(["2024-08-27"])] # 특정 일자 제외
|
|
125
|
+
# db = db[~db["Message"].isin([ # 특정 메시지 제외
|
|
126
|
+
# "L_H8L_01_10ms",
|
|
127
|
+
# "H8L_01_10ms",
|
|
128
|
+
# "H8L_02_10ms",
|
|
129
|
+
# ])]
|
|
130
|
+
# db.revision = "TEST SW" # 공식SW는 주석 처리
|
|
131
|
+
# DB CUSTOMIZE END --------------------------------------------------
|
|
132
|
+
|
|
133
|
+
model = ComRx(
|
|
134
|
+
db=db,
|
|
135
|
+
engine_spec=engine_spec,
|
|
136
|
+
# base_model="",
|
|
137
|
+
# base_model=env.ASCET / f"Export/ComRx_G/ComRx_G.main.amd"
|
|
138
|
+
)
|
|
139
|
+
model.export()
|