WIP
This commit is contained in:
@@ -30,7 +30,7 @@ ecmcDAQDataArray::~ecmcDAQDataArray() {
|
||||
}
|
||||
|
||||
void ecmcDAQDataArray::addDataItem(int type) {
|
||||
dataChannels_.push_back(new ecmcDAQDataChannel(type);
|
||||
dataChannels_.push_back(new ecmcDAQDataChannel(type);
|
||||
channelCounter_++;
|
||||
}
|
||||
|
||||
@@ -52,31 +52,45 @@ void ecmcDAQDataArray::connectToDataSources() {
|
||||
dataSourceLinked_ = 1;
|
||||
}
|
||||
|
||||
// Prepare header first in array 4 elements per channel.
|
||||
/* Prepare header first in array, 4 elements per channel:
|
||||
* array[0] = Ec timestamp, updated each cycle
|
||||
* Channel 1:
|
||||
* array[1] = Channel type
|
||||
* array[2] = Data start index
|
||||
* array[3] = Data element count
|
||||
* array[4] = spare..
|
||||
* Channel 2:
|
||||
* array[5] = Channel type
|
||||
* array[6] = Data start index
|
||||
* array[7] = Data element count
|
||||
* array[8] = spare..
|
||||
*....
|
||||
*/
|
||||
void ecmcDAQDataArray::buildArrayHeader(){
|
||||
// 4 elements plus first timestamp to first data element
|
||||
size_t dataStartOffset = channelCounter_* 4 + 1;
|
||||
size_t index = 0;
|
||||
size_t dataStartOffset=channelCounter_* 4 + 1; //4 elements plus first timestamp
|
||||
buffer_[index] = 0; // Timestamp, will be set in each loop in execute
|
||||
index++;
|
||||
|
||||
// Each Data channel takes 4 doubles
|
||||
for(std::vector<ecmcDAQDataChannel*>::iterator pDataCh = dataChannels_.begin(); pDataCh != dataChannels_.end(); ++pDataCh) {
|
||||
if(!(*pDataCh)) {
|
||||
throw std::runtime_error( "Channel empty..");
|
||||
}
|
||||
// 4 elements per channel
|
||||
// First element: Type
|
||||
// First element: Type
|
||||
buffer_[index] = (double)(*pDataCh)->getType();
|
||||
index++;
|
||||
// Second element: data start index
|
||||
// Second element: Data start index in array
|
||||
buffer_[index] = (double)dataStartOffset;
|
||||
index++;
|
||||
// Third element: data start index
|
||||
// Third element: Data element count (size)
|
||||
buffer_[index] = (double)(*pDataCh)->getElementCount();
|
||||
// Prepare data start index for next data item
|
||||
dataStartOffset = dataStartOffset + (*pDataCh)->getElementCount();
|
||||
index++;
|
||||
// Forth index spare...
|
||||
buffer_[index] = 0;
|
||||
buffer_[index] = 0.0;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,38 +15,7 @@
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "ecmcDAQDataArray.h"
|
||||
#include "ecmcDataItem.h"
|
||||
|
||||
/* Class to store data channels */
|
||||
class ecmcDAQDataChannel {
|
||||
public:
|
||||
ecmcDAQDataChannel(char* name, int formatAsTime) {
|
||||
dataItem_ = NULL;
|
||||
name_ = name;
|
||||
timeFormat_ = formatAsTime;
|
||||
}
|
||||
|
||||
void connectToSources() {
|
||||
// Get data item for
|
||||
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_;
|
||||
};
|
||||
#include "ecmcDAQDataChannel.h"
|
||||
|
||||
/* Class to fromat an array of ecmcDAQDataChannels with headers and push over asyn to epics */
|
||||
class ecmcDAQDataArray {
|
||||
|
||||
@@ -9,13 +9,12 @@
|
||||
* Author: anders sandstrom
|
||||
*
|
||||
\*************************************************************************/
|
||||
#ifndef ECMC_DAQ_DATA_ARRAY_H_
|
||||
#define ECMC_DAQ_DATA_ARRAY_H_
|
||||
#ifndef ECMC_DAQ_DATA_CHANNEL_H_
|
||||
#define ECMC_DAQ_DATA_CHANNEL_H_
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "ecmcDAQDataChannel.h"
|
||||
#include "ecmcDataItem.h"
|
||||
|
||||
/* Class to store data channels */
|
||||
@@ -64,7 +63,7 @@ private:
|
||||
double type_;
|
||||
};
|
||||
|
||||
#endif /* ECMC_DAQ_DATA_ARRAY_H_ */
|
||||
#endif /* ECMC_DAQ_DATA_CHANNEL_H_ */
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user