Running a User Supplied Program


Starting with version 4.7.4, WinSDR can run a user supplied program or batch file when the program goes into an alarm state, saves event files and/or produces a new set of GIF image helicorder plots. The program/batch file to run when WinSDR goes into an alarm state or saves event files is controlled in the System Settings / More Options dialog box. The program/batch file to run when WinSDR saves GIF image helicorder plots is controlled in the GIF Settings dialog box. 

User Supplied Programs:

The program or batch file that the users wants to run most be either in the system path or you must specify the complete path to the program in the edit box. Example: c:\apps\myprogram.exe 

WinSDR will supply additional information to the users program with one or more input parameters. For the Alarm program WinSDR will supply the alarm type and one or more channel names that caused the alarm. The alarm type can be either NORM, for normal STA/LTA or threshold triggering, or, TELE for Teleseismic triggering.   

The After Save Event program will be supplied one or more event file names that got saved to disk. 

The GIF File Save program will be supplied a list of GIF image file names that got saved to disk.

Example using C language:

Below is a simple test program that will save the input parameters supplied to the program into a file called c:\RunProgram.txt. 

#include <stdio.h>

int main( int argc, char *argv[] )
    int i;
    FILE *fp;

    // Note: The first argument will always be the program name
    if( ( fp = fopen( "c:\\RunProgram.txt", "w") ) != NULL ) {
        fprintf( fp, "Number of input arguments (argc) = %d\n", argc );
        for( i = 0; i != argc; ++i ) {
            fprintf(fp, "argv[%d] = %s\n", i, argv[i] );
        fclose( fp );

Here is an example of the test program output when WinSDR goes into an alarm state:

Number of input arguments (argc) = 4
argv[0] = C:\winsdr\TestProgram.exe
argv[1] = NORM   <-- This will be TELE for a teleseismic alarm trigger.
argv[2] = LCAZ
argv[3] = LCAN

After WinSDR saves event files:

Number of input arguments (argc) = 7
argv[0] = C:\winsdr\TestProgram.exe
argv[1] = c:\winsdr\events\1310\131027.065751.cha.psn
argv[2] = c:\winsdr\events\1310\131027.065751.chb.psn
argv[3] = c:\winsdr\events\1310\131027.065751.ch3.psn
argv[4] = c:\winsdr\events\1310\131027.065751.ch5.psn
argv[5] = c:\winsdr\events\1310\131027.065751.ch7.psn
argv[6] = c:\winsdr\events\1310\131027.065751.ch8.psn

And after WinSDR saves GIF Image Helicorder plots:

Number of input arguments (argc) = 3
argv[0] = C:\src\winsdr2\TestProgram.exe
argv[1] = c:\tmp\cha.gif
argv[2] = c:\tmp\ch6.gif

[ Back ]