|
5 | 5 | # activity diagram, i.e. interaction together with its input and output data. |
6 | 6 | # |
7 | 7 | # COPYRIGHT: Copyright (C) 2021-2023 Kamil Deć github.com/deckamil |
8 | | -# DATE: 7 SEP 2023 |
| 8 | +# DATE: 25 DEC 2023 |
9 | 9 | # |
10 | 10 | # LICENSE: |
11 | 11 | # This file is part of Mod Code Generator (MCG). |
|
32 | 32 | # This class represents node on activity diagram, i.e. interaction together with its input and output data. |
33 | 33 | class ActivityNode(object): |
34 | 34 |
|
35 | | - # indexes of interface element list |
| 35 | + # Indexes of interface element list |
36 | 36 | DATA_NAME_INDEX = 0 |
37 | 37 | PIN_NAME_INDEX = 1 |
38 | 38 |
|
39 | | - # interaction types |
| 39 | + # Node types |
40 | 40 | UNKNOWN = 10 |
41 | | - DATA = 30 |
42 | | - ACTION = 40 |
43 | | - OPERATION = 50 |
| 41 | + DATA = 20 |
| 42 | + ACTION = 30 |
| 43 | + OPERATION = 40 |
| 44 | + CONDITION = 50 |
44 | 45 |
|
45 | 46 | # Description: |
46 | 47 | # This is class constructor. |
47 | 48 | def __init__(self): |
48 | 49 | # initialize object data |
49 | 50 | self.input_data_list = [] |
50 | | - self.name = "N/A" |
51 | | - self.uid = "N/A" |
| 51 | + self.interaction = "UNKNOWN" |
| 52 | + self.uid = "UNKNOWN" |
52 | 53 | self.type = ActivityNode.UNKNOWN |
| 54 | + self.dependency_list = [] |
53 | 55 | self.output_data_list = [] |
54 | 56 |
|
55 | 57 | # Description: |
56 | 58 | # This method returns string representation of ActivityNode class. |
57 | 59 | def __str__(self): |
58 | | - # append input marker |
59 | | - line = "$INPUTS$: " |
60 | 60 |
|
61 | | - # if node is operation type |
62 | 61 | if self.type == ActivityNode.OPERATION: |
63 | 62 |
|
64 | 63 | # append input data |
| 64 | + line = "$INPUTS$: " |
65 | 65 | for input_data in self.input_data_list: |
66 | 66 | line = line + input_data[ActivityNode.DATA_NAME_INDEX] + \ |
67 | 67 | "->" + input_data[ActivityNode.PIN_NAME_INDEX] + " " |
68 | 68 |
|
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 + " " |
74 | 71 |
|
75 | 72 | # append output data |
| 73 | + line = line + "$OUTPUTS$: " |
76 | 74 | for output_data in self.output_data_list: |
77 | 75 | line = line + output_data[ActivityNode.PIN_NAME_INDEX] + \ |
78 | 76 | "->" + output_data[ActivityNode.DATA_NAME_INDEX] + " " |
79 | 77 |
|
80 | 78 | # remove spare whitespace |
81 | | - line = line[0:len(line)-1] |
| 79 | + line = line[0:len(line) - 1] |
82 | 80 |
|
83 | | - # if node is action type |
84 | 81 | elif self.type == ActivityNode.ACTION: |
85 | 82 |
|
86 | 83 | # append input data |
| 84 | + line = "$INPUTS$: " |
87 | 85 | for input_data in self.input_data_list: |
88 | 86 | line = line + input_data[ActivityNode.DATA_NAME_INDEX] + " " |
89 | 87 |
|
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 + " " |
95 | 90 |
|
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] |
98 | 93 |
|
99 | | - # if there is no interaction, but only connection between two data points |
100 | | - else: |
| 94 | + elif self.type == ActivityNode.DATA: |
101 | 95 |
|
102 | 96 | # 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] + " " |
105 | 114 |
|
106 | | - # append interaction name |
107 | | - line = line + "$INTERACTION$: ASSIGNMENT " |
| 115 | + # remove spare whitespace |
| 116 | + line = line[0:len(line) - 1] |
108 | 117 |
|
109 | | - # get output data |
110 | | - output_data = self.output_data_list[0] |
| 118 | + else: |
111 | 119 |
|
112 | | - # append output marker and data |
113 | | - line = line + "$OUTPUT$: " + output_data[ActivityNode.DATA_NAME_INDEX] |
| 120 | + line = "$UNKNOWN$" |
114 | 121 |
|
115 | 122 | # return string representation |
116 | 123 | return line |
0 commit comments