Skip to content

Commit be5a4df

Browse files
authored
Merge pull request #7 from deckamil/dev
v0.5.0-alpha release delivery
2 parents 27de852 + 5e6f0b8 commit be5a4df

13 files changed

+1160
-506
lines changed

MCG/MCG_CC/mcg_cc_activity_connection.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# between two model elements on activity diagram.
66
#
77
# COPYRIGHT: Copyright (C) 2021-2023 Kamil Deć github.com/deckamil
8-
# DATE: 7 SEP 2023
8+
# DATE: 13 OCT 2023
99
#
1010
# LICENSE:
1111
# This file is part of Mod Code Generator (MCG).
@@ -43,13 +43,14 @@ class ActivityConnection(object):
4343
# This is class constructor.
4444
def __init__(self):
4545
# initialize object data
46-
self.source_pin = "N/A"
47-
self.source_name = "N/A"
48-
self.source_uid = "N/A"
46+
self.index = 0
47+
self.source_pin = "UNKNOWN"
48+
self.source_name = "UNKNOWN"
49+
self.source_uid = "UNKNOWN"
4950
self.source_type = ActivityConnection.UNKNOWN
50-
self.target_pin = "N/A"
51-
self.target_name = "N/A"
52-
self.target_uid = "N/A"
51+
self.target_pin = "UNKNOWN"
52+
self.target_name = "UNKNOWN"
53+
self.target_uid = "UNKNOWN"
5354
self.target_type = ActivityConnection.UNKNOWN
5455

5556
# Description:
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# FILE: mcg_cc_activity_layer.py
2+
#
3+
# DESCRIPTION:
4+
# TThis module contains definition of classes, which collect data and artefacts
5+
# from different layers of activity diagram.
6+
#
7+
# COPYRIGHT: Copyright (C) 2021-2024 Kamil Deć github.com/deckamil
8+
# DATE: 3 FEB 2024
9+
#
10+
# LICENSE:
11+
# This file is part of Mod Code Generator (MCG).
12+
#
13+
# MCG is free software: you can redistribute it and/or modify
14+
# it under the terms of the GNU General Public License as published by
15+
# the Free Software Foundation, either version 3 of the License, or
16+
# (at your option) any later version.
17+
#
18+
# MCG is distributed in the hope that it will be useful,
19+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+
# GNU General Public License for more details.
22+
#
23+
# Under Section 7 of GPL version 3, you are granted additional
24+
# permissions described in the MCG Output Exception, version 1, which
25+
# copy you should have received along with this program.
26+
#
27+
# You should have received a copy of the GNU General Public License
28+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
29+
30+
31+
# Description:
32+
# This class collects data and artefacts that belongs directly to layer of activity diagram.
33+
class ActivityDiagramLayer(object):
34+
35+
# Description:
36+
# This is class constructor.
37+
def __init__(self):
38+
# initialize object data
39+
self.connection_list = []
40+
self.interaction_uid_list = []
41+
self.node_list = []
42+
self.sorted_node_list = []
43+
44+
# Description:
45+
# This method returns string representation of the class.
46+
def __str__(self):
47+
line = "$DIAGRAM$"
48+
return line
49+
50+
51+
# Description:
52+
# This class collects data and artefacts that belongs to layer of condition element on activity diagram.
53+
class ActivityConditionLayer(object):
54+
55+
# Description:
56+
# This is class constructor.
57+
def __init__(self):
58+
# initialize object data
59+
self.name = "UNKNOWN"
60+
self.uid = "UNKNOWN"
61+
self.clause_layer_list = []
62+
63+
# Description:
64+
# This method returns string representation of the class.
65+
def __str__(self):
66+
line = "$CONDITION$: " + self.name + " " + self.uid
67+
return line
68+
69+
70+
# Description:
71+
# This class collects data and artefacts that belongs to layer of clause element on activity diagram.
72+
class ActivityClauseLayer(object):
73+
74+
# Description:
75+
# This is class constructor.
76+
def __init__(self):
77+
# initialize object data
78+
self.decision = "UNKNOWN"
79+
self.uid = "UNKNOWN"
80+
self.start_index = 0
81+
self.end_index = 0
82+
self.connection_list = []
83+
self.interaction_uid_list = []
84+
self.node_list = []
85+
self.sorted_node_list = []
86+
87+
# Description:
88+
# This method returns string representation of the class.
89+
def __str__(self):
90+
line = "$CLAUSE$: " + self.decision + " " + self.uid
91+
return line

