Skip to content

Commit 27de852

Browse files
authored
Merge pull request #6 from deckamil/dev
v0.4.0-alpha release delivery
2 parents d156846 + 11f5377 commit 27de852

16 files changed

Lines changed: 674 additions & 314 deletions
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# FILE: mcg_cc_connection.py
1+
# FILE: mcg_cc_activity_connection.py
22
#
33
# DESCRIPTION:
4-
# This module contains definition of Connection class, which represents connection
4+
# This module contains definition of ActivityConnection class, which represents connection
55
# between two model elements on activity diagram.
66
#
77
# COPYRIGHT: Copyright (C) 2021-2023 Kamil Deć github.com/deckamil
8-
# DATE: 21 JAN 2023
8+
# DATE: 7 SEP 2023
99
#
1010
# LICENSE:
1111
# This file is part of Mod Code Generator (MCG).
@@ -30,7 +30,7 @@
3030

3131
# Description:
3232
# This class represents connection between two model elements on activity diagram.
33-
class Connection(object):
33+
class ActivityConnection(object):
3434

3535
# Connections types
3636
UNKNOWN = 10
@@ -46,24 +46,24 @@ def __init__(self):
4646
self.source_pin = "N/A"
4747
self.source_name = "N/A"
4848
self.source_uid = "N/A"
49-
self.source_type = Connection.UNKNOWN
49+
self.source_type = ActivityConnection.UNKNOWN
5050
self.target_pin = "N/A"
5151
self.target_name = "N/A"
5252
self.target_uid = "N/A"
53-
self.target_type = Connection.UNKNOWN
53+
self.target_type = ActivityConnection.UNKNOWN
5454

5555
# Description:
56-
# This method returns string representation of Connection class.
56+
# This method returns string representation of ActivityConnection class.
5757
def __str__(self):
5858

5959
# source
6060
line = "$SOURCE$: "
6161

6262
# if operation is source
63-
if self.source_type == Connection.OPERATION:
63+
if self.source_type == ActivityConnection.OPERATION:
6464
line = line + self.source_pin + " " + self.source_name + "() " + self.source_uid + " "
6565
# if action is source
66-
elif self.source_type == Connection.ACTION:
66+
elif self.source_type == ActivityConnection.ACTION:
6767
line = line + self.source_name + " " + self.source_uid + " "
6868
# if local data or other parameter is source
6969
else:
@@ -73,10 +73,10 @@ def __str__(self):
7373
line = line + "$TARGET$: "
7474

7575
# if operation is target
76-
if self.target_type == Connection.OPERATION:
76+
if self.target_type == ActivityConnection.OPERATION:
7777
line = line + self.target_pin + " " + self.target_name + "() " + self.target_uid
7878
# if action is target
79-
elif self.target_type == Connection.ACTION:
79+
elif self.target_type == ActivityConnection.ACTION:
8080
line = line + self.target_name + " " + self.target_uid
8181
# if local data or other parameter is target
8282
else:
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# FILE: mcg_cc_node.py
1+
# FILE: mcg_cc_activity_node.py
22
#
33
# DESCRIPTION:
4-
# This module contains definition of Node class, which represents node on
4+
# This module contains definition of ActivityNode class, which represents node on
55
# activity diagram, i.e. interaction together with its input and output data.
66
#
77
# COPYRIGHT: Copyright (C) 2021-2023 Kamil Deć github.com/deckamil
8-
# DATE: 25 MAR 2023
8+
# DATE: 7 SEP 2023
99
#
1010
# LICENSE:
1111
# This file is part of Mod Code Generator (MCG).
@@ -30,7 +30,7 @@
3030

3131
# Description:
3232
# This class represents node on activity diagram, i.e. interaction together with its input and output data.
33-
class Node(object):
33+
class ActivityNode(object):
3434

3535
# indexes of interface element list
3636
DATA_NAME_INDEX = 0
@@ -49,22 +49,22 @@ def __init__(self):
4949
self.input_data_list = []
5050
self.name = "N/A"
5151
self.uid = "N/A"
52-
self.type = Node.UNKNOWN
52+
self.type = ActivityNode.UNKNOWN
5353
self.output_data_list = []
5454

5555
# Description:
56-
# This method returns string representation of Node class.
56+
# This method returns string representation of ActivityNode class.
5757
def __str__(self):
5858
# append input marker
5959
line = "$INPUTS$: "
6060

6161
# if node is operation type
62-
if self.type == Node.OPERATION:
62+
if self.type == ActivityNode.OPERATION:
6363

