Question:
How can we map error message texts to error codes in different languages and with a simple version control?
Solution:
To do so we have to do some simple steps:
- Install Luna including the XML-Plugin
- Configure Luna for file upload
- Create an Error Code Mapping Event Schema
- Upload data
- Create a simple Analytics Query
- Use our error mapping code snippet in your script
1. Install Luna including the XML-Plugin:
First you have to install "Luna" our edge software for example on your local PC. Additionally you also have to install the XML-Plugin.
Attention: The XML-Plugin will not be installed with the Luna Core Application. The XML-Plugin will be delivered as an additional installer.
If you require a download link for the Luna Installer, please contact our customer support team.
2. Configure Luna for file upload:
You can find the default Luna configuration for the error mapping upload in the attached file "error_mapping_configs.zip".
Please change at least the following settings:
- "otasettings.xml":
- Username
- Password
- InstanceIdentifier
- "XmlFileParsingSettings.xml":
- FilePath
- "MqttSettings.xml":
- Port (if necessary)
- Username
- Password
- Topic
3. Create an Error Code Mapping Event Schema:
In the next step you have to create an Event Schema Defintion to store to uploaded error code mapping data in our database.
In the example error code mapping file (which is also included in the "error_mapping_configs.zip") each entry has 4 attributes.
These are:
- errorLabel
- errorNumber
- language
- version
So you have to define these 4 attributes in your event schema definition as shown in the figure below.
4. Upload data:
Now you are ready to upload your error code mapping data to our database. To do so you only have to start the Luna application which will periodically check for new files to upload.
5. Create a simple Analytics Query:
If everything was configured correct, your data should be stored and accessible in our database. To use this data in the error code mapping script you have to define an Analytics Query. This query should return the latest version of all error code mapping entries for each error number, in each language.
Therefore you have to define the analytics query as shown below:
6. Use our error mapping code snippet in your script:
To use the code snippet shown below you just have to add the Analytics Query with the error mapping data (which we have defined before) and an Analytics Query with the error messages for which you want to apply the error code mapping.
This query has to include the following information:
- Timestamp
- Thing
- ErrorCode
Please replace "YourErrorMessageAnalyticsQuery" with the correct name of your Analytics Query.
if(nrow(YourErrorMessageAnalyticsQuery) > 0 & nrow(ErrorCodeMappingData) > 0) { # Define lookup data for error code mapping errorLabels <- as.character(ErrorCodeMappingData$errorLabel) names(errorLabels) <- as.character(ErrorCodeMappingData$errorNumber) # Use lookup data defined above to apply error mapping on actual error messages timestamp = YourErrorMessageAnalyticsQuery$Timestamp thing = as.character(YourErrorMessageAnalyticsQuery$Thing) alarmnumber <- as.character(YourErrorMessageAnalyticsQuery$ErrorCode) alarmtext <- errorLabels[as.character(YourErrorMessageAnalyticsQuery$ErrorCode)] } else { timestamp = as.numeric(Sys.time())*1000 thing = "-" alarmnumber <- "-" alarmtext <- "-" }
Congratulations!!
Now you have made it! You are now able to apply the error code mapping to your error messages. Your error messages are now always up to date and if you use a filter on the language column in your dashboard you also have enabled multi-language support for your error messages.