Skip to content

Commit ca1a7b3

Browse files
authored
Merge pull request #1 from deckamil/dev
Early delivery into 0.1-alpha release milestone
2 parents 1b2e710 + 0d86443 commit ca1a7b3

21 files changed

Lines changed: 4233 additions & 1 deletion

MCG OUTPUT EXCEPTION

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
MCG Output Exception
2+
Version 1, 6 NOV 2021
3+
4+
Copyright (C) 2021 Kamil Deć github.com/deckamil
5+
Everyone is permitted to copy and distribute verbatim copies of this
6+
license document, but changing it is not allowed.
7+
8+
This MCG Output Exception is an additional permission under section 7 of
9+
the GNU General Public License, version 3 (GPLv3). It applies to any
10+
output generated with the Mod Code Generator (MCG) program.
11+
12+
1. Introduction
13+
14+
In general, if the user uses some program to enter or convert own data,
15+
the copyright on the output belongs to the user. More generally, when a
16+
program translates its input into some other form, the copyright status of
17+
the output inherits that of the input it was generated from.
18+
19+
However, some programs may copy parts of themselves into the output for
20+
technical reasons. If substantial parts of the output are copied from
21+
program's text, then usually in such cases the copied text in the output
22+
is covered by the same license that covers it in the source code.
23+
24+
The MCG program copies parts of itself into output files, therefore this
25+
exception was created to rule out interpretation that those parts of the
26+
output generated by the program are to be covered by GPLv3 license.
27+
28+
2. Exception
29+
30+
You have permission to use and distribute outputs generated with the MCG
31+
program under terms of your choice, consistent with the licensing of the
32+
inputs provided to the program. The copyright holder of the MCG program
33+
does not claim any copyrights to outputs generated with the program.
34+
35+
3. Limitation of Liability
36+
37+
In no event the copyright holder of the MCG program, or any other party
38+
who modifies and/or conveys the program as permitted by GPLv3 license, be
39+
liable to you for damages, including any general, special, incidental or
40+
consequential damages arising out of the use or inability to use the
41+
program outputs. It is your responsibility to use and/or distribute the
42+
outputs generated by the program in accordance with license conditions of
43+
inputs provided to the program.
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# FILE: mcg_cc_component_converter.py
2+
#
3+
# DESCRIPTION:
4+
# This module contains definition of ComponentConverter class, which is child
5+
# class of Converter class and is responsible for conversion of component content
6+
# into configuration file.
7+
#
8+
# COPYRIGHT: Copyright (C) 2021-2022 Kamil Deć github.com/deckamil
9+
# DATE: 20 FEB 2022
10+
#
11+
# LICENSE:
12+
# This file is part of Mod Code Generator (MCG).
13+
#
14+
# MCG is free software: you can redistribute it and/or modify
15+
# it under the terms of the GNU General Public License as published by
16+
# the Free Software Foundation, either version 3 of the License, or
17+
# (at your option) any later version.
18+
#
19+
# MCG is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# Under Section 7 of GPL version 3, you are granted additional
25+
# permissions described in the MCG Output Exception, version 1, which
26+
# copy you should have received along with this program.
27+
#
28+
# You should have received a copy of the GNU General Public License
29+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
30+
31+
32+
from mcg_cc_converter import Converter
33+
from mcg_cc_logger import Logger
34+
35+
36+
# Class:
37+
# ComponentConverter()
38+
#
39+
# Description:
40+
# This is child class responsible for converting of component content into configuration file.
41+
class ComponentConverter(Converter):
42+
43+
# Method:
44+
# convert_action_interaction()
45+
#
46+
# Description:
47+
# This method is responsible for conversion of action interaction into configuration file.
48+
#
49+
# Returns:
50+
# This method does not return anything.
51+
def convert_action_interaction(self, sorted_node, math_symbol):
52+
53+
# append interaction comment to configuration file
54+
self.configuration_file.append(str("COM Action Interaction ") + str(sorted_node.node_interaction))
55+
# append beginning of action interaction to conversion line
56+
conversion_line = str("INS ") + str(sorted_node.node_output) + str(" = ")
57+
58+
# search for all input signal names within sorted node and put them into conversion line
59+
for i in range(0, len(sorted_node.node_input_list)):
60+
# find input signal name within sorted node
61+
node_input = sorted_node.node_input_list[i]
62+
# append input signal name to conversion line
63+
conversion_line = conversion_line + str(node_input)
64+
# if sorted node processing is not completed
65+
if i < len(sorted_node.node_input_list) - 1:
66+
# append math symbol to conversion line
67+
conversion_line = conversion_line + str(" ") + str(math_symbol) + str(" ")
68+
69+
# append conversion line to configuration file
70+
self.configuration_file.append(conversion_line)
71+
72+
# Method:
73+
# convert_signal_assignment()
74+
#
75+
# Description:
76+
# This method is responsible for conversion of signal assignment into configuration file.
77+
#
78+
# Returns:
79+
# This method does not return anything.
80+
def convert_signal_assignment(self, sorted_node):
81+
82+
# find output signal name within sorted node
83+
node_output = sorted_node.node_output
84+
# find input signal name within sorted node
85+
node_input = sorted_node.node_input_list[0]
86+
87+
# append input and output signal to conversion line
88+
conversion_line = str("INS ") + str(node_output) + str(" = ") + str(node_input)
89+
90+
# append conversion line to configuration file
91+
self.configuration_file.append(conversion_line)
92+
93+
# Method:
94+
# convert_component()
95+
#
96+
# Description:
97+
# This method is responsible for converting of component content into configuration file.
98+
#
99+
# Returns:
100+
# This method does not return anything.
101+
def convert_component(self):
102+
103+
# component converter
104+
Logger.save_in_log_file(">>>>>>>>>>>>>>>>>>>>>>>>>>>> COMPONENT CONVERTER <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n")
105+
106+
# convert header
107+
Logger.save_in_log_file("*** convert header")
108+
109+
# append start marker of new component section to configuration file
110+
self.configuration_file.append(str("COMPONENT START"))
111+
112+
# append file name to configuration file
113+
self.configuration_file.append(str("COMPONENT SOURCE ") + str(self.activity_source))
114+
115+
# append component name to configuration file
116+
self.configuration_file.append(str("COMPONENT NAME ") + str(self.model_element_name))
117+
118+
# convert interface details to configuration file
119+
self.convert_interfaces()
120+
121+
# convert body
122+
Logger.save_in_log_file("*** convert body")
123+
124+
# append start marker of function body section to configuration file
125+
self.configuration_file.append(str("BODY START"))
126+
127+
# repeat for all nodes from sorted node list
128+
for sorted_node in self.sorted_node_list:
129+
130+
# if sorted node contains ADD action
131+
if "ADD " in sorted_node.node_interaction:
132+
# convert ADD action
133+
self.convert_action_interaction(sorted_node, "+")
134+
135+
# if sorted node contains SUB action
136+
if "SUB " in sorted_node.node_interaction:
137+
# convert SUB action
138+
self.convert_action_interaction(sorted_node, "-")
139+
140+
# if sorted node contains MUL action
141+
if "MUL " in sorted_node.node_interaction:
142+
# convert MUL action
143+
self.convert_action_interaction(sorted_node, "*")
144+
145+
# if sorted node contains DIV action
146+
if "DIV " in sorted_node.node_interaction:
147+
# convert DIV action
148+
self.convert_action_interaction(sorted_node, "/")
149+
150+
# if sorted node contains ASSIGNMENT action
151+
if "ASSIGNMENT" in sorted_node.node_interaction:
152+
# convert ASSIGNMENT action
153+
self.convert_signal_assignment(sorted_node)
154+
155+
# append end marker of function body section to configuration file
156+
self.configuration_file.append(str("BODY END"))
157+
158+
# append end marker of new component section to configuration file
159+
self.configuration_file.append(str("COMPONENT END"))
160+
161+
# save configuration file
162+
self.save_in_configuration_file()
163+
164+
# process completed
165+
Logger.save_in_log_file("PROCESS COMPLETED")
166+
167+
# display additional details after component conversion
168+
Logger.save_in_log_file("")
169+
Logger.save_in_log_file("Configuration File:")
170+
for line in self.configuration_file:
171+
Logger.save_in_log_file(" " + str(line))
172+
173+
# end of component converter
174+
Logger.save_in_log_file("\n>>>>>>>>>>>>>>>>>>>>>>>> END OF COMPONENT CONVERTER <<<<<<<<<<<<<<<<<<<<<<<<<<<")

0 commit comments

Comments
 (0)