0
Answered

Custom value to text function

Dennis Piet 7 months ago in Ideas updated by Aleksandr Romanov (CTO) 6 months ago 9

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?

I just found out Schemes does not work on a Panel-project, so that is not the way to go either ......

Why does Iridium Studio allow making Schemes in a Panel project if they don't work anyway? And why do I not get an error message?

Hi, it’s not entirely clear how you were able to create Schemes in a panel project?

Which version are you using? Can you show a screenshot?

Hi Aleksandr,

Right now, Studio does not allow adding  Schemes to an Panel project anymore..... at least, the add button does not work anymore. There is no error message or other info :-(  That is quite annoying about Iridium in general: sometimes things don't work as can be expected, but there is no good feedback to the user about this from the program.

The SCHEMES panel is still visible in a panel-project:

iRidium Environment: 1.3.16.2.20228

iRidium Studio: 2.0.5.20228 (64 bit)

Transfer: 1.1.3.14538 (32 bit)

iRidium: 1.3.16.20039 (64 bit)

Server: 1.3.16.20039 (32 bit)

iRidium lite: 1.3.11.19849 (32 bit)

Server lite: 1.3.11.19849 (32 bit)

Try to make MENU >> View / Reset Window Layout

That does exactly what it says.

After that I can still select "SCHEMES":


Alexander, i tested this, and Dennis is right: it's possible to recall the 'Schemes' panel.

This is how:

Start a new panel project

Right-click on the button 'WORKSPACE' or 'SCRIPT'. And there, you will see the option 'Schemes'.

i already sent you several emails about this behaviour: make Studio 'smart' and 'intelligent', and DISABLE functions that can't be used...

Thanks

Theo

Thank you for your attention and the error message, we set the task to fix.