1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
#include "DataFormats/HcalRecHit/interface/HcalSourcePositionData.h"
#include <cstdio>
using namespace std;
HcalSourcePositionData::HcalSourcePositionData() {
messageCounter_ = 0;
indexCounter_ = 0;
reelCounter_ = 0;
timestamp1_sec_ = 0;
timestamp1_usec_ = 0;
timestamp2_sec_ = 0;
timestamp2_usec_ = 0;
status_ = 0;
motorCurrent_ = 0;
motorVoltage_ = 0;
tubeId_ = -1;
driverId_ = -1;
sourceId_ = -1;
tubeNameFromCoord_ = "";
tubeDescriptionFromSD_ = "";
lastCommand_ = "";
message_ = "";
}
void HcalSourcePositionData::set(int message_counter,
int timestamp1_sec,
int timestamp1_usec,
int timestamp2_sec,
int timestamp2_usec,
int status,
int index_counter,
int reel_counter,
int motor_current,
int motor_voltage,
int driver_id,
int source_id,
std::string tubeNameFromCoord,
std::string tubeDescFromSD,
std::string lastCommand,
std::string message) {
messageCounter_ = message_counter;
indexCounter_ = index_counter;
reelCounter_ = reel_counter;
timestamp1_sec_ = timestamp1_sec;
timestamp1_usec_ = timestamp1_usec;
timestamp2_sec_ = timestamp2_sec;
timestamp2_usec_ = timestamp2_usec;
status_ = status;
motorCurrent_ = motor_current;
motorVoltage_ = motor_voltage;
driverId_ = driver_id;
sourceId_ = source_id;
tubeNameFromCoord_ = tubeNameFromCoord;
tubeDescriptionFromSD_ = tubeDescFromSD;
lastCommand_ = lastCommand;
message_ = message;
}
void HcalSourcePositionData::getDriverTimestamp(int& seconds, int& useconds) const {
seconds = timestamp1_sec_;
useconds = timestamp1_usec_;
}
void HcalSourcePositionData::getDAQTimestamp(int& seconds, int& useconds) const {
seconds = timestamp2_sec_;
useconds = timestamp2_usec_;
}
ostream& operator<<(ostream& s, const HcalSourcePositionData& hspd) {
s << " Message Counter =" << hspd.messageCounter() << endl;
s << " Index Counter =" << hspd.indexCounter() << endl;
s << " Reel Counter =" << hspd.reelCounter() << endl;
s << " Status =" << hex << hspd.status() << dec << endl;
s << " Motor Current =" << hspd.motorCurrent() << endl;
s << " Motor Voltage =" << hspd.motorVoltage() << endl;
s << " Tube Id =" << hspd.tubeId() << endl;
s << " Driver Id =" << hspd.driverId() << endl;
s << " Source Id =" << hspd.sourceId() << endl;
s << " TubeNameFromCoord =" << hspd.tubeNameFromCoord() << endl;
s << " TubeDescriptionFromSD =" << hspd.tubeDescriptionFromSD() << endl;
s << " Last Command =" << hspd.lastCommand() << endl;
s << " Message =" << hspd.message() << endl;
int timebase = 0;
int timeusec = 0;
hspd.getDriverTimestamp(timebase, timeusec);
// trim seconds off of usec and add to base
timeusec %= 1000000;
timebase += timeusec / 1000000;
char str[50];
sprintf(str, " Driver Timestamp : %s", ctime((time_t*)&timebase));
s << str;
timebase = 0;
timeusec = 0;
hspd.getDAQTimestamp(timebase, timeusec);
timeusec %= 1000000;
timebase += timeusec / 1000000;
sprintf(str, " DAQ Timestamp : %s", ctime((time_t*)&timebase));
s << str;
return s;
}
|