Merge branch 'master' of git.psi.ch:epics_ioc_modules/ecmc_plugin_daq
This commit is contained in:
@@ -26,6 +26,6 @@ SOURCES += $(SRC_DIR)/ecmcDAQDataArray.cpp
|
||||
SOURCES += $(SRC_DIR)/ecmcDAQDataChannel.cpp
|
||||
SOURCES += $(SRC_DIR)/ecmcDAQWrap.cpp
|
||||
SOURCES += $(SRC_DIR)/ecmcPluginDAQ.c
|
||||
|
||||
DBDS += $(SRC_DIR)/ecmcDAQPlg.dbd
|
||||
TEMPLATES += $(wildcard $(DB_DIR)/*.template)
|
||||
SCRIPTS += ./startup.cmd
|
||||
@@ -60,6 +60,7 @@ class ecmcDAQChannelItem {
|
||||
float32Ptr_ = NULL;
|
||||
float64Ptr_ = NULL;
|
||||
dataType_ = ECMC_EC_NONE;
|
||||
printf("ecmcDAQChannelItem: Created new item %s, format %d\n",name,(int)format);
|
||||
}
|
||||
|
||||
~ecmcDAQChannelItem() {
|
||||
@@ -98,34 +99,22 @@ 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;
|
||||
}
|
||||
|
||||
@@ -213,12 +202,10 @@ class ecmcDAQChannelItem {
|
||||
break;
|
||||
}
|
||||
dataIndexToReturn_++;
|
||||
|
||||
|
||||
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,6 +225,7 @@ class ecmcDAQChannelItem {
|
||||
;
|
||||
break;
|
||||
}
|
||||
//printf("DATA %s = %lf\n",cstrName_, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -154,14 +154,13 @@ 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()
|
||||
buffer_[index]=(*pDataCh)->getData(1);
|
||||
index++;
|
||||
while(!(*pDataCh)->empty()) {
|
||||
buffer_[index]=(*pDataCh)->getData(0);
|
||||
first = 1;
|
||||
for(size_t i = 0 ; i < (*pDataCh)->getDataElementCount(); i++) {
|
||||
buffer_[index]=(*pDataCh)->getData(first);
|
||||
first = 0;
|
||||
}
|
||||
}
|
||||
updateAsyn();
|
||||
|
||||
@@ -48,7 +48,7 @@ void ecmcDAQDataChannel::connectToDataSources() {
|
||||
(*pDataItem)->connectToSource();
|
||||
dataElementCount_ = dataElementCount_ + (*pDataItem)->getDataElementCount();
|
||||
}
|
||||
|
||||
printf("ecmcDAQDataChannel::connectToDataSources()::dataElementCount_=%zu\n",dataElementCount_);
|
||||
dataSourcesLinked_ = 1;
|
||||
}
|
||||
|
||||
@@ -63,26 +63,33 @@ double ecmcDAQDataChannel::getType() {
|
||||
double ecmcDAQDataChannel::getData(int first){
|
||||
if(first) {
|
||||
currItemIndex_ = 0;
|
||||
} else {
|
||||
first = false;
|
||||
returnedDataCounter_= 0;;
|
||||
}
|
||||
|
||||
if(dataItems_[currItemIndex_]->empty()) {
|
||||
// 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");
|
||||
if(currItemIndex_ >= itemCounter_) {
|
||||
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 dataElementCount_>=returnedDataCounter_;
|
||||
bool ecmcDAQDataChannel::empty(){
|
||||
return returnedDataCounter_>=dataElementCount_;
|
||||
}
|
||||
|
||||
1
src/ecmcDAQPlg.dbd
Normal file
1
src/ecmcDAQPlg.dbd
Normal file
@@ -0,0 +1 @@
|
||||
registrar("ecmcDAQPlgRegister")
|
||||
Reference in New Issue
Block a user