Skip to content

Commit 15b3dcd

Browse files
committed
Included short FileChecker class to check model input files
1 parent 647a7d0 commit 15b3dcd

3 files changed

Lines changed: 114 additions & 487 deletions

File tree

MCG/MCG_CC/mcg_cc_error_handler.py

Lines changed: 13 additions & 279 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# This module contains definition of ErrorHandler class, which is
55
# responsible for error recording, which may occur during run of MCG CC.
66
#
7-
# COPYRIGHT: Copyright (C) 2021-2022 Kamil Deć github.com/deckamil
8-
# DATE: 21 SEP 2022
7+
# COPYRIGHT: Copyright (C) 2021-2023 Kamil Deć github.com/deckamil
8+
# DATE: 7 JUN 2023
99
#
1010
# LICENSE:
1111
# This file is part of Mod Code Generator (MCG).
@@ -38,296 +38,30 @@ class ErrorHandler(object):
3838
# error list
3939
error_list = []
4040

41-
# SIGNAL errors
42-
SIG_ERR_MORE_INPUTS = 1
43-
SIG_ERR_NO_SIG_UID_TARGET = 20
44-
45-
# ACTION errors
46-
ACT_ERR_ACT_NOT_ALLOWED = 51
47-
ACT_ERR_NO_TARGET = 70
48-
ACT_ERR_NO_SIG_UID_TARGET = 71
49-
ACT_ERR_NO_FIRST_INPUT = 72
50-
ACT_ERR_ACT_IS_TARGET = 73
51-
52-
# STRUCTURE errors
53-
STR_ERR_MORE_INPUTS = 101
54-
STR_ERR_NO_COM_STR_UID_TARGET = 120
55-
56-
# COM_ERR_NO_TARGET errors
57-
COM_ERR_NO_TARGET = 170
58-
COM_ERR_NO_STR_UID_TARGET = 171
41+
# CONNECTION errors
42+
CON_ERR_INVALID_ACTION_TYPE = 1
5943

6044
# INTERFACE errors
61-
INT_ERR_NO_INP_INT_IN_COM = 201
62-
INT_ERR_NO_OUT_INT_IN_COM = 202
63-
INT_ERR_NO_LOC_DAT_IN_COM = 203
64-
INT_ERR_NO_INP_INT_IN_PAC = 204
65-
INT_ERR_NO_OUT_INT_IN_PAC = 205
66-
INT_ERR_NO_LOC_DAT_IN_PAC = 206
67-
INT_ERR_SIG_NOT_IN_INT = 210
68-
INT_ERR_STR_NOT_IN_INT = 211
69-
INT_ERR_INC_INP_INT_TYPE_IN_COM = 212
70-
INT_ERR_INC_OUT_INT_TYPE_IN_COM = 213
71-
INT_ERR_INC_LOC_DAT_TYPE_IN_COM = 214
72-
INT_ERR_INC_INP_INT_TYPE_IN_PAC = 215
73-
INT_ERR_INC_OUT_INT_TYPE_IN_PAC = 216
74-
INT_ERR_INC_LOC_DAT_TYPE_IN_PAC = 217
75-
INT_ERR_INP_INT_SIG_IS_TAR_IN_COM = 220
76-
INT_ERR_OUT_INT_SIG_IS_SRC_IN_COM = 221
77-
INT_ERR_INP_INT_STR_IS_TAR_IN_PAC = 222
78-
INT_ERR_OUT_INT_STR_IS_SRC_IN_PAC = 223
79-
INT_ERR_OUT_INT_STR_IS_INTER_TAR_IN_PAC = 224
80-
81-
# GENERAL errors
82-
GEN_ERR_NO_NAME_ELEMENT = 270
83-
GEN_ERR_NO_UID_ELEMENT = 271
84-
GEN_ERR_NO_COM_PAC_ACTIVITY = 272
85-
GEN_ERR_NO_COM_PAC_INTERFACE = 273
45+
INT_ERR_INVALID_INTERFACE_ELEMENT_TYPE = 51
8646

8747
# Description:
8848
# This method records error (i.e. append error to error list), found during run of MCG CC.
8949
@staticmethod
9050
def record_error(error_code, error_info1, error_info2):
9151

