Skip to content
Snippets Groups Projects
Commit 52dd695f authored by Ludovic Apvrille's avatar Ludovic Apvrille
Browse files

AVATAR:Update on simulator (better support of asynchronous messages, improved SD panel)

parent 37369e41
No related branches found
No related tags found
No related merge requests found
...@@ -167,7 +167,7 @@ public class AvatarSimulationBlock { ...@@ -167,7 +167,7 @@ public class AvatarSimulationBlock {
String s = Conversion.replaceAllString(guard, "[", "").trim(); String s = Conversion.replaceAllString(guard, "[", "").trim();
s = Conversion.replaceAllString(s, "]", "").trim(); s = Conversion.replaceAllString(s, "]", "").trim();
guardOk = evaluateBoolExpression(s, lastTransaction.attributeValues); guardOk = evaluateBoolExpression(s, lastTransaction.attributeValues);
TraceManager.addDev("guard ok=" + guardOk); //TraceManager.addDev("guard ok=" + guardOk);
} }
} }
...@@ -208,7 +208,7 @@ public class AvatarSimulationBlock { ...@@ -208,7 +208,7 @@ public class AvatarSimulationBlock {
aspt.myMaxDelay = evaluateIntExpression(trans.getMaxDelay(), lastTransaction.attributeValues); aspt.myMaxDelay = evaluateIntExpression(trans.getMaxDelay(), lastTransaction.attributeValues);
aspt.hasDelay = true; aspt.hasDelay = true;
TraceManager.addDev(">>>>> Signal with delay before"); //TraceManager.addDev(">>>>> Signal with delay before");
if (lastTransaction != null) { if (lastTransaction != null) {
if (lastTransaction.clockValueWhenFinished < _clockValue) { if (lastTransaction.clockValueWhenFinished < _clockValue) {
...@@ -309,7 +309,7 @@ public class AvatarSimulationBlock { ...@@ -309,7 +309,7 @@ public class AvatarSimulationBlock {
ast.clockValueWhenFinished = _aspt.selectedDuration + _clockValue; ast.clockValueWhenFinished = _aspt.selectedDuration + _clockValue;
_aspt.clockValueAtEnd = ast.clockValueWhenFinished; _aspt.clockValueAtEnd = ast.clockValueWhenFinished;
} }
TraceManager.addDev("Id= " + ast.id + " duration=" + ast.duration + " elapsed=" + _aspt.elapsedTime + " selectedDur=" + _aspt.selectedDuration + " at end: " + _aspt.clockValueAtEnd + "clockValue=" + _clockValue); //TraceManager.addDev("Id= " + ast.id + " duration=" + ast.duration + " elapsed=" + _aspt.elapsedTime + " selectedDur=" + _aspt.selectedDuration + " at end: " + _aspt.clockValueAtEnd + "clockValue=" + _clockValue);
} }
...@@ -367,7 +367,7 @@ public class AvatarSimulationBlock { ...@@ -367,7 +367,7 @@ public class AvatarSimulationBlock {
// Synchronous Sending! // Synchronous Sending!
// Must be in the receiving transaction the right parameters // Must be in the receiving transaction the right parameters
Vector<String> parameters = new Vector<String>(); Vector<String> parameters = new Vector<String>();
TraceManager.addDev("Adding value in :" + aaos); //TraceManager.addDev("Adding value in :" + aaos);
for(i=0; i<aaos.getNbOfValues(); i++) { for(i=0; i<aaos.getNbOfValues(); i++) {
value = aaos.getValue(i); value = aaos.getValue(i);
// Must get the type of the value // Must get the type of the value
...@@ -381,7 +381,7 @@ public class AvatarSimulationBlock { ...@@ -381,7 +381,7 @@ public class AvatarSimulationBlock {
result += evaluateBoolExpression(value, lastTransaction.attributeValues); result += evaluateBoolExpression(value, lastTransaction.attributeValues);
} }
TraceManager.addDev("Adding value:" + result); //TraceManager.addDev("Adding value:" + result);
parameters.add(result); parameters.add(result);
} catch (Exception e) { } catch (Exception e) {
TraceManager.addDev("EXCEPTION on adding value " + aaos); TraceManager.addDev("EXCEPTION on adding value " + aaos);
...@@ -393,7 +393,7 @@ public class AvatarSimulationBlock { ...@@ -393,7 +393,7 @@ public class AvatarSimulationBlock {
// Synchronous Receiving // Synchronous Receiving
String myAction = ""; String myAction = "";
for(i=0; i<aaos.getNbOfValues(); i++) { for(i=0; i<aaos.getNbOfValues(); i++) {
TraceManager.addDev("Reading value #" + i); //TraceManager.addDev("Reading value #" + i);
param = _aspt.parameters.get(i); param = _aspt.parameters.get(i);
name = aaos.getValue(i); name = aaos.getValue(i);
index = block.getIndexOfAvatarAttributeWithName(name); index = block.getIndexOfAvatarAttributeWithName(name);
...@@ -401,7 +401,7 @@ public class AvatarSimulationBlock { ...@@ -401,7 +401,7 @@ public class AvatarSimulationBlock {
if (index != -1) { if (index != -1) {
attributeValues.remove(index); attributeValues.remove(index);
attributeValues.add(index, param); attributeValues.add(index, param);
TraceManager.addDev("Reading value:" + param); //TraceManager.addDev("Reading value:" + param);
if (myAction.length() == 0) { if (myAction.length() == 0) {
myAction += "" + param; myAction += "" + param;
} else { } else {
...@@ -422,6 +422,7 @@ public class AvatarSimulationBlock { ...@@ -422,6 +422,7 @@ public class AvatarSimulationBlock {
// Asynchronous Sending // Asynchronous Sending
String myAction = ""; String myAction = "";
_aspt.linkedAsynchronousMessage.firstTransaction = ast;
for(i=0; i<aaos.getNbOfValues(); i++) { for(i=0; i<aaos.getNbOfValues(); i++) {
value = aaos.getValue(i); value = aaos.getValue(i);
// Must get the type of the value // Must get the type of the value
...@@ -432,9 +433,9 @@ public class AvatarSimulationBlock { ...@@ -432,9 +433,9 @@ public class AvatarSimulationBlock {
} else if (avat.getType() == AvatarType.BOOLEAN) { } else if (avat.getType() == AvatarType.BOOLEAN) {
result += evaluateBoolExpression(value, lastTransaction.attributeValues); result += evaluateBoolExpression(value, lastTransaction.attributeValues);
} }
TraceManager.addDev("Adding value:" + result); //TraceManager.addDev("Adding value:" + result);
_aspt.linkedAsynchronousMessage.addParameter(result); _aspt.linkedAsynchronousMessage.addParameter(result);
_aspt.linkedAsynchronousMessage.firstTransaction = ast;
if (myAction.length() == 0) { if (myAction.length() == 0) {
myAction += "" + result; myAction += "" + result;
} else { } else {
...@@ -467,6 +468,9 @@ public class AvatarSimulationBlock { ...@@ -467,6 +468,9 @@ public class AvatarSimulationBlock {
myAction += ", " + param; myAction += ", " + param;
} }
} }
}
if (_aspt.linkedAsynchronousMessage == null) {
TraceManager.addDev("NULL ASYN MSG");
} }
if (myAction.length() > 0) { if (myAction.length() > 0) {
ast.actions = new Vector<String>(); ast.actions = new Vector<String>();
......
...@@ -323,6 +323,9 @@ public class AvatarSpecificationSimulation { ...@@ -323,6 +323,9 @@ public class AvatarSpecificationSimulation {
if (asat != null) { if (asat != null) {
_aspt.linkedAsynchronousMessage = asat; _aspt.linkedAsynchronousMessage = asat;
transactions.add(_aspt); transactions.add(_aspt);
/*if (asat.firstTransaction == null) {
TraceManager.addDev("NULL FIRST");
}*/
} }
} }
} else { } else {
......
...@@ -73,7 +73,9 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous ...@@ -73,7 +73,9 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous
private final int limit = 10; private final int limit = 10;
// Drawing parameters // Drawing parameters
private int minSpaceBetweenLifeLines = 5;
private int spaceBetweenLifeLines = 150; private int spaceBetweenLifeLines = 150;
private boolean spaceBetweenLifeLinesComputed = false;
private int spaceAtEnd = 50; private int spaceAtEnd = 50;
private int spaceAtTop = 50; private int spaceAtTop = 50;
private int verticalSpaceUnderBlocks = 15; private int verticalSpaceUnderBlocks = 15;
...@@ -120,6 +122,10 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous ...@@ -120,6 +122,10 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous
int oldMaxY = maxY; int oldMaxY = maxY;
int oldMaxX = maxX; int oldMaxX = maxX;
if (!spaceBetweenLifeLinesComputed) {
computeSpaceBetweenLifeLines(g);
}
currentY = paintTopElements(g, currentX, currentY); currentY = paintTopElements(g, currentX, currentY);
paintTransactions(g, currentX, currentY); paintTransactions(g, currentX, currentY);
...@@ -171,6 +177,20 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous ...@@ -171,6 +177,20 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous
return currentY + verticalSpaceUnderBlocks; return currentY + verticalSpaceUnderBlocks;
} }
private void computeSpaceBetweenLifeLines(Graphics g) {
int w;
spaceBetweenLifeLinesComputed = true;
for(AvatarSimulationBlock block: ass.getSimulationBlocks()) {
w = g.getFontMetrics().stringWidth(block.getBlock().getName());
if ((w+minSpaceBetweenLifeLines) > spaceBetweenLifeLines) {
spaceBetweenLifeLines = w+minSpaceBetweenLifeLines;
}
}
}
// returns the currentY position // returns the currentY position
protected int paintTransactions(Graphics g, int currentX, int currentY) { protected int paintTransactions(Graphics g, int currentX, int currentY) {
AvatarSimulationTransaction ast; AvatarSimulationTransaction ast;
...@@ -449,7 +469,7 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous ...@@ -449,7 +469,7 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous
} }
} }
} else { } else {
TraceManager.addDev("No linked transaction"); //TraceManager.addDev("No linked transaction");
} }
currentY += 10; currentY += 10;
...@@ -525,7 +545,7 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous ...@@ -525,7 +545,7 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
xMouse = e.getX(); xMouse = e.getX();
yMouse = e.getY(); yMouse = e.getY();
if ((xMouse > minLimit) && (xMouse<maxX-spaceAtEnd) && (yMouse> spaceAtTop) && (yMouse<(maxY))) { if ((xMouse > minLimit) && (xMouse<maxX) && (yMouse> spaceAtTop) && (yMouse<(maxY))) {
drawInfo = true; drawInfo = true;
repaint(); repaint();
return; return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment