Edge Data Routing (EventDefinition.xml)
The Senseforce Edge Solution implements a powerful data routing engine. Input data can be directed to one or many output plugins on a per data point level. The configuration file used to set up the data routing is the EventDefinition.xml and can be found here:
[Edge Main Folder]/configs/configurations
These configs are only used for the Edge instance Luna.Console, executed directly from the [Edge Main Folder]. Click the "Service Application" tab above to check the location for Edge services.
You can install several Luna service instances onto one device - for example to collect data of several machines from a local data collection device. Each service instance needs it's own set of configurations. When using the Senseforce Edge Service Installer, the default configurations are automatically installed for any service.
The EventDefinition.xml contains one or several Mapping-blocks. Each block defines one data routing, redirecting the defined input data points to the specified target output plugin. See the following example for further reference:
The sample EventDefinition.xml defines two Mapping-blocks. The first block (line 6 to 41) redirects the defined datapoints Id, SawArea, and CutLength (see lines 29 to 31) to the plugin with the name Mqtt_senseforce (see line 13). Only data that are labelled with the IngressKey = OPCUA (see line 9) are processed. This is the default for the OPC UA plugin.
The second block (lines 38 to 66) processes the data points wind and oil, renames them to WindSpeed and OilTemperature (see lines 62 and 63), and directs them to an output-plugin called Sqlite_senseforce. Only data that are labelled with IngressKey = SIEMENS (see line 41) are processed. This is the default for the Siemens SINUMERIK plugin.
Both mapping-blocks are of type MDE10 (see lines 18 and 50). The type option has different meanings for different output plugins:
MQTT output plugin
Sqlite output plugin
The type-setting (see line 18) adds an additional type key to the transmitted JSON message. If the MQTT plugin is used to transmit data to the Senseforce cloud, the type value must match the "Key" of an Event Schema which is defined in the Senseforce platform Event Schema management tool.
The type setting is used to determine in which SQLITE table to insert the data. Setting the type to MDE10 requires a table called MDE10 to be present in the SQLITE table where the plugin is configured to insert into.
See the DataMappings.xml files of your input plugin configurations to check the IngressKey-labels of each plugin.
The name of the target plugin is defined in the appsettings.xml file. You can define one or several target plugins for each mapping block. This allows transmitting data to different data endpoints at the same time.
The notation $(someVariable) found in lines 29,30,31 and 62, 63 looks up incoming messages for keys someVariable and assigns the values of it to the name attribute of the mentioned line. Eg. line 62 looks for an incoming datapoint wind and assigns its value to a new key WindSpeed. This mechanism allows for effective data point renaming.
The latest versions of our SF Edge (V188.8.131.52+) additionally also have the posibility to define "dynamic topics". This feature allows to send data to multiple topics from one SF Edge instance. This is especially useful if you want to upload data from a central data source which includes information for multiple machines (like your ERP, or MES) but you want the data look like each of these machines has sent this information. This has several processing benefits on our plattform e.g. when filtering data for a specific machine.
To use this feature you have to specifiy the Topic attribute (see line 24). Here you can use a variable of your input data to define the topic (= the machine name) like shown in the example below. If this variable has missing values for some data in the input, the topic defined in the MQTT plugin is used as fallback. Please make sure that the "tenant/" is defined the same as in your MQTT plugin (see MQTT Plugin). If you need some pre- or postfix added to the names defined in the variable you are using as topic you can do this like shown in line 34.
TargetPlugin, IngressKey, Type, and Timestamp are mandatory fields of any mapping block. Note: The edge input plugins automatically creates a Timestamp-field for each message either from incoming data or from system time information.
<?xml version="1.0" encoding="utf-8" ?>
xsi:schemaLocation="https://senseforce.io/ Schemas/mappings.xsd" >
<!-- The list of MQTT mappings below define the data routing and data mapping (renaming of variables)-->
<!-- Define for which input plugin this mapping should be applied -->
<!-- In your Input plugins "DataMappings.xml" a field "IngressKey" can be found. Match the Input plugins key with this key. -->
<!-- Define, where this message should be directed to. You can also direct it to multiple output plugins -->
<!-- Here you can define all message settings -->
<Type>MDE10</Type> <!-- This is the name of this event. It has to match witch the event schema defined in Rocket. Otherwise the message will be categorised as invalid. -->
<Timestamp>$(Timestamp)</Timestamp> <!-- The timestamp which is added to the message (if you use $(Timestamp) the timestamp provided by the plugin will be used) -->
<Id>$(GUID)</Id> <!-- Unique message ID -->
<!-- Optionally you can override the Topic of your MQTT-Plugin by setting a topic-identifier as shown below.
If no Topic is defined, the default one from MqttSettings.xml is used -->
<!-- <Topic>tenant/$(MachineNumber)</Topic> -->
<!-- Place all your data information here. name="XXXX": XXXX must be defined in Senseforce Cloud (Event Schema Attribute Key); -->
<!-- $(YYYY): YYYY are internal Edge variables which are directed from Input plugins. If you define a Variable Name in your Input plugins, these names must match with YYYY-->
<!--isMetaData: If set to true, messages which only contain isMetaData-objects are not transmitted-->
<Data name="Id" isMetaData="true">$(Id)</Data>
<!-- you can enter text before or after your variable, as demonstrated below -->
<!-- Wildcard notation for adding "any datapoint". Please use with caution-->
<!-- <Data name="$(*)">$(*)</Data> -->