MCG/MCG_CC/mcg_cc_activity_node.py

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
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: 7 SEP 2023
8+
# DATE: 25 DEC 2023
99
#
1010
# LICENSE:
1111
# This file is part of Mod Code Generator (MCG).
@@ -32,85 +32,92 @@
3232
# This class represents node on activity diagram, i.e. interaction together with its input and output data.
3333
class ActivityNode(object):
3434

35-
# indexes of interface element list
35+
# Indexes of interface element list
3636
DATA_NAME_INDEX = 0
3737
PIN_NAME_INDEX = 1
3838

39-
# interaction types
39+
# Node types
4040
UNKNOWN = 10
41-
DATA = 30
42-
ACTION = 40
43-
OPERATION = 50
41+
DATA = 20
42+
ACTION = 30
43+
OPERATION = 40
44+
CONDITION = 50
4445

4546
# Description:
4647
# This is class constructor.
4748
def __init__(self):
4849
# initialize object data
4950
self.input_data_list = []
50-
self.name = "N/A"
51-
self.uid = "N/A"
51+
self.interaction = "UNKNOWN"
52+
self.uid = "UNKNOWN"
5253
self.type = ActivityNode.UNKNOWN
54+
self.dependency_list = []
5355
self.output_data_list = []
5456

5557
# Description:
5658
# This method returns string representation of ActivityNode class.
5759
def __str__(self):
58-
# append input marker
59-
line = "$INPUTS$: "
6060

61-
# if node is operation type
6261
if self.type == ActivityNode.OPERATION:
6362

6463
# append input data
64+
line = "$INPUTS$: "
6565
for input_data in self.input_data_list:
6666
line = line + input_data[ActivityNode.DATA_NAME_INDEX] + \
6767
"->" + input_data[ActivityNode.PIN_NAME_INDEX] + " "
6868

69-
# append interaction name and uid
70-
line = line + "$INTERACTION$: " + self.name + "() " + self.uid + " "
71-
72-
# append output marker and data
73-
line = line + "$OUTPUT$: "
69+
# append interaction and uid
70+
line = line + "$OPERATION$: " + self.interaction + " " + self.uid + " "
7471

7572
# append output data
73+
line = line + "$OUTPUTS$: "
7674
for output_data in self.output_data_list:
7775
line = line + output_data[ActivityNode.PIN_NAME_INDEX] + \
7876
"->" + output_data[ActivityNode.DATA_NAME_INDEX] + " "
7977

8078
# remove spare whitespace
81-
line = line[0:len(line)-1]
79+
line = line[0:len(line) - 1]
8280

83-
# if node is action type
8481
elif self.type == ActivityNode.ACTION:
8582

8683
# append input data
84+
line = "$INPUTS$: "
8785
for input_data in self.input_data_list:
8886
line = line + input_data[ActivityNode.DATA_NAME_INDEX] + " "
8987

90-
# append interaction name and uid
91-
line = line + "$INTERACTION$: " + self.name + " " + self.uid + " "
92-
93-
# get output data
94-
output_data = self.output_data_list[0]
88+
# append interaction and uid
89+
line = line + "$ACTION$: " + self.interaction + " " + self.uid + " "
9590

96-
# append output marker and data
97-
line = line + "$OUTPUT$: " + output_data[ActivityNode.DATA_NAME_INDEX]
91+
# append output data
92+
line = line + "$OUTPUT$: " + self.output_data_list[0][ActivityNode.DATA_NAME_INDEX]
9893

99-
# if there is no interaction, but only connection between two data points
100-
else:
94+
elif self.type == ActivityNode.DATA:
10195

