Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fb1f8e6
Changed version to v0.5.0-in-dev
deckamil Sep 8, 2023
1633f9a
Included ActivityCondition, ActivityClause class and reading of condi…
deckamil Oct 13, 2023
1897b12
Included list of conditions in file reader output list generated by F…
deckamil Oct 15, 2023
c8b65eb
Introduced 'collection' classes to store activity elements
deckamil Dec 6, 2023
9aa7126
Naming corrections
deckamil Dec 6, 2023
3a421e3
Description correction
deckamil Dec 8, 2023
97a9db2
Correction of interaction and node find functions
deckamil Dec 8, 2023
9419141
Included sorting of clauses under condition elements
deckamil Dec 16, 2023
a48159e
Added search of dependencies between nodes and representation of cond…
deckamil Dec 25, 2023
6f558ac
ActivityNode class string method corrections
deckamil Dec 25, 2023
9279a59
Added search of condition node dependencies
deckamil Jan 6, 2024
e9642ec
Added nodes sorting
deckamil Jan 7, 2024
5047629
Nodes sorting method divided into diagram- and clause-specific sortin…
deckamil Jan 7, 2024
4b60572
Node sorting functions replaced with sort_nodes() and sort_nodes_unde…
deckamil Jan 8, 2024
26545f0
Added sorting of input data list for action-type nodes
deckamil Jan 17, 2024
452ea31
Correction of clasue sorting process, external condition dependencies…
deckamil Jan 20, 2024
1c24e90
Conversion of condition elements from activity diagram into configura…
deckamil Jan 27, 2024
f1852aa
Included function that appends new lines to configuration file
deckamil Jan 27, 2024
5383493
Comments correction
deckamil Jan 27, 2024
479edcf
Collections replaced by concept of layers
deckamil Feb 3, 2024
a94214b
Included conversion of relational operators from clause decisions
deckamil Feb 5, 2024
28a9b68
Added dedicated function for operation body check
deckamil Feb 8, 2024
24b48fb
Included code generation for conditional branches
deckamil Feb 13, 2024
0c3518c
Included instructions on how to define conditional block in MCG Manua…
deckamil Feb 19, 2024
d191baf
Diagram corrections for conditional block examples
deckamil Feb 21, 2024
58548b9
Inluded check of operation call definition in operation body section …
deckamil Feb 25, 2024
feb4072
Included back FileChecker in MCG CC process
deckamil Feb 26, 2024
3c18a13
Included conditional interaction rules
deckamil Mar 2, 2024
a19de82
Included ending bracket in code generation for conditional branches
deckamil Apr 13, 2024
1958324
Correction of Action Interaction Rules for action types that require …
deckamil Apr 13, 2024
5e6f0b8
Changed version to v0.5.0-alpha
deckamil Apr 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions MCG/MCG_CC/mcg_cc_activity_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# between two model elements on activity diagram.
#
# COPYRIGHT: Copyright (C) 2021-2023 Kamil Deć github.com/deckamil
# DATE: 7 SEP 2023
# DATE: 13 OCT 2023
#
# LICENSE:
# This file is part of Mod Code Generator (MCG).
Expand Down Expand Up @@ -43,13 +43,14 @@ class ActivityConnection(object):
# This is class constructor.
def __init__(self):
# initialize object data
self.source_pin = "N/A"
self.source_name = "N/A"
self.source_uid = "N/A"
self.index = 0
self.source_pin = "UNKNOWN"
self.source_name = "UNKNOWN"
self.source_uid = "UNKNOWN"
self.source_type = ActivityConnection.UNKNOWN
self.target_pin = "N/A"
self.target_name = "N/A"
self.target_uid = "N/A"
self.target_pin = "UNKNOWN"
self.target_name = "UNKNOWN"
self.target_uid = "UNKNOWN"
self.target_type = ActivityConnection.UNKNOWN

