pmt_slow_encoder.cc

Go to the documentation of this file.
00001 #ifndef PMT_SLOW_ENCODER_CC
00002 #define PMT_SLOW_ENCODER_CC
00003 
00004 #include "pmt_slow_encoder.hh"
00005 
00006 void reset(){
00007 
00008 }
00009 
00010 bool pmt_slow_encoder::initialize() {
00011 
00012   _bin_file.open();
00013   return _bin_file.is_open();
00014 }
00015 
00016 bool pmt_slow_encoder::analyze(storage_manager *storage){
00017 
00018   _index=0;
00019 
00020   pmt_wf_collection *data = (pmt_wf_collection*)(storage->get_data(DATA_STRUCT::PMT_WF_COLLECTION));
00021 
00022   encode_event_header(data);
00023   encode_ch_word(data);
00024 
00025   _bin_file.write_multi_word(_words,_index+1);
00026   _index=0;
00027   return true;
00028 }
00029 
00030 void pmt_slow_encoder::encode_event_header(const pmt_wf_collection* data) {
00031 
00032   // (1) First 32-bit word include module address and id
00033   _words[_index]  = (format(PMT::FEM_HEADER,
00034                 ((data->module_id())<<5) + data->module_address()))<<16;
00035   _words[_index] += format(PMT::FEM_HEADER,0xfff);
00036   _index++;
00037 
00038   // (2) Second 32-bit word include word counts
00039   _words[_index]  = format(PMT::FEM_HEADER,(data->nwords())>>12);
00040   _words[_index] += (format(PMT::FEM_HEADER,(data->nwords()) & 0xfff))<<16;
00041   _index++;
00042   
00043   // (3) Third 32-bit word include event number
00044   _words[_index]  = format(PMT::FEM_HEADER,(data->event_id())>>12);
00045   _words[_index] += (format(PMT::FEM_HEADER,(data->event_id()) & 0xfff))<<16;
00046   _index++;
00047 
00048   // (4) Forth 32-bit word include frame number
00049   _words[_index]  = format(PMT::FEM_HEADER,(data->event_frame_id())>>12);
00050   _words[_index] += (format(PMT::FEM_HEADER,(data->event_frame_id()) & 0xfff))<<16;
00051   _index++;
00052 
00053   // (5) Fifth 32-bit word include checksum
00054   _words[_index]  = format(PMT::FEM_HEADER,
00055                (data->checksum())>>12);
00056   _words[_index] += (format(PMT::FEM_HEADER,
00057                 (data->checksum()) & 0xfff))<<16;
00058   _index++;
00059 
00060   // (6) Six-th 32-bit word include trigger info
00061   _words[_index]  = (format(PMT::FEM_HEADER,
00062                 (data->trigger_timeslice()) & 0xff))<<16;
00063   _words[_index] += format(PMT::FEM_HEADER,
00064                (((data->trigger_frame_id()) & 0xf)<<4) + ((data->trigger_timeslice() & 0xffff)>>8));
00065   _index++;
00066   
00067 }
00068 
00069 void pmt_slow_encoder::encode_ch_word(const pmt_wf_collection* data) {
00070 
00071 
00072   for(pmt_wf_collection::const_iterator iter(data->begin());
00073       iter!=data->end();
00074       ++iter){
00075 
00076     
00077 
00078   }
00079 
00080 }
00081 
00082 bool pmt_slow_encoder::finalize() {
00083 
00084   _bin_file.close();
00085   return true;
00086 }
00087 
00088 #endif

Generated on Mon Apr 7 15:35:12 2014 for MyProject by  doxygen 1.4.7