16 #ifndef MBS_SlowControlData
17 #define MBS_SlowControlData
107 void AddLong(
const std::string &name, int64_t value,
bool checkduplicate =
false)
121 void AddDouble(
const std::string &name,
double value,
bool checkduplicate =
false)
146 return sizeof(uint32_t) +
155 unsigned Write(
void* buf,
unsigned buflen)
158 if (size > buflen)
return 0;
160 char* ptr = (
char*) buf;
167 memcpy(ptr, &num64,
sizeof(num64)); ptr+=
sizeof(num64);
169 for (
unsigned ix = 0; ix <
fLongValues.size(); ++ix) {
171 memcpy(ptr, &val,
sizeof(val)); ptr+=
sizeof(val);
176 memcpy(ptr, &num64,
sizeof(num64)); ptr+=
sizeof(num64);
181 memcpy(ptr, &val,
sizeof(val)); ptr+=
sizeof(val);
190 bool Read(
void* buf,
unsigned bufsize)
192 if ((buf==0) || (bufsize<24))
return false;
196 char* ptr = (
char*) buf;
197 char* theEnd = ptr + bufsize;
204 memcpy(&num64, ptr,
sizeof(num64)); ptr+=
sizeof(num64);
206 for (uint64_t n=0;n<num64;n++) {
208 memcpy(&val, ptr,
sizeof(val)); ptr+=
sizeof(val);
213 memcpy(&num64, ptr,
sizeof(num64)); ptr+=
sizeof(num64);
215 for (uint64_t n=0;n<num64;n++) {
217 memcpy(&val, ptr,
sizeof(val)); ptr+=
sizeof(val);
222 if (sscanf(ptr,
"%u", &num)!=1) {
223 printf(
"cannot get number of long names\n");
227 printf(
"mismatch between count long names %u and values %u\n", num, (
unsigned)
fLongValues.size());
230 ptr = ptr + strlen(ptr) + 1;
233 for (
unsigned n=0;n<num;n++) {
235 printf(
"decoding error\n");
239 ptr = ptr + strlen(ptr) + 1;
243 if (sscanf(ptr,
"%u", &num)!=1) {
244 printf(
"cannot get number of double names\n");
248 printf(
"mismatch between count double names %u and values %u\n", num, (
unsigned)
fDoubleValues.size());
251 ptr = ptr + strlen(ptr) + 1;
254 for (
unsigned n=0;n<num;n++) {
256 printf(
"decoding error\n");
260 ptr = ptr + strlen(ptr) + 1;
Record for manipulation with slow control data.
void SetEventId(uint32_t id)
void SetEventTime(uint32_t tm)
std::string GetDoubleName(unsigned indx)
std::vector< double > fDoubleValues
values of double records
int64_t GetLongValue(unsigned indx)
std::vector< std::string > fLongRecords
names of long records
uint32_t GetEventId() const
std::string GetLongName(unsigned indx)
uint32_t fEventTime
unix time in seconds
unsigned Write(void *buf, unsigned buflen)
unsigned NumLongs() const
bool Read(void *buf, unsigned bufsize)
virtual ~SlowControlData()
std::vector< int64_t > fLongValues
values of long records
uint32_t GetEventTime() const
void AddDouble(const std::string &name, double value, bool checkduplicate=false)
Method add double record.
double GetDoubleValue(unsigned indx)
std::vector< std::string > fDoubleRecords
names of double records
unsigned NumDoubles() const
std::string fDescriptor
descriptor
void AddLong(const std::string &name, int64_t value, bool checkduplicate=false)
Method add long record.
uint32_t fEventId
event number
std::string format(const char *fmt,...)
Support for MBS - standard GSI DAQ.