The function editing window has three tabs:
The source page has a text box where you enter the source code for the function. A source template is automatically created for you, and is displayed in the text box. The areas in grey are not editable.
The function method takes a varargs parameter named “params”. When the function is called from Ecolego, all the function arguments are stored in this variable.
For instance, consider an equation in Ecolego specifying “Comp1*my_function(A,B)”, where A and B are objects in your model. The values of A and B, at the time the function is called, will now be packaged into an array, so that
params[0] = A
params[1] = B
The function ends with a “return Double.NaN” statement. You should here replace Double.NaN with the return value of your function.
double a=params[0]; double b=params[1]; return a+b;
Next
Previous
References