Examples for command-line invocation
   SIGVIEW Help Home

This chapter contains several examples for using command-line parameters in SIGVIEW. All examples are implemented as MS Windows batch files. You can find the source code of these examples in "Scripts" subdirectory of the SIGVIEW installation directory:


1. Record 10 seconds of signal and save signal to a file along with its averaged spectrum

In this example, we will create a batch file which starts 10 seconds of data acquisition, saves resulting signal in a file along with its average spectrum.

You should create a Workspace containing data acquisition window (from any device), FFT of data acquisition window and Averager of the FFT window. Control window display should look like this:

graphic

Data acquisition window has to have defined acquisition length (10s). You should rename data acquisition window to "daq_window" and Averager window in "average_window". Save this workspace in, for example, c:\test\daq_average.sws.

The following batch script will use this workspace to perform 10 seconds of acquisition and save recorded signal and average spectrum at the end.

REM close any opened windows
%SIGVIEW_EXE% -closeall

REM load workspace
%SIGVIEW_EXE% -loadsws c:\test\daq_average.sws

REM start data acquisition
%SIGVIEW_EXE% -daqstart daq_window

REM wait 11 seconds - until we are sure that acquisition is finished
%SIGVIEW_EXE% -waitms 11000

REM stop data acquisition
%SIGVIEW_EXE% -daqstop daq_window

REM save average spectrum
%SIGVIEW_EXE% -saveascii average_window c:\test\average_fft.dat

REM zoom-out data acquisition window and save it to WAV file
%SIGVIEW_EXE% -zoomout daq_window
%SIGVIEW_EXE% -savewav32 daq_window c:\test\daq_signal.wav

REM close SIGVIEW
%SIGVIEW_EXE% -closeapp


2. Generate averaged spectrum from a signal and store it to a file

In this example, we will create a batch file which can load any signal, generate its average spectrum and save it to a file.

Create a workspace containing a loaded file, zoomed-in to its first 4096 samples, FFT calculated from that signal part, and averager window attached to the FFT. Your workspace should look like this in Control Window:

graphic

Window title of a signal window has been changed to "signal" and window title of averager window has been changed to "averager".

Now save this workspace to a SWS file, for example named "sig_average.sws". When SIGVIEW asks if you would like to save actual signal file name(s) into workspace file, answer NO.

The following batch script will use this workspace to load any WAV file provided as first parameter of the batch file ( "%1" variable), will move through the signal for 10 seconds ( -playnotone option) and save resulting FFT average in a file which name is given as a second parameter of a batch file ("%2" variable):

REM close any opened windows
%SIGVIEW_EXE% -closeall

REM turn repeat forever option on
%SIGVIEW_EXE% -repeatforever on

REM load workspace
%SIGVIEW_EXE% -loadsws c:\test\sig_average.sws  %1

REM start playing
%SIGVIEW_EXE% -playnotone signal

REM wait 10 seconds
%SIGVIEW_EXE% -waitms 10000

REM save average spectrum
%SIGVIEW_EXE% -saveascii averager %2

REM close SIGVIEW
%SIGVIEW_EXE% -closeapp


If you save this batch file as "example2.bat", you can call it with, for example, the following command line:

example2.bat c:\test\mysignal.wav c:\test\average_fft.dat


3. Start data acquisition and log signal RMS energy in file each second

In this example, we will create an endless instrument logger. It will start data acquisition, calculate continuously RMS of the current signal, and save it to a file along with the system time.

Create a workspace containing data acquisition window (acquisition length = 0, any device) and an RMS instrument. Your workspace should look like this in Control Window:

graphic

Window title of a signal window has been changed to "daq_window" and window title of RMS instrument window has been changed to "rms_window".

This would be the content of a batch file:

REM close any opened windows
%SIGVIEW_EXE% -closeall

REM load workspace
%SIGVIEW_EXE% -loadsws c:\test\daq_rms.sws

REM start data acquisition
%SIGVIEW_EXE% -daqstart daq_window

REM endless loop
:start

REM wait 1 second
%SIGVIEW_EXE% -waitms 1000

REM read value from rms_window and add it to text file
%SIGVIEW_EXE% -getvalue rms_window >> c:\test\values.txt

REM time information after the value
echo   %time% >> c:\test\values.txt

REM loop again
GOTO start

Since this is an endless loop, you will have to stop the batch file manually. The result file will look like this:

0.011391  20:34:30,35
0.011418  20:34:31,51
0.011139  20:34:32,68
0.011373  20:34:33,84
0.011343  20:34:35,01
0.011335  20:34:36,17
.................

You can see on system times that the "-sleepms" option is not very accurate. Fluctuations of ~20 ms are quite normal.
  
Examples