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

Update on port checking. Reference ports are still missing in the evaluation

parent b3a1f0f3
No related branches found
No related tags found
No related merge requests found
...@@ -159,6 +159,27 @@ public class AvatarBlock extends AvatarElement { ...@@ -159,6 +159,27 @@ public class AvatarBlock extends AvatarElement {
return attributes.size(); return attributes.size();
} }
public void putAllTimers(ArrayList<AvatarAttribute> timers) {
for(AvatarAttribute attribute: attributes) {
if (attribute.getType() == AvatarType.TIMER) {
timers.add(attribute);
}
}
}
public boolean hasTimer(String _name) {
for(AvatarAttribute attribute: attributes) {
if (attribute.getType() == AvatarType.TIMER) {
if (attribute.getName().compareTo(_name) == 0) {
return true;
}
}
}
return false;
}
public AvatarAttribute getAttribute(int _index) { public AvatarAttribute getAttribute(int _index) {
return attributes.get(_index); return attributes.get(_index);
} }
......
...@@ -87,6 +87,10 @@ public class AvatarElement { ...@@ -87,6 +87,10 @@ public class AvatarElement {
return false; return false;
} }
public void setName(String _name) {
name = _name;
}
public String getName() { public String getName() {
return name; return name;
} }
......
...@@ -202,6 +202,8 @@ public class AvatarSpecification extends AvatarElement { ...@@ -202,6 +202,8 @@ public class AvatarSpecification extends AvatarElement {
} }
public void removeTimers() { public void removeTimers() {
renameTimers();
LinkedList<AvatarBlock> addedBlocks = new LinkedList<AvatarBlock>(); LinkedList<AvatarBlock> addedBlocks = new LinkedList<AvatarBlock>();
for(AvatarBlock block: blocks) { for(AvatarBlock block: blocks) {
block.removeTimers(this, addedBlocks); block.removeTimers(this, addedBlocks);
...@@ -212,6 +214,27 @@ public class AvatarSpecification extends AvatarElement { ...@@ -212,6 +214,27 @@ public class AvatarSpecification extends AvatarElement {
} }
} }
private void renameTimers() {
// Check whether timers have the same name in different blocks
ArrayList<AvatarAttribute> allTimers = new ArrayList<AvatarAttribute>();
for(AvatarBlock block: blocks) {
allTimers.clear();
block.putAllTimers(allTimers);
for(AvatarAttribute att: allTimers) {
for(AvatarBlock bl: blocks) {
if (block != bl) {
if (bl.hasTimer(att.getName())) {
// Must change name of timer
TraceManager.addDev("Changing name of Timer:" + att);
att.setName(att.getName() + "__" + block.getName());
}
}
}
}
}
}
public AvatarRelation getAvatarRelationWithSignal(AvatarSignal _as) { public AvatarRelation getAvatarRelationWithSignal(AvatarSignal _as) {
for(AvatarRelation ar: relations) { for(AvatarRelation ar: relations) {
if (ar.hasSignal(_as) > -1) { if (ar.hasSignal(_as) > -1) {
......
...@@ -176,6 +176,30 @@ public abstract class TMLCChannelFacility extends TGCScalableWithInternalCompone ...@@ -176,6 +176,30 @@ public abstract class TMLCChannelFacility extends TGCScalableWithInternalCompone
public Color getPortColor() { public Color getPortColor() {
return portColor; return portColor;
} }
public String getAttributes() {
if (conflict) {
return conflictMessage;
}
String s = "";
if (inp != null) {
s = s + inp.getAttributes();
if (outp != null) {
s = s + "\n";
}
}
if (outp != null) {
s = s + outp.getAttributes();
}
if (conflict) {
s += "Error in path=" + conflict;
}
return s;
}
......
...@@ -373,7 +373,7 @@ public class TMLCCompositePort extends TMLCChannelFacility implements SwallowedT ...@@ -373,7 +373,7 @@ public class TMLCCompositePort extends TMLCChannelFacility implements SwallowedT
return TGComponentManager.CONNECTOR_PORT_TMLC; return TGComponentManager.CONNECTOR_PORT_TMLC;
}*/ }*/
public String getAttributes() { /*public String getAttributes() {
if (conflict) { if (conflict) {
return conflictMessage; return conflictMessage;
} }
...@@ -391,7 +391,7 @@ public class TMLCCompositePort extends TMLCChannelFacility implements SwallowedT ...@@ -391,7 +391,7 @@ public class TMLCCompositePort extends TMLCChannelFacility implements SwallowedT
} }
return s; return s;
} }*/
public void myActionWhenRemoved() { public void myActionWhenRemoved() {
tdp = null; tdp = null;
......
...@@ -149,7 +149,7 @@ public class TMLCFork extends TMLCChannelFacility implements WithAttributes { ...@@ -149,7 +149,7 @@ public class TMLCFork extends TMLCChannelFacility implements WithAttributes {
public String getAttributes() { /*public String getAttributes() {
if (conflict) { if (conflict) {
return conflictMessage; return conflictMessage;
} }
...@@ -167,7 +167,7 @@ public class TMLCFork extends TMLCChannelFacility implements WithAttributes { ...@@ -167,7 +167,7 @@ public class TMLCFork extends TMLCChannelFacility implements WithAttributes {
} }
return s; return s;
} }*/
......
...@@ -151,7 +151,7 @@ public class TMLCJoin extends TMLCChannelFacility implements WithAttributes { ...@@ -151,7 +151,7 @@ public class TMLCJoin extends TMLCChannelFacility implements WithAttributes {
public String getAttributes() { /*public String getAttributes() {
if (conflict) { if (conflict) {
return conflictMessage; return conflictMessage;
} }
...@@ -169,7 +169,7 @@ public class TMLCJoin extends TMLCChannelFacility implements WithAttributes { ...@@ -169,7 +169,7 @@ public class TMLCJoin extends TMLCChannelFacility implements WithAttributes {
} }
return s; return s;
} }*/
......
...@@ -179,8 +179,20 @@ public class TMLCPath { ...@@ -179,8 +179,20 @@ public class TMLCPath {
} }
//rule4: producers and consumers must be of the same type //rule4: producers and consumers must be of the same type
if ((forks.size() > 0) && (producerPorts.size() >1)) { if ((consumerPorts.size()>0) && (producerPorts.size()>0)) {
errorNumber = 4; int type = consumerPorts.get(0).getPortType();
for(TMLCPrimitivePort porto: producerPorts) {
if (porto.getPortType() != type) {
errorNumber = 4;
break;
}
}
for(TMLCPrimitivePort porti: consumerPorts) {
if (porti.getPortType() != type) {
errorNumber = 4;
break;
}
}
} }
} }
...@@ -189,10 +201,83 @@ public class TMLCPath { ...@@ -189,10 +201,83 @@ public class TMLCPath {
// Setting the red color // Setting the red color
}*/ }*/
// For each channel facility,
// set the inp and outp primitive ports if possible (otherwise, null) // set the inp and outp primitive ports if possible (otherwise, null)
// if no error: set conflict to false // if no error: set conflict to false
// If error -> set the conflict to true // If error -> set the conflict to true
for(TMLCFork fork: forks) {
if (producerPorts.size() > 0) {
fork.setOutPort(producerPorts.get(0));
} else {
fork.setOutPort(null);
}
if (consumerPorts.size() > 0) {
fork.setInPort(consumerPorts.get(0));
} else {
fork.setInPort(null);
}
if (hasError()) {
fork.setConflict(hasError(), errors[errorNumber]);
} else {
fork.setConflict(false, "");
}
}
for(TMLCJoin join: joins) {
if (producerPorts.size() > 0) {
join.setOutPort(producerPorts.get(0));
} else {
join.setOutPort(null);
}
if (consumerPorts.size() > 0) {
join.setInPort(consumerPorts.get(0));
} else {
join.setInPort(null);
}
if (hasError()) {
join.setConflict(hasError(), errors[errorNumber]);
} else {
join.setConflict(false, "");
}
}
for(TMLCCompositePort port: cports) {
if (producerPorts.size() > 0) {
port.setOutPort(producerPorts.get(0));
} else {
port.setOutPort(null);
}
if (consumerPorts.size() > 0) {
port.setInPort(consumerPorts.get(0));
} else {
port.setInPort(null);
}
if (hasError()) {
port.setConflict(hasError(), errors[errorNumber]);
} else {
port.setConflict(false, "");
}
}
for(TMLCPrimitivePort pport: producerPorts) {
if (hasError()) {
pport.setConflict(hasError(), errors[errorNumber]);
} else {
pport.setConflict(false, "");
}
}
for(TMLCPrimitivePort cport: consumerPorts) {
if (hasError()) {
cport.setConflict(hasError(), errors[errorNumber]);
} else {
cport.setConflict(false, "");
}
}
} }
......
...@@ -82,6 +82,9 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent ...@@ -82,6 +82,9 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
protected int decPoint = 3; protected int decPoint = 3;
protected boolean conflict = false;
protected String conflictMessage;
public TMLCPrimitivePort(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { public TMLCPrimitivePort(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) {
super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
...@@ -135,17 +138,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent ...@@ -135,17 +138,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
} }
//System.out.println("NbTGConnectingPoint=" + nbConnectingPoint); //System.out.println("NbTGConnectingPoint=" + nbConnectingPoint);
calculatePortColor();
if ((myColor == null) || (oldTypep != typep)) {
//myColor = new Color(134, 229- (getMyDepth() * 10), 255);
if (typep == 0) {
myColor = ColorManager.TML_PORT_CHANNEL;
} else if (typep == 1) {
myColor = ColorManager.TML_PORT_EVENT;
} else {
myColor = ColorManager.TML_PORT_REQUEST;
}
}
if (rescaled) { if (rescaled) {
rescaled = false; rescaled = false;
...@@ -153,12 +146,24 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent ...@@ -153,12 +146,24 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
// Zoom is assumed to be computed // Zoom is assumed to be computed
Color c = g.getColor(); Color c = g.getColor();
g.drawRect(x, y, width, height);
if ((width > 2) && (height > 2)) { if ((width > 2) && (height > 2)) {
g.setColor(myColor); g.setColor(myColor);
g.fillRect(x+1, y+1, width-1, height-1); g.fillRect(x, y, width, height);
if (conflict) {
if (typep == 0) {
g.setColor(ColorManager.TML_PORT_CHANNEL);
} else if (typep == 1) {
g.setColor(ColorManager.TML_PORT_EVENT);
} else {
g.setColor(ColorManager.TML_PORT_REQUEST);
}
g.fillRect(x, y, width, height/2);
}
g.setColor(c); g.setColor(c);
} }
g.drawRect(x, y, width, height);
int []px = new int[5]; int []px = new int[5];
int []py = new int[5]; int []py = new int[5];
...@@ -698,6 +703,10 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent ...@@ -698,6 +703,10 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
} }
} }
if (conflict) {
attr += "Error in path=" + conflictMessage;
}
return attr; return attr;
} }
...@@ -713,4 +722,29 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent ...@@ -713,4 +722,29 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
return maxNbOfLoss; return maxNbOfLoss;
} }
public boolean getConflict() {
return conflict;
}
public void setConflict(boolean _conflict, String _msg) {
conflict = _conflict;
myColor = null;
conflictMessage = _msg;
calculatePortColor();
}
public void calculatePortColor() {
if (conflict) {
myColor = Color.red;
} else {
if (typep == 0) {
myColor = ColorManager.TML_PORT_CHANNEL;
} else if (typep == 1) {
myColor = ColorManager.TML_PORT_EVENT;
} else {
myColor = ColorManager.TML_PORT_REQUEST;
}
}
}
} }
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