Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

This tutorial shows how to configure MQTT Transmission module to generate custom records and send them as MQTT messages via MQTT Distributor to be stored in a MySQL database. The topology of this example shows MQTT Distributor, MQTT Engine, Record Store, and MQTT Transmission all running in the same Ignition instance.  This is done for simplicity of the tutorial.  But, but this isn't required or even intended to be a real use case.  In a more realistic scenario MQTT Transmission and MQTT Engine would be located on separate machines.

...

The first step is to load four Cirrus Link modules specified in the 'Prerequisites' section of this document. To load the modules, launch the Ignition Gateway and open HTTP connection to it.  If Ignition Gateway is running on your development machine, use http://localhost:8088 to connect.  You should see a the 'Welcome to the Ignition Gateway' screen shown below:

Click From here, click the "CONFIGURE" tab to go to the 'Configuration Section'. Ignition will ask you to sign in; , so use the admin/password as your credentials.

After signing in, you will see the screen 'Configuration' page shown below. Go to 'SYSTEM' on the left hand side of the screen and select 'Modules'. 

...

These modules can be configured by clicking 'Settings' on the left hand side below each module. Note that the 'MQTT Distributor' and MQTT Engine modules should not be touched; they will use default configuration. The 'Record Store' module should be configured to point for to the datasource used for storage, but this needs be done after configuring database connections. Finally, the 'MQTT Transmission' module needs to be configured to define custom records to be published. This will be described in subsequent sections of this document.

...

$ mysql --version
mysql  Ver 14.14 Distrib 5.7.12, for osx10.11 (x86_64) using  EditLine wrapper

Then configure user and Image AddedWhen MySQL is installed, login as root, then configure a user and setup a database as shown below:

$ mysql -u root -p

Enter password: 

mysql> CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';

Query OK, 0 rows affected (0.01 sec)

mysql> CREATE DATABASE testdb;

Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON testdb.* TO 'user'@'localhost';

Query OK, 0 rows affected (0.01 sec)

When database is created, login as a user and switch to this database as shown below.:

$ mysql -u user -p

Enter password: 

mysql> USE testdb;

Database changed

The database is now ready, and the next step is to configure Database Connection in Ignition. To do this, go to Ignition 'Configuration Section' as was shown above and click 'Connections' under 'DATABASES' on the left hand side of the screen.  This will bring you to the 'Database Connections' setup page shown below:


Now, click the "Create new Database Connection..." link and the following 'Choose Driver' screen page will appear:


Select the 'MySQL ConnectorJ' option and click 'Next' to configure new database connection as shown below:

Image AddedImage Removed

On the 'New Database Connection' configuration page shown above, configure the following fields:

  • Name - localMySQL 
    Database connection name to be set in the 'Record Store' module.
  • Description - Database connection to local MySQL
    Description of this database connection
  • Connect URL - jdbc:mysql://localhost:3306/testdb
    Connect URL to the 'testdb' database that was created earlier
  • Username - user
    MySQL username
  • Password - password
    MySQL user password

...

The next step is to configure the Tag Provider in Ignition in a way that MQTT Transmission understands. The Tag Provider needs to be set up in Ignition via the Ignition Designer.  To launch it, click 'Launch Designer'  Near near the upper right corner of Ignition page. This will open the following window after downloading the JNLP file and executing it.  Note the default username/password is admin/password.  Type those into the appropriate fields and click 'Login'.

...

For the 'default' provider, create TestGroup/TestNode/TestDevice directory tree under 'Edge Nodes' and leave those folders empty .as shown below:

Now, expand the 'MQTT Transmission' folder as shown on the picture below and click the 'Refresh' checkbox.

...

Pressing the 'Refresh' checkbox causes the Transmitter to publish NBIRTH and DBIRTH certificates as shown below:

2018-07-20 16:46:11,438 INFO --- MqttFX ClientModel : messageArrived() with topic: spBv1.0/TestGroup/NBIRTH/TestNode
2018-07-20 16:46:11,439 INFO --- MqttFX ClientModel : messageArrived() added: message #9 to topic 'spBv1.0/TestGroup/NBIRTH/TestNode'
2018-07-20 16:46:11,443 INFO --- MqttFX ClientModel : messageArrived() with topic: spBv1.0/TestGroup/DBIRTH/TestNode/TestDevice
2018-07-20 16:46:11,443 INFO --- MqttFX ClientModel : messageArrived() added: message #10 to topic 'spBv1.0/TestGroup/DBIRTH/TestNode/TestDevice

...

At this point, everything is ready to set setup custom records.  Go to the 'MQTT Transmitter' module configuration page and select the 'Records' tab as shown below:

...

When new record is submitted, it appears in the MQTT Transmission 'Records' table as shown below: 

Also note that Note that when new record is created, the 'CustomRecords' folder with the 'Publish' checkbox is created under the 'default' tag provider as shown below. Note that the 'Tag Folder Path' field may contain a path to subdirectories as well (e.g. MyRecords/TestGroup/TestNode or MyRecords\TestGroup\TestNode). In this case respective subdirectories will be created under 'MyRecords' folder and the 'Publish' checkbox will be in the MyRecords/TestGroup/TestNode directory.

Now, let's create a few tags in this 'Custom Records' folder as shown below:

...

We are now ready to publish tags we just created in the 'Customs Record' directory under 'default' tag provider. To do this click the 'Publish' check box, and it should automatically become unchecked in a second. This makes MQTT Transmitter publish tags on this topic:

topic: spBv1.0/TestGroup/DRECORD/TestNode/TestDevice

And with simple the SQL query shown below, we can verify that tags were are stored in the 'testdb' database:

...