cannect 1.0.2__py3-none-any.whl → 1.0.3__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/config.py +2 -3
- cannect/core/can/ascet/comdef.py +15 -15
- cannect/core/can/ascet/comrx.py +4 -4
- cannect/core/can/ascet/diag.py +26 -26
- cannect/core/can/db/_dbc.py +394 -0
- cannect/core/can/db/reader.py +56 -10
- cannect/core/can/db/specification/wrapper.py +37 -38
- cannect/core/can/db/vcs.py +10 -3
- cannect/core/ir/changehistory.py +118 -144
- cannect/core/ir/diff.py +6 -4
- cannect/core/ir/ir.py +40 -38
- cannect/core/subversion.py +25 -0
- cannect/core/testcase/unitcase.py +1 -1
- cannect/errors.py +6 -0
- cannect/utils/ppt.py +1 -4
- cannect/utils/tools.py +4 -1
- cannect-1.0.3.dist-info/METADATA +651 -0
- {cannect-1.0.2.dist-info → cannect-1.0.3.dist-info}/RECORD +21 -20
- cannect-1.0.2.dist-info/METADATA +0 -214
- {cannect-1.0.2.dist-info → cannect-1.0.3.dist-info}/WHEEL +0 -0
- {cannect-1.0.2.dist-info → cannect-1.0.3.dist-info}/licenses/LICENSE +0 -0
- {cannect-1.0.2.dist-info → cannect-1.0.3.dist-info}/top_level.txt +0 -0
cannect/config.py
CHANGED
|
@@ -31,7 +31,7 @@ E = ENV = env = DataDictionary(**os.environ)
|
|
|
31
31
|
E.COMPANY = "HYUNDAI KEFICO Co.,Ltd."
|
|
32
32
|
E.COPYRIGHT = f'Copyright {E.COMPANY} 2020-{datetime.now().year}. All rights reserved.'
|
|
33
33
|
E.DIVISION = "ELECTRIFICATION PT CONTROL TEAM 1"
|
|
34
|
-
E.
|
|
34
|
+
E.USER = __namespace__.get(E.USERNAME, '알 수 없음')
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
def mount(svn_path=None):
|
|
@@ -79,12 +79,11 @@ def mount(svn_path=None):
|
|
|
79
79
|
if key.startswith("SVN"):
|
|
80
80
|
if not path.exists():
|
|
81
81
|
raise InternalServerError(f"{{{path}}} NOT EXIST IN {E.COMPANY} SERVER")
|
|
82
|
-
|
|
83
82
|
return
|
|
84
83
|
|
|
85
84
|
|
|
86
85
|
if __name__ == "__main__":
|
|
87
|
-
print(env.
|
|
86
|
+
print(env.USER)
|
|
88
87
|
print(env.TEMP)
|
|
89
88
|
print(env.USERPROFILE / 'Downloads')
|
|
90
89
|
print(env.SVN)
|
cannect/core/can/ascet/comdef.py
CHANGED
|
@@ -58,7 +58,7 @@ class ComDef:
|
|
|
58
58
|
변경 전 모델 요소 수집
|
|
59
59
|
"""
|
|
60
60
|
logger.info(">>> Collecting Base Model Properties... 0.01s")
|
|
61
|
-
prev = self.
|
|
61
|
+
prev = self._collect_properties()
|
|
62
62
|
oids = dict(zip(prev.Elements['name'], prev.Elements.index))
|
|
63
63
|
oids.update(dict(zip(prev.MethodSignature['name'], prev.MethodSignature.index)))
|
|
64
64
|
self.prev = prev
|
|
@@ -79,15 +79,15 @@ class ComDef:
|
|
|
79
79
|
|
|
80
80
|
def generate(self):
|
|
81
81
|
self.main.find('Component/Comment').text = _db2code.INFO(self.db.revision)
|
|
82
|
-
self.
|
|
83
|
-
self.
|
|
84
|
-
self.
|
|
85
|
-
self.
|
|
86
|
-
self.
|
|
87
|
-
self.
|
|
88
|
-
self.
|
|
89
|
-
|
|
90
|
-
curr = self.
|
|
82
|
+
self._define_elements('MethodSignature')
|
|
83
|
+
self._define_elements('Element')
|
|
84
|
+
self._define_elements('ImplementationEntry')
|
|
85
|
+
self._define_elements('DataEntry')
|
|
86
|
+
self._define_elements('HeaderBlock')
|
|
87
|
+
self._define_elements('MethodBody')
|
|
88
|
+
self._export()
|
|
89
|
+
|
|
90
|
+
curr = self._collect_properties()
|
|
91
91
|
deleted = list(set(self.prev.Elements['name']) - set(curr.Elements['name']))
|
|
92
92
|
added = list(set(curr.Elements['name']) - set(self.prev.Elements['name']))
|
|
93
93
|
desc = DataFrame(
|
|
@@ -105,7 +105,7 @@ class ComDef:
|
|
|
105
105
|
f'* Deleted: {", ".join(deleted)}')
|
|
106
106
|
return
|
|
107
107
|
|
|
108
|
-
def
|
|
108
|
+
def _collect_properties(self) -> DataDictionary:
|
|
109
109
|
mainE = self.main.dataframe('Element').set_index(keys='OID').copy()
|
|
110
110
|
implE = self.impl.dataframe('ImplementationEntry').set_index(keys='elementOID').copy()
|
|
111
111
|
dataE = self.data.dataframe('DataEntry').set_index(keys='elementOID').copy()
|
|
@@ -118,7 +118,7 @@ class ComDef:
|
|
|
118
118
|
Elements=mainE.join(implE).join(dataE)
|
|
119
119
|
)
|
|
120
120
|
|
|
121
|
-
def
|
|
121
|
+
def _find_parents(self, tag:str) -> Union[Any, Tuple]:
|
|
122
122
|
if tag == "MethodSignature":
|
|
123
123
|
return self.main.find('Component/MethodSignatures'), None
|
|
124
124
|
if tag == "Element":
|
|
@@ -135,7 +135,7 @@ class ComDef:
|
|
|
135
135
|
self.spec.strictFind('CodeVariant', target="PC").find('HeaderBlock')
|
|
136
136
|
raise AttributeError
|
|
137
137
|
|
|
138
|
-
def
|
|
138
|
+
def _define_elements(self, tag:str):
|
|
139
139
|
"""
|
|
140
140
|
{tag}에 해당하는 AmdIO를 찾는다.
|
|
141
141
|
{tag}에 해당하는 AmdIO의 부모 tag를 찾는다.
|
|
@@ -145,7 +145,7 @@ class ComDef:
|
|
|
145
145
|
:param tag:
|
|
146
146
|
:return:
|
|
147
147
|
"""
|
|
148
|
-
pGlob, pLoc = self.
|
|
148
|
+
pGlob, pLoc = self._find_parents(tag)
|
|
149
149
|
for child in list(pGlob):
|
|
150
150
|
pGlob.remove(child)
|
|
151
151
|
if pLoc is not None:
|
|
@@ -204,7 +204,7 @@ class ComDef:
|
|
|
204
204
|
parent.append(getattr(_db2elem.crcClassElement(8, self.oids), tag))
|
|
205
205
|
return
|
|
206
206
|
|
|
207
|
-
def
|
|
207
|
+
def _export(self):
|
|
208
208
|
self.main.export_to_downloads()
|
|
209
209
|
self.impl.export_to_downloads()
|
|
210
210
|
self.data.export_to_downloads()
|
cannect/core/can/ascet/comrx.py
CHANGED
|
@@ -55,8 +55,8 @@ class ComRx:
|
|
|
55
55
|
method.attrib['methodName']: method.find('CodeBlock').text
|
|
56
56
|
for method in list(spec.strictFind('CodeVariant', target="G_HMCEMS").find('MethodBodies'))
|
|
57
57
|
}
|
|
58
|
-
curr = self.
|
|
59
|
-
self.
|
|
58
|
+
curr = self._code_generation(host)
|
|
59
|
+
self._spec_update(curr)
|
|
60
60
|
|
|
61
61
|
summary_prev = MessageCode.method_contains_message(prev)
|
|
62
62
|
summary_curr = MessageCode.method_contains_message(curr)
|
|
@@ -76,7 +76,7 @@ class ComRx:
|
|
|
76
76
|
f'* Deleted: {", ".join(deleted)}')
|
|
77
77
|
return
|
|
78
78
|
|
|
79
|
-
def
|
|
79
|
+
def _code_generation(self, host:str) -> Dict[str, str]:
|
|
80
80
|
context = {}
|
|
81
81
|
for name, obj in self.db.messages.items():
|
|
82
82
|
period = 40 if "E" in obj["Send Type"] else obj["Cycle Time"]
|
|
@@ -93,7 +93,7 @@ class ComRx:
|
|
|
93
93
|
context[key] += code.to_rx(host)
|
|
94
94
|
return context
|
|
95
95
|
|
|
96
|
-
def
|
|
96
|
+
def _spec_update(self, curr:Dict[str, str]):
|
|
97
97
|
parent = self.spec.strictFind('CodeVariant', target="G_HMCEMS").find('MethodBodies')
|
|
98
98
|
for method in list(parent):
|
|
99
99
|
name = method.attrib['methodName']
|
cannect/core/can/ascet/diag.py
CHANGED
|
@@ -5,6 +5,7 @@ from cannect.core.ascet.ws import WorkspaceIO
|
|
|
5
5
|
from cannect.core.can.db.reader import CANDBReader
|
|
6
6
|
from cannect.core.can.ascet._db2code import INFO
|
|
7
7
|
from cannect.core.can.rule import naming
|
|
8
|
+
from cannect.errors import CANDBMessageNotFound
|
|
8
9
|
from cannect.utils import tools
|
|
9
10
|
from cannect.utils.logger import Logger
|
|
10
11
|
|
|
@@ -17,26 +18,25 @@ from cannect.utils.tools import path_abbreviate
|
|
|
17
18
|
|
|
18
19
|
class CANDiag(Amd):
|
|
19
20
|
|
|
20
|
-
def __init__(self, db: CANDBReader,
|
|
21
|
+
def __init__(self, db: CANDBReader, base_model: str='', *messages):
|
|
21
22
|
|
|
22
23
|
for message in messages:
|
|
23
24
|
if not message in db.messages:
|
|
24
|
-
raise
|
|
25
|
+
raise CANDBMessageNotFound(f'{message} NOT EXIST IN CAN DB.')
|
|
25
26
|
|
|
26
27
|
template = env.SVN_CAN / "CAN_Model/_29_CommunicationVehicle/StandardDB/StandardTemplate/CANDiagTmplt/CANDiagTmplt.main.amd"
|
|
27
28
|
super().__init__(str(template))
|
|
28
29
|
|
|
29
|
-
self.ws = WorkspaceIO()
|
|
30
|
+
self.ws = ws = WorkspaceIO()
|
|
31
|
+
if not os.path.isfile(str(base_model)):
|
|
32
|
+
base_model = ws[base_model]
|
|
33
|
+
base = Amd(base_model)
|
|
30
34
|
|
|
31
35
|
# LOGGER 생성
|
|
32
|
-
base = Amd(src)
|
|
33
|
-
|
|
34
36
|
self.logger = Logger()
|
|
35
37
|
self.logger(f"%{{{base.name}}} MODEL GENERATION")
|
|
36
38
|
self.logger(f">>> DB VERSION: {db.revision}")
|
|
37
|
-
self.logger(f">>> BASE MODEL: {tools.path_abbreviate(
|
|
38
|
-
if "revision" in kwargs:
|
|
39
|
-
self.logger(f">>> MODEL REVISION: {kwargs['revision']}")
|
|
39
|
+
self.logger(f">>> BASE MODEL: {tools.path_abbreviate(base_model)}")
|
|
40
40
|
|
|
41
41
|
# @self.n : 메시지 순번
|
|
42
42
|
# @self.db : CAN DB 객체
|
|
@@ -75,7 +75,7 @@ class CANDiag(Amd):
|
|
|
75
75
|
cal[elem.get('name')] = list(data.iter('Numeric'))[0].get('value')
|
|
76
76
|
return tx, hw, cal
|
|
77
77
|
|
|
78
|
-
def
|
|
78
|
+
def _copy_from_basemodel(self, base: Amd):
|
|
79
79
|
"""
|
|
80
80
|
BASE 모델의 기본 정보들을 CANDiag으로 복사
|
|
81
81
|
"""
|
|
@@ -200,7 +200,7 @@ class CANDiag(Amd):
|
|
|
200
200
|
self.spec.find('Specification/BlockDiagramSpecification/DiagramElements').append(breaker)
|
|
201
201
|
return log
|
|
202
202
|
|
|
203
|
-
def
|
|
203
|
+
def _copy_common(self):
|
|
204
204
|
pascal = self.tx.lower().capitalize()
|
|
205
205
|
if self.tx.lower() == "nox":
|
|
206
206
|
pascal = "NOx"
|
|
@@ -231,7 +231,7 @@ class CANDiag(Amd):
|
|
|
231
231
|
.replace("__TX_UPPER__", self.tx.upper())
|
|
232
232
|
return
|
|
233
233
|
|
|
234
|
-
def
|
|
234
|
+
def _copy_by_message(self, n:int, message:str):
|
|
235
235
|
log = ''
|
|
236
236
|
|
|
237
237
|
db = self.db.messages[message]
|
|
@@ -423,7 +423,7 @@ CHANNEL : {db[f'{self.hw} Channel']}-CAN
|
|
|
423
423
|
self.spec.find('Specification/BlockDiagramSpecification/DiagramElements').append(diagram)
|
|
424
424
|
return log
|
|
425
425
|
|
|
426
|
-
def
|
|
426
|
+
def _clear(self):
|
|
427
427
|
# CANDiag Hierarchy 제거
|
|
428
428
|
removals = []
|
|
429
429
|
for elem in self.spec.iter():
|
|
@@ -481,7 +481,7 @@ CHANNEL : {db[f'{self.hw} Channel']}-CAN
|
|
|
481
481
|
data.remove(elem)
|
|
482
482
|
return
|
|
483
483
|
|
|
484
|
-
def
|
|
484
|
+
def _copy_dsm(self):
|
|
485
485
|
fid_md = Amd(self.ws["Fid_Typ.zip"])
|
|
486
486
|
fid = fid_md.impl.dataframe("ImplementationSet", depth="shallow").set_index("name")["OID"]
|
|
487
487
|
deve_md = Amd(self.ws["DEve_Typ.zip"])
|
|
@@ -530,14 +530,14 @@ CHANNEL : {db[f'{self.hw} Channel']}-CAN
|
|
|
530
530
|
})
|
|
531
531
|
return
|
|
532
532
|
|
|
533
|
-
def
|
|
533
|
+
def _copy_data(self):
|
|
534
534
|
for data in self.data.iter('DataEntry'):
|
|
535
535
|
if data.attrib.get('elementName', '') in self.cal:
|
|
536
536
|
numeric = list(data.iter('Numeric'))[0]
|
|
537
537
|
numeric.attrib['value'] = self.cal[data.attrib.get('elementName', '')]
|
|
538
538
|
return
|
|
539
539
|
|
|
540
|
-
def
|
|
540
|
+
def _exception(self):
|
|
541
541
|
|
|
542
542
|
def _change_attr(element_name: str, **change_attr):
|
|
543
543
|
for elem in self.main.iter('Element'):
|
|
@@ -592,29 +592,29 @@ CHANNEL : {db[f'{self.hw} Channel']}-CAN
|
|
|
592
592
|
|
|
593
593
|
# BASE 모델의 기본 정보들을 CANDiag으로 복사
|
|
594
594
|
self.logger('>>> COPY BASE MODEL TO TEMPLATE')
|
|
595
|
-
log = self.
|
|
595
|
+
log = self._copy_from_basemodel(self.base)
|
|
596
596
|
if log: self.logger(f'>>> ... {log}')
|
|
597
597
|
|
|
598
598
|
# 공용 변수 Naming Rule 적용
|
|
599
|
-
self.
|
|
599
|
+
self._copy_common()
|
|
600
600
|
|
|
601
601
|
# 메시지별 템플릿 적용
|
|
602
602
|
self.logger(f'>>> GENERATE HIERARCHY BY MESSAGES N={len(self.messages)}')
|
|
603
603
|
for n, message in enumerate(self.messages, start=1):
|
|
604
|
-
log = self.
|
|
604
|
+
log = self._copy_by_message(n, message)
|
|
605
605
|
self.logger(f'>>> ... [{n} / {len(self.messages)}] {message}: {log}')
|
|
606
606
|
|
|
607
607
|
# 템플릿 삭제
|
|
608
|
-
self.
|
|
608
|
+
self._clear()
|
|
609
609
|
|
|
610
610
|
self.logger(f'>>> COPY DSM LIBRARY IMPLEMENTATION')
|
|
611
|
-
self.
|
|
611
|
+
self._copy_dsm()
|
|
612
612
|
|
|
613
613
|
self.logger(f'>>> COPY CALIBRATION DATA FROM BASE MODEL')
|
|
614
|
-
self.
|
|
614
|
+
self._copy_data()
|
|
615
615
|
|
|
616
616
|
self.logger(f'>>> RUN EXCEPTION HANDLING')
|
|
617
|
-
self.
|
|
617
|
+
self._exception()
|
|
618
618
|
|
|
619
619
|
# 수동 예외처리 로그
|
|
620
620
|
for instruction in self.manual_instruction:
|
|
@@ -640,7 +640,6 @@ CHANNEL : {db[f'{self.hw} Channel']}-CAN
|
|
|
640
640
|
|
|
641
641
|
|
|
642
642
|
if __name__ == "__main__":
|
|
643
|
-
from cannect.core.ascet.ws import WorkspaceIO
|
|
644
643
|
from pandas import set_option
|
|
645
644
|
set_option('display.expand_frame_repr', False)
|
|
646
645
|
|
|
@@ -682,10 +681,11 @@ if __name__ == "__main__":
|
|
|
682
681
|
"CanNOXD": ["Main_Status_Rear", "O2_Rear"]
|
|
683
682
|
}
|
|
684
683
|
|
|
685
|
-
proj = WorkspaceIO()
|
|
686
|
-
data = CANDBReader()
|
|
684
|
+
# proj = WorkspaceIO()
|
|
685
|
+
data = CANDBReader()
|
|
686
|
+
# data = data.to_developer_mode("HEV")
|
|
687
687
|
|
|
688
|
-
template = CANDiag(data,
|
|
688
|
+
template = CANDiag(data, "CanFDMCUD_HEV", "MCU_01_10ms", "MCU_02_10ms", "MCU_03_100ms")
|
|
689
689
|
template.generate()
|
|
690
690
|
|
|
691
691
|
|