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 {
String s = Conversion.replaceAllString(guard, "[", "").trim();
s = Conversion.replaceAllString(s, "]", "").trim();
guardOk = evaluateBoolExpression(s, lastTransaction.attributeValues);
TraceManager.addDev("guard ok=" + guardOk);
//TraceManager.addDev("guard ok=" + guardOk);
}
}
......@@ -208,7 +208,7 @@ public class AvatarSimulationBlock {
aspt.myMaxDelay = evaluateIntExpression(trans.getMaxDelay(), lastTransaction.attributeValues);
aspt.hasDelay = true;
TraceManager.addDev(">>>>> Signal with delay before");
//TraceManager.addDev(">>>>> Signal with delay before");
if (lastTransaction != null) {
if (lastTransaction.clockValueWhenFinished < _clockValue) {
......@@ -309,7 +309,7 @@ public class AvatarSimulationBlock {
ast.clockValueWhenFinished = _aspt.selectedDuration + _clockValue;
_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 {
// Synchronous Sending!
// Must be in the receiving transaction the right parameters
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++) {
value = aaos.getValue(i);
// Must get the type of the value
......@@ -381,7 +381,7 @@ public class AvatarSimulationBlock {
result += evaluateBoolExpression(value, lastTransaction.attributeValues);
}
TraceManager.addDev("Adding value:" + result);
//TraceManager.addDev("Adding value:" + result);
parameters.add(result);
} catch (Exception e) {
TraceManager.addDev("EXCEPTION on adding value " + aaos);
......@@ -393,7 +393,7 @@ public class AvatarSimulationBlock {
// Synchronous Receiving
String myAction = "";
for(i=0; i<aaos.getNbOfValues(); i++) {
TraceManager.addDev("Reading value #" + i);
//TraceManager.addDev("Reading value #" + i);
param = _aspt.parameters.get(i);
name = aaos.getValue(i);
index = block.getIndexOfAvatarAttributeWithName(name);
......@@ -401,7 +401,7 @@ public class AvatarSimulationBlock {
if (index != -1) {
attributeValues.remove(index);
attributeValues.add(index, param);
TraceManager.addDev("Reading value:" + param);
//TraceManager.addDev("Reading value:" + param);
if (myAction.length() == 0) {
myAction += "" + param;
} else {
......@@ -422,6 +422,7 @@ public class AvatarSimulationBlock {
// Asynchronous Sending
String myAction = "";
_aspt.linkedAsynchronousMessage.firstTransaction = ast;
for(i=0; i<aaos.getNbOfValues(); i++) {
value = aaos.getValue(i);
// Must get the type of the value
......@@ -432,9 +433,9 @@ public class AvatarSimulationBlock {
} else if (avat.getType() == AvatarType.BOOLEAN) {
result += evaluateBoolExpression(value, lastTransaction.attributeValues);
}
TraceManager.addDev("Adding value:" + result);
//TraceManager.addDev("Adding value:" + result);
_aspt.linkedAsynchronousMessage.addParameter(result);
_aspt.linkedAsynchronousMessage.firstTransaction = ast;
if (myAction.length() == 0) {
myAction += "" + result;
} else {
......@@ -467,6 +468,9 @@ public class AvatarSimulationBlock {
myAction += ", " + param;
}
}
}
if (_aspt.linkedAsynchronousMessage == null) {
TraceManager.addDev("NULL ASYN MSG");
}
if (myAction.length() > 0) {
ast.actions = new Vector<String>();
......
......@@ -323,6 +323,9 @@ public class AvatarSpecificationSimulation {
if (asat != null) {
_aspt.linkedAsynchronousMessage = asat;
transactions.add(_aspt);
/*if (asat.firstTransaction == null) {
TraceManager.addDev("NULL FIRST");
}*/
}
}
} else {
......
......@@ -73,7 +73,9 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous
private final int limit = 10;
// Drawing parameters
private int minSpaceBetweenLifeLines = 5;
private int spaceBetweenLifeLines = 150;
private boolean spaceBetweenLifeLinesComputed = false;
private int spaceAtEnd = 50;
private int spaceAtTop = 50;
private int verticalSpaceUnderBlocks = 15;
......@@ -120,6 +122,10 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous
int oldMaxY = maxY;
int oldMaxX = maxX;
if (!spaceBetweenLifeLinesComputed) {
computeSpaceBetweenLifeLines(g);
}
currentY = paintTopElements(g, currentX, currentY);
paintTransactions(g, currentX, currentY);
......@@ -171,6 +177,20 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous
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
protected int paintTransactions(Graphics g, int currentX, int currentY) {
AvatarSimulationTransaction ast;
......@@ -449,7 +469,7 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous
}
}
} else {
TraceManager.addDev("No linked transaction");
//TraceManager.addDev("No linked transaction");
}
currentY += 10;
......@@ -525,7 +545,7 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous
public void mouseMoved(MouseEvent e) {
xMouse = e.getX();
yMouse = e.getY();
if ((xMouse > minLimit) && (xMouse<maxX-spaceAtEnd) && (yMouse> spaceAtTop) && (yMouse<(maxY))) {
if ((xMouse > minLimit) && (xMouse<maxX) && (yMouse> spaceAtTop) && (yMouse<(maxY))) {
drawInfo = true;
repaint();
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