WIP
This commit is contained in:
@@ -19,32 +19,50 @@
|
||||
#include "ecmcPluginClient.h"
|
||||
|
||||
ecmcDAQDataArray::ecmcDAQDataArray(size_t nelm){
|
||||
buffer_ = new double [nelm];
|
||||
memset(buffer_,0,sizeof(buffer_))
|
||||
nelm_ = nelm;
|
||||
channelCounter_ = 0;
|
||||
dataElementCount_= 0;
|
||||
totalElementCount_ = 0;
|
||||
firstDataElementIndex_ = 0;
|
||||
}
|
||||
|
||||
ecmcDAQDataArray::~ecmcDAQDataArray() {
|
||||
|
||||
}
|
||||
|
||||
void ecmcDAQDataArray::addDataItem(int type) {
|
||||
void ecmcDAQDataArray::addChannel(int type) {
|
||||
dataChannels_.push_back(new ecmcDAQDataChannel(type);
|
||||
channelCounter_++;
|
||||
}
|
||||
|
||||
void ecmcDAQDataArray::addDataItemToChannel(char* name, int format) {
|
||||
// Always add to last added channel
|
||||
dataChannels_.back().addDataItem(name, format);
|
||||
}
|
||||
|
||||
void ecmcDAQDataArray::connectToDataSources() {
|
||||
if( dataSourceLinked_ ) {
|
||||
return;
|
||||
}
|
||||
|
||||
dataElementCount_ = 0;
|
||||
|
||||
for(std::vector<ecmcDAQDataChannel*>::iterator pDataCh = dataChannels_.begin(); pDataCh != dataChannels_.end(); ++pDataCh) {
|
||||
if(!(*pDataCh)) {
|
||||
throw std::runtime_error( "Channel empty..");
|
||||
}
|
||||
(*pDataCh)->connectToSources();
|
||||
dataElementCount_ = dataElementCount_ + (*pDataCh)->getDataElementCount();
|
||||
}
|
||||
|
||||
// Header: First element is time stamp then 4 elements per channel
|
||||
totalElementCount_ = dataElementCount_ + channelCounter_ * 4 + 1;
|
||||
|
||||
// Now we we can finally allocate teh buffer (ecmc is still not in realtime, enterRT)
|
||||
buffer_ = new double [totalElementCount_];
|
||||
memset(buffer_,0,sizeof(buffer_))
|
||||
|
||||
// Build header
|
||||
buildArrayHeader();
|
||||
|
||||
// Register asyn parameters
|
||||
initAsyn();
|
||||
@@ -53,7 +71,7 @@ void ecmcDAQDataArray::connectToDataSources() {
|
||||
}
|
||||
|
||||
/* Prepare header first in array, 4 elements per channel:
|
||||
* array[0] = Ec timestamp, updated each cycle
|
||||
* array[0] = Ec timestamp, updated each cycle, the reset of header is static
|
||||
* Channel 1:
|
||||
* array[1] = Channel type
|
||||
* array[2] = Data start index
|
||||
@@ -67,8 +85,10 @@ void ecmcDAQDataArray::connectToDataSources() {
|
||||
*....
|
||||
*/
|
||||
void ecmcDAQDataArray::buildArrayHeader(){
|
||||
// 4 elements plus first timestamp to first data element
|
||||
// 4 elements plus first timestamp to first data element, only first element will change in realtime
|
||||
|
||||
size_t dataStartOffset = channelCounter_* 4 + 1;
|
||||
firstDataElementIndex_ = dataStartOffset;
|
||||
|
||||
if( nelm_ < dataStartOffset) {
|
||||
throw std::runtime_error( "Array to small, header will not fit (array size must be bigger than total data size plus 4*data_channel_count+1)..");
|
||||
@@ -90,18 +110,22 @@ void ecmcDAQDataArray::buildArrayHeader(){
|
||||
buffer_[index] = (double)dataStartOffset;
|
||||
index++;
|
||||
// Third element: Data element count (size)
|
||||
buffer_[index] = (double)(*pDataCh)->getElementCount();
|
||||
buffer_[index] = (double)(*pDataCh)->getDataElementCount();
|
||||
// Prepare data start index for next data item
|
||||
dataStartOffset = dataStartOffset + (*pDataCh)->getElementCount();
|
||||
dataStartOffset = dataStartOffset + (*pDataCh)->getDataElementCount();
|
||||
index++;
|
||||
// Forth index spare...
|
||||
buffer_[index] = 0.0;
|
||||
buffer_[index] = -1234567890;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
void ecmcDAQDataArray::execute() {
|
||||
|
||||
}
|
||||
|
||||
void ecmcDAQDataArray::initAsyn() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user