LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can LabVIEW pickup from where it left off?

Solved!
Go to solution
Solution
Accepted by topic author mhaque

First some basics.

 

I don't know why you save the steps value. Isn't that give by the array size? Too many degrees of freedom!

You don't need to set the file position.

You haven't solved the original problem. Basically, you want to check if the file exists (e.g. defaults.mpc) before the main loop and

if the file exists, read it, it it does not exist, keep the defaults

After the main loop has finished, overwrite the values to the same defaults.mpc. (Or do it in the "panel close" event).

If you want to specify paths, You should use a file dialog and skip the rest of the file IO if its cancelled.

 

Here's a quick rewrite of the file IO parts.

 

 

Message 11 of 16
(1,312 Views)
you make it look too easy ;) mhaque
0 Kudos
Message 12 of 16
(1,285 Views)

Hey altenbach

 

Where does the VI initialize, i.e from where are the zero filled arrays created.

 

I want to place a read/write binary file and I am wondering where I should wire it to, to save the timers when I exit the program.

 

Otherwise the timer starts from 0 which is not what I want.

 

Thanks

 

mhaque

0 Kudos
Message 13 of 16
(1,245 Views)

Whew, what a mess.

 

It is difficult to make sense because of of all the overlapping wires and structures, but there are some serious flaws:

 

  • Why are you reading the same file at the bottom? Since this is an independent code segment, we cannot tell when it executed with respect to the loop. You only write to a indicator which gets overwritten in a max. of 100ms with different data. What is the purpose? No purpose!
  • If you operate on the same file, use a single path constant and branch the wire to avoid editing errors.
  • Why does the representation not match between the read and write operation (I32 vs U32)
  • Why are you constantly opening and closing the file? Typically, you would open before the loop, write in the loop, and close after the loop. If you want to overwrite, simply set the file position to zero before writing again.
  • Assuming that the program correctly shuts down (with the stop button in the loop and not with the abort button in the toolbar!), you only need to write once after the loop has finished.
Use a shift register and initialize it with the values from the file (if it exists) before the loop starts. Overwrite the same file once tohe loop completes.
Try it!
0 Kudos
Message 14 of 16
(1,233 Views)

Hi altenbach I did as you said but I still can't get the file to save. Also I am getting an error message when I stop the loop.

 

 

0 Kudos
Message 15 of 16
(1,221 Views)

No, you did not do as I said. Look at the data dependency. You are reading from the file only after the loop has finished and you are branching the file ref so the reading and writing occurs at the same time. That's not good.

 

Also, writing to an indicator does not change the wire value leading to it. Think dataflow!

 

Try something like this, maybe it can give you some ideas..

(Note that the code is incomplete and does not do all required error handling, etc.)

0 Kudos
Message 16 of 16
(1,215 Views)