This guide will give a short overview to design and implementation of the LLRP message repository. The message repository provides two different datastructures:
NOTICE: The ROAccessReportsRepository is optional!
The Repository and ROAccessReportsRepository both implement a Strategy Pattern allowing to exchange the underlying repository implementation transparently. At runtime, the LLRP Commander automatically invokes the "Concrete Strategy" depending on the configuration specified by the user.
ResourceCenter represents the "Context" and Repository models the "Strategy".
Currently the LLRP Commander provides three different "Concrete Strategies", namely the default repository implemented by a file-based Java Derby Repository (org.fosstrak.llrp.client.repository.sql.DerbyRepository), the external PostgreSQL Repository (org.fosstrak.llrp.client.repository.sql.PostgreSQLRepository) and the external MySQL database (org.fosstrak.llrp.client.repository.sql.MySQLRepository).
Repository represents the "Context" and ROAccessReportsRepository models the "Strategy".
Currently the LLRP Commander uses only one "Concrete Strategy" for the two "Contexts" Derby/MySQL implemented by org.fosstrak.llrp.client.repository.sql.DerbyROAccessReportsRepository.
NOTICE: ROAccessReportsRepository is not accessible without Repository!
Users, that like to access the Repository from within the LLRP Commander, can use the ResourceCenter for that purpose:
// how to get a handle to the Repository Repository repository = ResourceCenter.getInstance().getRepository();
Access to the ROAccessReportsRepository can then be gained via the Repository:
// how to get a handle on the ROAccessReportsRepository: // first get a handle of the repository: Repository repository = ResourceCenter.getInstance().getRepository(); // now obtain a handle of the ROAccessReportsRepository ROAccessReportsRepository roAccessReportsRepo = repository.getROAccessRepository();
By default, the LLRP Commander uses the derby interface as its primary logging backend (zero configuration). In the eclipse preferences page select the option "Use internal standalone Derby Database" (should be checked by default).
In order to log the LLRP messages to an external MySQL database, the LLRP Commander needs access to a database of the MySQL server. Please be aware that MySQL currently is not able to log fractional time-parts (milliseconds and smaller). So, if you plan to inspect the timestamp on such a fine grain level, you should probably consider using the PostgreSQL database.
We assume, that you have MySQL installed and running on your system.
Log into the MySQL Command Line Client as root and perform the following steps:
mysql> CREATE DATABASE llrpMsgDB;
mysql> GRANT CREATE,SELECT,INSERT,UPDATE,DELETE,DROP ON llrpMsgDB.* TO llrp IDENTIFIED BY 'llrp';
For the Fosstrak MySQL-connector this equals to: org.fosstrak.llrp.client.repository.sql.MySQLRepository
Syntax: jdbc:mysql://<HOSTNAME_OR_IP>:<PORT>/<DATABASE> If you set the database to llrpMsgDB and the MySQL server runs on the localhost, put: jdbc:mysql://localhost:3306/llrpMsgDB
In order to log the LLRP messages to an external PostgreSQL database, the LLRP Commander needs access to a database of the PostgreSQL server.
Command-line command to create the role in *nix > sudo -u postgres createuser -D -A -P llrp
Command-line command to create the database in *nix > sudo -u postgres createdb -O llrp llrpmsgdb
For the Fosstrak PostgreSQL-connector this equals to: org.fosstrak.llrp.client.repository.sql.PostgreSQLRepository
Syntax: jdbc:postgresql://<HOSTNAME_OR_IP>:<PORT>/<DATABASE> If you set the database to llrpmsgdb and the PostgreSQL server runs on the localhost, put: jdbc:postgresql://localhost:5432/llrpmsgdb
Make sure to configure the LLRP Commander to use either the MySQL or the PostgreSQL database as backend!
Connect from Matlab:
Store the file to a location of your choice.
file: matlabroot\toolbox\local\classpath.txt Example: add reference to the JDBC Connector ... c:/sqlDrivers/mysql-connector-java-5.1.6.jar c:/sqlDrivers/postgresql-8.3-603.jdbc4.jar
Example MySQL: >> conn = database('llrpMsgDB', 'llrp', 'llrp', 'com.mysql.jdbc.Driver', 'jdbc:mysql://localhost:3306/llrpMsgDB'); Example PostgreSQL: >> conn = database('llrpmsgdb', 'llrp', 'llrp', 'org.postgresql.Driver', 'jdbc:postgresql://localhost:3306/llrpmsgdb');
>> result = get(fetch(exec(conn, 'SELECT * FROM table_ro_access_reports')), 'Data');
>> result = get(fetch(exec(conn, 'SELECT count(EPC) FROM table_ro_access_reports')), 'Data');
>> disp(result)
User-settings for the PostgreSQL: