I have a function for the setuptime + processingtime for my Agents that go into the Serviceblock. The first Agent that go into the service Block doesn't have a setuptime. They have only processing time. The first agent can be variable, so i would have to use an if function.
I want that the Serviceblock take only the processingtime for the first Agent and then the setuptime for the successor. But the first Agent can be variable, so i have to wirite an if function like this:
if Agent A then return X (processingtime), else if Agent B then return X (processingtime)... and so on.
This is the start, and then it goes into the setuptime + processingtime function. But how i can say in the function, that the first Agent have only the processingtime? Because the first Agent doesnt have a currentAgent.
My function for the setuptime + processingtime is this:
if (currentAgent instanceof Oberteil && predecessor instanceof Unterteil) {
return 45;
} else if (currentAgent instanceof Oberteil && predecessor instanceof Halteteil) {
return 40;
}else if (currentAgent instanceof Oberteil && predecessor instanceof Ring) {
return 45;
}else if (currentAgent instanceof Unterteil && predecessor instanceof Oberteil) {
return 45;
}else if (currentAgent instanceof Unterteil && predecessor instanceof Halteteil) {
return 40;
}else if (currentAgent instanceof Unterteil && predecessor instanceof Ring) {
return 45;
}else if (currentAgent instanceof Halteteil && predecessor instanceof Oberteil) {
return 40;
}else if (currentAgent instanceof Halteteil && predecessor instanceof Unterteil) {
return 40;
}else if (currentAgent instanceof Halteteil && predecessor instanceof Ring) {
return 45;
}else if (currentAgent instanceof Ring && predecessor instanceof Oberteil) {
return 45;
}else if (currentAgent instanceof Ring && predecessor instanceof Unterteil) {
return 45;
}else if (currentAgent instanceof Ring && predecessor instanceof Halteteil) {
return 45;
}
return 2;
Simply add this check at the start of the function:
if (predecessor == null) { // this is the first agent that has no predecessor
return ...; // return only processingTime
} else {
// continue with your existing code here
if (currentAgent instanceof Oberteil && predecessor instanceof Unterteil) {
return 45;
} else if (currentAgent instanceof Oberteil && predecessor instanceof Halteteil) {
return 40;
... and so on
}