Skip to content

Commit a9aedb5

Browse files
committed
Introduced fix that allows for conversion and code generation of operations with more than one output pin, i.e. more than one return parameter
1 parent 88cfd6c commit a9aedb5

3 files changed

Lines changed: 29 additions & 18 deletions

File tree

MCG/MCG_CC/mcg_cc_file_reader.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# responsible for reading of module content from .exml file.
66
#
77
# COPYRIGHT: Copyright (C) 2021-2023 Kamil Deć github.com/deckamil
8-
# DATE: 21 JAN 2023
8+
# DATE: 24 JUN 2023
99
#
1010
# LICENSE:
1111
# This file is part of Mod Code Generator (MCG).
@@ -388,8 +388,18 @@ def read_interaction_targets(self):
388388
Logger.save_in_log_file("FileReader", "Have found " + str(connection) + " connection",
389389
False)
390390

391-
# if end of target section if found
392-
if "</COMP>" in self.activity_file[j]:
391+
# if end of action target section is found
392+
if "</COMP>" in self.activity_file[j] and \
393+
source_interaction_type == Connection.ACTION:
394+
# exit "for j in range" loop
395+
break
396+
397+
# if end of operation target section is found
398+
if "</COMP>" in self.activity_file[j] and \
399+
"</DEPENDENCIES>" in self.activity_file[j+1] and \
400+
"</OBJECT>" in self.activity_file[j+2] and \
401+
"</COMP>" in self.activity_file[j+3] and \
402+
source_interaction_type == Connection.OPERATION:
393403
# exit "for j in range" loop
394404
break
395405

MCG/MCG_CC/mcg_cc_module_sorter.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# for finding and sorting of module nodes.
66
#
77
# COPYRIGHT: Copyright (C) 2021-2023 Kamil Deć github.com/deckamil
8-
# DATE: 23 JUN 2023
8+
# DATE: 24 JUN 2023
99
#
1010
# LICENSE:
1111
# This file is part of Mod Code Generator (MCG).
@@ -248,10 +248,8 @@ def sort_nodes(self):
248248
self.sorted_node_list.append(dependency[0])
249249
# remove dependency sublist from dependency list
250250
self.dependency_list.remove(dependency)
251-
# get output link
252-
output_link = dependency[0].output_data_list[0]
253-
# get output data name
254-
output_data_name = output_link[Node.DATA_NAME_INDEX]
251+
# get output data list
252+
output_data_list = dependency[0].output_data_list
255253
# recalculate number of nodes to sort, i.e. length of dependency list
256254
dependency_list_length = len(self.dependency_list)
257255

@@ -267,15 +265,18 @@ def sort_nodes(self):
267265
for k in range(index, len(dependency)):
268266
# if given node consumes local data elements, which comes from node, which
269267
# was appended above to sorted node list
270-
if output_data_name == dependency[index]:
271-
# remove local data element from dependency sublist
272-
dependency.remove(dependency[index])
273-
# decrement index for next iteration, as one dependence was removed
274-
# therefore all next dependencies in dependency sublist were pushed by
275-
# one position towards beginning of the sublist, e.g. [...,A,B,C] -> [...,B,C];
276-
# A was removed and now B is under previous position of A so at next
277-
# iteration the same index need to be checked to examine B;
278-
index = index - 1
268+
for output_link in output_data_list:
269+
if output_link[Node.DATA_NAME_INDEX] == dependency[index]:
270+
# remove local data element from dependency sublist
271+
dependency.remove(dependency[index])
272+
# decrement index for next iteration, as one dependence was removed
273+
# therefore all next dependencies in dependency sublist were pushed by
274+
# one position towards beginning of the sublist, e.g. [...,A,B,C] -> [...,B,C];
275+
# A was removed and now B is under previous position of A so at next
276+
# iteration the same index need to be checked to examine B;
277+
index = index - 1
278+
# exit "for output_link in" loop
279+
break
279280
index = index + 1
280281

281282
# exit "for i in range" loop
@@ -336,7 +337,7 @@ def sort_input_data_list(self):
336337
# record info
337338
Logger.save_in_log_file("ModuleSorter", "Have sorted " + str(sorted_node) + " node",
338339
False)
339-
# exit "for input_data in" loop
340+
# exit "for input_link in" loop
340341
break
341342

342343
# Description:

Mod Code Generator Manual.pdf

77 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)