ISIS Logo
HVCAEN
HVCAEN IOC
HVCAEN-IOC-01Main.cpp
Go to the documentation of this file.
1 /* $Header: HVCAENx527/HVCAENx527App/src/HVCAENx527Main.cpp 1.6 2007/06/01 13:32:58CST Ru Igarashi (igarasr) Exp Ru Igarashi (igarasr)(2007/06/01 13:32:58CST) $
2  *
3  * Copyright Canadian Light Source, Inc. All rights reserved.
4  * - see licence.txt and licence_CAEN.txt for limitations on use.
5  *
6  * Author: Ru Igarasr Date: 2006-04-07
7  *
8  */
9 
10 #include <stddef.h>
11 #include <stdlib.h>
12 #include <stddef.h>
13 #include <string.h>
14 #include <stdio.h>
15 
16 #include "epicsThread.h"
17 #include "epicsExit.h"
18 #include "iocsh.h"
19 
20 #ifdef _WIN32
21 #define snprintf _snprintf
22 #endif
23 
24 extern "C" {
25 // epicsShareFunc int ConnectCrate( char *name);
26  epicsShareFunc void Shutdown();
27  epicsShareFunc void SetSigShutdownHandler();
28 
29  epicsShareExtern short DEBUG;
30 }
31 
32 int main(int argc,char *argv[])
33 {
34  int i, j;
35  short daemon;
36  char stcmd[256];
37 
38  /* Need to catch hang up signal to make sure semaphores are
39  cleaned up properly */
41 
42  daemon = 0;
43  if(argc>=2) {
44  snprintf( stcmd, 255, "%s", argv[1]);
45  j = 0;
46  for( i = 2; i < argc; i++) {
47  if( strcmp( argv[i], "-D") == 0) {
48  i++;
49  DEBUG = atoi( argv[i]);
50  } else if( strcmp( argv[i], "-d") == 0) {
51  daemon = 1;
52  }
53  }
54  }
55  else
56  {
57  printf( "Syntax: hvcontrol <st.cmd> [-d] [-D <debuglevel>]\n");
58  printf( " -d = run in daemon mode\n");
59  printf( " <debuglevel> = 0 no messages\n");
60  printf( " <debuglevel> = 10 all available messages\n");
61  }
62 
63  if (strlen(stcmd)>0) iocsh(stcmd);
64 
65  if (daemon) {
66  for(;;)
67  epicsThreadSleep(1.0);
68  } else {
69  iocsh(NULL);
70  }
71  Shutdown();
72  epicsExit(0);
73  return(0);
74 }
75 
76 /*
77  * $Log: HVCAENx527/HVCAENx527App/src/HVCAENx527Main.cpp $
78  * Revision 1.6 2007/06/01 13:32:58CST Ru Igarashi (igarasr)
79  * Member moved from EPICS/HVCAENx527App/src/HVCAENx527Main.cpp in project e:/MKS_Home/archive/cs/epics_local/drivers/CAENx527HV/project.pj to HVCAENx527/HVCAENx527App/src/HVCAENx527Main.cpp in project e:/MKS_Home/archive/cs/epics_local/drivers/CAENx527HV/project.pj.
80  */
81 
int main(int argc, char *argv[])
epicsShareExtern short DEBUG
epicsShareFunc void Shutdown()
epicsShareFunc void SetSigShutdownHandler()
Copyright © 2013 Science and Technology Facilities Council | Generated by   doxygen 1.8.5