0
Answered

Custom value to text function

Dennis Piet 3 weeks ago in Ideas updated 2 weeks ago 2

In Iridium Studio there are some output templates to automatically convert value to text.

There is $V to show integer value, there is $F to show a float.

But what if we need some other conversion from equipment output to human readable labels?

Is there a way to let a custom function do this for us?  I think there is something like this in Iridium server, called script modifier, but how about in a panel-project?

Example usage:

In my project I have a modbus driver that provides 12 tags that read times in minutes.

These times have to be displayed on various pages on the panel in human readable form:

i.e. 5 = 00:05  and 1439 = 23:59

So, since I could not find the automatic conversion from value to text in label properties, I now have to do in JS script for all 12 time-values:

// Tag listener

IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, function(name, value)

{

function minutes2Time(minutes){

IR.Log("Minutes: " + minutes);

var l_date = new Date(0,0,0,0,minutes);

IR.Log(l_date);

return ("0" + l_date.getHours()).slice(-2) +

":" + ("0" + l_date.getMinutes()).slice(-2);

};

IR.SetVariable("Tokens.Time1 Text",

minutes2Time(IR.GetVariable("Drivers.WAGO Main PLC.Time1")));

...

IR.SetVariable("Tokens.Time12 Text",

minutes2Time(IR.GetVariable("Drivers.WAGO Main PLC.Time12")));

});

// Subscribe

IR.SubscribeTagChange("Drivers.WAGO Main PLC.Time1");

...

IR.SubscribeTagChange("Drivers.WAGO Main PLC.Time12");


// script end.


I would rather just drag the drive tag to the label I want to display it in. And then in the label properties specifiy my minutes2Time function to handle the conversion from value to text. 

Answered

Hello, we sent your idea to the development department. Terms of implementation, unfortunately, are not defined. Thank you for your participation!

OK, so such option is not available yet.

Is the way I do it now the best way? Or would I be better of using schemes? Or is there another better/easier way?