00001 #ifndef ARTDAQ_DAQDATA_GLOBALS_HH
00002 #define ARTDAQ_DAQDATA_GLOBALS_HH
00003
00004 #include <sstream>
00005 #include "artdaq-utilities/Plugins/MetricManager.hh"
00006
00007 #define my_rank artdaq::Globals::my_rank_
00008 #define app_name artdaq::Globals::app_name_
00009 #define metricMan artdaq::Globals::metricMan_
00010 #define seedAndRandom() artdaq::Globals::seedAndRandom_()
00011
00012 #define mftrace_iteration artdaq::Globals::mftrace_iteration_
00013 #define mftrace_module artdaq::Globals::mftrace_module_
00014 #define SetMFModuleName(name) mftrace_module = name
00015 #define SetMFIteration(name) mftrace_iteration = name
00016
00017
00018 #include <fcntl.h>
00019 #include <unistd.h>
00020 #include <stdlib.h>
00021
00022
00026 namespace artdaq
00027 {
00031 class Globals
00032 {
00033 public:
00034 static int my_rank_;
00035 static MetricManager* metricMan_;
00036 static std::string app_name_;
00037
00038
00039 static std::string mftrace_module_;
00040 static std::string mftrace_iteration_;
00041
00046 static uint32_t seedAndRandom_()
00047 {
00048 static bool initialized_ = false;
00049 if (!initialized_) {
00050 int fp = open("/dev/random", O_RDONLY);
00051 if (fp == -1) abort();
00052 unsigned seed;
00053 unsigned pos = 0;
00054 while (pos < sizeof(seed))
00055 {
00056 int amt = read(fp, (char *)&seed + pos, sizeof(seed) - pos);
00057 if (amt <= 0) abort();
00058 pos += amt;
00059 }
00060 srand(seed);
00061 close(fp);
00062 initialized_ = true;
00063 }
00064 return rand();
00065 }
00066 };
00067 }
00068
00069 #include "artdaq-core/Utilities/configureMessageFacility.hh"
00070 #include "tracemf.h"
00071 #include "artdaq-core/Utilities/TimeUtils.hh"
00072 #endif // ARTDAQ_DAQDATA_GLOBALS_HH