70 return tv.tv_sec + 0.000001*
tv.tv_usec;
80static std::vector<Source>
gSrc;
170 timeout.tv_sec =
msec/1000;
171 timeout.tv_usec = (
msec%1000)*1000;
215 cm_msg(
MERROR,
"read_udp",
"UDP packet from unknown host \"%s\"", host);
216 cm_msg(
MINFO,
"read_udp",
"Register this host by running following commands:");
217 cm_msg(
MINFO,
"read_udp",
"odbedit -c \"create STRING /Equipment/%s/Settings/%s\"",
EQ_NAME, host);
218 cm_msg(
MINFO,
"read_udp",
"odbedit -c \"set /Equipment/%s/Settings/%s AAAA\", where AAAA is the MIDAS bank name for this host",
EQ_NAME, host);
226 cm_msg(
MERROR,
"read_udp",
"ODB \"/Equipment/%s/Settings/%s\" should be set to a 4 character MIDAS bank name",
EQ_NAME, host);
228 cm_msg(
MINFO,
"read_udp",
"odbedit -c \"set /Equipment/%s/Settings/%s AAAA\", where AAAA is the MIDAS bank name for this host",
EQ_NAME, host);
232 cm_msg(
MINFO,
"read_udp",
"UDP packets from host \"%s\" will be stored in bank \"%s\"", host,
bankname);
247 static int count = 0;
248 static double tt = 0;
269 for (
unsigned i=0;
i<
gSrc.size();
i++) {
290 cm_msg(
MERROR,
"read_udp",
"further messages are now suppressed...");
315 cm_msg(
MERROR,
"frontend_init",
"Cannot connect to ODB, cm_get_experiment_database() returned %d",
status);
320 path +=
"/Equipment";
325 std::string
path1 = path +
"/udp_port";
339 cm_msg(
MERROR,
"frontend_init",
"Cannot find \"%s\", db_find_key() returned %d", path.c_str(),
status);
346 printf(
"frontend_init: cannot open udp socket\n");
401#define MAX_UDP_SIZE (0x10000)
const char * frontend_file_name
int frontend_exit()
Frontend exit.
int read_event(char *pevent, INT off)
int end_of_run(int run, char *err)
End of Run.
bool addr_match(const Source *s, void *addr, int addr_len)
static int gUnknownPacketCount
int frontend_loop()
Frontend loop.
BOOL equipment_common_overwrite
int interrupt_configure(INT cmd, INT source, PTYPE adr)
int open_udp_socket(int server_port)
INT poll_event(INT source, INT count, BOOL test)
int read_udp(int socket, char *buf, int bufsize, char *pbankname)
int find_source(Source *src, const sockaddr *paddr, int addr_len)
const char * frontend_name
static double GetTimeSec()
static bool gSkipUnknownPackets
int wait_udp(int socket, int msec)
int frontend_init()
Frontend initialization.
static std::vector< Source > gSrc
int begin_of_run(int run, char *err)
Begin of Run.
INT bk_close(void *event, void *pdata)
void bk_init32(void *event)
void bk_create(void *event, const char *name, WORD type, void **pdata)
INT bk_size(const void *event)
INT cm_get_experiment_database(HNDLE *hDB, HNDLE *hKeyClient)
INT ss_sleep(INT millisec)
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
INT db_get_value(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, void *data, INT *buf_size, DWORD type, BOOL create)
INT db_find_key(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
int gettimeofday(struct timeval *tp, void *tzp)
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)