6464
# append input data
6565
for input_data in self.input_data_list:
66-
line = line + input_data[Node.DATA_NAME_INDEX] + \
67-
"->" + input_data[Node.PIN_NAME_INDEX] + " "
66+
line = line + input_data[ActivityNode.DATA_NAME_INDEX] + \
67+
"->" + input_data[ActivityNode.PIN_NAME_INDEX] + " "
6868

6969
# append interaction name and uid
7070
line = line + "$INTERACTION$: " + self.name + "() " + self.uid + " "
@@ -74,18 +74,18 @@ def __str__(self):
7474

7575
# append output data
7676
for output_data in self.output_data_list:
77-
line = line + output_data[Node.PIN_NAME_INDEX] + \
78-
"->" + output_data[Node.DATA_NAME_INDEX] + " "
77+
line = line + output_data[ActivityNode.PIN_NAME_INDEX] + \
78+
"->" + output_data[ActivityNode.DATA_NAME_INDEX] + " "
7979

8080
# remove spare whitespace
8181
line = line[0:len(line)-1]
8282

8383
# if node is action type
84-
elif self.type == Node.ACTION:
84+
elif self.type == ActivityNode.ACTION:
8585

8686
# append input data
8787
for input_data in self.input_data_list:
88-
line = line + input_data[Node.DATA_NAME_INDEX] + " "
88+
line = line + input_data[ActivityNode.DATA_NAME_INDEX] + " "
8989

9090
# append interaction name and uid
9191
line = line + "$INTERACTION$: " + self.name + " " + self.uid + " "
@@ -94,14 +94,14 @@ def __str__(self):
9494
output_data = self.output_data_list[0]
9595

9696
# append output marker and data
97-
line = line + "$OUTPUT$: " + output_data[Node.DATA_NAME_INDEX]
97+
line = line + "$OUTPUT$: " + output_data[ActivityNode.DATA_NAME_INDEX]
9898

9999
# if there is no interaction, but only connection between two data points
100100
else:
101101

102102
# append input data
103103
for input_data in self.input_data_list:
104-
line = line + input_data[Node.DATA_NAME_INDEX] + " "
104+
line = line + input_data[ActivityNode.DATA_NAME_INDEX] + " "
105105

106106
# append interaction name
107107
line = line + "$INTERACTION$: ASSIGNMENT "
@@ -110,7 +110,7 @@ def __str__(self):
110110
output_data = self.output_data_list[0]
111111

112112
# append output marker and data
113-
line = line + "$OUTPUT$: " + output_data[Node.DATA_NAME_INDEX]
113+
line = line + "$OUTPUT$: " + output_data[ActivityNode.DATA_NAME_INDEX]
114114

115115
# return string representation
116116
return line

MCG/MCG_CC/mcg_cc_file_checker.py

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# responsible for checking of model module content from .exml file.
66
#
77
# COPYRIGHT: Copyright (C) 2021-2023 Kamil Deć github.com/deckamil
8-
# DATE: 23 JUN 2023
8+
# DATE: 7 SEP 2023
99
#
1010
# LICENSE:
1111
# This file is part of Mod Code Generator (MCG).
@@ -28,19 +28,21 @@
2828
# along with this program. If not, see <https://www.gnu.org/licenses/>.
2929

3030

31+
from mcg_cc_activity_connection import ActivityConnection
3132
from mcg_cc_file_reader import FileReader
3233
from mcg_cc_error_handler import ErrorHandler
3334
from mcg_cc_logger import Logger
34-
from mcg_cc_connection import Connection
3535

3636

3737
# Description:
3838
# This class allows to check model module content from .exml files.
3939
class FileChecker(object):
4040

4141
# list of actions types
42-
action_3letter_type_list = ["ADD", "SUB", "MUL", "DIV", "AND", "NOT"]
43-
action_2letter_type_list = ["OR", "EQ", "NE", "GT", "LT", "GE", "LE"]
42+
action_type_list = ["ADD", "SUB", "MUL", "DIV",
43+
"AND", "OR", "NOT",
44+
"BAND", "BOR", "BXOR", "BNOT", "BLS", "BRS",
45+
"EQ", "NE", "GT", "LT", "GE", "LE"]
4446

