Data Stream
The purpose of this data stream is to use the triggered recommendations to assign a color to be used by the app for a visual indicator on the status.
The assumption made is that the recommendations are being triggered using an EntityId of AssetNo which is used in the stream loaded from a Context Provider.
Agent | Description |
---|---|
Read Recommendations | Read the configured pending recommendations |
SQL Context Provider | Read the consumer reference data from SQL |
Join transformation | Contextualize the data with data from SQL |
Calculated Field | Give a weight for the aggregate to use and work out the color scheme |
Aggregate | This allows for the higher priority recommendations to move to the top |
XMPro App | View data in the App Designer |
The read asset information agent can be swapped for any other context provider that provides the respective asset information. The default information this stream requires is:
- AssetNo
- Description
- AlertX
- AlertY
The AssetNo is used to uniquely identify the records as they move through the data stream.
The AlertX and AlertY are used by the application to render in a specific location. They should of two types:
- percentage value - excluding the % symbol (used in the Image Map block)
- geo-location as lat and lon (used in the Map block)
This is an example of a configured context provider with the respective fields required for this stream:
The join is configured as:
- Behaviour: Context
- Context Endpoint: Right
- Prefix: Only for duplicates
- Join Type: Right Outer Join
The Right option is used due to the SQL Context Provider being on the Right input leg into the Join transformation. The Join is done on the AssetNo and the EntityId from the recommendations.
The calculated transformation is used to clean the description to remove the R_ or L_ and normalise to Description, it also creates a RuleWeight for
- High as 3
- Medium as 2
- Low as 1
- Null as 0
The logic for the calculated field is:
RulePriority == null ? 0 : RulePriority == "High" ? 3 : RulePriority == "Medium" ? 2 : RulePriority == "Low" ? 1 : 0
This field is being used in the aggregate to help sort the highest priority above lower ones. It helps when multiple recommendations have been triggered for a single asset and you only want to indicate the highest value as the overall status. If you dont do this step you run the risk of the app changing its colors on each refresh of the data, i.e. if the data is refreshing at 5 seconds, every 5 seconds the indicator would change from red to orange etc, this helps resolve that challange.
The aggregate is configured to the listener interval polling of 5 seconds to ensure all the data that is loaded into the aggregate window before the aggregation is done.
This block is what ensures only the highest rule is available for the downstream color indication.
The calcualted field following the aggreate is used to assign the colors to pass to the app for use. Its defined as:
MaxWeight == 3 ? "#CB715E" : MaxWeight == 2 ? "#EBA464" : MaxWeight == 1 ? "#E8C268" : "#79A681"
The resulting colors are:
#CB715E
#EBA464
#E8C268
#79A681
These are passed to the XMPro agent to be usable within the app.
Steps to Import
1. Create/confirm variables
Ensure the following variables are available to be used in the data stream:
- App Designer URL
- App Designer Integration Key (Encrypted)
- SQL Server
- SQL Username
- SQL Password (Encrypted)
2. Import the Data Stream
- Select the highest agent version number on import, if prompted
- Assign Access to others as required
- XMPro agents () - ensure the URL & Integration Key are selected
- Recommendation agent () - ensure the URL & Integration Key are selected
- SQL agent () - ensure the Instance, Username & Password fields are filled in
- Click Apply and save the data stream
- Publish the data stream and open the live view
- Ensure there is data in the live view by monitoring the agents