Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
ludovic.apvrille AT enst.fr
This software is a computer program whose purpose is to allow the
edition of TURTLE analysis, design and deployment diagrams, to
allow the generation of RT-LOTOS or Java code from this diagram,
and at last to allow the analysis of formal validation traces
obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
from INRIA Rhone-Alpes.
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
/**
* Class AvatarRelation
* synchronizatio in Avatar ...
* Creation: 20/05/2010
* @version 1.0 20/05/2010
* @author Ludovic APVRILLE
* @see
*/
package avatartranslator;
import java.util.*;
import myutil.*;
public class AvatarRelation extends AvatarElement {
public AvatarBlock block1, block2;
private LinkedList<AvatarSignal> signals1, signals2;
private boolean blocking, asynchronous, isPrivate, isBroadcast, isLossy;
private int sizeOfFIFO; // -1 means infinite
public AvatarRelation(String _name, AvatarBlock _block1, AvatarBlock _block2, Object _referenceObject) {
super(_name, _referenceObject);
signals1 = new LinkedList<AvatarSignal>();
signals2 = new LinkedList<AvatarSignal>();
block1 = _block1;
block2 = _block2;
blocking = false;
sizeOfFIFO = 1024;
asynchronous = false;
isBroadcast = false;
}
public boolean containsSignal(AvatarSignal _as) {
return (signals1.contains(_as) || signals2.contains(_as));
}
public void setAsynchronous(boolean _b) {
asynchronous = _b;
}
public void setBlocking(boolean _b) {
blocking = _b;
}
public void setPrivate(boolean _b) {
isPrivate = _b;
}
public void setBroadcast(boolean _b) {
isBroadcast = _b;
}
public void setLossy(boolean _b) {
isLossy = _b;
}
public void setSizeOfFIFO(int _sizeOfFIFO) {
sizeOfFIFO = _sizeOfFIFO;
}
public boolean isAsynchronous() {
return asynchronous;
}
public boolean isPrivate() {
return isPrivate;
}
public boolean isBroadcast() {
return isBroadcast;
}
public boolean isLossy() {
return isLossy;
}
public int getSizeOfFIFO() {
return sizeOfFIFO;
}
public boolean isBlocking() {
return blocking;
}
public void addSignals(AvatarSignal _sig1, AvatarSignal _sig2) {
signals1.add(_sig1);
signals2.add(_sig2);
}
public int nbOfSignals() {
return signals1.size();
}
public AvatarSignal getSignal1(int _index) {
return signals1.get(_index);
}
public AvatarSignal getSignal2(int _index) {
return signals2.get(_index);
}
public AvatarSignal getInSignal(int _index) {
AvatarSignal sig1 = signals1.get(_index);
if (sig1.isIn()) {
return sig1;
}
return getSignal2(_index);
}
public AvatarBlock getInBlock(int _index) {
AvatarSignal sig1 = signals1.get(_index);
if (sig1.isIn()) {
return block1;
}
return block2;
}
public AvatarSignal getOutSignal(int _index) {
AvatarSignal sig1 = signals1.get(_index);
if (sig1.isOut()) {
return sig1;
}
return getSignal2(_index);
}
public AvatarBlock getOutBlock(int _index) {
AvatarSignal sig1 = signals1.get(_index);
if (sig1.isOut()) {
return block1;
}
return block2;
}
public String toString() {
StringBuffer sb = new StringBuffer();
for(int i=0; i<signals1.size(); i++) {
if (i>0) {
sb.append(" ; ");
}
sb.append(block1.getName() + "." + signals1.get(i).getName() + "=" + block2.getName() + "." + signals2.get(i).getName());
}
return sb.toString();
}
public String toStringIndex(int index) {
return block1.getName() + "." + signals1.get(index).getName() + " -> " + block2.getName() + "." + signals2.get(index).getName();
}
// Return index of signal. If not found, return -1
public int hasSignal(AvatarSignal sig) {
int index1 = signals1.indexOf(sig);
int index2 = signals2.indexOf(sig);
return Math.max(index1, index2);
}
public int getIndexOfSignal(AvatarSignal sig) {
int index1 = signals1.indexOf(sig);
if (index1 > -1) {
return index1;
}
return signals2.indexOf(sig);
}
/*public void makeRobustness() {
LinkedList<AvatarSignal> signals1_tmp = new LinkedList<AvatarSignal>();
LinkedList<AvatarSignal> signals2_tmp = new LinkedList<AvatarSignal>();
AvatarSignal as1, as2, astmp;
for(int i=0; i<signals1.size(); i++) {
as1 = signals1.get(i);
as2 = signals2.get(i);
if (as1.isOut()) {
astmp = as2;
as2 = as1;
as1 = astmp;
}
signals1_tmp.add(as1);
astmp = new AvatarSignal(as1.getName() + "__in", AvatarSignal.IN, as1.getReferenceObject());
astmp.setInOut(AvatarSignal.IN);
signals2_tmp.add(astmp);
astmp = new AvatarSignal(as2.getName() + "__out", AvatarSignal.OUT, as2.getReferenceObject());
astmp.setInOut(AvatarSignal.OUT);
signals1_tmp.add(astmp);
signals2_tmp.add(as2);
}
signals1 = signals1_tmp;
signals2 = signals2_tmp;
}*/
public AvatarRelation advancedClone(HashMap<AvatarBlock, AvatarBlock> correspondenceBlocks) {
AvatarBlock b1, b2;
b1 = correspondenceBlocks.get(block1);
b2 = correspondenceBlocks.get(block2);
if ((b1 == null) || (b2 == null)) {
return null;
}
AvatarRelation ar = new AvatarRelation(getName(), b1, b2, getReferenceObject());
ar.setAsynchronous(isAsynchronous());
ar.setBlocking(isBlocking());
ar.setPrivate(isPrivate());
ar.setBroadcast(isBroadcast());
ar.setLossy(isLossy());
ar.setSizeOfFIFO(getSizeOfFIFO());
// Signals
for(int i=0; i<signals1.size(); i++) {
AvatarSignal s1 = getSignal1(i);
AvatarSignal s2 = getSignal2(i);
AvatarSignal ns1 = b1.getSignalByName(s1.getName());
AvatarSignal ns2 = b2.getSignalByName(s2.getName());
if ((ns1 == null) || (ns2 == null)) {
continue;
}
ar.addSignals(ns1, ns2);
}
cloneLinkToReferenceObjects(ar);
return ar;
}
}