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

Adding ports to basic channels

parent 7c345c41
Branches
No related tags found
No related merge requests found
......@@ -100,7 +100,7 @@ myrelease: basic launcher ttooljar
basic:
$(JAVAC) $(CLASSPATH) $(TTOOL_SRC) $(TTOOL_SRC)/*.java
jar: launcher ttooljar
jar: launcher ttooljar tiftranslator tmltranslator rundse remotesimulator
ttooljar:
rm -f $(TTOOL_BIN)/$(TTOOL_BINARY)
......
......@@ -60,6 +60,7 @@ public class TMLChannel extends TMLCommunicationElement {
// Used on for 1 -> 1 channel
protected TMLTask origin, destination;
protected TMLPort originPort, destinationPort; // Not used by the simulator
// Used for 1 -> many channel, or for many -> 1 channel
protected ArrayList<TMLTask> originTasks, destinationTasks;
......@@ -83,6 +84,31 @@ public class TMLChannel extends TMLCommunicationElement {
return (originTasks.size() == 0);
}
public boolean isBadComplexChannel() {
if ((originTasks.size() == 1) && (destinationTasks.size() >= 1)) {
return false;
}
if ((destinationTasks.size() == 1) && (originTasks.size() >= 1)) {
return false;
}
return true;
}
public void toBasicIfPossible() {
if ((originTasks.size() ==1) && (destinationTasks.size() ==1)) {
origin = originTasks.get(0);
destination = destinationTasks.get(0);
originPort = originPorts.get(0);
destinationPort = destinationPorts.get(0);
originTasks = new ArrayList<TMLTask>();
destinationTasks = new ArrayList<TMLTask>();
originPorts = new ArrayList<TMLPort>();
destinationPorts = new ArrayList<TMLPort>();
}
}
public void addTaskPort(TMLTask _task, TMLPort _port, boolean isOrigin) {
if (isOrigin) {
originTasks.add(_task);
......@@ -118,6 +144,11 @@ public class TMLChannel extends TMLCommunicationElement {
destination = _destination;
}
public void setPorts(TMLPort _origin, TMLPort _destination) {
originPort = _origin;
destinationPort = _destination;
}
public TMLTask getOriginTask() {
return origin;
}
......@@ -126,6 +157,14 @@ public class TMLChannel extends TMLCommunicationElement {
return destination;
}
public TMLPort getOriginPort() {
return originPort;
}
public TMLPort getDestinationPort() {
return destinationPort;
}
public void setPriority(int _priority) {
priority = _priority;
}
......
......@@ -658,18 +658,12 @@ public class TMLTextSpecification {
return -1;
}
if (!((_split.length > 5) && (_split.length < 8))) {
error = "A channel must be declared with only 5 or 6 parameters, and not " + (_split.length - 1) ;
if (!((_split.length < 9))) {
error = "A channel must be declared with at least 7, and not: " + (_split.length - 1) ;
addError(0, _lineNb, 0, error);
return -1;
}
if (_split.length == 7) {
dec = 1;
} else {
dec = 0;
}
if (!checkParameter("CHANNEL", _split, 1, 0, _lineNb)) {
return -1;
}
......@@ -682,18 +676,33 @@ public class TMLTextSpecification {
return -1;
}
if (_split.length == 7) {
if (!checkParameter("CHANNEL", _split, 4, 1, _lineNb)) {
// Max nb of elements?
try {
tmp = Integer.decode(_split[4]).intValue();
dec = 1;
} catch (Exception e) {dec = 0; tmp=8;}
TraceManager.addDev("Checking OUT");
// "OUT" keyword?
if (!checkParameter("CHANNEL", _split, 4+dec, 10, _lineNb)) {
return -1;
}
}
if (!checkParameter("CHANNEL", _split, 4 + dec, 0, _lineNb)) {
TraceManager.addDev("Checking other params of channels");
int indexOfIN = -1;
for(i=5+dec; i<_split.length; i++) {
if (!checkParameter("CHANNEL", _split, i, 0, _lineNb)) {
return -1;
}
if (_split[i].compareTo("IN") == 0) {
indexOfIN = i;
}
}
if (!checkParameter("CHANNEL", _split, 5 + dec, 0, _lineNb)) {
if (indexOfIN == -1) {
error = "\"IN\" keyword is missing";
addError(0, _lineNb, 0, error);
return -1;
}
......@@ -713,28 +722,29 @@ public class TMLTextSpecification {
tmp = Integer.decode(_split[3]).intValue();
} catch (Exception e) {tmp = 4;}
ch.setSize(tmp);
if (_split.length == 7) {
try {
tmp = Integer.decode(_split[4]).intValue();
} catch (Exception e) {tmp = 8;}
//TraceManager.addDev("Setting max to" + tmp);
ch.setMax(tmp);
}
t1 = tmlm.getTMLTaskByName(_split[4+dec]);
for(i=5+dec; i<_split.length; i++) {
if (i != indexOfIN) {
t1 = tmlm.getTMLTaskByName(_split[i]);
if (t1 == null) {
t1 = new TMLTask(_split[4+dec], null, null);
t1 = new TMLTask(_split[i], null, null);
//TraceManager.addDev("New task:" + _split[4+dec]);
tmlm.addTask(t1);
}
t2 = tmlm.getTMLTaskByName(_split[5+dec]);
if (t2 == null) {
t2 = new TMLTask(_split[5+dec], null, null);
//TraceManager.addDev("New task:" + _split[5+dec]);
tmlm.addTask(t2);
ch.addTaskPort(t1, null, (i<indexOfIN));
}
}
ch.toBasicIfPossible();
if (!(ch.isBasicChannel())) {
if (ch.isBadComplexChannel()) {
error = "A complex channel must be \"1 -> many\" of \"many -> 1\"";
addError(0, _lineNb, 0, error);
return -1;
}
}
ch.setTasks(t1, t2);
tmlm.addChannel(ch);
} // CHANNEL
......@@ -2436,6 +2446,11 @@ public class TMLTextSpecification {
err = true;
}
break;
case 10:
if (!(_split[_parameter].compareTo("OUT") == 0)) {
err = true;
}
break;
}
} else {
err = true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment