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
/* 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.
*/
package ui;
import ui.eln.*;
import ui.eln.sca_eln.*;
import ui.eln.sca_eln_sca_tdf.*;
import syscamstranslator.*;
/**
* Class ELNPanelTranslator
* Translation of semantics of ELN Diagrams
* Creation: 24/07/2018
* @version 1.0 24/07/2018
* @author Irina Kit Yan LEE
*/
public class ELNPanelTranslator {
private List<TGComponent> tgcComponents;
private List<ELNTComponent> elnComponents;
private List<ELNTConnector> elnConnectors;
private List<SysCAMSTComponent> syscamsComponents;
private List<SysCAMSTConnector> syscamsConnectors;
public ELNPanelTranslator(ELNDiagramPanel _elnDiagramPanel) {
tgcComponents = _elnDiagramPanel.getComponentList();
elnComponents = new LinkedList<ELNTComponent>();
elnConnectors = new LinkedList<ELNTConnector>();
syscamsComponents = new LinkedList<SysCAMSTComponent>();
syscamsConnectors = new LinkedList<SysCAMSTConnector>();
MakeListOfComponent(_elnDiagramPanel);
}
private void MakeListOfComponent(ELNDiagramPanel elnDiagramPanel) {
Map<TGComponent, ELNTComponent> elnMap = new HashMap<TGComponent, ELNTComponent>();
Map<TGComponent, SysCAMSTComponent> syscamsMap = new HashMap<TGComponent, SysCAMSTComponent>();
TGComponent tgc;
Iterator<TGComponent> iterator1 = tgcComponents.listIterator();
Iterator<TGComponent> iterator2 = tgcComponents.listIterator();
List<TGComponent> list = new ArrayList<TGComponent>();
while (iterator1.hasNext()) {
tgc = iterator1.next();
if (!(tgc instanceof TGConnector)) {
list.add(tgc);
}
}
while (iterator2.hasNext()) {
tgc = iterator2.next();
if (tgc instanceof TGConnector) {
list.add(tgc);
}
}
for (TGComponent dp : list) {
if (dp instanceof ELNCluster) {
ELNCluster cluster = (ELNCluster) dp;
String clusterName = cluster.getValue();
ELNTCluster elnCluster = new ELNTCluster(clusterName);
List<SysCAMSPortDE> portsDE = cluster.getAllPortDE();
for (int i = 0; i < portsDE.size(); i++) {
SysCAMSPortDE portDE = portsDE.get(i);
String portName = portDE.getPortName();
String type = portDE.getDEType();
int origin = portDE.getOrigin();
boolean sensitive = portDE.getSensitive();
String sensitiveMethod = portDE.getSensitiveMethod();
SysCAMSTPortDE syscamsPortDE = new SysCAMSTPortDE(portName, origin, type, sensitive, sensitiveMethod, elnCluster);
syscamsMap.put(portDE, syscamsPortDE);
elnCluster.addPortDE(syscamsPortDE);
syscamsComponents.add(syscamsPortDE);
List<SysCAMSPortTDF> portsTDF = cluster.getAllPortTDF();
for (int i = 0; i < portsTDF.size(); i++) {
SysCAMSPortTDF portTDF = portsTDF.get(i);
String portName = portTDF.getPortName();
int periodPort = portTDF.getPeriod();
String time = portTDF.getTime();
int rate = portTDF.getRate();
int delay = portTDF.getDelay();
String type = portTDF.getTDFType();
int origin = portTDF.getOrigin();
SysCAMSTPortTDF syscamsPortTDF = new SysCAMSTPortTDF(portName, periodPort, time, rate, delay, origin, type, elnCluster);
syscamsMap.put(portTDF, syscamsPortTDF);
elnCluster.addPortTDF(syscamsPortTDF);
syscamsComponents.add(syscamsPortTDF);
List<ELNModule> modules = cluster.getAllModule();
for (int i = 0; i < modules.size(); i++) {
ELNModule module = modules.get(i);
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
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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
String moduleName = module.getValue();
ELNTModule elnModule = new ELNTModule(moduleName, elnCluster);
List<ELNComponentCapacitor> capacitors = module.getAllComponentCapacitor();
for (int j = 0; j < capacitors.size(); j++) {
ELNComponentCapacitor capacitor = capacitors.get(i);
String name = capacitor.getValue();
double val = capacitor.getVal();
double q0 = capacitor.getQ0();
String unit0 = capacitor.getUnit0();
String unit1 = capacitor.getUnit1();
ELNConnectingPoint[] cp = (ELNConnectingPoint[]) capacitor.connectingPoint;
ELNTComponentCapacitor elnCapacitor = new ELNTComponentCapacitor(name, val, q0, unit0, unit1, cp, elnModule);
elnMap.put(capacitor, elnCapacitor);
elnModule.addCapacitor(elnCapacitor);
elnComponents.add(elnCapacitor);
}
List<ELNComponentCurrentSinkTDF> TDF_isinks = module.getAllComponentCurrentSinkTDF();
for (int j = 0; j < TDF_isinks.size(); j++) {
ELNComponentCurrentSinkTDF TDF_isink = TDF_isinks.get(i);
String name = TDF_isink.getValue();
double scale = TDF_isink.getScale();
ELNConnectingPoint[] cp = (ELNConnectingPoint[]) TDF_isink.connectingPoint;
ELNTComponentCurrentSinkTDF elnTDF_isink = new ELNTComponentCurrentSinkTDF(name, scale, cp, elnModule);
elnMap.put(TDF_isink, elnTDF_isink);
elnModule.addTDF_isink(elnTDF_isink);
elnComponents.add(elnTDF_isink);
}
List<ELNComponentCurrentSourceTDF> TDF_isources = module.getAllComponentCurrentSourceTDF();
for (int j = 0; j < TDF_isources.size(); j++) {
ELNComponentCurrentSourceTDF TDF_isource = TDF_isources.get(i);
String name = TDF_isource.getValue();
double scale = TDF_isource.getScale();
ELNConnectingPoint[] cp = (ELNConnectingPoint[]) TDF_isource.connectingPoint;
ELNTComponentCurrentSourceTDF elnTDF_isource = new ELNTComponentCurrentSourceTDF(name, scale, cp, elnModule);
elnMap.put(TDF_isource, elnTDF_isource);
elnModule.addTDF_isource(elnTDF_isource);
elnComponents.add(elnTDF_isource);
}
List<ELNComponentIdealTransformer> idealTransformers = module.getAllComponentIdealTransformer();
for (int j = 0; j < idealTransformers.size(); j++) {
ELNComponentIdealTransformer idealTransformer = idealTransformers.get(i);
String name = idealTransformer.getValue();
double ratio = idealTransformer.getRatio();
ELNConnectingPoint[] cp = (ELNConnectingPoint[]) idealTransformer.connectingPoint;
ELNTComponentIdealTransformer elnIdealTransformer = new ELNTComponentIdealTransformer(name, ratio, cp, elnModule);
elnMap.put(idealTransformer, elnIdealTransformer);
elnModule.addIdealTransformer(elnIdealTransformer);
elnComponents.add(elnIdealTransformer);
}
List<ELNComponentIndependentCurrentSource> isources = module.getAllComponentIndependentCurrentSource();
for (int j = 0; j < isources.size(); j++) {
ELNComponentIndependentCurrentSource isource = isources.get(i);
String name = isource.getValue();
double initValue = isource.getInitValue();
double offset = isource.getOffset();
double amplitude = isource.getAmplitude();
double frequency = isource.getFrequency();
double phase = isource.getPhase();
double acAmplitude = isource.getAcAmplitude();
double acPhase = isource.getAcPhase();
double acNoiseAmpliture = isource.getAcNoiseAmplitude();
String delay = isource.getDelay();
String unit0 = isource.getUnit0();
ELNConnectingPoint[] cp = (ELNConnectingPoint[]) isource.connectingPoint;
ELNTComponentIndependentCurrentSource elnISource = new ELNTComponentIndependentCurrentSource(name, initValue, offset, amplitude, frequency, phase, acAmplitude, acPhase, acNoiseAmpliture, delay, unit0, cp, elnModule);
elnMap.put(isource, elnISource);
elnModule.addIsource(elnISource);
elnComponents.add(elnISource);
}
List<ELNComponentIndependentVoltageSource> vsources = module.getAllComponentIndependentVoltageSource();
for (int j = 0; j < vsources.size(); j++) {
ELNComponentIndependentVoltageSource vsource = vsources.get(i);
String name = vsource.getValue();
double initValue = vsource.getInitValue();
double offset = vsource.getOffset();
double amplitude = vsource.getAmplitude();
double frequency = vsource.getFrequency();
double phase = vsource.getPhase();
double acAmplitude = vsource.getAcAmplitude();
double acPhase = vsource.getAcPhase();
double acNoiseAmpliture = vsource.getAcNoiseAmplitude();
String delay = vsource.getDelay();
String unit0 = vsource.getUnit0();
ELNConnectingPoint[] cp = (ELNConnectingPoint[]) vsource.connectingPoint;
ELNTComponentIndependentVoltageSource elnVSource = new ELNTComponentIndependentVoltageSource(name, initValue, offset, amplitude, frequency, phase, acAmplitude, acPhase, acNoiseAmpliture, delay, unit0, cp, elnModule);
elnMap.put(vsource, elnVSource);
elnModule.addVsource(elnVSource);
elnComponents.add(elnVSource);
}
List<ELNComponentInductor> inductors = module.getAllComponentInductor();
for (int j = 0; j < inductors.size(); j++) {
ELNComponentInductor inductor = inductors.get(i);
String name = inductor.getValue();
double val = inductor.getVal();
double phi0 = inductor.getPhi0();
String unit0 = inductor.getUnit0();
String unit1 = inductor.getUnit1();
ELNConnectingPoint[] cp = (ELNConnectingPoint[]) inductor.connectingPoint;
ELNTComponentInductor elnInductor = new ELNTComponentInductor(name, val, phi0, unit0, unit1, cp, elnModule);
elnMap.put(inductor, elnInductor);
elnModule.addInductor(elnInductor);
elnComponents.add(elnInductor);
}
List<ELNComponentNodeRef> nodeRefs = module.getAllComponentNodeRef();
for (int j = 0; j < nodeRefs.size(); j++) {
ELNComponentNodeRef nodeRef = nodeRefs.get(i);
String name = nodeRef.getValue();
ELNTComponentNodeRef elnNodeRef = new ELNTComponentNodeRef(name, elnModule);
elnMap.put(nodeRef, elnNodeRef);
elnModule.addNodeRef(elnNodeRef);
elnComponents.add(elnNodeRef);
}
List<ELNComponentResistor> resistors = module.getAllComponentResistor();
for (int j = 0; j < resistors.size(); j++) {
ELNComponentResistor resistor = resistors.get(i);
String name = resistor.getValue();
double val = resistor.getVal();
String unit = resistor.getUnit();
ELNConnectingPoint[] cp = (ELNConnectingPoint[]) resistor.connectingPoint;
ELNTComponentResistor elnResistor = new ELNTComponentResistor(name, val, unit, cp, elnModule);
elnMap.put(resistor, elnResistor);
elnModule.addResistor(elnResistor);
elnComponents.add(elnResistor);
}
List<ELNComponentTransmissionLine> transmissionLines = module.getAllComponentTransmissionLine();
for (int j = 0; j < transmissionLines.size(); j++) {
ELNComponentTransmissionLine transmissionLine = transmissionLines.get(i);
String name = transmissionLine.getValue();
double z0 = transmissionLine.getZ0();
double delta0 = transmissionLine.getDelta0();
String delay = transmissionLine.getDelay();
String unit0 = transmissionLine.getUnit0();
String unit2 = transmissionLine.getUnit2();
ELNConnectingPoint[] cp = (ELNConnectingPoint[]) transmissionLine.connectingPoint;
ELNTComponentTransmissionLine elnTransmissionLine = new ELNTComponentTransmissionLine(name, z0, delta0, delay, unit0, unit2, cp, elnModule);
elnMap.put(transmissionLine, elnTransmissionLine);
elnModule.addTransmissionLine(elnTransmissionLine);
elnComponents.add(elnTransmissionLine);
}
List<ELNComponentVoltageControlledCurrentSource> vccss = module.getAllComponentVoltageControlledCurrentSource();
for (int j = 0; j < vccss.size(); j++) {
ELNComponentVoltageControlledCurrentSource vccs = vccss.get(i);
String name = vccs.getValue();
double val = vccs.getVal();
String unit = vccs.getUnit();
ELNConnectingPoint[] cp = (ELNConnectingPoint[]) vccs.connectingPoint;
ELNTComponentVoltageControlledCurrentSource elnVCCS = new ELNTComponentVoltageControlledCurrentSource(name, val, unit, cp, elnModule);
elnMap.put(vccs, elnVCCS);
elnModule.addVccs(elnVCCS);
elnComponents.add(elnVCCS);
}
List<ELNComponentVoltageControlledVoltageSource> vcvss = module.getAllComponentVoltageControlledVoltageSource();
for (int j = 0; j < vcvss.size(); j++) {
ELNComponentVoltageControlledVoltageSource vcvs = vcvss.get(i);
String name = vcvs.getValue();
double val = vcvs.getVal();
ELNConnectingPoint[] cp = (ELNConnectingPoint[]) vcvs.connectingPoint;
ELNTComponentVoltageControlledVoltageSource elnVCVS = new ELNTComponentVoltageControlledVoltageSource(name, val, cp, elnModule);
elnMap.put(vcvs, elnVCVS);
elnModule.addVcvs(elnVCVS);
elnComponents.add(elnVCVS);
}
List<ELNComponentVoltageSinkTDF> TDF_vsinks = module.getAllComponentVoltageSinkTDF();
for (int j = 0; j < TDF_vsinks.size(); j++) {
ELNComponentVoltageSinkTDF TDF_vsink = TDF_vsinks.get(i);
String name = TDF_vsink.getValue();
double scale = TDF_vsink.getScale();
ELNConnectingPoint[] cp = (ELNConnectingPoint[]) TDF_vsink.connectingPoint;
ELNTComponentVoltageSinkTDF elnTDF_vsink = new ELNTComponentVoltageSinkTDF(name, scale, cp, elnModule);
elnMap.put(TDF_vsink, elnTDF_vsink);
elnModule.addTDF_vsink(elnTDF_vsink);
elnComponents.add(elnTDF_vsink);
}
List<ELNComponentVoltageSourceTDF> TDF_vsources = module.getAllComponentVoltageSourceTDF();
for (int j = 0; j < TDF_vsources.size(); j++) {
ELNComponentVoltageSourceTDF TDF_vsource = TDF_vsources.get(i);
String name = TDF_vsource.getValue();
double scale = TDF_vsource.getScale();
ELNConnectingPoint[] cp = (ELNConnectingPoint[]) TDF_vsource.connectingPoint;
ELNTComponentVoltageSourceTDF elnTDF_vsource = new ELNTComponentVoltageSourceTDF(name, scale, cp, elnModule);
elnMap.put(TDF_vsource, elnTDF_vsource);
elnModule.addTDF_vsource(elnTDF_vsource);
elnComponents.add(elnTDF_vsource);
}
List<ELNModuleTerminal> moduleTerminals = module.getAllModuleTerminal();
for (int j = 0; j < moduleTerminals.size(); j++) {
ELNModuleTerminal moduleTerminal = moduleTerminals.get(i);
String name = moduleTerminal.getValue();
ELNTModuleTerminal elnModuleTerminal = new ELNTModuleTerminal(name, elnModule);
elnMap.put(moduleTerminal, elnModuleTerminal);
elnModule.addModuleTerminal(elnModuleTerminal);
elnComponents.add(elnModuleTerminal);
}
List<SysCAMSPortDE> portsDEModule = module.getAllPortDE();
for (int j = 0; j < portsDEModule.size(); j++) {
SysCAMSPortDE portDE = portsDEModule.get(i);
String portName = portDE.getPortName();
String type = portDE.getDEType();
int origin = portDE.getOrigin();
boolean sensitive = portDE.getSensitive();
String sensitiveMethod = portDE.getSensitiveMethod();
SysCAMSTPortDE syscamsPortDE = new SysCAMSTPortDE(portName, origin, type, sensitive, sensitiveMethod, elnModule);
syscamsMap.put(portDE, syscamsPortDE);
elnModule.addPortDE(syscamsPortDE);
syscamsComponents.add(syscamsPortDE);
}
List<SysCAMSPortTDF> portsTDFModule = module.getAllPortTDF();
for (int j = 0; j < portsTDFModule.size(); j++) {
SysCAMSPortTDF portTDF = portsTDFModule.get(i);
String portName = portTDF.getPortName();
int periodPort = portTDF.getPeriod();
String time = portTDF.getTime();
int rate = portTDF.getRate();
int delay = portTDF.getDelay();
String type = portTDF.getTDFType();
int origin = portTDF.getOrigin();
SysCAMSTPortTDF syscamsPortTDF = new SysCAMSTPortTDF(portName, periodPort, time, rate, delay, origin, type, elnModule);
syscamsMap.put(portTDF, syscamsPortTDF);
elnModule.addPortTDF(syscamsPortTDF);
syscamsComponents.add(syscamsPortTDF);
}
elnMap.put(module, elnModule);
elnCluster.addModule(elnModule);
elnComponents.add(elnModule);
elnMap.put(cluster, elnCluster);
elnComponents.add(elnCluster);
} else if (dp instanceof ELNConnector) {
ELNConnector connector = (ELNConnector) dp;
String name = connector.getValue();
ELNConnectingPoint connectingPoint1 = (ELNConnectingPoint) connector.get_p1();
ELNConnectingPoint connectingPoint2 = (ELNConnectingPoint) connector.get_p2();
String p1Name = connectingPoint1.getName();
String p2Name = connectingPoint2.getName();
TGComponent owner_p1 = elnDiagramPanel.getComponentToWhichBelongs(connectingPoint1);
TGComponent owner_p2 = elnDiagramPanel.getComponentToWhichBelongs(connectingPoint2);
ELNTComponent avowner_p1 = elnMap.get(owner_p1);
ELNTComponent avowner_p2 = elnMap.get(owner_p2);
ELNTConnectingPoint avConnectingPoint1 = new ELNTConnectingPoint(avowner_p1, p1Name);
ELNTConnectingPoint avConnectingPoint2 = new ELNTConnectingPoint(avowner_p2, p2Name);
ELNTConnector avconnector = new ELNTConnector(avConnectingPoint1, avConnectingPoint2, name);
List<ELNMidPortTerminal> midPortTerminals = connector.getAllMidPortTerminal();
for (int i = 0; i < midPortTerminals.size(); i++) {
ELNMidPortTerminal midPortTerminal = midPortTerminals.get(i);
ELNTMidPortTerminal elnMidPortTerminal = new ELNTMidPortTerminal(avconnector);
elnMap.put(midPortTerminal, elnMidPortTerminal);
avconnector.addMidPortTerminal(elnMidPortTerminal);
elnComponents.add(elnMidPortTerminal);
}
elnConnectors.add(avconnector);
} else if (dp instanceof SysCAMSPortConnector) {
SysCAMSPortConnector connector = (SysCAMSPortConnector) dp;
TGConnectingPoint connectingPoint1 = connector.get_p1();
TGConnectingPoint connectingPoint2 = connector.get_p2();
String name = connector.getValue();
TGComponent owner_p1 = elnDiagramPanel.getComponentToWhichBelongs(connectingPoint1);
TGComponent owner_p2 = elnDiagramPanel.getComponentToWhichBelongs(connectingPoint2);
SysCAMSTComponent avowner_p1 = syscamsMap.get(owner_p1);
SysCAMSTComponent avowner_p2 = syscamsMap.get(owner_p2);
SysCAMSTConnectingPoint avConnectingPoint1 = new SysCAMSTConnectingPoint(avowner_p1);
SysCAMSTConnectingPoint avConnectingPoint2 = new SysCAMSTConnectingPoint(avowner_p2);
SysCAMSTConnector avconnector = new SysCAMSTConnector(avConnectingPoint1, avConnectingPoint2, name);
syscamsConnectors.add(avconnector);
}
}
}
public ELNSpecification getELNSpecification() {
return new ELNSpecification(elnComponents, elnConnectors, syscamsComponents, syscamsConnectors);