Low-Energy Muon (LEM) Experiment  0.5.2
sample_scfe.cxx
Go to the documentation of this file.
1 /********************************************************************\
2 
3  Name: sample_scfe.cxx
4  Created by: Andreas Suter
5 
6  Contents: Midas Slowcontrol Frontend to readout all devices related
7  to the sample region (except high voltages)
8 
9 \********************************************************************/
10 
11 #include <cstdio>
12 #include <cstdlib>
13 #include <cstring>
14 #include <cmath>
15 
16 #include "midas.h"
17 #include "mfe.h"
18 #include "class/multi.h"
19 #include "lem_generic.h"
20 #include "LakeShore336.h"
21 #include "bronkhorst.h"
22 #include "thcd_100.h"
23 #include "tcpip_rs232.h"
24 
25 //-- Globals -------------------------------------------------------
26 
28 const char *frontend_name = "Sample_SC";
30 const char *frontend_file_name = __FILE__;
31 
33 BOOL frontend_call_loop = FALSE;
34 
36 INT display_period = 1000;
37 
39 INT max_event_size = 10000;
40 
42 INT max_event_size_frag = 5*1024*1024;
43 
45 INT event_buffer_size = 10*10000;
46 
48 char sample_cryo[NAME_LENGTH];
49 
50 //-- Equipment list ------------------------------------------------
54 DEVICE_DRIVER sample_driver[] = {
55  { "Lake336_Sample", ls336_in, 24, tcpip_rs232, DF_INPUT },
56  { "Lake336_Sample", ls336_out, 14, tcpip_rs232, DF_OUTPUT },
57  { "BH_Flow_1", bh_flow_in, 2, tcpip_rs232, DF_INPUT },
58  { "BH_Flow_1", bh_flow_out, 2, tcpip_rs232, DF_OUTPUT },
59  { "BH_Flow_2", bh_flow_in, 2, tcpip_rs232, DF_INPUT },
60  { "BH_Flow_2", bh_flow_out, 2, tcpip_rs232, DF_OUTPUT },
61  { "THCD_100_1", thcd_100_in, 1, tcpip_rs232, DF_INPUT },
62  { "THCD_100_1", thcd_100_out, 1, tcpip_rs232, DF_OUTPUT },
63  { "THCD_100_2", thcd_100_in, 1, tcpip_rs232, DF_INPUT },
64  { "THCD_100_2", thcd_100_out, 1, tcpip_rs232, DF_OUTPUT },
65  { "" }
66 };
67 
77 
79 EQUIPMENT equipment[] = {
80 
81  { "SampleCryo", // equipment name
82  {70, 0, // event ID, trigger mask
83  "SYSTEM", // event buffer
84  EQ_SLOW, // equipment type
85  0, // event source
86  "FIXED", // format
87  TRUE, // enabled
88  RO_RUNNING |
89  RO_TRANSITIONS, // read when running and on transitions
90  30000, // read every 30 sec
91  0, // stop run after this event limit
92  0, // number of sub events
93  1, // log history every event
94  "", "", "",},
95  cd_multi_read, // readout routine
96  cd_multi, // class driver main routine
97  sample_driver, // device driver list
98  NULL, // init string
99  },
100 
101  { "" }
102 };
103 
104 
105 
106 //-- Dummy routines ------------------------------------------------
107 
108 INT poll_event(INT source, INT count, BOOL test) {return 1;};
109 INT interrupt_configure(INT cmd, INT source, POINTER_T adr) {return 1;};
110 
111 //-- Global hotlink dispatcher routines ----------------------------
121 void sample_cryo_changed(INT hDB, INT dummy2, void *info)
122 {
123  int status;
124  char cryo_path[256];
125  HNDLE hKey;
126 
127  // get experiment handle
128  cm_get_experiment_database(&hDB, NULL);
129 
130  // get main handle
131  sprintf(cryo_path, "/Equipment/SampleCryo/Settings/Devices/Lake336_Sample_0/DD/ODB Names/LS336 Name");
132 
133  status = db_find_key(hDB, 0, cryo_path, &hKey);
134  if (status != DB_SUCCESS) {
135  cm_msg(MINFO, "sample_cryo_changed",
136  "sample_scfe, sample_cryo_changed: couldn't find sample cryo ODB entry.");
137  return;
138  }
139 
140  // write new name to DD structure
141  db_set_data(hDB, hKey, (void *)&sample_cryo, sizeof(sample_cryo), 1, TID_STRING);
142 }
143 
144 //-- Frontend Init -------------------------------------------------
150 {
151  HNDLE hDB, hKey;
152  int size, status;
153 
154  // de-register run-transition notifications
155  cm_deregister_transition(TR_START);
156  cm_deregister_transition(TR_STOP);
157  cm_deregister_transition(TR_PAUSE);
158  cm_deregister_transition(TR_RESUME);
159 
160  // get experiment handle
161  cm_get_experiment_database(&hDB, NULL);
162 
163  // find ODB entry
164  status = db_find_key(hDB, 0, "/Info/Sample Cryo", &hKey);
165  if (status != DB_SUCCESS) {
166  cm_msg(MINFO, "frontend_init", "sample_scfe, frontend_init: couldn't find sample cryo ODB entry");
167  return CM_SUCCESS;
168  }
169 
170  // hotlink sample cryo name
171  size = sizeof(sample_cryo);
172  db_open_record(hDB, hKey, (void *)&sample_cryo, size, MODE_READ, &sample_cryo_changed, NULL);
173 
174  return CM_SUCCESS;
175 }
176 
177 //-- Frontend Exit -------------------------------------------------
183 {
184  return CM_SUCCESS;
185 }
186 
187 //-- Frontend Loop -------------------------------------------------
193 {
194  return CM_SUCCESS;
195 }
196 
197 //-- Begin of Run --------------------------------------------------
202 INT begin_of_run(INT run_number, char *error)
203 {
204  return CM_SUCCESS;
205 }
206 
207 //-- End of Run ----------------------------------------------------
212 INT end_of_run(INT run_number, char *error)
213 {
214  return CM_SUCCESS;
215 }
216 
217 //-- Pause Run -----------------------------------------------------
222 INT pause_run(INT run_number, char *error)
223 {
224  return CM_SUCCESS;
225 }
226 
227 //-- Resume Run ----------------------------------------------------
232 INT resume_run(INT run_number, char *error)
233 {
234  return CM_SUCCESS;
235 }
236 
237 //------------------------------------------------------------------
void sample_cryo_changed(INT hDB, INT dummy2, void *info)
const char * frontend_name
&lt; created by ODBedit, command &quot;make&quot;
Definition: vme_fe.cxx:167
INT max_event_size
maximum event size produced by this frontend
Definition: vme_fe.cxx:179
BOOL frontend_call_loop
frontend_loop is called periodically if this variable is TRUE
Definition: vme_fe.cxx:173
INT display_period
a frontend status page is displayed with this frequency in ms
Definition: vme_fe.cxx:176
INT event_buffer_size
buffer size to hold events
Definition: vme_fe.cxx:185
char sample_cryo[NAME_LENGTH]
sample cryo name
Definition: sample_scfe.cxx:48
INT frontend_exit()
Definition: vme_fe.cxx:565
EQUIPMENT equipment[]
Definition: vme_fe.cxx:343
INT begin_of_run(INT run_number, char *error)
Definition: vme_fe.cxx:597
INFO info
Definition: analyzer.cxx:94
DEVICE_DRIVER sample_driver[]
Definition: sample_scfe.cxx:54
INT interrupt_configure(INT cmd, INT source, PTYPE adr)
Definition: vme_fe.cxx:2105
INT frontend_loop()
Definition: vme_fe.cxx:957
INT resume_run(INT run_number, char *error)
Definition: vme_fe.cxx:900
INT max_event_size_frag
maximum event size for fragmented events (EQ_FRAGMENTED)
Definition: vme_fe.cxx:182
INT bh_flow_out(INT cmd,...)
INT frontend_init()
Definition: vme_fe.cxx:429
HNDLE hKey
BOOL equipment_common_overwrite
Definition: vme_fe.cxx:341
INT end_of_run(INT run_number, char *error)
Definition: vme_fe.cxx:865
INT poll_event(INT source, INT count, BOOL test)
Definition: vme_fe.cxx:2088
INT bh_flow_in(INT cmd,...)
HNDLE hDB
INT pause_run(INT run_number, char *error)
Definition: vme_fe.cxx:893
const char * frontend_file_name
The frontend file name, don&#39;t change it.
Definition: vme_fe.cxx:170