User Tools

Site Tools


tutorials:interfaces:tour

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorials:interfaces:tour [2025/06/04 12:41] – [A tour through GroIMP interfaces] tim2tutorials:interfaces:tour [2025/06/04 15:03] (current) – [Minimal required preparations] tim2
Line 1: Line 1:
 ====== A tour through GroIMP interfaces ====== ====== A tour through GroIMP interfaces ======
  
 +In the following, we will use the same model in different GroIMP user interfaces.
  
 | {{page>user-guide:additional_interfaces}} | | {{page>user-guide:additional_interfaces}} |
Line 6: Line 7:
 ===== The model ===== ===== The model =====
  
-To highlight the flow of simulations in the different interfaces we use a simple model of a plant that can grow apically and with a second function split one bud into two of half the strength. +To highlight the flow of simulations across different interfaceswe use a simple model of a plant that can grow apically andwith a second functionsplit one bud into two, each with half the strength. 
-The idea is to see how different indicators change over 10 growth steps depending on the time the buds split.+The idea is to observe how different indicators change over 10 growth stages, depending on when the buds split.
  
 {{ :tutorials:interfaces:split_plant.png?400 |}} {{ :tutorials:interfaces:split_plant.png?400 |}}
Line 98: Line 99:
 </code> </code>
  
 +
 +{{ :tutorials:interfaces:cut.gsz |}}
 ===== Headless ===== ===== Headless =====
  
Line 108: Line 111:
  
  
-In this mode GroIMP starts executes a model or a command and closes again after it was done.  This way we can execute our model with only one system call. +In this modeGroIMP starts executing a model or a command and closes again after it is done.  This way we can execute our model with only one system call. 
-For that to work we have to take care of three things, first that GroIMP knows what to do with the model once its opened, then that the model closes it self at the end and finally that we can get the data out of it.+For that to workwe have to take care of three things, first GroIMP knows what to do with the model once it'opened, then the model closes itself at the end and finallywe can get the data out of it.
  
 === startup === === startup ===
Line 131: Line 134:
 === run(Object info) === === run(Object info) ===
  
-In this run function we must describe everything that is suppose to happen in the simulation, including closing the software.+In this run functionwe must describe everything that is supposed to happen in the simulation, including closing the software.
  
 <code java> <code java>
Line 144: Line 147:
  
 Even though GroIMP ran the simulation to completion we did not define any output for our data. Even though GroIMP ran the simulation to completion we did not define any output for our data.
-There are several ways to do this using java, but for this tutorial we are going with one of the simplest. +There are several ways to do this using Java, but for this tutorialwe are going with one of the simplest. 
-We are exporting the dataset we anyway already created to a csv file in and save this in the same directory as the project.+We are exporting the dataset we already created to a CSV file and saving it in the same directory as the project.
  
 <code java> <code java>
Line 161: Line 164:
 === Parameters === === Parameters ===
  
-GroIMP gives us the ability to forward custom parameter form command line, in general these are model independent but in headless this is no issue since we have to start GroIMP for every model any way.+GroIMP gives us the ability to forward custom parameters from the command line, in generalthese are model-independent but in headless this is no issue since we have to start GroIMP for every model anyway.
  
 The usage of this is quite simple, every value we add with -X<key>=value will be added to Main.getProperty(<key>). So in our case: if we put -Xsp=6 to the command line we can use: The usage of this is quite simple, every value we add with -X<key>=value will be added to Main.getProperty(<key>). So in our case: if we put -Xsp=6 to the command line we can use:
Line 175: Line 178:
 </code> </code>
  
 +And to make the csv a bit clearer:
 +
 +<code java>
 +protected void init ()[
 + Axiom ==> A(1);
 + {time=0;
 + dataset("data").clear();
 + dataset("data").addRow()
 +  .setText(0,"time")
 +  .setText(2,"sumFlength")
 +  .setText(3,"meanFlength")
 +  .setText(4,"countLeaf")
 +  .setText(5,"sumLeafgetArea")
 +  .setText(6,"meanLeaf getArea");
 + }
 +]
 +</code>
 +
 +{{ :tutorials:interfaces:cut_headless.gsz |}}
  
 This setup would now allow us to integrate the model into pipelines, e.g. an R script: This setup would now allow us to integrate the model into pipelines, e.g. an R script:
Line 188: Line 210:
 ===== HTTP ===== ===== HTTP =====
  
-With a bit of scripting we could use th headless mode also for orchestration or automation, yet we would start and stop GroIMP every time which of course take a bit of time. To avoid this, and to also allow us to execute on a remote server or in parallel on a GroIMP instance we can use the HTTP-Server+With a bit of scriptingwe could use the headless mode also for orchestration or automation, yet we would start and stop GroIMP every time which of course takes a bit of time. To avoid this, and to also allow us to execute on a remote server or in parallel on a GroIMP instance we can use the HTTP-Server
  
 | {{page>user-guide:additional_interfaces:http}} | | {{page>user-guide:additional_interfaces:http}} |
