LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

keyboard mapping and logging architecture

Solved!
Go to solution

Greetings,

I am after some general advice about the best architecture to use for a program I have to write as follows:

 

I have an underwater camera system that shows live video on the surface, as we pass animals, features etc, I need to log what is seen. We have an awful program that does this in java already but I want to rewrite it in LabVIEW. We use a special USB keyboard to log what we see, each key has a sticker on it so that Q = fish type A, W = fish type B and so on. Each time a key is pressed, I need to add a line to a CSV log file that shows time/date, GPS coordinates, depth and the value that the key represents. To make things a little tricky, some keys are "sticky" to represent "bottom type, sandy" for example.

I have written logging programs before and so I have sub VI's to acquire GPS data, depth, time/date etc and log it accordingly. I would like to use a config file so that keys can be defined/edited by a user outside of the development environment if the keyboard changes at all. There are about 60 key values used for different animals, plants and bottom features and I will be adding 4 columns to my CSV file. The Front Panel is fairly simple, with controls to start logging and stop logging as well as string indicators showing the string being logged and GPS data etc.

 

So, I am thinking an event structure and maybe using the scan code function, but how to reconcile what is pressed, and the numeric output from the node with the values defined in a config file?

 

Or, the monitor keyboard activity provides the ASCII output of each keystroke, but again, suggestions of how to relate this to values in a config file and then pop out the appropriate string to add to the log file.

 

And any recommendations for the general structure for this; State Machine? Producer/Consumer? Parallel?

 

As I said, I know this is fairly general, but parts of the code have already been written for other programs, and I can write remaining code, but I would appreciate some best practice advice about how to  to structure a program like this.

 

Many Thanks

0 Kudos
Message 1 of 2
(2,584 Views)
Solution
Accepted by KarlosAmigos

From the information you provided, I would use a state machine to handle an Initialization, Record, and Exit state.  The initialization state would parse the config file and assign values to key strokes.  You could store this in an array or cluster.  The record state would be event driven based on key strokes.  Each event, the key stroke value would be searched for in the array you created and the corresponding ‘fish value’ would be written to file.  You could use logic and shift registers to pass along ‘sticky’ values.  Producer/Consumer architecture should not be necessary due to the low frequency nature of user key inputs.  Producer/Consumer architecture can be implemented if the processing is taking too much time, though. 

Message 2 of 2
(2,530 Views)