AlcapDAQ  1
EPICSGFA_eblpie1.c
Go to the documentation of this file.
1 /********************************************************************\
2 
3  Name: frontend.c
4  Created by: RA35
5 
6  Contents: Slow control FE for PSI Beam line using EPICS
7 
8 \********************************************************************/
9 
10 #include <stdio.h>
11 #include "midas.h"
12 //#include "class/generic.h"
13 //#include "device/epics_ca.h"
14 //#include "bus/null.h"
15 #include "generic.h"
16 #include "epics_ca.h"
17 #include "null.h"
18 
19 #ifdef FORTIFY
20 #include "fortify.h"
21 #endif
22 
23 /*-- Globals -------------------------------------------------------*/
24 
25 //#define DF_NOUPDALL (1<<5) /**< do not update all demand values if no change was found */
26 
27 
28 /* The frontend name (client name) as seen by other MIDAS clients */
29 char *frontend_name = "Beamline Frontend";
30 
31 /* The frontend file name, don't change it */
32 char *frontend_file_name = __FILE__;
33 
34 /* frontend_loop is called periodically if this variable is TRUE */
36 
37 /* a frontend status page is displayed with this frequency in ms */
38 INT display_period = 1000;
39 
40 /* maximum event size produced by this frontend */
41 INT max_event_size = 10000;
42 
43 /* maximum event size for fragmented events (EQ_FRAGMENTED) */
44 INT max_event_size_frag = 5*1024*1024;
45 
46 /* buffer size to hold events */
47 INT event_buffer_size = 10*10000;
48 
49 int crate_number = 0;
50 
51 /*-- Equipment list ------------------------------------------------*/
52 
53 /* device driver list */
54 DEVICE_DRIVER epics_ca_driver[] = {
55 //{ "EPICSGFA", epics_ca, 111, null, DF_PRIO_DEVICE | DF_ALW_DEVICE | DF_NOUPDALL},
56 // { "EPICSGFA", epics_ca, 111, null, DF_PRIO_DEVICE | DF_NOUPDALL},
57  { "EPICSGFA", epics_ca, 71, null, DF_PRIO_DEVICE },
58  /* initial demand value taken from instrument, demand value is read from device */
59  { "" }
60 };
61 
62 
63 EQUIPMENT equipment[] = {
64 
65  { "Beamline", /* equipment name */
66  11, 0, /* event ID, trigger mask */
67  "SYSTEM", /* event buffer */
68  EQ_SLOW, /* equipment type */
69  0, /* event source */
70  "MIDAS", /* format */
71  TRUE, /* enabled */
72  RO_ALWAYS, /* always read, whether running or not */
73  30000, /* read every 30 sec */
74  0, /* stop run after this event limit */
75  0, /* number of sub events */
76  1, /* log history every event */
77  "", "", "",
78  cd_gen_read, /* readout routine */
79  cd_gen, /* class driver main routine */
80  epics_ca_driver, /* device driver list */
81  NULL, /* init string */
82  },
83 
84  { "" }
85 };
86 
87 
88 /*-- Dummy routines ------------------------------------------------*/
89 
90 INT poll_event(INT source[], INT count, BOOL test) {return 1;}
91 INT interrupt_configure(INT cmd, INT source[], PTYPE adr) {return 1;}
92 INT frontend_early_init(){ return SUCCESS; };
93 INT pre_begin_of_run(INT run_number, char *error){ return SUCCESS; };
94 
95 /*-- Frontend Init -------------------------------------------------*/
96 
98 {
99 #ifdef FORTIFY
100  Fortify_CheckAllMemory();
101 #endif
102  return CM_SUCCESS;
103 }
104 
105 /*-- Frontend Exit -------------------------------------------------*/
106 
108 {
109 #ifdef FORTIFY
110  Fortify_CheckAllMemory();
111  Fortify_OutputStatistics();
112 #endif
113  return CM_SUCCESS;
114 }
115 
116 /*-- Frontend Loop -------------------------------------------------*/
117 
118 #ifdef FORTIFY
119 static DWORD last_time_fortify = 0;
120 #endif
121 
123 {
124  INT status;
125 
126 #ifdef FORTIFY
127  Fortify_CheckAllMemory();
128 #endif
129 
130 #ifdef FORTIFY
131  /* time to display fortify output? */
132  if (ss_millitime()-last_time_fortify > 600000) {
133  Fortify_OutputStatistics();
134  last_time_fortify = ss_millitime();
135  }
136 #endif
137 
138  //status = cm_client_in_list();
139  //if (status == SS_ABORT) return status;
140 
141  //ss_sleep(2500);
142  return CM_SUCCESS;
143 }
144 
145 /*-- Begin of Run --------------------------------------------------*/
146 
147 INT begin_of_run(INT run_number, char *error)
148 {
149  return CM_SUCCESS;
150 }
151 
152 /*-- End of Run ----------------------------------------------------*/
153 
154 INT end_of_run(INT run_number, char *error)
155 {
156  return CM_SUCCESS;
157 }
158 
159 /*-- Pause Run -----------------------------------------------------*/
160 
161 INT pause_run(INT run_number, char *error)
162 {
163  return CM_SUCCESS;
164 }
165 
166 /*-- Resuem Run ----------------------------------------------------*/
167 
168 INT resume_run(INT run_number, char *error)
169 {
170  return CM_SUCCESS;
171 }
172 
173 /*------------------------------------------------------------------*/