Screenshot of the Equipment Information Model in SMARTUNIFIER¶
Structure of the Information Model for the File Consumer Channel:
Event:
The event specified in the Information Model for the File Reader will serve as a trigger in the Mapping.
When a file in the target directory is detected by SMARTUNIFIER the associated rule will be executed.
Variables:
Variables defined within the Event represent the key-value pairs in the XML-file.
ID
Node Type
Data Type
FileEvent
Event
FileEventType
FileEvent/OrderNr
Variable
String
FileEvent/ProductNr
Variable
String
FileEvent/Date
Variable
String
FileEvent/Quality
Variable
String
FileEvent/Quantity
Variable
String
Note
The group function allows you to combine logical entities into paths. You can use existing naming conventions and styles for naming equipment to organize the configuration components. This simplifies the structuring and management of configurations.
Hint
We recommend using a consistent “Group” name throughout the demo. For instance, to identify the artifacts created for this scenario, the group name “demo.xml-database-2-mqtt” is used.
Create an Information Model that represents the structure of the database query:
Screenshot of the Database Information Model in SMARTUNIFIER¶
Structure of the Information Model for the SQL Database Channel:
Command:
We need a structure that allows us to receive a reply, and commands provide this capability.
The Parameter variable, OrderNumber, is used in the database select query as a parameter.
The Reply variable, Customer, will store the outcome of the corresponding database query.
Create an Information Model that represents the data structure of the MQTT payload.
Screenshot of the Host Information Model in SMARTUNIFIER¶
Structure of the Information Model for the MQTT payload:
Event:
In this demo we want to send JSON data to the MQTT broker.
The structure of the payload is defined in the Event by adding Variables of simple (e.g. OrderNumber) or complex (e.g. TimestampType) data type.
To create the File Reader Communication Channel we need to proceed with the steps outlined below:
1. Create File Reader (XML) Channel:
Enter the group name: demo.xml-database-2-mqtt
Enter a name: e.g. Equipment
Select the Equipment Information Model created previously
Select File Reader (XML) as the Channel Type
2. Configuration of the File Reader (XML) Channel:
a. Select the root node and specify paths to following folders:
In
Process
Out
Error
Screenshot of the configuration of the File Reader in SMARTUNIFIER¶
b. Enable the Event FileEvent to tell SMARTUNIFIER that this event is going to be used for reading in the file. We can further explicitly define which files in the directory should be processed by configuring the File Name Filter.
Screenshot of the configuration of the File Reader in SMARTUNIFIER¶
To create the MQTT Communication Channel we need to proceed with the steps outlined below:
1. Create the MQTT Channel:
Enter the group name: demo.xml-database-2-mqtt
Enter a name: e.g. Host
Select the Host Information Model created previously
Select MQTT (JSON) as Channel Type
2. Configuration of the MQTT Channel:
a. Select the root node and enter the Host (ip address) and the port of the MQTT Broker (We can leave the other configurations at their default value for this demo).
Screenshot of the configuration of the MQTT Channel in SMARTUNIFIER¶
b. Select the Event node to enable the Producers and enter a name for the Topic.
Screenshot of the configuration of the MQTT Channel in SMARTUNIFIER¶
host/MQTTEvent/Customer := reply.Customer (enable code for assigning the reply of the request)
host/MQTTEvent/Timestamp/Date := java.time.format.DateTimeFormatter.ofPattern("dd.MM.yyyy").format(java.time.OffsetDateTime.parse(event.Date.value.toString)) (enable code to format the date)
host/MQTTEvent/Timestamp/Time := java.time.format.DateTimeFormatter.ofPattern("HH:mm:ss").format(java.time.OffsetDateTime.parse(event.Date.value.toString)) (enable code to format the time)
host/MQTTEvent/Quantity := toInt(event.Quantity) (enable code to do a type conversion)
Deployments are described in the chapter Deployment.
To deploy our Communication Instance we need to proceed with the steps outlined below:
1. Select the Local Deployment
2. Select the Instance, the Endpoint default:Default and Info for the level of detail of the log (We can leave the other configuration at their default value for this demo).
3. Save the Deployment.
4. Now Deploy and Start the Instance.
Screenshot of a deployed Instance in SMARTUNIFIER¶
In order to send the data from the equipment with the customer information via MQTT, move the XML-file into the specified In Folder (Step 2.1 Communication Channel - Equipment - Configuration).