After following the advice given in the answer for this question, I ended up with a model with:
An empty population of agents in main
A statechart in said agent type that references main (made possible by the previous point)
A discrete event flowchart, that references the state of the agents
But after building the model, 3 type and casting errors have appeared, and they are in autogenerated code. I don't understand what functionality is provided by said code.
For context, my model is called "Trenes", and my agent type is "Train". All the errors happen inside the Train
java file.
The exceptions happen in the following snippets:
first one:
// User API -----------------------------------------------------
public Main get_Main() {
{
Agent owner = getOwner();
if ( owner instanceof Main ) return (Main) owner;
}
return null;
}
This one causes Cannot cast from Agent to Main
, thanks to the casting (Main) owner
. It also causes Incompatible conditional operand types Agent and Main.
because of owner instanceof Main
.
second one:
@AnyLogicInternalCodegenAPI
private void setupReferences_xjal() {
main = get_Main();
}
This one calls the method from the first snippet and causes a Type mismatch: cannot convert from org.eclipse.jdt.internal.compiler.batch.Main to trenes.Main.
in the line main = get_Main();
I'd be grateful if someone could guide me about what kind of graphical interface configurations could result in these errors, and how could I correct it without undoing my work with the statechart that references main.
Editing to add captures of the structure of my model and the relevant logic: