//=============================================================== // This is a simple ET to ET transport program //=============================================================== #include #include #include #include using namespace std; #include #include #include #include using namespace evio; #define USE_CODA_RUNOBJECTS 0 #if USE_CODA_RUNOBJECTS #include using namespace codaObject; #endif // USE_CODA_RUNOBJECTS bool QUIT = false; uint32_t Nevents = 0; string source_name=""; string sink_name=""; et_sys_id source_sys_id; et_att_id source_att_id; et_sys_id sink_sys_id; et_att_id sink_att_id; uint32_t OUTPUT_BUFFER_SIZE = 150000; // bytes uint32_t INPUT_BUFFER_SIZE = 150000; // bytes int ET_STATION_NEVENTS = 100; bool ET_STATION_CREATE_BLOCKING = true; evioChannel *input_chan; #ifndef _DBG_ #define _DBG_ cout<<__FILE__<<":"<<__LINE__<<" " #define _DBG__ cout<<__FILE__<<":"<<__LINE__<connect(); // Create CODA RunObject HDet2et hdet2et(UDL, "hdet2et", "ET 2 ET bridge", session); hdet2et.startProcessing(); #endif // USE_CODA_RUNOBJECTS // Allocate memory for event buffer //uint32_t *buff = (uint32_t*)malloc(INPUT_BUFFER_SIZE); //SendDummyEvents(10); // Loop over events until user says to quit cout << "==============================================" << endl; cout << "Starting event transfer. Hit ctl-C to quit ..." << endl; while(!QUIT){ // Read event from input ET system et_event *pe_in=NULL; struct timespec timeout = {0, (uint32_t)5E8}; int err = et_event_get(source_sys_id, source_att_id, &pe_in, ET_TIMED , &timeout); if( err==ET_ERROR_TIMEOUT ){ // No event available. Do nothing. }else if( err == ET_OK && pe_in==NULL){ cout << " !!! ET returned no error, but event pointer is NULL!!!" << endl; continue; }else if( err == ET_OK && pe_in!=NULL){ // got an event from source uint32_t *et_buff=NULL; err = et_event_getdata(pe_in, (void**)&et_buff); if(et_buff == NULL){ cerr << " Got event from ET, but pointer to data is NULL!" << endl; continue; } size_t buff_size_bytes = 0; et_event_getlength(pe_in, &buff_size_bytes); // get event from sink et_event *pe_out=NULL; int status = et_event_new(sink_sys_id, sink_att_id, &pe_out, ET_SLEEP, NULL, buff_size_bytes); if(status != ET_OK){ cerr << "Unable to write new event to output (et_event_new returns "< fields; string str = source_name; size_t startpos=0, endpos=0; while((endpos = str.find(":", startpos)) != str.npos){ size_t len = endpos-startpos; fields.push_back(len==0 ? "":str.substr(startpos, len)); startpos = endpos+1; } if(startpos1 ? fields[1]:""; string station = fields.size()>2 ? fields[2]:""; string host = fields.size()>3 ? fields[3]:""; int port = fields.size()>4 ? atoi(fields[4].c_str()):ET_SERVER_PORT; if(session == "") session = "none"; if(station == "") station = "ET2ET"; string fname = session.at(0)=='/' ? session:(string("/tmp/et_sys_") + session); // Report to user what we're doing cout << " Input ET system ==================" << endl; if(session.at(0)!='/') cout << " session: " << session << endl; cout << " station: " << station << endl; cout << " system file: " << fname << endl; if(host!=""){ cout << " host:\""< INPUT_BUFFER_SIZE){ cout<<" Events in ET system are larger than currently set buffer size:"< "< fields; string str = sink_name; size_t startpos=0, endpos=0; while((endpos = str.find(":", startpos)) != str.npos){ size_t len = endpos-startpos; fields.push_back(len==0 ? "":str.substr(startpos, len)); startpos = endpos+1; } if(startpos1 ? fields[1]:""; string host = fields.size()>2 ? fields[2]:""; int port = fields.size()>3 ? atoi(fields[3].c_str()):0; if(session == "") session = "none"; string fname = session.at(0)=='/' ? session:(string("/tmp/et_sys_") + session); // Report to user what we're doing cout << " Output ET system ==================" << endl; if(session.at(0)!='/') cout << " session: " << session << endl; cout << " system file: " << fname << endl; if(host!=""){ cout << " host: \""< OUTPUT_BUFFER_SIZE){ cout<<" Events in ET system are larger than currently set buffer size:"< "< 0) cout << end_message << endl; exit(0); }