27 sprintf(buf,
"%d", i);
34 printf(
"int[%d] has [", size);
35 for (
int i=0; i<size; i++) {
46 printf(
"int[%d] has [", size);
47 for (
int i=0; i<size; i++) {
59 printf(
"FAIL: %s\n", text);
65 fprintf(stderr,
"Usage: test_midasio.exe [-h] [-o output_file] input_file1 [input_file2...]\n");
71int main(
int argc,
char *argv[])
76 signal(SIGILL, SIG_DFL);
77 signal(SIGBUS, SIG_DFL);
78 signal(SIGSEGV, SIG_DFL);
79 signal(SIGPIPE, SIG_DFL);
82 const char* hostname = NULL;
83 const char* exptname = NULL;
85 std::vector<std::string> rfilenames;
86 std::string wfilename;
88 bool test_init =
false;
90 for (
int i=1; i<argc; i++) {
91 if (strcmp(argv[i],
"-h")==0) {
93 }
else if (strcmp(argv[i],
"--help")==0) {
95 }
else if (strcmp(argv[i],
"-i")==0) {
97 }
else if (strcmp(argv[i],
"-o")==0) {
99 if (i == argc)
usage();
101 }
else if (argv[i][0] ==
'-') {
102 fprintf(stderr,
"invalid switch: \"%s\"\n", argv[i]);
105 rfilenames.push_back(argv[i]);
111 if (!wfilename.empty()) {
116 for (
int i=0; i<10; i++) {
123 buf32[0] = 0x11111111;
124 buf32[1] = 0x22222222;
125 buf32[2] = 0x33333333;
126 event.AddBank(
"AAAA",
TID_UINT32, (
char*)buf32,
sizeof(buf32));
131 buf64[0] = 0x1111111111111111;
132 buf64[1] = 0x2222222222222222;
133 buf64[2] = 0x3333333333333333;
134 event.AddBank(
"BBBB",
TID_UINT64, (
char*)buf64,
sizeof(buf64));
144 if (rfilenames.empty())
154 printf(
"Using MidasOdb\n");
157 int err = midas->connect(hostname, exptname,
"test_mvodb");
159 fprintf(stderr,
"Cannot connect to MIDAS, error %d\n", err);
168 printf(
"MIDAS support not available, sorry! Bye.\n");
173 for (
size_t ri=0; ri<rfilenames.size(); ri++) {
177 printf(
"Cannot open input file \"%s\"\n", rfilenames[ri].c_str());
193 printf(
"event with error, bye!\n");
198 printf(
"Event: id 0x%04x, mask 0x%04x, serial 0x%08x, time 0x%08x, data size %d\n",
205 if ((e->
event_id & 0xFFFF) == 0x8000) {
206 printf(
"Event: this is a begin of run ODB dump\n");
215 }
else if ((e->
event_id & 0xFFFF) == 0x8001) {
216 printf(
"Event: this is an end of run ODB dump\n");
229 }
else if (counter == 1) {
void PrintBanks(int level=0)
uint32_t time_stamp
MIDAS event time stamp (unix time in sec)
uint32_t serial_number
MIDAS event serial number.
uint32_t data_size
MIDAS event data size.
uint16_t trigger_mask
MIDAS trigger mask.
uint16_t event_id
MIDAS event ID.
bool error
event has an error - incomplete, truncated, inconsistent or corrupted
static TMidasOnline * instance()
void TMWriteEvent(TMWriterInterface *writer, const TMEvent *event)
TMWriterInterface * TMNewWriter(const char *destination)
TMEvent * TMReadEvent(TMReaderInterface *reader)
TMReaderInterface * TMNewReader(const char *source)
MVOdb * MakeMidasOdb(int hDB, MVOdbError *error=NULL)
MVOdb * MakeFileDumpOdb(const char *buf, int bufsize, MVOdbError *error=NULL)
Access ODB from a midas file dump. FOrmat could be .xml, .json or .odb.
void print_da(const std::vector< double > &da)
int main(int argc, char *argv[])
void report_fail(const char *text)
void print_ia(const std::vector< int > &ia)
std::string toString(int i)