I use IoT version to read information from an industrial HMI using Modbus. I have a name of current recipe that I need to display on the dashboard. I can read the 20 input registers and see the ACSII numbers in the variables of my Modbus connection but for the life of me I cannot figure a way to display the text on the dashboard. Was thinking of using the recipe index numbers and maintain the name lists in both the HMI and again in the IoT dashboard and use visibility on text/label widget but updates would be problematic to keep these lists synced and displaying correctly. I will also have the same issue with operator name when I get to that point. Any suggestions?
Hi,
you have to add a java script code.
1. Read all the variables from the script.
2. Convert the alues to characters
3. Create a text from the charactes.
4. Write the text to a new Variable
Please check the attached image. I have created an example.
In this example the variables V1-V5 contains the numbers 65,66,67,68,69
The result to V10 is the text: ABCDE
Code:
//--- Copy values from Virtuino Variables to JavaScript variables
var inputValue1 =+Virtuino.readValue("inputTag1"); //Read inputTag1 value as number from V1.
var inputValue2 =+Virtuino.readValue("inputTag2"); //Read inputTag2 value as number from V2
var inputValue3 =+Virtuino.readValue("inputTag3"); //Read inputTag3 value as number from V3
var inputValue4 =+Virtuino.readValue("inputTag4"); //Read inputTag4 value as number from V4
var inputValue5 =+Virtuino.readValue("inputTag5"); //Read inputTag5 value as number from V5
//--- enter the JavaScript code like the example below
var char1 = String.fromCharCode(inputValue1);
var char2 = String.fromCharCode(inputValue2);
var char3 = String.fromCharCode(inputValue3);
var char4 = String.fromCharCode(inputValue4);
var char5 = String.fromCharCode(inputValue5);
var text = char1+char2+char3+char4+char5;
result = '{"tag":"outputTag", "value":"'+ text+ '"}'; // return a json message