4547
# list of interface element types
4648
interface_element_type_list = ["INT8", "INT16", "INT32", "INT64",
@@ -68,7 +70,7 @@ def check_connection_errors(self):
6870
# check action types in connections
6971
for connection in self.connection_list:
7072
# if action is connection source
71-
if connection.source_type == Connection.ACTION:
73+
if connection.source_type == ActivityConnection.ACTION:
7274

7375
# check if action type is valid
7476
action_type_valid = FileChecker.check_action_type(connection.source_name)
@@ -79,7 +81,7 @@ def check_connection_errors(self):
7981
ErrorHandler.record_error(ErrorHandler.CON_ERR_INVALID_ACTION_TYPE, connection, "none")
8082

8183
# if action is connection target
82-
if connection.target_type == Connection.ACTION:
84+
if connection.target_type == ActivityConnection.ACTION:
8385
# check if action type is valid
8486
action_type_valid = FileChecker.check_action_type(connection.target_name)
8587

@@ -95,27 +97,16 @@ def check_action_type(action_type_ref):
9597
# result flag
9698
action_type_valid = False
9799

98-
# is valid type is not found
99-
if not action_type_valid:
100-
# check all possible 3-letter action types
101-
for action_type in FileChecker.action_3letter_type_list:
102-
# if action type is the same as in reference
103-
if action_type == action_type_ref[0:3]:
104-
# set flag
105-
action_type_valid = True
106-
# exit loop
107-
break
108-
109-
# is valid types is not found
110-
if not action_type_valid:
111-
# check 2-letter action types
112-
for action_type in FileChecker.action_2letter_type_list:
113-
# if action type is the same as in reference
114-
if action_type == action_type_ref[0:2]:
115-
# set flag
116-
action_type_valid = True
117-
# exit loop
118-
break
100+
# check all possible action types
101+
for action_type in FileChecker.action_type_list:
102+
# get length of action type
103+
action_type_length = len(action_type)
104+
# if action type is the same as in reference
105+
if action_type == action_type_ref[0:action_type_length]:
106+
# set positive flag
107+
action_type_valid = True
108+
# exit loop
109+
break
119110

120111
# return flag
121112
return action_type_valid
@@ -130,7 +121,7 @@ def check_interface_errors(self):
130121
# check interface element types in input interface
131122
for interface_element in self.input_interface_list:
132123
# get interface element type
133-
interface_element_type = interface_element[FileReader.INTERFACE_ELEMENT_TYPE_INDEX]
124+
interface_element_type = interface_element[FileReader.DATA_ELEMENT_TYPE_INDEX]
134125
# check interface element type
135126
interface_element_type_valid = FileChecker.check_interface_element_type(interface_element_type)
136127

@@ -142,7 +133,7 @@ def check_interface_errors(self):
142133
# check interface element types in output interface
143134
for interface_element in self.output_interface_list:
144135
# get interface element type
145-
interface_element_type = interface_element[FileReader.INTERFACE_ELEMENT_TYPE_INDEX]
136+
interface_element_type = interface_element[FileReader.DATA_ELEMENT_TYPE_INDEX]
146137
# check interface element type
147138
interface_element_type_valid = FileChecker.check_interface_element_type(interface_element_type)
148139

@@ -154,7 +145,7 @@ def check_interface_errors(self):
154145
# check interface element types in local interface
155146
for interface_element in self.local_interface_list:
156147
# get interface element type
157-
interface_element_type = interface_element[FileReader.INTERFACE_ELEMENT_TYPE_INDEX]
148+
interface_element_type = interface_element[FileReader.DATA_ELEMENT_TYPE_INDEX]
158149
# check interface element type
159150
interface_element_type_valid = FileChecker.check_interface_element_type(interface_element_type)
160151

MCG/MCG_CC/mcg_cc_file_finder.py

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# responsible for finding .exml files, that describe module content.
66
#
77
# COPYRIGHT: Copyright (C) 2021-2023 Kamil Deć github.com/deckamil
8-
# DATE: 21 JAN 2023
8+
# DATE: 7 SEP 2023
99
#
1010
# LICENSE:
1111
# This file is part of Mod Code Generator (MCG).
@@ -29,8 +29,8 @@
2929

3030

3131
from os import listdir
32+
from mcg_cc_file_supporter import FileSupporter
3233
from mcg_cc_logger import Logger
33-
from mcg_cc_supporter import Supporter
3434

3535

3636
# Description:
@@ -55,24 +55,20 @@ class FileFinder(object):
5555

5656
# return data
5757
module_file = []
58-
activity_file = []
5958
module_name = ""
6059
module_uid = ""
61-
operation_name = ""
62-
operation_uid = ""
60+
activity_file = []
6361
activity_name = ""
6462
activity_uid = ""
6563

6664
# indexes of return data
6765
FILES_FOUND_INDEX = 0
6866
MODULE_FILE_INDEX = 1
69-
ACTIVITY_FILE_INDEX = 2
70-
MODULE_NAME_INDEX = 3
71-
MODULE_UID_INDEX = 4
72-
OPERATION_NAME_INDEX = 5
73-
OPERATION_UID_INDEX = 6
74-
ACTIVITY_NAME_INDEX = 7
75-
ACTIVITY_UID_INDEX = 8
67+
MODULE_NAME_INDEX = 2
68+
MODULE_UID_INDEX = 3
69+
ACTIVITY_FILE_INDEX = 4
70+
ACTIVITY_NAME_INDEX = 5
71+
ACTIVITY_UID_INDEX = 6
7672

7773
# Description:
7874
# This method sets paths to .exml files, that describe model content.
@@ -124,11 +120,9 @@ def clear_return_data():
124120

125121
# clear return data
126122
FileFinder.module_file = []
127-
FileFinder.activity_file = []
128123
FileFinder.module_name = "UNKNOWN_MODULE_NAME"
129124
FileFinder.module_uid = "UNKNOWN_MODULE_UID"
130-
FileFinder.operation_name = "UNKNOWN_OPERATION_NAME"
131-
FileFinder.operation_uid = "UNKNOWN_OPERATION_UID"
125+
FileFinder.activity_file = []
132126
FileFinder.activity_name = "UNKNOWN_ACTIVITY_NAME"
133127
FileFinder.activity_uid = "UNKNOWN_ACTIVITY_UID"
134128

@@ -169,16 +163,14 @@ def find_module_file():
169163
"mc=\"Standard.Package\"" in module_file[i]) and
170164
"<PID name=" in module_file[i+1]):
171165
# get module name
172-
FileFinder.module_name = Supporter.get_name(module_file[i])
166+
FileFinder.module_name = FileSupporter.get_name(module_file[i])
173167
# get module uid
174-
FileFinder.module_uid = Supporter.get_uid(module_file[i])
168+
FileFinder.module_uid = FileSupporter.get_uid(module_file[i])
175169

