04-23-2015 10:04 PM
Hi!
I'm working on a way to change the slide fill color dynamically, in the picture you can see what i came up to, however in most of the post i see in the forum, they say this is "bad programing" and I want to know if there is a better method to do this.
This slide is going to show a tank's level thus in the VI is going to be a data adquisition, this is why i want to improve the code.
Thanks in advance.
Cesar.
PS: let me explain what i do: the tank level changes between 10 and 40 so i took that number and scaled so on the green port of the RGB to color vi i've a signal that changes between 0 and 255, this makes the color change on the property node
04-23-2015 11:11 PM
04-24-2015 03:07 AM
While it's true that there's no need to repeatedly set the color, I wouldn't actually call it a problem, especially if your data is coming from DAQ and not from the user. LV can usually manage just fine with that if you're only doing it a few times a second, so I would say that your only real problem is that you don't have a wait, because that would cause the loop to run as fast as possible and eat up all the CPU time. Every long-running loop should have something delaying it.
A second problem is the dynamic data. I never worked with it, so I don't know it well enough, but the main reason I haven't worked with it is that I can't understand or predict how it will behave, because it's a kind of magic data type which automatically adapts and coerces to fit the code, so I would suggest you replace that piece of code with one of your own, which uses a primitive numeric data type.
Since you're doing a simple linear conversion, it's simply a matter of a straight line equation, which you probably learned in middle school. I believe LV has some VIs which ship which already do that, and you can probably also right click the express VI and open its FP, which will convert it to a regular VI you can look at. Or you can write the code on your own.
04-24-2015 07:15 AM
Hi cdarangoo,
I also would suggest to replace the express vi; in this particular case, I would use an expression node from the numeric palette:
Regards,
Alex
04-24-2015 12:09 PM - edited 04-24-2015 12:10 PM
Hi again thank you all for your answers:
mikeporter and tst:
In the hurry making the post i don't really post the complete code, just the changing color part, that's why i dont have the delay in the while loop.
I guess as a final solution, i'll change the express VI as alexderjuengere suggested and take the tst advice about the continous color seting.
Thanks Again here is a final picture of my project:
Cesar