# Description:
Expand Down
91 changes: 91 additions & 0 deletions MCG/MCG_CC/mcg_cc_activity_layer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# FILE: mcg_cc_activity_layer.py
#
# DESCRIPTION:
# TThis module contains definition of classes, which collect data and artefacts
# from different layers of activity diagram.
#
# COPYRIGHT: Copyright (C) 2021-2024 Kamil Deć github.com/deckamil
# DATE: 3 FEB 2024
#
# LICENSE:
# This file is part of Mod Code Generator (MCG).
#
# MCG is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# MCG is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# Under Section 7 of GPL version 3, you are granted additional
# permissions described in the MCG Output Exception, version 1, which
# copy you should have received along with this program.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.


# Description:
# This class collects data and artefacts that belongs directly to layer of activity diagram.
class ActivityDiagramLayer(object):

# Description:
# This is class constructor.
def __init__(self):
# initialize object data
self.connection_list = []
self.interaction_uid_list = []
self.node_list = []
self.sorted_node_list = []

# Description:
# This method returns string representation of the class.
def __str__(self):
line = "$DIAGRAM$"
return line


# Description:
# This class collects data and artefacts that belongs to layer of condition element on activity diagram.
class ActivityConditionLayer(object):

# Description:
# This is class constructor.
def __init__(self):
# initialize object data
self.name = "UNKNOWN"
self.uid = "UNKNOWN"
self.clause_layer_list = []

# Description:
# This method returns string representation of the class.
def __str__(self):
line = "$CONDITION$: " + self.name + " " + self.uid
return line


# Description:
# This class collects data and artefacts that belongs to layer of clause element on activity diagram.
class ActivityClauseLayer(object):

# Description:
# This is class constructor.
def __init__(self):
# initialize object data
self.decision = "UNKNOWN"
self.uid = "UNKNOWN"
self.start_index = 0
self.end_index = 0
self.connection_list = []
self.interaction_uid_list = []
self.node_list = []
self.sorted_node_list = []

# Description:
# This method returns string representation of the class.
def __str__(self):
line = "$CLAUSE$: " + self.decision + " " + self.uid
return line
77 changes: 42 additions & 35 deletions MCG/MCG_CC/mcg_cc_activity_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# activity diagram, i.e. interaction together with its input and output data.
#
# COPYRIGHT: Copyright (C) 2021-2023 Kamil Deć github.com/deckamil
# DATE: 7 SEP 2023
# DATE: 25 DEC 2023
#
# LICENSE:
# This file is part of Mod Code Generator (MCG).
Expand All @@ -32,85 +32,92 @@
# This class represents node on activity diagram, i.e. interaction together with its input and output data.
class ActivityNode(object):

# indexes of interface element list
# Indexes of interface element list
DATA_NAME_INDEX = 0
PIN_NAME_INDEX = 1

# interaction types
# Node types
UNKNOWN = 10
DATA = 30
ACTION = 40
OPERATION = 50
DATA = 20
ACTION = 30
OPERATION = 40
CONDITION = 50

# Description:
# This is class constructor.
def __init__(self):
# initialize object data
self.input_data_list = []
self.name = "N/A"
self.uid = "N/A"
self.interaction = "UNKNOWN"
self.uid = "UNKNOWN"
self.type = ActivityNode.UNKNOWN
self.dependency_list = []
self.output_data_list = []

# Description:
# This method returns string representation of ActivityNode class.
def __str__(self):
# append input marker
line = "$INPUTS$: "

# if node is operation type
if self.type == ActivityNode.OPERATION:

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

# append interaction name and uid
line = line + "$INTERACTION$: " + self.name + "() " + self.uid + " "

# append output marker and data
line = line + "$OUTPUT$: "
# append interaction and uid
line = line + "$OPERATION$: " + self.interaction + " " + self.uid + " "

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

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

# if node is action type
elif self.type == ActivityNode.ACTION:

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

# append interaction name and uid
line = line + "$INTERACTION$: " + self.name + " " + self.uid + " "

# get output data
output_data = self.output_data_list[0]
# append interaction and uid
line = line + "$ACTION$: " + self.interaction + " " + self.uid + " "

