Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Introduction to the MQTTspB Simulator

Overview

This document has information on the MQTTspB Simulator configuration and Runtime Behavior. Below you will find more information on the requirements and supported features..

The MQTTspB Simulator can be Started from the DataExplorer User interface, or running its executable directly with the proper command line parameters.

When running, it will create an MQTTspB Client that will connect to the configured Broker, publishing simulated data to mapped Topics. From the Broker point of view, the MQTTspB Simulator, will act as any other MQTT Client.

Image Added

Info

Watch a video on how to use the MQTT Simulator with Tag Provider here.


On this page:

Table of Contents
maxLevel3


System Requirements

This simulator application comes with the default installation of product version 910. 2. The executable file can be found under the ../9.2fx-10/Protocols/MQTTspBSimulator.exe directory.

Make sure to execute the file from inside this folder to ensure all dependencies are satisfied.

Supported Features

The following features are supported:

  • Connection to Brokers (local and Remote) that may (or not) require a Username and Password.
  • Customization of Topic parameters - GroupID, NodeID and DeviceID.
  • Create Multiple NodeIds in the same GroupID, each with its own DeviceID’s.
  • Create Multiple DeviceIDs in the same NodeID.
  • Change the DeviceIds attributes using a config file.
  • Publish NBIRTH, DBIRTH, DDATA, NDEATH and DDEATH messages.


Note

The Simulator is Write-Only! You will not be able to subscribe to any topic; only publishing is allowed.





Simulator Configuration

File

The DeviceID attributes can be customized using the configuration file, MQTTspBSimulator.exe.config. This file uses an XML syntax that is parsed during the application initialization.

This means that any change that is made requires the application to be restarted in order to be applied. 

The file syntax is illustrated below.

Code Block
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Name" value="Type=string;Sampling=constant;range=;defaultValue=Barcelona" />
<add key="State" value="Type=int;Sampling=variable;range=0,10;defaultValue=" />
<add key="Longitude" value="Type=double;Sampling=constant;range=1.56,2.49;defaultValue=" />
<add key="Latitude" value="Type=double;Sampling=constant;range=41.34,41.71;defaultValue=" />
<add key="PanelPower" value="Type=double;Sampling=variable;range=200,500;defaultValue=" />
<add key="PanelVoltage" value="Type=double;Sampling=variable;range=-220,220;defaultValue=" />
<add key="PanelCurrent" value="Type=double;Sampling=variable;range=-10,10;defaultValue=" />
<add key="TemperaturePort" value="Type=double;Sampling=variable;range=15,35;defaultValue=" />
</appSettings>
</configuration>

Each AppSetting entry have two parameters, Key and Value.

  • Key: Attribute Name that will be added to the DeviceID payload.
  • Value: Attribute customization parameters (Type, Sampling, Range and DefaultValue). The parameters are detailed below:
    • Type: Variable DataType - It can be string, int or double
    • Sampling: Defines if attribute will have its value changed on each iteration
      • Variable: Data changes on every DDATA message sent
      • Constant: Attribute is sent only in DBIRTH message
    • Range: Min and Max range For int and double types only.
    • DefaultValue: Default value for For string type the value will be a concatenation of ”Default- Value - DeviceID”.
Info

The file name must be the same as the executable file. If one is changed, the other must be as well.

The MQTTspB Simulator is divided in three main regions. Configuration (Connection Parameters and Payload Settings), SimulationControl and View (DataBrowser and EventLog).

Connection Parameters

Here is configured the necessary information required to establish a connection to a Broker.

Application Settings

The Simulator is divided in three tabs: Connection String Parameters, Simulation Settings and Runtime Simulation Settings. More information on each one is available below.

Image Removed

Connection String Parameters

  • Broker URL: MQTT Broker (Server) Default value is loopback (local) ip (127.0.0.1).
  • Port Number: MQTT Broker listening port Default value is 1883.
  • Username: Username defined on the This will be requested if the Broker needs this configuration (optional).
  • Password: Password defined on the This will be requested if the Broker needs this configuration (optional).
  • Start Minimized: Application starts minimized (valid for the next time the application is started).
  • Connect : Connect to Broker.On Startup: MQTTspB Client tries to connect to Broker automatically when application is started (valid for the next time the application is started).
  • Publish Data On Startup: MQTTspB Client tries to publish Data to Broker automatically when application is started (valid for the next time the application is started).
  • Block All Configuration Fields: Make configuration fields read-onlyDisconnect: End connection.

 

