EventB2SQL is a tool for translating Event-B models to Java database applications (implemented using JDBC and MySQL or SQLite), Android applications (using the Android-native SQLite API), and PHP applications (using PDO and MySQL). It can translate Event-B models written at a high level of abstraction, and translating to database applications provides data persistence and allows the implementation to be used as a client-server application with minimal additional effort. EventB2SQL is implemented as a plugin for Rodin and has been tested under Linux and MacOS.
http://users.dickinson.edu/~wahlst/EventB2SQL-update
select EventB2SQL and click Next.
Install Details page, click Next again, then accept the (empty) license agreement.Finish, and then OK at the security warning. From the Event-B Explorer pane in Rodin, right-click on the machine that you wish to translate and select the translation target:
The first three options generate Java code, while the fourth generates PHP. For all four options, the generated code is placed in the generated_sql directory within the Rodin project by default, but this can be edited in the "Output File" pop-up. For the three Java options, the user can then enter a package for the generated class. For all options, the generated code consists of a single class with the same name as the machine.
eventB2SQL.jar: http://users.dickinson.edu/~wahlst/eventb2sql/eventB2SQL.jar and add it to your classpath.eventb, the user is ebuser and the password is pass.Write a driver program to use the class generated by EventB2SQL. Note that the constructor for the generated class takes a database connection as its parameter. If your generated class is Test.java, machine Test uses no carrier sets, and you named your database and user as mentioned above, the following should work:
Class.forName("com.mysql.jdbc.Driver");
Connection con;
con = DriverManager.getConnection("jdbc:mysql://localhost/eventb?&autoDeserialize=true", "ebuser", "pass");
Test test = new Test(con);
test.createTables();
test.INITIALISATION();
The createTables method should be called only once (to create the database tables used by the implementation), while INITIALISATION can be called at any point to reset machine variables to their initial values. If machine that you translated sees any contexts that use given sets, the createTables method takes additional parameters containing the initial values of each of those sets.
eventB2SQL.jar: http://users.dickinson.edu/~wahlst/eventb2sql/eventB2SQL.jar and add it to your classpath.Write a driver program to use the class generated by EventB2SQL. Note that the constructor for the generated class takes a database connection as its parameter. If your generated class is Test.java, machine Test uses no carrier sets, and you named your database and user as mentioned above, the following should work (note that the database is stored in file sample.db):
Class.forName("org.sqlite.JDBC");
Connection con;
con = DriverManager.getConnection("jdbc:sqlite:sample.db");
Test test = new Test(con);
test.createTables();
test.INITIALISATION();
The createTables method should be called only once (to create the database tables used by the implementation), while INITIALISATION can be called at any point to reset machine variables to their initial values. If machine that you translated sees any contexts that use given sets, the createTables method takes additional parameters containing the initial values of each of those sets.
eventB2SQL.jar: http://users.dickinson.edu/~wahlst/eventb2sql/eventB2SQL.jareventB2SQL.jar to the app/libs directory of your Android Studio project.Build menu in Android Studio, select Rebuild Project (so the project finds the jar that you copied in the previous step).The constructor for the generated class takes the context for your application as a parameter. This can be obtained by calling:
this.getApplicationContext()
After creating an instance, use it to call the createTables, INITIALISATION and other methods in the generated class as specified in the previous two sections.
The constructor for the generated class takes a database connection as a parameter. If you have created a MySQL database and user as specified in the MySQL (JDBC) section above and translated a machine called Test, the following should work:
$con = new PDO("mysql:host=localhost;dbname=eventb", "ebuser", "pass",
array(PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$tst = new Test($con);
$tst->dropTables();
$tst->createTables();
$tst->INITIALISATION();
The createTables method should be called only once (to create the database tables used by the implementation), while INITIALISATION can be called at any point to reset machine variables to their initial values. If machine that you translated sees any contexts that use given sets, the createTables method takes additional parameters containing the initial values of each of those sets (as arrays).
eventB2SQL.jar and the appropriate database driver jar file to your Build Path/CLASSPATH as described above.SocialNetworking. Rodin will create the project using the files from the previous step.ref0_abstract as described above, entering the path to place ref0_abstract.java into the directory containing the files from Step 1.ref0_abstract.java.SocialNetworkCaller, set variable SQLite to true if you are using SQLite, and false if you are using MySQL. If you are using MySQL, adjust the database name, database user and password to match your setup.SocialNetworkCaller. Note that you should create three users before using the transmit option.SocialNetwork with a blank main activity in package edu.dickinson.socialnetwork.AndroidExample/java to the app/src/main/java/edu/dickinson/socialnetwork directory in your new project.AndroidExample/layout to the app/src/main/res/layout directory in your new project.AndroidExample/manifest to the app/src/main directory in your new project.app/libs directory of your project (if you haven't already done so).SocialNetworking project in Rodin as described in the previous section, and translate machine ref0_abstract to SQLite (Android). Place the generated code in the app/src/main/java/edu/dickinson/socialnetwork directory in your Android Studio project, and enter edu.dickinson.socialnetwork as the package. (Note that AndroidExample.zip already contains a translation, so you can skip this step if you wish.)Rebuild ProjectCREATE DATABASE button to create the database.ADD PERSON or ADD CONTENT.CREATE ACCOUNT button to create accounts.