LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

having problem in making iteration in grid.

Solved!
Go to solution

Sorry for troubling you again and again. But now I am done with my program but their is some bug. It occurs often but not always, I dont understand the reason why this is happening. And I tried to implement what you said that I should update display once for all arrays by placing my sub vi outside loop. That way the frequency of that bug increases and it is their whenever the program executes. And I didn't knew how to implement reference of  arrays in my subvi so didn't implemented that part.

And regarding the bug it is like when you click on any array cell of that array don't respond at times according to the logic of program but rest array work perfectly fine. I have attached screenshot to explain it in a better way. May be the error is as I have a loop inside event structure but I dont know an alternate way to get the same result.

0 Kudos
Message 11 of 18
(593 Views)

A one minute glance at the diagram shows the following problems (outside case):

 

  • There is no event for array 2, 3, or 4
  • Why is there a feedback node in the "down case"?
  • ...

 

 

0 Kudos
Message 12 of 18
(590 Views)

Actually when placed subvi outside case it was giving this bug. So I stopped working on it, and was updating array in each loop. Therefore the outside array vi was unfinished, but the otherone is complete. I have attached new outside case vi, please check this one. It does not have any uncompleted stuff that you have stated above.

0 Kudos
Message 13 of 18
(585 Views)

Well, your VI is a bloody mess and very difficult to debug. That subVI with tons of connectors and filled with Rube Goldberg constructs is a nightmare. Just use index array and everything will fall into place. 😄

 

I cleaned it up a bit and things seem to be working just fine now in my LabVIEW version. See if you still see the problem.

Message 14 of 18
(577 Views)

Now for the analysis of the problem you encountered with incomplete patterns:

 

Race condition!!!!

 

In the main event case, you write to a value property of the array with a value that only contains the clicked element with the new color. Since there is no data depedency to the rest of the code, this write operation does not necessarily occur before the controls are updated. If it occurs after the controls are updated, it will overwrite the freshly decorated row that just has been clicked, thus removing the color changes added in the inner while loop.

 

Wile the property write is not needed anyway and can be deleted in this case (I deleted it!), a general fix would be to enforce execution order, e.g. as follows: place a wire between the value property node and the following case structure. This ensure that the case structure cannot start until the property is written and all's well.

Message 15 of 18
(576 Views)

I tried connecting a wire from property node to case structure after that code works without any bug. Just one question you knew from the starting that you just had to add one more wire to remove that bug than why did you took so much pain of cleaning my code. Anyways thank you very much for doing that, from next time I will write more cleaner code. Smiley Happy

0 Kudos
Message 16 of 18
(559 Views)

"Hey I am done with my program but stuck on some bug-----"

No, you are not done with your program!  Smiley Very Happy

 

Been there, done that- 

 

I almost fell off my chair when I read the subject--

 

Futher analisys per Christians astute observations on race conditions.   " I am done with my program but stuck" is ALSO a race condition since you generate the output "DONE WITH PROGRAM" before you clear state "STUCK ON BUG"


"Should be" isn't "Is" -Jay
Message 17 of 18
(554 Views)

@altenbach wrote:

First of all, your are using way too much code for all this. Here's a quick implementation that modifies the visibility using an array of references (You are using a huge case structure with many cases, making the code very complicated and unmaintainable).

 

You should really change to arrays of picture rings or color boxes. (Using arrays of pictures seems a little bit weird). Once you do that, things will become much simpler and you can do all your "patternization" in a single additional event case. Try it.


Hello Altenbach,

 

 I was looking across NI posts when I came across this and even though I understood what GJ:AKLDFJG had done, I am not sure about how you have implemented the code. Can you please elaborate on this as I am trying to understand what the code does.

 

Some of the questions which came to me are:

a) How did you customize the " 2D Picture/ Color Box to look this way. When I implemented the same code and used Color Box, when ever I run the code and try to click the color box, it shows the menu with different colors ( which is typically shown in color box). How shoud it be disabled?

b) Also even though I followed the code which you have shown , my code does not run the same way. There is a mismatch and it does not consider the first element of the array at all  ( The element 00 is not considered, also row 0 is not working at all!!) I am not sure why.

 

I also tried adding a picture from powerpoint to customize the color box. ( I went to advanced-customize- and took a picture from powerpoint and added onto it..) However it behaves more weirdly when clicked.

 

This brings up to some of the questions in the code:

 

For example, why are we able to get "coords" option in events only when we use "Mouse Up"  and not anything else and what is its use? What values is it outputting and why are we comparing it with position Left?

What does the number 42 in the block diagram signify? Based on how I change the number it changes the way the color box buttons operate. For example , the number 42 does not make the element A10 work. If number is 50, then the element A17 changes color when I click even around element A18. I am not sure what it signifies. Can you please elaborate.

 

I tried looking at some Labview books , however even though it explains the basics, there is not much information on efficient porgramming skills and nuances of LabVIEW. I beleive that can be obtained only through a lot of practice and patience..:)

 

I beleive my questions are very simple and it will be really wonderful if you can help me out and elaborate on it.

 

G

 

 

 

0 Kudos
Message 18 of 18
(508 Views)