92-
# SIGNAL errors, range 1-50
93-
if error_code == ErrorHandler.SIG_ERR_MORE_INPUTS:
94-
# set error notification
95-
error = "ERROR " + str(error_code) + ": Signal " + str(error_info1) + \
96-
" has more than one input connection (source) within component content"
97-
# append error to error list
98-
ErrorHandler.error_list.append(error)
99-
100-
elif error_code == ErrorHandler.SIG_ERR_NO_SIG_UID_TARGET:
101-
# set error notification
102-
error = "ERROR " + str(error_code) + ": Could not find target signal with uid=" + str(error_info1) + \
103-
" for signal " + str(error_info2) + " within component content"
104-
# append error to error list
105-
ErrorHandler.error_list.append(error)
106-
107-
# ACTIONS errors, range 51-100
108-
elif error_code == ErrorHandler.ACT_ERR_ACT_NOT_ALLOWED:
109-
# set error notification
110-
error = "ERROR " + str(error_code) + ": Action " + str(error_info1) + \
111-
" has invalid type within component content"
112-
# append error to error list
113-
ErrorHandler.error_list.append(error)
114-
115-
elif error_code == ErrorHandler.ACT_ERR_NO_TARGET:
116-
# set error notification
117-
error = "ERROR " + str(error_code) + ": Could not find any target for action " + \
118-
str(error_info1) + " within component content"
119-
# append error to error list
120-
ErrorHandler.error_list.append(error)
121-
122-
elif error_code == ErrorHandler.ACT_ERR_NO_SIG_UID_TARGET:
123-
# set error notification
124-
error = "ERROR " + str(error_code) + ": Could not find target signal with uid=" + str(error_info1) + \
125-
" for action " + str(error_info2) + " within component content"
126-
# append error to error list
127-
ErrorHandler.error_list.append(error)
128-
129-
elif error_code == ErrorHandler.ACT_ERR_NO_FIRST_INPUT:
130-
# set error notification
131-
error = "ERROR " + str(error_code) + ": Could not find first input signal for action " + \
132-
str(error_info1) + " within component content"
133-
# append error to error list
134-
ErrorHandler.error_list.append(error)
135-
136-
elif error_code == ErrorHandler.ACT_ERR_ACT_IS_TARGET:
137-
# set error notification
138-
error = "ERROR " + str(error_code) + ": Another action is target of action " + \
139-
str(error_info1) + " within component content"
140-
# append error to error list
141-
ErrorHandler.error_list.append(error)
142-
143-
# STRUCTURE errors, range 101-150
144-
elif error_code == ErrorHandler.STR_ERR_MORE_INPUTS:
145-
# set error notification
146-
error = "ERROR " + str(error_code) + ": Structure " + str(error_info1) + \
147-
" has more than one input connection (source) within package content"
148-
# append error to error list
149-
ErrorHandler.error_list.append(error)
150-
151-
elif error_code == ErrorHandler.STR_ERR_NO_COM_STR_UID_TARGET:
152-
# set error notification
153-
error = "ERROR " + str(error_code) + ": Could not find target component or structure with uid=" + \
154-
str(error_info1) + " for structure " + str(error_info2) + " within package content"
155-
# append error to error list
156-
ErrorHandler.error_list.append(error)
157-
158-
# COMPONENT errors, range 151-200
159-
elif error_code == ErrorHandler.COM_ERR_NO_TARGET:
160-
# set error notification
161-
error = "ERROR " + str(error_code) + ": Could not find any target for component " + \
162-
str(error_info1) + " within package content"
163-
# append error to error list
164-
ErrorHandler.error_list.append(error)
165-
166-
elif error_code == ErrorHandler.COM_ERR_NO_STR_UID_TARGET:
167-
# set error notification
168-
error = "ERROR " + str(error_code) + ": Could not find target structure with uid=" + \
169-
str(error_info1) + " for component " + str(error_info2) + " within package content"
170-
# append error to error list
171-
ErrorHandler.error_list.append(error)
172-
173-
# INTERFACE errors, range 201-250
174-
elif error_code == ErrorHandler.INT_ERR_NO_INP_INT_IN_COM:
175-
# set error notification
176-
error = "ERROR " + str(error_code) + ": Could not find Input Interface element within component content"
177-
# append error to error list
178-
ErrorHandler.error_list.append(error)
179-
180-
elif error_code == ErrorHandler.INT_ERR_NO_OUT_INT_IN_COM:
181-
# set error notification
182-
error = "ERROR " + str(error_code) + ": Could not find Output Interface element within component content"
183-
# append error to error list
184-
ErrorHandler.error_list.append(error)
185-
186-
elif error_code == ErrorHandler.INT_ERR_NO_LOC_DAT_IN_COM:
187-
# set error notification
188-
error = "ERROR " + str(error_code) + ": Could not find Local Data element within component content"
189-
# append error to error list
190-
ErrorHandler.error_list.append(error)
191-
192-
elif error_code == ErrorHandler.INT_ERR_NO_INP_INT_IN_PAC:
193-
# set error notification
194-
error = "ERROR " + str(error_code) + ": Could not find Input Interface element within package content"
195-
# append error to error list
196-
ErrorHandler.error_list.append(error)
197-
198-
elif error_code == ErrorHandler.INT_ERR_NO_OUT_INT_IN_PAC:
199-
# set error notification
200-
error = "ERROR " + str(error_code) + ": Could not find Output Interface element within package content"
201-
# append error to error list
202-
ErrorHandler.error_list.append(error)
203-
204-
elif error_code == ErrorHandler.INT_ERR_NO_LOC_DAT_IN_PAC:
205-
# set error notification
206-
error = "ERROR " + str(error_code) + ": Could not find Local Data element within package content"
207-
# append error to error list
208-
ErrorHandler.error_list.append(error)
209-
210-
elif error_code == ErrorHandler.INT_ERR_SIG_NOT_IN_INT:
211-
# set error notification
212-
error = "ERROR " + str(error_code) + ": Could not find " + str(error_info1) + \
213-
" signal within component interface"
214-
# append error to error list
215-
ErrorHandler.error_list.append(error)
216-
217-
elif error_code == ErrorHandler.INT_ERR_STR_NOT_IN_INT:
218-
# set error notification
219-
error = "ERROR " + str(error_code) + ": Could not find " + str(error_info1) + \
220-
" structure within package interface"
221-
# append error to error list
222-
ErrorHandler.error_list.append(error)
223-
224-
elif error_code == ErrorHandler.INT_ERR_INC_INP_INT_TYPE_IN_COM:
225-
# set error notification
226-
error = "ERROR " + str(error_code) + ": Input Interface signal " + str(error_info1) + \
227-
" has invalid type " + str(error_info2) + " within component content"
228-
# append error to error list
229-
ErrorHandler.error_list.append(error)
230-
231-
elif error_code == ErrorHandler.INT_ERR_INC_OUT_INT_TYPE_IN_COM:
232-
# set error notification
233-
error = "ERROR " + str(error_code) + ": Output Interface signal " + str(error_info1) + \
234-
" has invalid type " + str(error_info2) + " within component content"
235-
# append error to error list
236-
ErrorHandler.error_list.append(error)
237-
238-
elif error_code == ErrorHandler.INT_ERR_INC_LOC_DAT_TYPE_IN_COM:
239-
# set error notification
240-
error = "ERROR " + str(error_code) + ": Local Data signal " + str(error_info1) + \
241-
" has invalid type " + str(error_info2) + " within component content"
242-
# append error to error list
243-
ErrorHandler.error_list.append(error)
244-
245-
elif error_code == ErrorHandler.INT_ERR_INC_INP_INT_TYPE_IN_PAC:
246-
# set error notification
247-
error = "ERROR " + str(error_code) + ": Input Interface signal " + str(error_info1) + \
248-
" has invalid type " + str(error_info2) + " within package content"
249-
# append error to error list
250-
ErrorHandler.error_list.append(error)
251-
252-
elif error_code == ErrorHandler.INT_ERR_INC_OUT_INT_TYPE_IN_PAC:
253-
# set error notification
254-
error = "ERROR " + str(error_code) + ": Output Interface signal " + str(error_info1) + \
255-
" has invalid type " + str(error_info2) + " within package content"
256-
# append error to error list
257-
ErrorHandler.error_list.append(error)
258-
259-
elif error_code == ErrorHandler.INT_ERR_INC_LOC_DAT_TYPE_IN_COM:
260-
# set error notification
261-
error = "ERROR " + str(error_code) + ": Local Data structure " + str(error_info1) + \
262-
" has invalid type " + str(error_info2) + " within package content"
263-
# append error to error list
264-
ErrorHandler.error_list.append(error)
265-
266-
elif error_code == ErrorHandler.INT_ERR_INP_INT_SIG_IS_TAR_IN_COM:
267-
# set error notification
268-
error = "ERROR " + str(error_code) + ": Input Interface signal " + str(error_info1) + \
269-
" is connected as output (target) of " + str(error_info2) + " within component content"
270-
# append error to error list
271-
ErrorHandler.error_list.append(error)
272-
273-
elif error_code == ErrorHandler.INT_ERR_OUT_INT_SIG_IS_SRC_IN_COM:
274-
# set error notification
275-
error = "ERROR " + str(error_code) + ": Output Interface signal " + str(error_info1) + \
276-
" is connected as input (source) of " + str(error_info2) + " within component content"
277-
# append error to error list
278-
ErrorHandler.error_list.append(error)
279-
280-
elif error_code == ErrorHandler.INT_ERR_INP_INT_STR_IS_TAR_IN_PAC:
281-
# set error notification
282-
error = "ERROR " + str(error_code) + ": Input Interface structure is connected as output (target) of " \
283-
+ str(error_info1) + " within package content"
284-
# append error to error list
285-
ErrorHandler.error_list.append(error)
286-
287-
elif error_code == ErrorHandler.INT_ERR_OUT_INT_STR_IS_SRC_IN_PAC:
288-
# set error notification
289-
error = "ERROR " + str(error_code) + ": Output Interface structure is connected as input (source) of " \
290-
+ str(error_info1) + " within package content"
291-
# append error to error list
292-
ErrorHandler.error_list.append(error)
293-
294-
elif error_code == ErrorHandler.INT_ERR_OUT_INT_STR_IS_INTER_TAR_IN_PAC:
295-
# set error notification
296-
error = "ERROR " + str(error_code) + ": Output Interface structure is connected as output (target) of " \
297-
+ str(error_info1) + " interaction within package content"
298-
# append error to error list
299-
ErrorHandler.error_list.append(error)
300-
301-
# GENERAL errors, range 251-300
302-
elif error_code == ErrorHandler.GEN_ERR_NO_NAME_ELEMENT:
303-
# set error notification
304-
error = "ERROR " + str(error_code) + ": Could not find <name> element at line " + \
305-
str(error_info1) + " within file content"
306-
# append error to error list
307-
ErrorHandler.error_list.append(error)
308-
309-
elif error_code == ErrorHandler.GEN_ERR_NO_UID_ELEMENT:
310-
# set error notification
311-
error = "ERROR " + str(error_code) + ": Could not find <uid> element at line " + \
312-
str(error_info1) + " within file content"
313-
# append error to error list
314-
ErrorHandler.error_list.append(error)
315-
316-
elif error_code == ErrorHandler.GEN_ERR_NO_COM_PAC_ACTIVITY:
317-
# set error notification
318-
error = "ERROR " + str(error_code) + ": Activity file does not belong to component or package"
319-
# append error to error list
320-
ErrorHandler.error_list.append(error)
321-
322-
elif error_code == ErrorHandler.GEN_ERR_NO_COM_PAC_INTERFACE:
52+
# CONNECTION errors, range 1-50
53+
if error_code == ErrorHandler.CON_ERR_INVALID_ACTION_TYPE:
32354
# set error notification
324-
error = "ERROR " + str(error_code) + ": Interface file does not belong to component or package"
55+
error = "ERROR " + str(error_code) + ": Invalid action type was found in " + str(error_info1) + \
56+
" connection"
32557
# append error to error list
32658
ErrorHandler.error_list.append(error)
32759

328-
else:
60+
# INTERFACE errors, range 51-100
61+
elif error_code == ErrorHandler.INT_ERR_INVALID_INTERFACE_ELEMENT_TYPE:
32962
# set error notification
330-
error = "UNKNOWN ERROR " + str(error_code) + ": Error code not recognized"
63+
error = "ERROR " + str(error_code) + ": Invalid interface element type was found in " + str(error_info1) + \
64+
" interface element"
33165
# append error to error list
33266
ErrorHandler.error_list.append(error)
33367

0 commit comments

Comments
 (0)