Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
daq_device_pluginexample.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file daq_device_pluginexample.cc
2 
3 #include <strings.h>
4 
5 
6 using namespace std;
7 
9  , const int subeventid
10  , const int n_words
11  , const int trigger_enabled)
12 {
13 
14  m_eventType = eventtype;
15  m_subeventid = subeventid;
16  number_of_words = n_words;
17  if (trigger_enabled)
18  {
19  th = new pulserTriggerHandler();
21  }
22  else
23  {
24  th = 0;
25  }
26 }
27 
29 {
31  delete th;
32 }
33 
34 
35 
36 // the put_data function
37 
38 int daq_device_pluginexample::put_data(const int etype, int * adr, const int length )
39 {
40 
41  int len = 0;
42 
43  if (etype != m_eventType ) // not our id
44  {
45  return 0;
46  }
47 
48 
49  sevt = (subevtdata_ptr) adr;
50  // set the initial subevent length
51  sevt->sub_length = SEVTHEADERLENGTH;
52 
53  // update id's etc
54  sevt->sub_id = m_subeventid;
55  sevt->sub_type=4;
56  sevt->sub_decoding = ID4EVT;
57  sevt->reserved[0] = 0;
58  sevt->reserved[1] = 0;
59 
60 
61  int *d = (int *) &sevt->data;
62 
63  unsigned int ia;
64 
65  for ( ia = 0; ia < number_of_words; ia++)
66  {
67  *d++ = ia;
68  len++;
69  }
70 
71 
72  sevt->sub_padding = len%2;
73  len = len + (len%2);
74  sevt->sub_length += len;
75  return sevt->sub_length;
76 }
77 
78 
79 void daq_device_pluginexample::identify(std::ostream& os) const
80 {
81 
82  os << "Plugin Device Event Type: " << m_eventType << " Subevent id: " << m_subeventid
83  << " n_words: " << number_of_words;
84 
85  if (th)
86  {
87  os << " ** Trigger enabled";
88  }
89 
90  os << endl;
91 
92 }
93 
94 int daq_device_pluginexample::max_length(const int etype) const
95 {
96  if (etype != m_eventType) return 0;
97  return (number_of_words + SEVTHEADERLENGTH);
98 }
99 
101 {
102 
103  return 0;
104 }
105 
106 // the rearm() function
108 {
109  if (etype != m_eventType) return 0;
110  return 0;
111 }
112 
113