Hi Harry,
we are trying to adapt the source code of the Assign object to realize some custom logic implementation in Java. We are intending to create an object which is located in front of our branch following specific rules to guide the entities to different servers (see Picture). Attached you will find our source code. For example with this object we want to choose the next server of the entity based on the WorkingState Attribute of the servers.
Now we don´t want to fill out the AttributeAssignmentList with the attributes of our servers everytime we create a new model.
We want to do it automatically in our sourcecode, which is also much easier when the models get more complicated.
In our latest version we are trying to do it with a for loop and the ExpressionParser but it doesnt work so far. The idea is that we only enter the number of servers behind the Keyword "Number of Servers" in the input of the function and then the AssignmentString is generated and parsed, so that we get the information about the server statusses.
private ArrayList<ExpParser.Assignment> getAssignmentString2(int numberOfServers) {
ArrayList<ExpParser.Assignment> servStatus = new ArrayList<>();
for(int i = 1; i <= numberOfServers; i++) {
ExpParser.Assignment assignment = new ExpParser.Assignment("this.Server" + i + "=[Server" + i + "].Working");
servStatus.add(assignment);
}
return servStatus;
Another approach, which we are currently testing, is to filter for example all servers from the entityList ((p) basicsim/ (c) ObjectSelector) and work with this list.
I would be great if it somehow possible to simply access the list of all servers in the model, so that the number can be read out and for each server in the list the attributes can used.
Do you have some advice for us?
Thank you very much!
Martin
