RIVERtools is an IDE supporting the use of the "trace expressions" formalism by users that want to perform Runtime Verification of their own system.
What you are going to install.
• SWI-Prolog
• Eclipse(with Xtext plugin)
• RIVERtools Eclipse plugin
Installing SWI-Prolog is very easy:
• On Linux:
1. sudo apt-get install software-properties-common
2. sudo apt-add-repository ppa:swi-prolog/stable
3. sudo apt-get update
4. sudo apt-get install swi-prolog
• On Windows
- Download either 32 bit or 64 bit from http://www.swi-prolog.org/download/stable
• On MacOSX (using Homebrew http://mxcl.github.io/homebrew/)
– brew install swi-prolog
-
Link for downloading last Eclipse IDE: https://www.eclipse.org/downloads/packages/installer
-
Install Xtext plugin on Eclipse: a) Choose Help -> Install New Software... from the menu bar and Add...
b) Insert http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/. This site aggregates all the necessary and optional components and dependencies of Xtext.
c) Select the Xtext SDK from the category Xtext and complete the wizard by clicking the Next button until you can click Finish.
d) After a quick download and a restart of Eclipse, Xtext is ready to use.
-
Link for downloading RIVERtools plugin: https://github.com/AngeloFerrando/website/raw/master/assets/rivertools/plugin/rivertools.zip
-
Install RIVERtools plugin:
a) Choose Help -> Install New Software... from the menu bar and Add...
b) Choose Archive...
c) Select the rivertools.zip file downloaded previously.
d) Select TExp Feature from the list ("group items by category" must be unchecked) and Next -> Finish.
e) After a quick download and a restart of Eclipse, the plugin is ready to use.
-
Create a new project (a General project, not a Java Project) and call it MyPingPongExample.
-
Inside the created project, create a new file and call it pingpong.texp.
-
An Eclipse popup should ask you if you want to configure the project with Xtext: say yes. If Eclipse does not ask you, right-click on the project folder -> Configure -> Convert to Xtext project...
-
Now you can define trace expressions with the full support of the RIVERtools plugin.
Example of trace expression in RIVERtools.
interaction_trace_expression {
id : pingpong
target : jade
roles :
alice$SenderAgent(’bob’, ’ping’, ’5’)$
bob$ReceiverAgent ( ’ alice ’ , ’pong ’ , ’5 ’)$
types :
ping : { alice => bob : ping }
pong : { bob => alice : pong }
body :
main <− pingpong ∗ main
pingpong <−
( ping : ( pingpong \/ epsilon ) * pong : epsilon )
}
Since Eclipse is using the RIVERtools plugin to analyze the trace expression, all syntax and types errors are promptly indicated to the developer. As presented before in this chapter, we are interested in automatically generating the code that will be used for verifying our multiagent system. When no errors are found from RIVERtools, a new folder src-gen is created. Inside this folder we can find the Java and Prolog code that have been automatically generated through the compilation of the trace expression.
-
Link for downloading ping pong MAS example: https://github.com/AngeloFerrando/website/raw/master/assets/rivertools/jadeconnector/example/pingpongmas.zip
-
Import the example into Eclipse:
a) File -> Import... -> Existing Projects into Workspace.
b) Select archive file and select pingpongmas.zip downloaded previously, then finish.
-
Inside the JADE project example you have two agents SenderAgent and ReceiverAgent. Note that you have already indicated these classes inside pingpong.texp.
-
Copy Pingpong.java from the MyPingPongExample project to this project.
-
Run it. An exception will be thrown ("SWI_LIB environment variable not defined").
-
How to set the SWI_LIB environment variable
a) Right-click on Pingpong.java (the one inside MyPingPongMAS) -> Run as -> Run Configurations...
b) Pass to the Environment tab and then New...
c) Set the name to SWI_LIB
d) Set the value to the path to the SWI-Prolog library. For instance, on MacOSX is something like:
/opt/local/lib/swipl-<version>/lib/x86_64- darwin15.0.0/
-
The last thing you need to do before running the MAS is to change the path to pingpong.pl (line 27 in Pingpong.java). You have to set it to the absolute path corresponding to the file generated in MyPingPongExample project.
-
You are now ready to execute the MAS with the automatically generated RV monitor.
-
Right-click on Pingpong.java (inside MyPingPongMAS) -> Run as -> Java Application
The SenderAgent and ReceiverAgent are parametric. In particular, the third parameter says how many messages the agent should send. In order to better observe if the monitor is working, you can introduce a wrong behaviour in the receiver agent. Instead of passing 5 as third argument to both the agents, you pass 5 to alice and 6 to bob. After that, you will observe the monitor printing an error message when the sixth pong will be observed.