https:///weradocs/stm.shtml Last update:

WERA HF Radar Software - stm - start WERA measurements

Revision 03-Nov-2003 adds a wait loop to delay starts of measurements, if cron starts stm before the minute defined within the crontab entry is actually reached.

stm reads and interprets control parameters from the extended header (XHeader) file, which has been generated by WeraDesk.
stm implements the low-level protocol between the Unix/Linux machine and the CL7 (WERA's CPU running vxWorks).
stm also modifies the file Status.html to reflect the actual state of the measurement cycle.
If requested by WeraDesk, post-processing scripts located at /home/wera/etc will be called at the end of the measurement:

  • "CAL 1":   /home/wera/etc/process_CAL.sh   /name/of/measured/file
  • "SORT1":   /home/wera/etc/process_SORT.sh   /name/of/measured/file
  • "RAW 1":   /home/wera/etc/process_RAW.sh   /name/of/measured/file

    The syntax for calling stm is:

    $ /path/to/stm /path/to/xheader_file /path/to/crontab_file s > /path/to/log_file
    

    The following lines show a typical crontab entry:

    wera@ifmwera2:~/weractrl> crontab -l
    # DO NOT EDIT THIS FILE - edit the master and reinstall.
    # (/home/wera/weractrl/cron_hawaii installed on Thu Jan  2 18:27:37 2003)
    # (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
    #Start - WERA automatic crontab entry
    0,10,20,30,40,50,0 * * * * /home/wera/weractrl/stm /home/wera/weractrl/ctrl_data.cpy /home/wera/weractrl/cron_hawaii s > /home/wera/weractrl/cron_hawaii.log
    #End --- WERA automatic crontab entry
    

    The basic functions of stm are as follows:

    /* --- Read eXtended header (XHeader, 1147 Byte) --------------------------- */
    /* ------------------------------------------------------------------------- */
    
    The following functions removed 16-Jan-2003, as they are already implemented in mkcron.
    {
    // SNGL1 && CONT0
       /* --- Stop Cont Acqu by deleting the stm command in the crontab file  -- */
       /* --- This should normally already been done by mkcron. ---------------- */
       /* ---------------------------------------------------------------------- */
       // send message to WeraDesk Status (Crontab.html)
       sprintf(CRONmessage,"Disabled  \0");
    // SNGL0 && CONT1
       /* --- Continuous Acquisition, do nothing special ----------------------- */
       /* --- Crontab has already been generated by mkcron --------------------- */
       /* ---------------------------------------------------------------------- */
    // SNGL1 && CONT1  or SNGL0 && CONT0
       fprintf(stderr,"Wrong status information in %s !\n",nam1);
       EXIT
    // End cases
    }
    End of removed functions
    
    /* Start of protocol: */
    
    /* --- Copy measurement header structure (512 bytes) to head_buf ------------ */
    /* -------------------------------------------------------------------------- */
    
    /* --- Read actual time ----------------------------------------------------- */
    /* -------------------------------------------------------------------------- */
    /* Delay for 1 second until the actual system time second within a minute     */
    /* is < 30 sec (too early start by cron)                                      */
    
    /* --- Now open a socket connection to the CL7 (running WERA) --------------- */
    /* -------------------------------------------------------------------------- */
    
    /* --- Set watchdog to 20 sec. for terminating 'stm' protocol --------------- */
    /* --- in case of CL7 timeout. ---------------------------------------------- */
    /* -------------------------------------------------------------------------- */
    
    /* --- Which is the version of the VxWorks (CL7) WERA software ? ------------ */
    /* -------------------------------------------------------------------------- */
    
    /* --- CL7 replies with version id. ----------------------------------------- */
    /* -------------------------------------------------------------------------- */
    
    /* --- Is WERA currently busy ? (ASK_4_BUSY) -------------------------------- */
    /* -------------------------------------------------------------------------- */
    
    /* --- CL7 replies with 'BUSY' status. -------------------------------------- */
    /* -------------------------------------------------------------------------- */
    
       /* --- If 'BUSY' close socket and return with error ---------------------- */
       /* ----------------------------------------------------------------------- */
    
    /* --- Ensure that cdat.path2data exists ? ---------------------------------- */
    /* -------------------------------------------------------------------------- */
    
    /* ----- Generate filename from actual time and FM_MODE --------------------- */
    /* -------------------------------------------------------------------------- */
    
    /* ----- Send file name to CL7 if .not. 'test' mode. ------------------------ */
    /* ----- ('test' mode does not store data.) --------------------------------- */
    /* -------------------------------------------------------------------------- */
    
       /* ----- CL7 replies, that he received the file name. -------------------- */
       /* ----------------------------------------------------------------------- */
    
    /* --- Send measurement header to CL7. -------------------------------------- */
    /* -------------------------------------------------------------------------- */
    
    /* --- CL7 replies, that he received the header. ---------------------------- */
    /* -------------------------------------------------------------------------- */
    
    /* --- Finally, start the measurement. -------------------------------------- */
    /* -------------------------------------------------------------------------- */
    /* --------- TEST mode: ----------------------------------------------------- */
    
        SEND_AUXPORTSTART: "auxStart\n\0"
                           "auxSweep\n\0"
                           "auxStop_\n\0"
        /* ----- CL7 replies, that he started the measurement. */
        /* --------------------------------------------------- */
        Close socket and EXIT
    
    /* --------- non-TEST measurements: ----------------------------------------- */
        START_ACQ
    
       /* ----- CL7 replies, that he started the measurement. */
       /* --------------------------------------------------- */
    
       /* --- Set watchdog to 60 sec. for terminating 'stm' protocol ------------ */
       /* --- in case of CL7 timeout. ------------------------------------------- */
       /* ----------------------------------------------------------------------- */
    
    read_again:
       /* --- if(FINISH_ACQ): CL7 notifies end of measurement cycle. */
       /* ---------------------------------------------------------- */
        Close socket and EXIT
    
       /* --- if(Status && Stopped): disable watchdog -------------- */
       /* ---------------------------------------------------------- */
       goto read_again;
    
       /* --- if(Status && Storing): disable watchdog -------------- */
       /* ---------------------------------------------------------- */
       goto read_again;
    
       /* --- if(Status && Running): set watchdog to 20 sec. ------- */
       /* ---------------------------------------------------------- */
       goto read_again;
    
    /* --- disable watchdog ---- */
    /* ------------------------- */
    
    // Measurement finished.
    // Start postprocessing scripts if requested from WeraDesk:
    
       switch (header.typenum) {
       case 11 :  // "CAL 1"
         printf "Now calling ~/etc/process_CAL.sh %s\n",acq_nam);
       case 8 :   // "SORT1"
         printf ("Now calling ~/etc/process_SORT.sh %s\n",acq_nam);
       case 9 :   // "RAW 1"
          printf ("Now calling ~/etc/process_RAW.sh %s\n",acq_nam);
       default :
          printf ("Processing of %s not implemented.\n",acq_nam);
    
    


    Comments to: gurgel@ifm.uni-hamburg.de (Klaus-Werner Gurgel)