Line 196: Line 218:
  
  
-If we want to run our model through the HTTP-server we have to do three small changes first:+If we want to run our model through the HTTP-server we have to make three small changes first:
  
 __1. Change the condition in the startup function, to make sure it runs if the model was opened through the http server.__ __1. Change the condition in the startup function, to make sure it runs if the model was opened through the http server.__
  
-To do so we test if we have an HTTPResponse object, this object is created when the model was opened through the server and holds the request from the client and the ability to respond. +To do so we test if we have an HTTPResponse object, this object is created when the model is opened through the server and holds the request from the client and the ability to respond. 
  
-<code >+<code java>
 protected void startup(){ protected void startup(){
  super.startup();  super.startup();
Line 213: Line 235:
 </code> </code>
  
-__2. Make sure that we are not looking for the headless parameter any more (its not there).__+__2. Make sure that we are not looking for the headless parameter anymore (its not there).__
  
 we have to make sure we removed  the line 'splitPoint = Integer.valueOf (Main.getProperty("sp"));' since it would otherwise crash. we have to make sure we removed  the line 'splitPoint = Integer.valueOf (Main.getProperty("sp"));' since it would otherwise crash.
Line 219: Line 241:
 __3. We have to stop stopping GroIMP __ __3. We have to stop stopping GroIMP __
  
-In the headless mode we finished the run(Object info) function with 'System.exit(0)' to close GroIMP, in the HTTP server we do not want to do that. Therefore we have to remove this line.+In the headless modewe finished the run(Object info) function with 'System.exit(0)' to close GroIMP, in the HTTP server we do not want to do that. Therefore we have to remove this line.
  
  
Line 225: Line 247:
  
 To open a model through the HTTPServer we have to provide the path to the gsz file, this path is relative to a given "root directory" To open a model through the HTTPServer we have to provide the path to the gsz file, this path is relative to a given "root directory"
-We can set this base directory in the GroIMP preferences under "HTTP > open Project", easy solution is to just set this to the directory of your project.+We can set this base directory in the GroIMP preferences under "HTTP > open Project", an easy solution is to just set this to the directory of your project.
  
-After we defined our root directory we can start the http server through the main menu through "Net > Open HTTP Server". In most cases we do not care about the port number, if you want/need to change it you can do so without any issues just keep chaining it in the examples below as well.+After we define our root directory we can start the HTTP server through the main menu through "Net > Open HTTP Server". In most cases we do not care about the port number, if you want/need to change it you can do so without any issues just keep chaining it in the examples below as well.
  
 If the server is running we can visit [[http://localhost:58080]] to see the installed plugins and possible HTTP commands. If the server is running we can visit [[http://localhost:58080]] to see the installed plugins and possible HTTP commands.
Line 244: Line 266:
  
  
-To give the browser feedback we need to use the send function from the HttpResponse object at the end of our run function:+To give the browser feedback we need to use the send function from the HttpResponse object at the end of our run function:
  
 <code java> <code java>
Line 283: Line 305:
  
  
-additionally we close the workbench at the end of our execution because we do not need it any more now since we got the data in the browser. +Additionally, we closed the workbench at the end of our execution because we do not need it anymore now since we got the data in the browser. 
  
  
 === Parameters === === Parameters ===
  
-Using the LazyHttp library we can also parse given values from the http request:+Using the LazyHttp library we can also parse given values from the HTTP request:
  
 <code java> <code java>
Line 297: Line 319:
 </code> </code>
  
-to give a parameter like this the http server we add '&sp=3' to our url:+To give a parameter like this to the HTTP server we add '&sp=3' to our URL:
  
 [[http://localhost:58080/open?l_model.gsz&sp=3]] [[http://localhost:58080/open?l_model.gsz&sp=3]]
Line 328: Line 350:
  
  
- +{{ :tutorials:interfaces:lazy_http_cut.gsz |}}
-{{ :tutorials:interfaces:cut_grow.gsz |}}+
 ===== API ===== ===== API =====
  
Line 337: Line 358:
  
  
-To start the API is a bit more complicated then the HTTP-server, instruction can be found here:+To start the API is a bit more complicated than the HTTP-server, an instruction can be found here:
 [[tutorials:startup-api|Start GroIMP in API mode]]. [[tutorials:startup-api|Start GroIMP in API mode]].
  
tutorials/interfaces/tour.1749033670.txt.gz · Last modified: 2025/06/04 12:41 by tim2