/********************************************************
* emcspy.h  
*              include file for User definitions   
*
* Define here only Variables 
                        and Commands for your own process
**********************************************************/

#ifndef emcspy_h
#define emcspy_h

#include <sys/time.h>

/*---------------------------------------------------------------*/
/*        Definitions for the User Variable Dictionary           */
/*---------------------------------------------------------------*/

typedef struct _AskVariables
{
  char eventsource[20];
  int  eventnr;
  int  runnr;
  int  runstate;
  struct timeval timeout;
  int  timeouts;
  int  check;
  char record[64];
  char basedir[128];
  char monitor[4];
} AskVariables;

#ifdef THIS_IS_THE_MAIN

AskVariables ask_var =
{
  "emcspy", /* eventsource */
  1,        /* eventnr */
  0,        /* runnr */
  UNDEFINED_STATE,/* runstate */
 {0,10000}, /* timeout (sec, usec) */
  0,        /* timouts */
  0,        /* check */
  "n"        /* record */
  "."        /* basedir */
  "m"        /* Monitor Conditions **/
};

struct var_dict_type var_dict_usr[20] = 
{
  "eventnr",     INTEGER, (long) &ask_var.eventnr,
  "runnr",       INTEGER, (long) &ask_var.runnr, 
  "eventsource", STRING,  (long) ask_var.eventsource, 
  "runstate",    INTEGER, (long) &ask_var.runstate, 
  "timeout_us",  INTEGER, (long) &ask_var.timeout.tv_usec,
  "timeouts",    INTEGER, (long) &ask_var.timeouts,
  "check",       INTEGER, (long) &ask_var.check,
  "record",      STRING,  (long) ask_var.record,
  "basedir",     STRING,  (long) ask_var.basedir,
  "monitor",     STRING,  (long) ask_var.monitor
};

int var_number_usr = 10;

/*---------------------------------------------------------------*/
/*        Definitions for the User Command Dictionary            */
/*---------------------------------------------------------------*/
int Begin();
int Pause();
int Resume();
int End();
int ExitC();
int Status();
 
struct cmd_dict_type cmd_dict_usr[20] = {
   "BEGIN" , (int (*)()) Begin,
   "PAUSE" , (int (*)()) Pause,
   "RESUME", (int (*)()) Resume,
   "END"   , (int (*)()) End,
   "EXIT"  , (int (*)()) ExitC,
   "STATUS", (int (*)()) Status
};
 
int cmd_number_usr = 6;

#endif /* THIS_IS_THE_MAIN */ 

int  EmcspyInit    (AskVariables*);
int  EmcspyBegin   (AskVariables*);
int  EmcspyProcess (AskVariables*);
int  EmcspyEnd     (AskVariables*);
void EmcspyStatus  (AskVariables*);

#endif /* emcspy_h */