Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-02 08:21:01

0001 #include "daq_device_pluginexample.h"
0002 
0003 #include <strings.h>
0004 
0005  
0006 using namespace std;
0007 
0008 daq_device_pluginexample::daq_device_pluginexample(const int eventtype
0009     , const int subeventid
0010     , const int n_words
0011     , const int trigger_enabled)
0012 {
0013 
0014   m_eventType  = eventtype;
0015   m_subeventid = subeventid;
0016   number_of_words = n_words;
0017   if (trigger_enabled) 
0018     {
0019       th = new pulserTriggerHandler();
0020       registerTriggerHandler(th);
0021     }
0022   else
0023     {
0024       th = 0;
0025     }
0026 }
0027 
0028 daq_device_pluginexample::~daq_device_pluginexample()
0029 {
0030   clearTriggerHandler();
0031   delete th;
0032 }
0033 
0034 
0035 
0036 // the put_data function
0037 
0038 int daq_device_pluginexample::put_data(const int etype, int * adr, const int length )
0039 {
0040 
0041   int len = 0;
0042 
0043   if (etype != m_eventType )  // not our id
0044     {
0045       return 0;
0046     }
0047 
0048 
0049   sevt =  (subevtdata_ptr) adr;
0050   // set the initial subevent length
0051   sevt->sub_length =  SEVTHEADERLENGTH;
0052 
0053   // update id's etc
0054   sevt->sub_id =  m_subeventid;
0055   sevt->sub_type=4;
0056   sevt->sub_decoding = ID4EVT;
0057   sevt->reserved[0] = 0;
0058   sevt->reserved[1] = 0;
0059 
0060 
0061   int  *d = (int *) &sevt->data;
0062 
0063   unsigned int ia;
0064  
0065   for ( ia = 0; ia < number_of_words; ia++)
0066     {
0067      *d++  = ia;
0068      len++;
0069     }
0070   
0071   
0072   sevt->sub_padding = len%2;
0073   len = len + (len%2);
0074   sevt->sub_length += len;
0075   return  sevt->sub_length;
0076 }
0077 
0078 
0079 void daq_device_pluginexample::identify(std::ostream& os) const
0080 {
0081   
0082   os  << "Plugin Device  Event Type: " << m_eventType << " Subevent id: " << m_subeventid 
0083       << " n_words: " << number_of_words; 
0084 
0085     if (th) 
0086       {
0087     os << " ** Trigger enabled";
0088       }
0089 
0090   os << endl;
0091 
0092 }
0093 
0094 int daq_device_pluginexample::max_length(const int etype) const
0095 {
0096   if (etype != m_eventType) return 0;
0097   return  (number_of_words + SEVTHEADERLENGTH);
0098 }
0099 
0100 int  daq_device_pluginexample::init()
0101 {
0102 
0103   return 0;
0104 }
0105 
0106 // the rearm() function
0107 int  daq_device_pluginexample::rearm(const int etype)
0108 {
0109   if (etype != m_eventType) return 0;
0110   return 0;
0111 }
0112 
0113