10-24-2016 04:12 AM
Is there any structure that can wrap the code to make the code have the top priority when the code is executed?
Thanks,
Solved! Go to Solution.
10-24-2016 04:37 AM
Use an FPGA Target...
Can't be more specific with your vague question.
Vincent
10-24-2016 04:56 AM
Yes. It is called Timed Sequence.
However, there are a lot of specific rules to follow when using timed structures. Breaking that rules can lead to performance degregation up to undesired runtime behavior. So please make sure to know and understand those rules before starting to meddle with priorities by using timed structures.
Norbert
10-24-2016 07:08 AM
If you're using a cRIO or other embedded targets (e.g. PXI), then you might be able to use timed loops on RT or code on an FPGA. On Windows, neither of those suggestions are useful.
You can set the 'priority' of a SubVI but it is unlikely to make a significant difference.
The most important thing you can do is to optimise that specific piece of code - which we can only help you with if you share it with us. There are some basic guidelines (e.g. avoid property nodes, avoid memory allocations etc.) but without knowing what your code is doing, or how you have implemented it, it's impossible to tell.
10-24-2016 08:11 AM - edited 10-24-2016 08:14 AM
Appreciate above replies.
I think I don't show my question very clearly,thus complicats the question.
My application is simple,just a UI operation code as below.
This code is highlighting a row in a table on Mouse Move Event.The problem is that when the mouse moves just inside a row,the row will blink,which is not expected.The reason is that it takes about 10ms between the two property node of CellBGColor.My whole software is a little complicated and it has some background code running always.
I tried the code in a simple demo VI ,and it only takes 2ms ,so it won't blink.
So I have to prioritize the code to make sure it executes fast enough.
10-24-2016 08:23 AM - edited 10-24-2016 08:24 AM
Property Nodes for front panel items are just slow because they force thread swapping to the UI thread and redraw the front panel each time you write to one. About the only thing you can do to speed it up is to use the Defer Front Panel Updates.
10-24-2016 08:24 AM
You should change color only if the mouse changes row. So include code to check "previous row vs. current row" and recolor only if that is not the same.
I'm not sure about performance impact but it might be better to not recolor the whole table, but only rows which are "used". That means if mouse pointer changes row, you color the "old row" in default color and the "new row" in the highlighted one. It also might be beneficial to defer panel updates until both recolor commands are being issued to only get a single redraw. This could also prevent blinking to a certain degree...
Norbert
10-24-2016 08:30 AM
Set the 'defer panel updates' property of the VI front panel to true before your code starts, and set it back to false afterwards. That should stop the table from blinking when you clear and change the colour and will significantly speed up the updates.
Here's an example:
10-26-2016 11:48 AM
Works awesome!
Thanks.