Noteinfo

The Simulator does not support SSL Protocols.

Simulation Settings

  • Base GroupID Name: GroupID name that will be used in the payload
  • Base NodeID Name: NodeID name that will be used in the payload. When there are more than one node, the names will be a concatenation of the base name and index.

E.g.: NodeId 1, NodeId 2 ... NodeId N.

  • Number of Nodes: Amount of Nodes that will be created
  • Base DeviceID Name: DeviceID name that will be used in the payload. When there are more than one device, the names will be a concatenation of the base name and index.

E.g.: DeviceID 1, DeviceID 2 ... DeviceID N.

  • Number of Devices per Node: Amount of Devices that will be created.
  • Apply: Apply new settings.


Info

The fields can only be modified while the MQTTspB Client is not connected to a Broker.

Payload Settings

In this tab, you will be able to configure the Payload Structure to be published.

Image Added

The structure is defined based on a hierarchical structure illustrated below:

Code Block
languagexml
<GroupID Name="<GroupName>">
|-- <NodeIDs>
|   |-- <NodeID Name="<NodeName>">
|   |   |-- <DeviceIDs>
|   |   |   |-- <DeviceID Name="<DeviceName>">
|   |   |   |   |-- <Variables>
|   |   |   |   |   |-- Var1
|   |   |   |   |   |-- ... 
|   |   |   |   |   |-- VarN
|   |   |   |-- <DeviceID Name="<DeviceName2>">
|   |   |       |-- <Variables>
|   |   |   |   |   |-- Var1
|   |   |   |   |   |-- ... 
|   |   |   |   |   |-- VarX
|   |-- <NodeID Name="<NodeName2>">
|       |-- <DeviceIDs>
|       |   |-- <DeviceID Name="<DeviceName>">
|       |   |   |-- <Variables>
|   |   |   |   |   |-- Var1
|   |   |   |   |   |-- ... 
|   |   |   |   |   |-- VarY
|       |   |-- <DeviceID Name="<DeviceName>">
|       |       |-- <Variables>
|   |   |   |   |   |-- Var1
|   |   |   |   |   |-- ... 
|   |   |   |   |   |-- VarZ

To edit the structure, click on the Edit Data Structure button and customize your Payloas at the dialog window.

Image Added

There are some properties to be defined for Variables:

  • Type: Define the Variable DataType. Options are:
    • Double
    • Integer
    • Boolean
    • String
  • VariationFlag: Flag that indicates if variable value will be simulated every second in Runtime.
  • Min: Defines the minimum value for simulated data.
  • Max: Defines the maximum value for simulated data.
  • InitialValue: Defines an initial value for the variable.


Info

The DataStructure can only be edited while the OPC Server is not running.

Simulation Control

This section is used to define the simulator behavior in runtime.

  • Publish One

Runtime Simulation Settings

  • Send one Data Sample: Sends one DDATA message for each Device created in the session.
  • Send Publish Continuous Data: Sends continuous DDATA messages with a time rate of 1 second.Show Log: Shows log window with diagnostics messages. You can also see log messages in the status bar at the bottom of the application.
  • Stop Publishing Data: Stop publishing continuous data.

Data Browser

In this region, you will be able to see the Payload Structure existing in the Broker.

Image Added


EventLog

This log displays useful information regarding the MQTTspB Simulator activity.

Image Added




MQTTspB Simulator with the fxAssetsMonitor demo project

Additional Information:

Solution for when the configurations from the XML MQTTspBSimulator-Demo9.2.exe.config are applied and the tags do not appear.

When you are using the demo project fsAssetsMonitor via the MQTTspB Simulator, it's necessary that the file "MQTTspBSimulator-Demo9.2.exe.config" be copied and pasted into the folder along with the project "fxAssetsMonitor.tproj". Upon opening the project, you can verify in Edit>Scripts>Classes, within the class CheckStatus that this class contains a method called StartMqttSimulator(). When running the project this method will fetch some arguments and together with the .config file, and from these configured arguments, the MQTTSpb Simulator will be called to run the values that are configured within this .config. When running the project this will be done automatically, without needing to manually open the simulator.

The original file "MQTTspBSimulator.exe.config" within the product's installation folder comes with default values for simulation and can be modified to generate new simulation values. To add new attributes, you can follow the pattern of the other attributes in the file.



In this section...

Page Tree
root@parent
spacesV10