LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Append only last 5 messages

Solved!
Go to solution

Wollee,

I am using LV 2013 and your VI is 2015.

 

Thanks,

SM

0 Kudos
Message 11 of 60
(1,203 Views)

Give this a try.



-Matt
0 Kudos
Message 12 of 60
(1,201 Views)

Matt,

 

Yeah it didn't really work... It caused so many issues with my program including causing LV to crash several times... I think it was the WHILE loop that messed it up, but I can't be sure. I didn't write the initial program that this is being implemented in and it is very fragile... Is there another way to do it, like with a case structure or something instead of a while loop? It also wasn't writing to my text file at all, even just putting in 1 message...


Thanks,

SM

0 Kudos
Message 13 of 60
(1,194 Views)

Can you post your code? That was just a simple example and the while loop is not necessary.  I have no idea what youre working with ha Smiley Frustrated



-Matt
0 Kudos
Message 14 of 60
(1,192 Views)

Unfortunately I cannot post my code, due to several things... But here is the format of the incoming message:

[ABB Robot] [Abb Motion] [Set Target] [[0~0~0]~[0.96593~-0.25882~0~0]~[1~0~0~0]~[150~50]] [Pending] [0] [1]

Attached is a screenshot of where I am writing to the file if it helps...


Thanks,

SM

0 Kudos
Message 15 of 60
(1,189 Views)

I really cant give you a lot of help. Thats a small portion of the code. The write to spreadsheet vi is great, but you have to realize it is going to open/create and close that file every time you run it.  I cant tell when the message you want to store is created or the rest of the vi, but assuming you have a while or for loop in the main architecture in your application.  You should try to store the messages in a shift register, you can use the logic i provided inside the while loop in my example to keep the last 5 messages, and when you are ready to shutdown the application you can use that write to spreadsheet vi to write those 5 messages.

 

Other than that i cant give much advice without seeing the code.



-Matt
0 Kudos
Message 16 of 60
(1,178 Views)

Bob,


Regarding your message:

"The simplest solution is to simply wait until the end of the program and then do any file I/O that you want (it would be up to you how many messages you save -- you could even save them all and simply write out the last 5, or use a circular buffer of length 5)."

Do you have an example of this?


Thanks,

SM

 

0 Kudos
Message 17 of 60
(1,174 Views)

Bob said to use something like the example i provided or to store all of the messages in the shift register, i only keep 5 in the example i provided, or to use a circular buffer, which is provided in this link.

 

http://www.ni.com/tutorial/7188/en/



-Matt
Message 18 of 60
(1,170 Views)

Matt,

 

I kind of played around a bit with your code and I believe I am getting close. Instead of going into any kind of loop, I just added all that straight to my code (see attached screenshot). The problem is, it only stores the last message, not the last 5 messages. How do I store the messages in a register or whatever?


Thanks,

SM

0 Kudos
Message 19 of 60
(1,166 Views)

I see now that you have a cluster in a while loop. 

1.So to that cluster add a string array, call that your last msgs or something.  Unbundle that and feed that array into the delete from array function.

2.You should remove the concatenate and number to decimal string, that was just for the example, but your last message should go into that build array node on the bottom.

3. Bundle the build array output back into the cluster.

4. Delete the write to file, and just use write to spreadsheet there and feed the array of messages into that. 

 

There are better ways to log but this will work for if you dont mind opening and closing the file every time you iterate that case.



-Matt
0 Kudos
Message 20 of 60
(1,162 Views)