10296
# append input data
103-
for input_data in self.input_data_list:
104-
line = line + input_data[ActivityNode.DATA_NAME_INDEX] + " "
97+
line = "$INPUT$: " + self.input_data_list[0][ActivityNode.DATA_NAME_INDEX] + " "
98+
99+
# append interaction
100+
line = line + "$ASSIGNMENT$: "
101+
102+
# append output data
103+
line = line + "$OUTPUT$: " + self.output_data_list[0][ActivityNode.DATA_NAME_INDEX]
104+
105+
elif self.type == ActivityNode.CONDITION:
106+
107+
# append interaction and uid
108+
line = "$CONDITION$: " + self.interaction + " " + self.uid + " "
109+
110+
# append output data
111+
line = line + "$OUTPUTS$: "
112+
for output_data in self.output_data_list:
113+
line = line + output_data[ActivityNode.DATA_NAME_INDEX] + " "
105114

106-
# append interaction name
107-
line = line + "$INTERACTION$: ASSIGNMENT "
115+
# remove spare whitespace
116+
line = line[0:len(line) - 1]
108117

109-
# get output data
110-
output_data = self.output_data_list[0]
118+
else:
111119

112-
# append output marker and data
113-
line = line + "$OUTPUT$: " + output_data[ActivityNode.DATA_NAME_INDEX]
120+
line = "$UNKNOWN$"
114121

115122
# return string representation
116123
return line

MCG/MCG_CC/mcg_cc_file_checker.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# This module contains definition of FileChecker class, which is
55
# responsible for checking of model module content from .exml file.
66
#
7-
# COPYRIGHT: Copyright (C) 2021-2023 Kamil Deć github.com/deckamil
8-
# DATE: 7 SEP 2023
7+
# COPYRIGHT: Copyright (C) 2021-2024 Kamil Deć github.com/deckamil
8+
# DATE: 26 FEB 2024
99
#
1010
# LICENSE:
1111
# This file is part of Mod Code Generator (MCG).
@@ -55,7 +55,8 @@ class FileChecker(object):
5555
def __init__(self, file_reader_list):
5656

5757
# initialize object data
58-
self.connection_list = file_reader_list[FileReader.CONNECTION_LIST_INDEX]
58+
self.diagram_layer = file_reader_list[FileReader.DIAGRAM_LAYER_INDEX]
59+
self.condition_layer_list = file_reader_list[FileReader.CONDITION_LAYER_LIST_INDEX]
5960
self.input_interface_list = file_reader_list[FileReader.INPUT_INTERFACE_LIST_INDEX]
6061
self.output_interface_list = file_reader_list[FileReader.OUTPUT_INTERFACE_LIST_INDEX]
6162
self.local_interface_list = file_reader_list[FileReader.LOCAL_INTERFACE_LIST_INDEX]
@@ -65,10 +66,28 @@ def __init__(self, file_reader_list):
6566
def check_connection_errors(self):
6667

6768
# record info
68-
Logger.save_in_log_file("FileChecker", "Looking for connection errors in .exml file", False)
69+
Logger.save_in_log_file("FileChecker", "Looking for diagram layer connection errors", False)
6970

70-
# check action types in connections
71-
for connection in self.connection_list:
71+
# search for connection errors under diagram layer
72+
FileChecker.check_connection_actions_from_layer(self.diagram_layer)
73+
74+
# record info
75+
Logger.save_in_log_file("FileChecker", "Looking for clause layer connection errors", False)
76+
77+
# search for connection errors under clause layer
78+
for condition_layer in self.condition_layer_list:
79+
Logger.save_in_log_file("FileChecker", "Looking under " + str(condition_layer) + " layer", False)
80+
for clause_layer in condition_layer.clause_layer_list:
81+
Logger.save_in_log_file("FileChecker", "Looking under " + str(clause_layer) + " layer", False)
82+
FileChecker.check_connection_actions_from_layer(clause_layer)
83+
84+
# Description:
85+
# This method looks for connection errors related with actions from given layer.
86+
@staticmethod
87+
def check_connection_actions_from_layer(layer):
88+
89+
# check action types
90+
for connection in layer.connection_list:
7291
# if action is connection source
7392
if connection.source_type == ActivityConnection.ACTION:
7493

@@ -116,7 +135,7 @@ def check_action_type(action_type_ref):
116135
def check_interface_errors(self):
117136

118137
# record info
119-
Logger.save_in_log_file("FileChecker", "Looking for interface errors in .exml file", False)
138+
Logger.save_in_log_file("FileChecker", "Looking for module interface errors", False)
120139

121140
# check interface element types in input interface
122141
for interface_element in self.input_interface_list:

0 commit comments

Comments
 (0)