01-30-2015 09:39 AM
I am looking for a reccomended practice for my use case, which I feel has to be what a lot of people do/need.
I have a NI-SCOPE PXI device, but this applies to most instruments on some level. I have multiple VIs that do simple things, such as one VI that changes the horizontal settings, one VI that changes trigger settings, one VI that reads the current trace from the scope. How can I have multiple VIs talk to the same instrument, some of them might even be called at the same time.
Some more specifics about my use case is that I am calling these VIs from a web service, and the trace VI is called very frequently and streamed to the user (via the web service).
I was thinking of implementing a VI that would give me the VISA connection for the instrument and a semephore. I would then have the VI doing the work aquire the semephore, make the instrument calls and then release the semephore. Are there better or different ways? Maybe something I am over looking with the semephore implementation?
01-30-2015 11:06 AM
Typically for this sort of thing I would have a device handler VI which contains your VIs for talking to the instrument. This VI acts like a 'server' and does your device communications and then you can send commands to the device handler VI (e.g. via a queue/event) and it will return the result.
I would implement this as a state machine (normally using queues) - states for initialising the device, a state for each action you want to perform and a close/shutdown state when your application finishes.
01-30-2015 11:21 AM
I have done similar things for other instruments when the commands are formatted as a string, I can simply pass the string in to the device handler VI, but with the NI-SCOPE device the commands are already packaged up by the driver as sub VIs. To pass in the command to another VI I would have to first define some sort of mechanism (such as strings) to encode my commands in, pass that in to the device handler, then decode the string, determine what command it refers to and call that VI. This mechanism would require a lot of work for every new command I wanted to add.
Am I approching your method the wrong way, it seems that the normal method would not work with the NI-scope drivers?
01-30-2015 12:13 PM - edited 01-30-2015 12:13 PM
hi
for similar things I am using ActionEngine.. just make sure the ActionEngine exit only when the action is finished
N