Fetching data works..
This commit is contained in:
@@ -99,37 +99,25 @@ class ecmcDAQChannelItem {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*struct ecmcDataItemInfo {
|
||||
char *name;
|
||||
uint8_t *data;
|
||||
size_t dataSize;
|
||||
size_t dataElementSize;
|
||||
size_t dataBitCount;
|
||||
ecmcEcDataType dataType;
|
||||
ecmcDataDir dataDirection;
|
||||
double dataUpdateRateMs;
|
||||
int dataPointerValid;
|
||||
};*/
|
||||
void resetIndex(int reset) {
|
||||
if(reset) {
|
||||
dataIndexToReturn_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return data:
|
||||
* if "first" is set to true the first data point will be returned.
|
||||
* if "first" is set to false the the next data point will be returned.
|
||||
* looping with false will return new data for each call untill theres no more data
|
||||
* before call, check if data is available with notEmpty()
|
||||
*/
|
||||
double getData(int first) {
|
||||
double getData() {
|
||||
double data = 0;
|
||||
uint64_t time = 0;
|
||||
if(first) {
|
||||
dataIndexToReturn_ = 0;
|
||||
}
|
||||
|
||||
if(dataIndexToReturn_ >= dataElementCount_) {
|
||||
printf("ERROR: Try to read outside data buffer for data item %s\n", name_.c_str());
|
||||
printf("ecmcDAQChannelItem::ERROR: Try to read outside data buffer for data item %s (elements %zu)\n", name_.c_str(),dataElementCount_);
|
||||
return -1;
|
||||
}
|
||||
printf("DATATYPE = %d\n",(int) dataType_);
|
||||
|
||||
switch (dataType_) {
|
||||
case ECMC_EC_B1:
|
||||
uint8Ptr_ = (uint8_t *)&dataItemInfo_->data[dataIndexToReturn_ * bytesPerElement_];
|
||||
@@ -218,7 +206,6 @@ class ecmcDAQChannelItem {
|
||||
return formatData(data,time);
|
||||
}
|
||||
|
||||
|
||||
double formatData(double data, uint64_t time){
|
||||
// Time format only works for integer values, otherwise a 0 will be returned
|
||||
switch(format_) {
|
||||
@@ -238,7 +225,7 @@ class ecmcDAQChannelItem {
|
||||
;
|
||||
break;
|
||||
}
|
||||
printf("DATA = %lf\n",data);
|
||||
printf("DATA %s = %lf\n",cstrName_, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -154,12 +154,11 @@ void ecmcDAQDataArray::execute() {
|
||||
if(!enablePlugin_) {
|
||||
return;
|
||||
}
|
||||
|
||||
int first = 1;
|
||||
size_t index = firstDataElementIndex_ ;
|
||||
for(std::vector<ecmcDAQDataChannel*>::iterator pDataCh = dataChannels_.begin(); pDataCh != dataChannels_.end(); ++pDataCh) {
|
||||
//always atleast one data item in a channel. Set "first" bit in call to getData()
|
||||
int first = 1;
|
||||
for(int i = 0 ; i < (*pDataCh)->getDataElementCount(); i++) {
|
||||
first = 1;
|
||||
for(size_t i = 0 ; i < (*pDataCh)->getDataElementCount(); i++) {
|
||||
buffer_[index]=(*pDataCh)->getData(first);
|
||||
first = 0;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ void ecmcDAQDataChannel::connectToDataSources() {
|
||||
(*pDataItem)->connectToSource();
|
||||
dataElementCount_ = dataElementCount_ + (*pDataItem)->getDataElementCount();
|
||||
}
|
||||
printf("ecmcDAQDataChannel::connectToDataSources()::dataElementCount_=%d\n",dataElementCount_);
|
||||
printf("ecmcDAQDataChannel::connectToDataSources()::dataElementCount_=%zu\n",dataElementCount_);
|
||||
dataSourcesLinked_ = 1;
|
||||
}
|
||||
|
||||
@@ -63,27 +63,33 @@ double ecmcDAQDataChannel::getType() {
|
||||
double ecmcDAQDataChannel::getData(int first){
|
||||
if(first) {
|
||||
currItemIndex_ = 0;
|
||||
} else {
|
||||
first = false;
|
||||
returnedDataCounter_= 0;;
|
||||
}
|
||||
|
||||
if(dataItems_[currItemIndex_]->empty() && currItemIndex_+1 < itemCounter_) {
|
||||
// get first index of next dataItem
|
||||
first = true;
|
||||
currItemIndex_++;
|
||||
// Get data from the first index
|
||||
dataItems_[currItemIndex_]->resetIndex(first);
|
||||
|
||||
if(dataItems_[currItemIndex_]->empty()){
|
||||
if(currItemIndex_ < itemCounter_ - 1) {
|
||||
first = true;
|
||||
currItemIndex_++;
|
||||
dataItems_[currItemIndex_]->resetIndex(first);
|
||||
} else {
|
||||
printf("ecmcDAQDataChannel::ERROR: No more data item in list but array still requires data (items %zu)\n",itemCounter_);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if(currItemIndex_ >= itemCounter_) {
|
||||
printf("No more data here!!!\n");
|
||||
printf("ecmcDAQDataChannel::ERROR: item counter out of range (items %zu)\n",itemCounter_);
|
||||
return 0;
|
||||
//throw std::runtime_error( "Item index out of range");
|
||||
}
|
||||
|
||||
returnedDataCounter_++;
|
||||
return dataItems_[currItemIndex_]->getData(first);
|
||||
return dataItems_[currItemIndex_]->getData();
|
||||
}
|
||||
|
||||
bool ecmcDAQDataChannel::empty(){
|
||||
return 1;
|
||||
return dataElementCount_>=returnedDataCounter_;
|
||||
bool ecmcDAQDataChannel::empty(){
|
||||
return returnedDataCounter_>=dataElementCount_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user