LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to write to and read from cache in Labview?

Solved!
Go to solution
Hi. I am doing the program to scan the serial numbers.
Here's how the program works like this:-
Read the scanned number and compare with records in cache for similiarly, If found none, saved to cache and hard-drive.
Then read the same number and compare with records, if found, it will not be saved to cache and hard-drive.
So how do I write to and read from cache? And how to clean up cache after the program is closed?
 
Any help will be appreciated.
Thanks in advance.
Clement
0 Kudos
Message 1 of 10
(5,256 Views)
Solution
Accepted by topic author astroboy
Hi

I would use the "Read from Spreadsheet file" to read saved serial numbers on your hard drive. If your file has each serial number on each line Read from Spreadsheet file will return a 2D array with the first column containing your numbers. Then use "Index Array" to get a 1D array of your Serial numbers. In your loop you then have to use "Search 1D array" VI to check if the SN is in the array. It returns -1 if its not found. If so use build array to add the serial number. Then use "Write Spreadsheet file" to save the new serial number list to file.

Hope this helps
0 Kudos
Message 2 of 10
(5,245 Views)

 Thansk But I am sure there'a better method to write to acahed rather than to file alone. What I would like to write to and read from cache efficiency and speed.

 

Clement

0 Kudos
Message 3 of 10
(5,218 Views)


@astroboy wrote:

 Thansk But I am sure there'a better method to write to acahed rather than to file alone. What I would like to write to and read from cache efficiency and speed.

 

Clement



Applications are not supposed to control the cache at all. The CPU cache is handled by Windows an/or BIOS only and varies per motherboard/CPU and other system parameters. Trying to control that would be a really big hassle.
The disk cache is similarly handled by Windows and dynamically managed depending on available system resources, disk organization and formatting. Again trying to control that from an application would be a hassle and more likely make the computer slower rather than faster.

What you want to do is either write the data in some array and just keep that around (A LabVIEW 2 style global would be ideal for this) if those serial numbers need only to be volatile (meaning they are not needed after a restart of the applciation). This can't be a performance problem if you do it right (LabVIEW 2 style global instead of a simple normal global). Faster than this won't be working unless you start to do assembler programming, but then you shouldn't shoot for LabVIEW programming nor using Windows.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 4 of 10
(5,203 Views)

Hi Rolf, Thanks for enlightening me on this cache issues.

I am using labview 7.1, LabSQL and MySQL.

I have a question to ask.

From what I read, about cache in wikipedia. It is said that everytime there are data to wriite, they would be written in both cache and hardrive.

In my case, my LV program acquires values, write to cache, local and remote database. In case of network breakdown , it will still save data to caches and local database.

Once the network is up, old data from caches will not be saved to remote databases automatically. Is that correct?

Clement

 

0 Kudos
Message 5 of 10
(4,963 Views)


astroboy wrote:

In my case, my LV program acquires values, write to cache, local and remote database. In case of network breakdown , it will still save data to caches and local database.

Once the network is up, old data from caches will not be saved to remote databases automatically. Is that correct?

Clement



I would be careful about using the terminology of "cache".  As Rolf said, cache implies a temporary storage either in hardware or the operating system either for RAM communication or communication with the hard drive.
 
By your description, it sounds like you essentially want a redundancy in your data storage split between active memory, local hard drive storage and remote hard drive storage.  As Rolf said a LV2 style global variable is a good storage mechanism for active memory storage.  From there, I think you will need to work out an architecture that communicates that data to your local hard drive storage or database periodically.  And from there, move it into the remote storage database assuming the network is good.  It will need to be a good, well thought out architecture because of course you'll need to figure out when the network is down, and also track that updates would need to be made once you figure out the network is back up.  There would be nothing automatic about any of this.  It would be features you'd have to program.


Message Edited by Ravens Fan on 03-26-2008 11:22 PM
0 Kudos
Message 6 of 10
(4,946 Views)

Hi Ravens

Thanks May I know what is A LabVIEW 2 style global ?

I had not come across this before. Can you link me to this? Thank you.

0 Kudos
Message 7 of 10
(4,934 Views)

Hi astroboy,

a LabView 2 style global is a while loop with shiftregisters and a case structure in it. For more information see this link.

Mike

0 Kudos
Message 8 of 10
(4,927 Views)

I wrote a Nugget on Action Engines which is another name for LV2 style globals.

See this thread.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 10
(4,913 Views)

Dear Mike and Ben,

 Thanks alot

0 Kudos
Message 10 of 10
(4,886 Views)