This commit is contained in:
2024-03-01 21:06:50 +01:00
parent c1b7742561
commit 02012d9841
4 changed files with 164 additions and 11 deletions

70
src/ecmcDAQDataChannel.h Normal file
View File

@@ -0,0 +1,70 @@
/*************************************************************************\
* Copyright (c) 2024 PSI
* ecmc is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*
* ecmcDAQDataChannel.h
*
* Created on: Mar 01, 2024
* Author: anders sandstrom
*
\*************************************************************************/
#ifndef ECMC_DAQ_DATA_ARRAY_H_
#define ECMC_DAQ_DATA_ARRAY_H_
#include <stdexcept>
#include <vector>
#include <string>
#include "ecmcDAQDataChannel.h"
#include "ecmcDataItem.h"
/* Class to store data channels */
class ecmcDAQChannelItem {
public:
ecmcDAQChannelItem(char* name, int formatAsTime) {
dataItem_ = NULL;
dataItemInfo_ = NULL;
name_ = name;
timeFormat_ = formatAsTime; // micro s in int32
}
void connectToSource() {
// Get data item
dataItem_ = (ecmcDataItem*) getEcmcDataItem(name_.c_str());
if(!dataItem_) {
printf("ERROR: DataItem %s NULL.\n", name_.c_str());
throw std::runtime_error( "ERROR: DataItem NULL." );
}
dataItemInfo_ = dataItem_->getDataItemInfo();
if(!dataItemInfo_) {
printf("ERROR: DataItemInfo %s NULL.\n", name_.c_str());
throw std::runtime_error( "ERROR: DataItemInfo NULL." );
}
}
ecmcDataItem* dataItem_;
ecmcDataItemInfo* dataItemInfo_;
std::string name_;
int timeFormat_;
};
/* Class for an data channel */
class ecmcDAQDataChannel {
public:
ecmcDAQDataChannel(int type);
~ecmcDAQDataChannel();
void connectToSources();
void execute();
void addDataItem(char* name, int timeFormat);
private:
std::vector<ecmcDAQChannelItem*> dataItems_;
size_t itemCounter_;
double type_;
};
#endif /* ECMC_DAQ_DATA_ARRAY_H_ */