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
package avatartranslator.tosysmlv2;
import java.util.ArrayList;
public class AvatarFromSysMLSyntax {
public class MyArray<E> extends ArrayList<E> {
@Override
public E set(int index, E element){
int max = size();
for(int i = max; i <= index; i++)
add(null);
return super.set(index, element);
}
}
/** idents collected while parsing an Avatar SysML Model */
interface Ident {
public String getSysMLname();
public String getAvatarName();
}
/** idents with same SysMLname and AvatarName (or no Avatar Name) */
class UniIdent implements Ident {
private String sysMLname;
public UniIdent(String _sysMLname){ sysMLname = _sysMLname; }
public String getSysMLname(){ return sysMLname; }
public String getAvatarName(){ return sysMLname; }
}
/** idents with different SysMLname and AvatarName */
class BiIdent implements Ident {
private String avatarName;
private String sysMLname;
public BiIdent(String _sysMLname, String _avatarName){
sysMLname = _sysMLname;
avatarName = _avatarName;
}
public String getSysMLname(){ return sysMLname; }
public String getAvatarName(){ return avatarName; }
}
public BiIdent identFromDATATYPENAME(String _ident){
return new BiIdent(_ident.substring(1,_ident.length() - 2), _ident.substring(5,_ident.length() - 2));
}
public BiIdent identFromATTRIBUTENAME(String _ident){
return new BiIdent(_ident.substring(1,_ident.length() - 2), _ident.substring(2,_ident.length() - 2));
}
public BiIdent identFromSIGNALNAMENAME(String _ident){
return new BiIdent(_ident.substring(1,_ident.length() - 2), _ident.substring(6,_ident.length() - 2));
}
public BiIdent identFromSTANDARDSTATENAME(String _ident){
return new BiIdent(_ident.substring(1,_ident.length() - 2), _ident.substring(14,_ident.length() - 2));
}
public BiIdent identFromBLOCKNAME(String _ident){
return new BiIdent(_ident.substring(1,_ident.length() - 2), _ident.substring(6,_ident.length() - 2));
}
public UniIdent identFromString(String _ident){
return new UniIdent(_ident.substring(1,_ident.length() - 2));
}
public abstract class StxElement {
private int row;
private int column;
public StxElement(int _row, int _column){ row = _row; column = _column; }
public StxElement(){ row = -1; column = -1; }
public void setRowColumn(int _row, int _column) { row = _row; column = _column; }
public int getRow() { return row; }
public int getColumn() { return column; }
}
public class StxDataType extends StxElement {
private String name;
private ArrayList<String> fieldNames;
private ArrayList<String> fieldTypes;
public StxDataType(int _row, int _column, String _name) {
super(_row, _column);
name = _name;
fieldNames = new ArrayList<String>();
fieldTypes = new ArrayList<String>();
}
public StxDataType(String _name) {
super();
name = _name;
fieldNames = new ArrayList<String>();
fieldTypes = new ArrayList<String>();
}
public boolean addField(String fieldName, String fieldType){
boolean result = true;
for (String fld : fieldNames) result &= (! fld.equals(fieldName));
if (result) {
fieldNames.add(fieldName);
fieldTypes.add(fieldType);
}
return result;
}
public String getName() { return name; }
public int getSize() { return fieldNames.size(); }
public String getFieldName(int i) { return fieldNames.get(i);}
public String getFieldType(int i) { return fieldTypes.get(i);}
}
public class StxAttribute extends StxElement {
String name;
String type;
public StxAttribute(int _row, int _column, String _name, String _type){
super(_row, _column);
name = _name;
type = _type;
}
public StxAttribute(String _name, String _type){
super();
name = _name;
type = _type;
}
public String getName() { return name; }
public String getType() { return type; }
}
public class StxMethod extends StxElement {
private String name;
private ArrayList<String> fieldNames;
private ArrayList<String> fieldTypes;
public StxMethod(int _row, int _column, String _name) {
super(_row, _column);
name = _name;
fieldNames = new ArrayList<String>();
fieldTypes = new ArrayList<String>();
}
public StxMethod(String _name) {
super();
name = _name;
fieldNames = new ArrayList<String>();
fieldTypes = new ArrayList<String>();
}
public boolean addField(String fieldName, String fieldType){
boolean result = true;
for (String fld : fieldNames) result &= (! fld.equals(fieldName));
if (result) {
fieldNames.add(fieldName);
fieldTypes.add(fieldType);
}
return result;
}
public String getName() { return name; }
public int getSize() { return fieldNames.size(); }
public String getFieldName(int i) { return fieldNames.get(i);}
public String getFieldType(int i) { return fieldTypes.get(i);}
}
public class StxTimer extends StxElement {
String name;
public StxTimer(int _row, int _column, String _name){
super(_row, _column);
name = _name;
}
public StxTimer(String _name){
super();
name = _name;
}
public String getName() { return name; }
}
public class StxBlock extends StxElement {
String name;
StxBlock father = null;
ArrayList<StxAttribute> attributes;
ArrayList<StxMethod> methods;
ArrayList<StxSignal> signals;
ArrayList<StxTimer> timers;
StxStateMachine statemachine;
public StxBlock(int _row, int _column, String _name) {
super(_row, _column);
name = _name;
father = null;
statemachine = null;
attributes = new ArrayList<StxAttribute>();
methods = new ArrayList<StxMethod>();
signals = new ArrayList<StxSignal>();
timers = new ArrayList<StxTimer>();
}
public StxBlock(String _name) {
super();
name = _name;
father = null;
statemachine = null;
attributes = new ArrayList<StxAttribute>();
methods = new ArrayList<StxMethod>();
signals = new ArrayList<StxSignal>();
timers = new ArrayList<StxTimer>();
}
public void setFather(StxBlock _father) { father = _father; }
public void setstatemachine(StxStateMachine _statemachine) { statemachine = _statemachine; }
public boolean addAttribute(StxAttribute a){
boolean result = true;
for (StxAttribute att : attributes) result &= (! att.getName().equals(a.getName()));
if (result) attributes.add(a);
return result;
}
public boolean addMethod(StxMethod m){
boolean result = true;
for (StxMethod mth : methods) result &= (! mth.getName().equals(m.getName()));
if (result) methods.add(m);
return result;
}
public boolean addTimer(StxTimer t){
boolean result = true;
for (StxTimer tm : timers) result &= (! tm.getName().equals(t.getName()));
if (result) timers.add(t);
return result;
}
public String getName() { return name; }
public StxBlock getFather() { return father; }
public StxStateMachine getstatemachine() { return statemachine; }
public int getNbAttributes() { return attributes.size(); }
public int getNbMethods() { return methods.size(); }
public int getNbSignals() { return signals.size(); }
public int getNbTimerss() { return timers.size(); }
public StxAttribute getAttribute(int i) { return attributes.get(i); }
public StxMethod getMethod(int i) { return methods.get(i); }
public StxSignal getSignal(int i) { return signals.get(i); }
public StxTimer getTimers(int i) { return timers.get(i); }
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
}
public class StxRelation extends StxElement {
ArrayList<StxChannel> channels;
String block1;
String block2;
boolean blocking;
int sizeOfFIFO;
boolean asynchronous;
public StxRelation(int _row, int _column) {
super(_row, _column);
channels = new ArrayList<StxChannel>();
String block1 = null;
String block2 = null;
}
public StxRelation() {
super();
channels = new ArrayList<StxChannel>();
String block1 = null;
String block2 = null;
}
public void setBlock1(String _name) { block1 = _name; }
public void setBlock2(String _name) { block2 = _name; }
public void setblocking(Boolean _b) { blocking = _b; }
public void setFifoSize(int _size) { sizeOfFIFO = _size; }
public void setAsynchronous(boolean _b) { asynchronous = _b; }
public void addChannel(StxChannel ch) { channels.add(ch); }
public String getBlock1(String _name) { return block1; }
public String getBlock2(String _name) { return block2; }
public Boolean getblocking(boolean _b) { return blocking; }
public int getFifoSize(int _size) { return sizeOfFIFO; }
public boolean getAsynchronous(boolean _b) { return asynchronous = _b; }
public int getSize() { return channels.size(); }
public StxChannel getChannel(int i) { return channels.get(i); }
}
public class StxChannel extends StxElement {
private String relation;
private StxInMessage inProfile;
private StxOutMessage outProfile;
private String blockA;
private StxSignal signalA;
private String blockB;
private StxSignal signalB;
public StxChannel(int _row, int _column){
super(_row, _column);
relation = null;
inProfile = null;
outProfile = null;
blockA = null;
blockB = null;
signalA = null;
signalB = null;
}
public StxChannel(){
super();
relation = null;
inProfile = null;
outProfile = null;
blockA = null;
blockB = null;
signalA = null;
signalB = null;
}
public void setRelationrelation(String _name) { relation = _name; }
public void setInProfile(StxInMessage m) { inProfile = m; }
public void setOutProfile(StxOutMessage m) { outProfile = m; }
public void setSignal(String _block, StxSignal s) {
if (signalA == null) { blockA = _block; signalA = s; }
else if (signalB == null) { blockB = _block; signalB = s; }
}
public void commuteSignals(String _block1) {
boolean permut =
(blockB != null && blockB.equals(_block1)) ||(blockA != null && ! blockB.equals(_block1));
if (permut) {
String auxStr = blockA;
StxSignal auxSig = signalA;
blockA = blockB;
signalA = signalB;
blockB = auxStr;
signalB = auxSig;
}
}
public void setSignalA(StxSignal s) { signalA = s; }
public void setSignalB(StxSignal s) { signalB = s; }
public String getRelationrelation() { return relation; }
public StxInMessage getInProfile() { return inProfile; }
public StxOutMessage getOutProfile() { return outProfile; }
public StxSignal getSignalA() { return signalA; }
public StxSignal getSignalB() { return signalB; }
}
public class StxSignal extends StxElement {
private String name;
private boolean input;
public StxSignal(int _row, int _column, String _name){
super(_row, _column);
name = _name;
}
public void setInput(boolean _b) { input = _b; }
public boolean isInput() { return input; }
public String getName() { return name; }
}
public class StxInMessage extends StxElement {
private String channel;
private ArrayList<String> fieldNames;
private ArrayList<String> fieldTypes;
public StxInMessage(int _row, int _column, String _channel) {
super(_row, _column);
channel = _channel;
fieldNames = new ArrayList<String>();
fieldTypes = new ArrayList<String>();
}
public StxInMessage(String _channel) {
super();
channel = _channel;
fieldNames = new ArrayList<String>();
fieldTypes = new ArrayList<String>();
}
public boolean addField(String fieldName, String fieldType){
boolean result = true;
for (String fld : fieldNames) result &= (! fld.equals(fieldName));
if (result) {
fieldNames.add(fieldName);
fieldTypes.add(fieldType);
}
return result;
}
public String getChannel() { return channel; }
public int getSize() { return fieldNames.size(); }
public String getFieldName(int i) { return fieldNames.get(i);}
public String getFieldType(int i) { return fieldTypes.get(i);}
}
public class StxOutMessage extends StxElement {
private String inMessage;
private ArrayList<String> fieldNames;
private ArrayList<String> inFieldNames;
public StxOutMessage(int _row, int _column, String _inMessage) {
super(_row, _column);
inMessage = _inMessage;
fieldNames = new ArrayList<String>();
inFieldNames = new ArrayList<String>();
}
public StxOutMessage(String _inMessage) {
super();
inMessage = _inMessage;
fieldNames = new ArrayList<String>();
inFieldNames = new ArrayList<String>();
}
public boolean addField(String fieldName, String inFieldName){
boolean result = true;
for (String fld : fieldNames) result &= (! fld.equals(fieldName));
for (String fld : inFieldNames) result &= (! fld.equals(inFieldName));
if (result) {
fieldNames.add(fieldName);
inFieldNames.add(inFieldName);
}
return result;
}
public String getInMessage() { return inMessage; }
public int getSize() { return fieldNames.size(); }
public String getFieldName(int i) { return fieldNames.get(i);}
public String getFieldType(int i) { return inFieldNames.get(i);}
}
public class StxStartState {}
public class StxStopState {}
public class StxStandardState {}
public class StxRandomState {}
public class StxCountState {}
public class StxSendState {}
public class StxReceiveState {}
public class StxPresendState {}
public class StxPrereceiveState {}
public class StxSetTimerState {}
public class StxResetTimerState {}
public class StxExpireTimerState {}
public class StxPresetTimerState {}
public class StxPreresetTimerState {}
public class StxPreexpireTimerState {}
public class StxTimerBlock {}
public class StxTimerRelation {}
public class StxSetTimerChannel {}
public class StxResetTimerChannel {}
public class StxExpireTimerChannel {}
public class StxTransition {}
public class StxStateMachine {}
}