176170
# if operation is defined in module
177171
if "<COMP relation=\"OwnedOperation\">" in module_file[i]:
178172
# store module file
179173
FileFinder.module_file = module_file
180-
# get operation name
181-
FileFinder.operation_name = Supporter.get_name(module_file[i+2])
182174
# set module finder state
183175
FileFinder.module_finder_state = FileFinder.FILE_FOUND
184176
# record info
@@ -234,13 +226,13 @@ def find_activity_file():
234226
("mc=\"Standard.Component\"" in activity_file[i+1] or
235227
"mc=\"Standard.Package\"" in activity_file[i+1])):
236228
# get activity name
237-
FileFinder.activity_name = Supporter.get_name(activity_file[i])
229+
FileFinder.activity_name = FileSupporter.get_name(activity_file[i])
238230
# get activity uid
239-
FileFinder.activity_uid = Supporter.get_uid(activity_file[i])
231+
FileFinder.activity_uid = FileSupporter.get_uid(activity_file[i])
240232
# get parent module name
241-
parent_module_name = Supporter.get_name(activity_file[i+1])
233+
parent_module_name = FileSupporter.get_name(activity_file[i+1])
242234
# get parent module uid
243-
parent_module_uid = Supporter.get_uid(activity_file[i+1])
235+
parent_module_uid = FileSupporter.get_uid(activity_file[i+1])
244236
# if there is name and uid compatibility
245237
if FileFinder.module_name == parent_module_name and FileFinder.module_uid == parent_module_uid:
246238
# store activity file
@@ -295,11 +287,9 @@ def find_files():
295287
file_finder_list = []
296288
file_finder_list.insert(FileFinder.FILES_FOUND_INDEX, files_found)
297289
file_finder_list.insert(FileFinder.MODULE_FILE_INDEX, FileFinder.module_file)
298-
file_finder_list.insert(FileFinder.ACTIVITY_FILE_INDEX, FileFinder.activity_file)
299290
file_finder_list.insert(FileFinder.MODULE_NAME_INDEX, FileFinder.module_name)
300291
file_finder_list.insert(FileFinder.MODULE_UID_INDEX, FileFinder.module_uid)
301-
file_finder_list.insert(FileFinder.OPERATION_NAME_INDEX, FileFinder.operation_name)
302-
file_finder_list.insert(FileFinder.OPERATION_UID_INDEX, FileFinder.operation_uid)
292+
file_finder_list.insert(FileFinder.ACTIVITY_FILE_INDEX, FileFinder.activity_file)
303293
file_finder_list.insert(FileFinder.ACTIVITY_NAME_INDEX, FileFinder.activity_name)
304294
file_finder_list.insert(FileFinder.ACTIVITY_UID_INDEX, FileFinder.activity_uid)
305295

0 commit comments

Comments
 (0)