tutorials:interfaces:tour
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:interfaces:tour [2025/06/04 12:33] – [API] tim2 | tutorials: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> | ||
===== The model ===== | ===== The model ===== | ||
- | To highlight the flow of simulations | + | To highlight the flow of simulations |
- | The idea is to see how different indicators change over 10 growth | + | The idea is to observe |
{{ : | {{ : | ||
Line 97: | Line 99: | ||
</ | </ | ||
+ | |||
+ | {{ : | ||
===== Headless ===== | ===== Headless ===== | ||
Line 107: | Line 111: | ||
- | In this mode GroIMP starts | + | In this mode, GroIMP starts |
- | 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 | + | For that to work, we have to take care of three things, first GroIMP knows what to do with the model once it' |
=== startup === | === startup === | ||
Line 130: | Line 134: | ||
=== run(Object info) === | === run(Object info) === | ||
- | In this run function we must describe everything that is suppose | + | In this run function, we must describe everything that is supposed |
<code java> | <code java> | ||
Line 143: | 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 tutorial, we are going with one of the simplest. |
- | We are exporting the dataset we anyway | + | 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 160: | Line 164: | ||
=== Parameters === | === Parameters === | ||
- | GroIMP gives us the ability to forward custom | + | GroIMP gives us the ability to forward custom |
The usage of this is quite simple, every value we add with -X< | The usage of this is quite simple, every value we add with -X< | ||
Line 174: | Line 178: | ||
</ | </ | ||
+ | And to make the csv a bit clearer: | ||
+ | |||
+ | <code java> | ||
+ | protected void init ()[ | ||
+ | Axiom ==> A(1); | ||
+ | | ||
+ | | ||
+ | | ||
+ | .setText(0," | ||
+ | .setText(2," | ||
+ | .setText(3," | ||
+ | .setText(4," | ||
+ | .setText(5," | ||
+ | .setText(6," | ||
+ | } | ||
+ | ] | ||
+ | </ | ||
+ | |||
+ | {{ : | ||
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 187: | 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 | + | With a bit of scripting, we could use the headless mode also for orchestration or automation, yet we would start and stop GroIMP every time which of course |
| {{page> | | {{page> | ||
Line 195: | 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 > | + | < |
protected void startup(){ | protected void startup(){ | ||
| | ||
Line 212: | Line 235: | ||
</ | </ | ||
- | __2. Make sure that we are not looking for the headless parameter | + | __2. Make sure that we are not looking for the headless parameter |
we have to make sure we removed | we have to make sure we removed | ||
Line 218: | 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 ' | + | In the headless mode, we finished the run(Object info) function with ' |
Line 224: | 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", | + | We can set this base directory in the GroIMP preferences under "HTTP > open Project", |
- | After we defined | + | After we define |
If the server is running we can visit [[http:// | If the server is running we can visit [[http:// | ||
Line 243: | Line 266: | ||
- | To give the browser | + | 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 282: | Line 305: | ||
- | additionally | + | Additionally, |
=== 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 296: | Line 319: | ||
</ | </ | ||
- | to give a parameter like this the http server we add '& | + | To give a parameter like this to the HTTP server we add '& |
[[http:// | [[http:// | ||
Line 327: | Line 350: | ||
- | + | {{ : | |
- | {{ : | + | |
===== API ===== | ===== API ===== | ||
Line 336: | Line 358: | ||
- | To start the API is a bit more complicated | + | To start the API is a bit more complicated |
[[tutorials: | [[tutorials: | ||
tutorials/interfaces/tour.1749033223.txt.gz · Last modified: 2025/06/04 12:33 by tim2