# append output marker and data
line = line + "$OUTPUT$: " + output_data[ActivityNode.DATA_NAME_INDEX]
# append output data
line = line + "$OUTPUT$: " + self.output_data_list[0][ActivityNode.DATA_NAME_INDEX]

# if there is no interaction, but only connection between two data points
else:
elif self.type == ActivityNode.DATA:

# append input data
for input_data in self.input_data_list:
line = line + input_data[ActivityNode.DATA_NAME_INDEX] + " "
line = "$INPUT$: " + self.input_data_list[0][ActivityNode.DATA_NAME_INDEX] + " "

# append interaction
line = line + "$ASSIGNMENT$: "

# append output data
line = line + "$OUTPUT$: " + self.output_data_list[0][ActivityNode.DATA_NAME_INDEX]

elif self.type == ActivityNode.CONDITION:

# append interaction and uid
line = "$CONDITION$: " + self.interaction + " " + self.uid + " "

# append output data
line = line + "$OUTPUTS$: "
for output_data in self.output_data_list:
line = line + output_data[ActivityNode.DATA_NAME_INDEX] + " "

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

# get output data
output_data = self.output_data_list[0]
else:

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

# return string representation
return line
33 changes: 26 additions & 7 deletions MCG/MCG_CC/mcg_cc_file_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# This module contains definition of FileChecker class, which is
# responsible for checking of model module content from .exml file.
#
# COPYRIGHT: Copyright (C) 2021-2023 Kamil Deć github.com/deckamil
# DATE: 7 SEP 2023
# COPYRIGHT: Copyright (C) 2021-2024 Kamil Deć github.com/deckamil
# DATE: 26 FEB 2024
#
# LICENSE:
# This file is part of Mod Code Generator (MCG).
Expand Down Expand Up @@ -55,7 +55,8 @@ class FileChecker(object):
def __init__(self, file_reader_list):

# initialize object data
self.connection_list = file_reader_list[FileReader.CONNECTION_LIST_INDEX]
self.diagram_layer = file_reader_list[FileReader.DIAGRAM_LAYER_INDEX]
self.condition_layer_list = file_reader_list[FileReader.CONDITION_LAYER_LIST_INDEX]
self.input_interface_list = file_reader_list[FileReader.INPUT_INTERFACE_LIST_INDEX]
self.output_interface_list = file_reader_list[FileReader.OUTPUT_INTERFACE_LIST_INDEX]
self.local_interface_list = file_reader_list[FileReader.LOCAL_INTERFACE_LIST_INDEX]
Expand All @@ -65,10 +66,28 @@ def __init__(self, file_reader_list):
def check_connection_errors(self):

# record info
Logger.save_in_log_file("FileChecker", "Looking for connection errors in .exml file", False)
Logger.save_in_log_file("FileChecker", "Looking for diagram layer connection errors", False)

# check action types in connections
for connection in self.connection_list:
# search for connection errors under diagram layer
FileChecker.check_connection_actions_from_layer(self.diagram_layer)

# record info
Logger.save_in_log_file("FileChecker", "Looking for clause layer connection errors", False)

# search for connection errors under clause layer
for condition_layer in self.condition_layer_list:
Logger.save_in_log_file("FileChecker", "Looking under " + str(condition_layer) + " layer", False)
for clause_layer in condition_layer.clause_layer_list:
Logger.save_in_log_file("FileChecker", "Looking under " + str(clause_layer) + " layer", False)
FileChecker.check_connection_actions_from_layer(clause_layer)

# Description:
# This method looks for connection errors related with actions from given layer.
@staticmethod
def check_connection_actions_from_layer(layer):

# check action types
for connection in layer.connection_list:
# if action is connection source
if connection.source_type == ActivityConnection.ACTION:

Expand Down Expand Up @@ -116,7 +135,7 @@ def check_action_type(action_type_ref):
def check_interface_errors(self):

# record info
Logger.save_in_log_file("FileChecker", "Looking for interface errors in .exml file", False)
Logger.save_in_log_file("FileChecker", "Looking for module interface errors", False)

# check interface element types in input interface
for interface_element in self.input_interface_list:
Expand Down
Loading