Nasal reading non-base properties

29 Jun 2021 13:56 - 29 Jun 2021 13:59 #50616 by ScottBouch
Nasal reading non-base properties was created by ScottBouch
I have one Nasal switches script setting a bool:

/controls/panelA5/inst-master-sw

in another nasal DC electrical script, I want to read the bool value once each loop, and set a program variable to match:

instMasterSw

This variable does not need to be set in the property tree (no need to duplicate the original), it's only for saving reading the main variable several times from the electrical script.

The DC electrical script base is set to: var base = props.globals.getNode("/systems/electrical/",1); whereas the swich script base is: var base = props.globals.getNode("/controls/",1);

What's the best way to read it? I did read somewhere on the wiki that using getprop is less efficient than getValue. Any example code will help! I have been looking through other scripts but got into a mess.

Please Log in or Create an account to join the conversation.

29 Jun 2021 14:20 - 29 Jun 2021 14:54 #50617 by ScottBouch
Replied by ScottBouch on topic Nasal reading non-base properties
I have this in the electrical script in a non-looping defining parameters section:
.
var instMasterSw = props.globals.getNode("/controls/panelA5/inst-master-sw",1);
instMasterSw.setBoolValue(0);


Then in a looped function I try to read this property it with:
.
if (instMasterSw.getBoolValue())
{px11V.setValue(px1V.getValue())}
else
{px11V.setValue(0)}

The above should read the Voltage at busbar PX1 and set PX11 Voltage accordingly as the instrument master switch joins the two busbars.

I have tested the if statement with another bool, and it works fine in setting the voltages.

But it just isn't working when I set /controls/panelA5/inst-master-sw true or false in the property tree. There must be something simple I'm doing wrong here!

Cheers, Scott.

Please Log in or Create an account to join the conversation.

29 Jun 2021 15:38 - 29 Jun 2021 15:39 #50618 by ScottBouch
Replied by ScottBouch on topic Nasal reading non-base properties
Arghh!!

Fixed it! It was a typo in the property path!!!!!

At least I know I was going about the logic correctly though.

Ignore me, back in my box.

Please Log in or Create an account to join the conversation.

Time to create page: 0.125 seconds
Powered by Kunena Forum

Latest Forum Posts

PM Notifications

You are not logged in.

PM Mailbox

You are not logged in.