DAQ Plot ► Programming ► DAQ Command
Note: Programming is an optional feature and is not part of DAQ Plot
DAQ Command is a command line utility which outputs data from DAQ hardware and accepts input to alter the DAQ hardware settings. You can incorporate it into your own program for automation purposes (see Logger or the Xcode Projects).
Configuring DAQ Command
DAQ Command is configured by the DAQ Plot application. First set the Preference Style to Pro to gain access to programming features, configure DAQ Plot the way you wish and then save your preference settings using the File ► Save DAQ Command Preferences... menu item.
Important Export Preferences Pane Settings:
Important Hardware Preferences Pane Settings:
Thus DAQ Plot is used to configure the hardware interface so you don't have to do it using code.
Running DAQ Command
Run DAQ Command using this command:
/Library/Vvidget/Helpers/daq_command my_config.daqplot
where my_config.daqplot
is the preference file you saved using the instructions above. You will see output from the DAQ hardware immediately.
You can alter the states of the DAQ Hardware using these commands (simply type them at the command line while running DAQ Command):
Command | Description |
set analog output | Sets the analog output channels of the device to the values specified. The parameters are white space two voltage values. |
set digital output | Sets the digital output channels of the device to the values specified. The parameters is a list of 1 and 0 indicating states of each channel consecutively. |
quit | Quits daq command. Execute this right before exiting your application. |
verbose on | Causes executed commands to be echoed back. You probably want to leave verbose off. |
verbose off | Turns off verbose messaging. |
Examples:
set digital output 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Turns on all 20 digital output channels, and turns the 5th one off, for the Standard device.
set analog output 1.5 3.4
Sets the first analog output terminal to 1.5 volts, and the second to 3.4 volts.
Writing your own applications with DAQ Command
DAQ Command is intended to be embedded into applications you write. Your application receives data from the DAQ hardware and can send commands to the DAQ hardware just as explained above, except not at the command line, but rather within your own application. The Logger example and Xcode Projects show how to do it.
Sending Output To A File
daq_command
output can be sent to a file like this:
/Library/Vvidget/Helpers/daq_command my_config.daqplot >> /Area_On_Disk/myfile.data
So the data can be later processed by another application or can be attached to another process using fopen() or popen() calls.
Scripting Form
A simple script can be used to make daq_command
iterate, such as:
while (( 1 )); do
/Library/Vvidget/Helpers/daq_command my_config.daqplot
sleep 5
done
You can also embed the command line interface into a shell script incorporated into a startup process thus automating data acquisition altogether. That is, automatically starting it when your computer boots and having continuous output without intervention or the need for a user to be logged into the computer. If you place daq_command into a startup script make sure to add a & so it forks the process. Such as this:
/Library/Vvidget/Helpers/daq_command my_config.daqplot >> /Area_On_Disk/myfile.data &
Web Service
daq_command
outputs to stdout, so can be incorporated into a CGI readily. For example, placing the following into the cgi-bin directory of your web server will output the text format of daq_command.
#!/bin/sh
set -f
echo Content-type: text/plain
echo
/Library/Vvidget/Helpers/daq_command my_config.daqplot
A web graph of the output can also be made using Vvidget Code (optional). Other scripts can be written to produce various effects.
Alternating State
You may wish to alter the state of data acquisition based on the input or some other criterion such as a database field. You can use multiple preference files for this purpose. Just run the commands like:
/Library/Vvidget/Helpers/daq_command state_one_config.daqplot
/Library/Vvidget/Helpers/daq_command state_two_config.daqplot
In your applications, scripts, etc. Make sure to use DAQ Plot to configure each preference file and to save them into the DAQ Command Preference folder as explained above.
Administration
To see the version of daq_command
type:
/Library/Vvidget/Helpers/daq_command -v