Java script

good evening, i have written a js script which should light up buttons on the screen as well as display my Ewon variables (Flexy 205) but the buttons do not change color.
also how to make a bit array from a number

EX: 60 -> 11 1100
EX [1] = 0
EX [2] = 0
EX [3] = 1
to vary the colors of the buttons?

var ps = getEwonTagVal (‘PPE_STATUS’);
if (ps [0] == 1) {
setViewOnTagVal (stop, true);
}
else {
setViewOnTagVal (stop, false);
}

if (ps [1] == 2) {
setViewOnTagVal (trip, true);
}
else {
setViewOnTagVal (trip, false);
}

if (ps == 4) {
setViewOnTagVal (alarm, true);
}
else {
setViewOnTagVal (alarm, false);
}

if (ps == 8) {
setViewOnTagVal (on, true);
}
else {
setViewOnTagVal (on, false);
}

if (ps == 16) {
setViewOnTagVal (checked, true);
}
else {
setViewOnTagVal (checked, false);
}

if (ps == 32) {
setViewOnTagVal (auto, true);
}
else {
setViewOnTagVal (auto, false);
}

Thank you

wjm

Hello can I take a look at this over TeamViewer with you?

https://get.teamviewer.com/6w2xnbk

Or can you send me the full project file for this ViewON project?

Hi, thank you, I am joining you the project

++

wjm

One way you could go about converting the tag values to binary and then making changes based off of that could be to use the BIN$ function in the BASIC IDE section

I did a short example with a variable in the Ewon called test

Test@ = 19 //example value for a tag
binaryvariable$ = BIN$ Test@ //creates a variable that is a 32 bit binary value of the tag
print binaryvariable$ // prints the binary value
alarm$ = binaryvariable$(32) //Sets the variable alarm to be tied to the 32nd bit of the binary value
print alarm$ //shows the output of that new variable

As for this section, how was this image made? How are you tying variables to the different LED indicators?
image

re: this is why I ask you why my javascript of this page is not working
++

wjm

good evening, I’m importing the variables from my Ewon.
Here PPE_STATUS if == at 2 turn on the “on / off” led …
I created the led objects with Viewon see attached file

++

wjm

I’m not sure if maybe there was some kind of issue when the project was exported but if all of those circles are supposed to be separate images and not one large SVG file, but when I try and click on an individual circle it selects them all. Perhaps I can try to take a look at this with you over TeamViewer or if you want to work with local support in your area to avoid the time difference you can create a ticket on mysupport.hms.se

hello,
the objects are grouped, they must be ungrouped or entered in the group

++

jm

I found my mistake
not “setViewOnTagVal (stop, true);”
But
“setViewOnTagVal (‘stop’, true);”

++

jm

1 Like

Hi Jm,

Sorry for the delay on this, we had been trying to catch up on some tickets but were pretty busy last week. Glad to hear that you got it working though!

-Tim