Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 498e752eb5 | |||
| 135d738eb0 | |||
| af41f31527 | |||
| b2b9ab5268 | |||
| bdfc2ff3cc | |||
| 411a083a77 | |||
| b0a55c7409 | |||
| 66f0001a39 | |||
| 7b35cb0f5c | |||
| 867c9f6a06 | |||
| e6d5589df7 | |||
| 3eccabce12 | |||
| ffc0add235 | |||
| 520521e07c | |||
| 1cd2c32b2d | |||
| 7963eccabf | |||
| fab4050ff4 | |||
| f9a1db806c | |||
| 57946a17e3 |
@@ -2,12 +2,12 @@
|
|||||||
record(waveform,"$(P)DAQ-${Name}-DataAct"){
|
record(waveform,"$(P)DAQ-${Name}-DataAct"){
|
||||||
info(asyn:FIFO, "1000")
|
info(asyn:FIFO, "1000")
|
||||||
field(DESC, "Data")
|
field(DESC, "Data")
|
||||||
field(PINI, "1")
|
|
||||||
field(DTYP, "asynFloat64ArrayIn")
|
field(DTYP, "asynFloat64ArrayIn")
|
||||||
field(INP, "@asyn(${PORT},$(ADDR=0),$(TIMEOUT=1000))plugin.daq.${Name}.data")
|
field(INP, "@asyn(${PORT},$(ADDR=0),$(TIMEOUT=1000))plugin.daq.${Name}.data")
|
||||||
field(FTVL, "DOUBLE")
|
field(FTVL, "DOUBLE")
|
||||||
field(NELM, "${NELM}")
|
field(NELM, "${NELM}")
|
||||||
field(SCAN, "I/O Intr")
|
field(SCAN, "I/O Intr")
|
||||||
|
field(FLNK, "${FLNK=''}")
|
||||||
field(TSE, "0")
|
field(TSE, "0")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
Db/ecmcPluginDAQ_chX-itmX.template
Normal file
4
Db/ecmcPluginDAQ_chX-itmX.template
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
record(stringin,"$(P)DAQ-${Name}-CH${CH}-${ITEM}-Info") {
|
||||||
|
field(DESC, "${DESC=empty}")
|
||||||
|
field(VAL, "${VAL=empty}")
|
||||||
|
}
|
||||||
4
Db/ecmcPluginDAQ_chX.template
Normal file
4
Db/ecmcPluginDAQ_chX.template
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
record(ai,"$(P)DAQ-${Name}-CH${CH}-Type") {
|
||||||
|
field(DESC, "${DESC=}")
|
||||||
|
field(VAL, "${TYPE=0}")
|
||||||
|
}
|
||||||
32
GNUmakefile
32
GNUmakefile
@@ -2,11 +2,13 @@ include /ioc/tools/driver.makefile
|
|||||||
|
|
||||||
MODULE = ecmc_plugin_daq
|
MODULE = ecmc_plugin_daq
|
||||||
|
|
||||||
BUILDCLASSES = Linux
|
# "Transfer" module name to plugin
|
||||||
ARCH_FILTER = deb10%
|
USR_CFLAGS +=-DECMC_PLUGIN_MODULE_NAME=${MODULE}
|
||||||
|
|
||||||
# Run 7.0.6 for now
|
BUILDCLASSES = Linux
|
||||||
EXCLUDE_VERSIONS+=3 7.0.5 7.0.6
|
ARCH_FILTER = deb10% deb12%
|
||||||
|
|
||||||
|
EXCLUDE_VERSIONS+=3 7.0.5 7.0.6 7.0.7
|
||||||
|
|
||||||
IGNORE_MODULES += asynMotor
|
IGNORE_MODULES += asynMotor
|
||||||
IGNORE_MODULES += motorBase
|
IGNORE_MODULES += motorBase
|
||||||
@@ -15,8 +17,26 @@ USR_CXXFLAGS += -std=c++17
|
|||||||
OPT_CXXFLAGS_YES = -O3
|
OPT_CXXFLAGS_YES = -O3
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
ECmasterECMC_VERSION = v1.1.0
|
ecmc_VERSION = 11.0
|
||||||
ecmc_VERSION = 9.4.0
|
|
||||||
|
# ethercat
|
||||||
|
# debian 12
|
||||||
|
EC_MASTER_VER = 1.6.3
|
||||||
|
EC_BASE_PATH = /ioc/NeedfulThings/EtherCAT/4epics/${EC_MASTER_VER}/
|
||||||
|
USR_CXXFLAGS_deb12-x86_64 += -I${EC_BASE_PATH}${T_A}/include/
|
||||||
|
USR_CXXFLAGS_deb12-x86_64 += -L${EC_BASE_PATH}${T_A}/lib/
|
||||||
|
|
||||||
|
LIB_SYS_LIBS += ethercat
|
||||||
|
USR_LDFLAGS_deb12-x86_64 += -Wl,-rpath=${EC_BASE_PATH}${T_A}/lib/
|
||||||
|
USR_LDFLAGS_deb12-x86_64 += -L ${EC_BASE_PATH}${T_A}/lib/
|
||||||
|
|
||||||
|
# debian 10
|
||||||
|
# note: EC_MASTER LIB does not depend on epics version hence use the 7.0.8 build..
|
||||||
|
USR_LDFLAGS_deb10-x86_64 += -lethercat
|
||||||
|
EC_MASTER_LIB = /ioc/NeedfulThings/EtherCAT/4epics/v1.1.0/R7.0.8/
|
||||||
|
USR_LDFLAGS_deb10-x86_64 += -Wl,-rpath=${EC_MASTER_LIB}lib/${T_A}
|
||||||
|
USR_LDFLAGS_deb10-x86_64 += -L ${EC_MASTER_LIB}lib/${T_A}
|
||||||
|
USR_CXXFLAGS_deb10-x86_64 += -I${EC_MASTER_LIB}/include/
|
||||||
|
|
||||||
BASE_DIR = .
|
BASE_DIR = .
|
||||||
SRC_DIR = $(BASE_DIR)/src
|
SRC_DIR = $(BASE_DIR)/src
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ ${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd, "TYPE=1234"
|
|||||||
|
|
||||||
### Adding a data item the a channel
|
### Adding a data item the a channel
|
||||||
|
|
||||||
Add a channel to the last created array with ecmcDAQAddDataItem.cmd. The command takes two parameters:
|
Add a channel to the last created array with ecmcDAQAddDataItem.cmd. The command takes three parameters:
|
||||||
1. PARAM : Parameter name to specify the data to read from ecmc, ec0.s1.analogInput01, ax1.poserr,...
|
1. PARAM : Parameter name to specify the data to read from ecmc, ec0.s1.analogInput01, ax1.poserr,...
|
||||||
2. FORMAT : Optional formatting of data:
|
2. FORMAT : Optional formatting of data:
|
||||||
```
|
```
|
||||||
@@ -71,6 +71,9 @@ Add a channel to the last created array with ecmcDAQAddDataItem.cmd. The command
|
|||||||
The calculated time then would correspond to the first data in the array recived.
|
The calculated time then would correspond to the first data in the array recived.
|
||||||
3 = time_ns_minus_period : Time: Raw value minus one period.
|
3 = time_ns_minus_period : Time: Raw value minus one period.
|
||||||
```
|
```
|
||||||
|
3. SEND_OLD : Optional to send old data (for scalars from previosu cycle, for arrays just one element shift)
|
||||||
|
|
||||||
|
|
||||||
### Finalizing a array
|
### Finalizing a array
|
||||||
When the configurations for an array is finalized then the ecmcDAQFinalizeArray.cmd must be called.
|
When the configurations for an array is finalized then the ecmcDAQFinalizeArray.cmd must be called.
|
||||||
The command will read the total array size (header plus data) from the plugin and then load the database with the waveform record (with correct NELM). The command takes the array name as a parameter ("NAME").
|
The command will read the total array size (header plus data) from the plugin and then load the database with the waveform record (with correct NELM). The command takes the array name as a parameter ("NAME").
|
||||||
|
|||||||
@@ -49,40 +49,40 @@ epicsEnvSet(NAME,ToEdwin) # PREFIX:DAQ-ToEdwin-DataAct
|
|||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddArray.cmd, "NAME=${NAME}"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddArray.cmd, "NAME=${NAME}"
|
||||||
|
|
||||||
#- EL5021: Incremental sin/cos 1vpp
|
#- EL5021: Incremental sin/cos 1vpp
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd, "TYPE=10"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd, "TYPE=10,DESC='Sin/Cos 1VPP'"
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s1.positionActual01"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s1.positionActual01"
|
||||||
|
|
||||||
#- EL5112: Incremental (treat as array, but same timestamp twice, the second actualy not used)
|
#- EL5112: Incremental (treat as array, but same timestamp twice, the second actualy not used)
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd, "TYPE=1001"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd, "TYPE=1001,DESC='Incremental'"
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s2.timestamp01, FORMAT=1"
|
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s2.timestamp01, FORMAT=1"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s2.timestamp01, FORMAT=1"
|
||||||
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s2.timestamp01, FORMAT=1, SEND_OLD=1"
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s2.positionActual01"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s2.positionActual01"
|
||||||
|
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd, "TYPE=11"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd, "TYPE=11,DESC='Incremental'"
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s2.positionActual01"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s2.positionActual01"
|
||||||
|
|
||||||
#- EL5042: BISS-C ch 01
|
#- EL5042: BISS-C ch 01
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd, "TYPE=12"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd, "TYPE=12,DESC='BISS-C'"
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s3.positionActual01"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s3.positionActual01"
|
||||||
|
|
||||||
#- EL5101-0011: Incremental oversampling
|
#- EL5101-0011: Incremental oversampling
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd, "TYPE=1000"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd, "TYPE=1000,DESC='Incremental Oversampling'"
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s4.nextSyncTime, FORMAT=2"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s4.nextSyncTime, FORMAT=2"
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s4.nextSyncTime, FORMAT=1"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s4.nextSyncTime, FORMAT=1"
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s4.mm.positionActualArray01"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s4.mm.positionActualArray01"
|
||||||
|
|
||||||
#- EL1252-0050: timestamped input ch 01
|
#- EL1252-0050: timestamped input ch 01
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd, "TYPE=1"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd, "TYPE=1,DESC='Timestamped input 5V'"
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s6.timestampLatchPositive01 ,FORMAT=1"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s6.timestampLatchPositive01 ,FORMAT=1"
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s6.timestampLatchNegative01 ,FORMAT=1"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s6.timestampLatchNegative01 ,FORMAT=1"
|
||||||
|
|
||||||
#- ELM3602-0002: Analog input ch 01
|
#- ELM3602-0002: Analog input ch 01
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd, "TYPE=1000"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd, "TYPE=1000,DESC='Analog input +-10V'"
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s7.timestamp01, FORMAT=2"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s7.timestamp01, FORMAT=2"
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s7.timestamp01, FORMAT=1"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s7.timestamp01, FORMAT=1"
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s7.mm.analogInputArray01"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s7.mm.analogInputArray01"
|
||||||
|
|
||||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQFinalizeArray.cmd "NAME=${NAME}"
|
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQFinalizeArray.cmd "NAME=${NAME},DATA_FLNK=''"
|
||||||
|
|
||||||
#- To check result use camon -t c6025a:DAQ-ToEdwin-DataAct
|
#- To check result use camon -t c6025a:DAQ-ToEdwin-DataAct
|
||||||
|
|
||||||
|
|||||||
@@ -17,3 +17,4 @@
|
|||||||
|
|
||||||
#- Name , Asyn port name
|
#- Name , Asyn port name
|
||||||
ecmcDAQAddArray(${NAME},ECMC.PLUGIN.DAQ.${NAME})
|
ecmcDAQAddArray(${NAME},ECMC.PLUGIN.DAQ.${NAME})
|
||||||
|
epicsEnvSet(ECMC_DAQ_CURR_CH,-1)
|
||||||
|
|||||||
@@ -12,7 +12,12 @@
|
|||||||
#-
|
#-
|
||||||
#- Arguments
|
#- Arguments
|
||||||
#- TYPE : Type (number of data type)
|
#- TYPE : Type (number of data type)
|
||||||
|
#- NAME : Name of DAQ array object
|
||||||
|
#- DESC : Optional description of channel
|
||||||
#-
|
#-
|
||||||
#-################################################################################
|
#-################################################################################
|
||||||
|
|
||||||
ecmcDAQAddChannel(${TYPE})
|
ecmcDAQAddChannel(${TYPE})
|
||||||
|
epicsEnvSet(ECMC_DAQ_CURR_ITM,-1)
|
||||||
|
ecmcEpicsEnvSetCalc("ECMC_DAQ_CURR_CH" ,${ECMC_DAQ_CURR_CH=-1}+1,"%02d")
|
||||||
|
dbLoadRecords(ecmcPluginDAQ_chX.template,"P=${ECMC_PREFIX},Name=${NAME},PORT=ECMC.PLUGIN.DAQ.${NAME},CH=${ECMC_DAQ_CURR_CH=00},TYPE=${TYPE=0},DESC=${DESC=}")
|
||||||
|
|||||||
@@ -19,7 +19,11 @@
|
|||||||
#- Useful for oversampling slaves where normally the nextsync time is available.\n");
|
#- Useful for oversampling slaves where normally the nextsync time is available.\n");
|
||||||
#- The calculated time then would correspond to the first data in the array recived.\n");
|
#- The calculated time then would correspond to the first data in the array recived.\n");
|
||||||
#- 3 = time_ns_minus_period : Time: Raw value minus one period.\n");
|
#- 3 = time_ns_minus_period : Time: Raw value minus one period.\n");
|
||||||
|
#- SEND_OLD : 1 = Send one element old data (for scalars from last cycle, for arrays shift one element), defaults to 0 (send fresh data)
|
||||||
|
#- NAME : Name of DAQ array object
|
||||||
#-
|
#-
|
||||||
#-################################################################################
|
#-################################################################################
|
||||||
|
|
||||||
ecmcDAQAddItem(${PARAM},${FORMAT=0})
|
ecmcDAQAddItem(${PARAM},${FORMAT=0},${SEND_OLD=0})
|
||||||
|
ecmcEpicsEnvSetCalc("ECMC_DAQ_CURR_ITM" ,${ECMC_DAQ_CURR_ITM=-1}+1,"%02d")
|
||||||
|
dbLoadRecords(ecmcPluginDAQ_chX-itmX.template,"P=${ECMC_PREFIX},Name=${NAME},PORT=ECMC.PLUGIN.DAQ.${NAME},CH=${ECMC_DAQ_CURR_CH=00},ITEM=${ECMC_DAQ_CURR_ITM=00},VAL=${PARAM=empty},DESC='FORMAT=${FORMAT=0},SEND_OLD=${SEND_OLD=0}'")
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
#-###############################################################################
|
#-###############################################################################
|
||||||
#-
|
#-
|
||||||
#- Arguments
|
#- Arguments
|
||||||
#- NAME : Name of DAQ array
|
#- NAME : Name of DAQ array
|
||||||
|
#- DATA_FLNK : Forward link from data array (optional, default to '')
|
||||||
#-
|
#-
|
||||||
#-################################################################################
|
#-################################################################################
|
||||||
|
|
||||||
@@ -24,5 +25,7 @@ ecmcIf("${DAQ_NELM=-1}<0")
|
|||||||
${IF_TRUE}ecmcExit : Failed read DAQ array NELM
|
${IF_TRUE}ecmcExit : Failed read DAQ array NELM
|
||||||
ecmcEndIf()
|
ecmcEndIf()
|
||||||
|
|
||||||
dbLoadRecords(ecmcPluginDAQ.template,"P=${ECMC_PREFIX},Name=${NAME},NELM=${DAQ_NELM},PORT=ECMC.PLUGIN.DAQ.${NAME}")
|
dbLoadRecords(ecmcPluginDAQ.template,"P=${ECMC_PREFIX},Name=${NAME},NELM=${DAQ_NELM},PORT=ECMC.PLUGIN.DAQ.${NAME},FLNK=${DATA_FLNK=''}")
|
||||||
epicsEnvUnset(DAQ_NELM)
|
epicsEnvUnset(DAQ_NELM)
|
||||||
|
epicsEnvUnset(ECMC_DAQ_CURR_CH)
|
||||||
|
epicsEnvUnset(ECMC_DAQ_CURR_ITM)
|
||||||
|
|||||||
@@ -35,16 +35,19 @@ enum class ecmcDAQDataFormat { raw = 0,
|
|||||||
* Useful for oversampling slaves where normally the nextsync time is available.
|
* Useful for oversampling slaves where normally the nextsync time is available.
|
||||||
* The calculated time then would correspond to the first data in the array recived.
|
* The calculated time then would correspond to the first data in the array recived.
|
||||||
* 3=time_ns_minus_period : Time: Raw value minus one period.
|
* 3=time_ns_minus_period : Time: Raw value minus one period.
|
||||||
|
* sendOneCycleOldData : Send data from previous cycle (or for arrays elements are shifted one index). To be used by Edwin to trigger on timechange for incremntal timestamped cards..
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
class ecmcDAQChannelItem {
|
class ecmcDAQChannelItem {
|
||||||
public:
|
public:
|
||||||
ecmcDAQChannelItem(const char* name, ecmcDAQDataFormat format) {
|
ecmcDAQChannelItem(const char* name, ecmcDAQDataFormat format, int sendOneCycleOldData) {
|
||||||
dataItem_ = NULL;
|
dataItem_ = NULL;
|
||||||
dataItemInfo_ = NULL;
|
dataItemInfo_ = NULL;
|
||||||
name_ = name;
|
name_ = name;
|
||||||
cstrName_ = strdup(name);
|
cstrName_ = strdup(name);
|
||||||
format_ = format; // micro s in int32
|
format_ = format; // micro s in int32
|
||||||
|
sendOneCycleOldData_ = sendOneCycleOldData; // Will only work for scalars (if arrays the elements are shifted once)
|
||||||
sampleTimeCompensation_ = 0;
|
sampleTimeCompensation_ = 0;
|
||||||
dataIndexToReturn_ = 0;
|
dataIndexToReturn_ = 0;
|
||||||
dataElementCount_ = 0;
|
dataElementCount_ = 0;
|
||||||
@@ -60,6 +63,7 @@ class ecmcDAQChannelItem {
|
|||||||
float32Ptr_ = NULL;
|
float32Ptr_ = NULL;
|
||||||
float64Ptr_ = NULL;
|
float64Ptr_ = NULL;
|
||||||
dataType_ = ECMC_EC_NONE;
|
dataType_ = ECMC_EC_NONE;
|
||||||
|
dataOld_ = 0;
|
||||||
printf("ecmcDAQChannelItem: Created new item %s, format %d\n",name,(int)format);
|
printf("ecmcDAQChannelItem: Created new item %s, format %d\n",name,(int)format);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,13 +208,21 @@ class ecmcDAQChannelItem {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if(dataIndexToReturn_>0) {
|
|
||||||
// printf("%s[%zu] data = %lf\n",cstrName_,dataIndexToReturn_,data);
|
|
||||||
//}
|
|
||||||
|
|
||||||
dataIndexToReturn_++;
|
dataIndexToReturn_++;
|
||||||
|
|
||||||
return formatData(data,time);
|
double freshData = formatData(data,time);
|
||||||
|
double dataToSend = 0;
|
||||||
|
|
||||||
|
if(sendOneCycleOldData_) {
|
||||||
|
dataToSend = dataOld_;
|
||||||
|
} else {
|
||||||
|
dataToSend = freshData;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store the fresh data here
|
||||||
|
dataOld_ = freshData;
|
||||||
|
|
||||||
|
return dataToSend;
|
||||||
}
|
}
|
||||||
|
|
||||||
double formatData(double data, uint64_t time){
|
double formatData(double data, uint64_t time){
|
||||||
@@ -274,6 +286,8 @@ class ecmcDAQChannelItem {
|
|||||||
uint64_t *uint64Ptr_;
|
uint64_t *uint64Ptr_;
|
||||||
float *float32Ptr_;
|
float *float32Ptr_;
|
||||||
double *float64Ptr_;
|
double *float64Ptr_;
|
||||||
|
int sendOneCycleOldData_;
|
||||||
|
double dataOld_;
|
||||||
};
|
};
|
||||||
#endif /* ECMC_DAQ_CHANNEL_ITEM_H_ */
|
#endif /* ECMC_DAQ_CHANNEL_ITEM_H_ */
|
||||||
|
|
||||||
|
|||||||
@@ -62,9 +62,9 @@ void ecmcDAQDataArray::addChannel(int type) {
|
|||||||
channelCounter_++;
|
channelCounter_++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ecmcDAQDataArray::addDataItemToChannel(const char* name, int format) {
|
void ecmcDAQDataArray::addDataItemToChannel(const char* name, int format, int oldData) {
|
||||||
// Always add to last added channel
|
// Always add to last added channel
|
||||||
dataChannels_.back()->addDataItem(name, format);
|
dataChannels_.back()->addDataItem(name, format, oldData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ecmcDAQDataArray::connectToDataSources() {
|
void ecmcDAQDataArray::connectToDataSources() {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class ecmcDAQDataArray : public asynPortDriver {
|
|||||||
void connectToDataSources();
|
void connectToDataSources();
|
||||||
void execute();
|
void execute();
|
||||||
void addChannel(int type);
|
void addChannel(int type);
|
||||||
void addDataItemToChannel(const char* name, int format); // Always add to last added channel
|
void addDataItemToChannel(const char* name, int format, int oldData); // Always add to last added channel
|
||||||
void setEnable(int enable);
|
void setEnable(int enable);
|
||||||
size_t getArraySize();
|
size_t getArraySize();
|
||||||
int validate();
|
int validate();
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ ecmcDAQDataChannel::ecmcDAQDataChannel(int type){
|
|||||||
ecmcDAQDataChannel::~ecmcDAQDataChannel() {
|
ecmcDAQDataChannel::~ecmcDAQDataChannel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ecmcDAQDataChannel::addDataItem(const char* name, int format) {
|
void ecmcDAQDataChannel::addDataItem(const char* name, int format,int oldData) {
|
||||||
dataItems_.push_back(new ecmcDAQChannelItem(name, (ecmcDAQDataFormat)format));
|
dataItems_.push_back(new ecmcDAQChannelItem(name, (ecmcDAQDataFormat)format, oldData));
|
||||||
itemCounter_++;
|
itemCounter_++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class ecmcDAQDataChannel {
|
|||||||
ecmcDAQDataChannel(int type);
|
ecmcDAQDataChannel(int type);
|
||||||
~ecmcDAQDataChannel();
|
~ecmcDAQDataChannel();
|
||||||
void connectToDataSources();
|
void connectToDataSources();
|
||||||
void addDataItem(const char* name, int format);
|
void addDataItem(const char* name, int format, int oldData);
|
||||||
size_t getDataElementCount();
|
size_t getDataElementCount();
|
||||||
double getData(int first);
|
double getData(int first);
|
||||||
bool empty();
|
bool empty();
|
||||||
|
|||||||
@@ -91,9 +91,9 @@ int createDAQChannel(int type) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int createDAQItem(const char* name, int type) {
|
int createDAQItem(const char* name, int type, int oldData) {
|
||||||
try {
|
try {
|
||||||
arrays.back()->addDataItemToChannel(name,type);
|
arrays.back()->addDataItemToChannel(name,type,oldData);
|
||||||
}
|
}
|
||||||
catch(std::exception& e) {
|
catch(std::exception& e) {
|
||||||
printf("Exception: %s. Plugin will unload.\n",e.what());
|
printf("Exception: %s. Plugin will unload.\n",e.what());
|
||||||
@@ -261,7 +261,7 @@ static void initCallFunc_1(const iocshArgBuf *args) {
|
|||||||
*/
|
*/
|
||||||
void ecmcAddDAQItemHelp() {
|
void ecmcAddDAQItemHelp() {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf(" Use ecmcAddDAQItem(<dataitem_name>, <format>)\n");
|
printf(" Use ecmcAddDAQItem(<dataitem_name>, <format>,<send_one_cycle_old_data>)\n");
|
||||||
printf(" <dataitem_name> : Data item name ex: 'ec0.s11.analogInput01' .\n");
|
printf(" <dataitem_name> : Data item name ex: 'ec0.s11.analogInput01' .\n");
|
||||||
printf(" <format> : Optional format conversion of data:.\n");
|
printf(" <format> : Optional format conversion of data:.\n");
|
||||||
printf(" 0 = raw : Take raw value (do not apply special format)\n");
|
printf(" 0 = raw : Take raw value (do not apply special format)\n");
|
||||||
@@ -270,17 +270,18 @@ void ecmcAddDAQItemHelp() {
|
|||||||
printf(" Useful for oversampling slaves where normally the nextsync time is available.\n");
|
printf(" Useful for oversampling slaves where normally the nextsync time is available.\n");
|
||||||
printf(" The calculated time then would correspond to the first data in the array recived.\n");
|
printf(" The calculated time then would correspond to the first data in the array recived.\n");
|
||||||
printf(" 3 = time_ns_minus_period : Time: Raw value minus one period.\n");
|
printf(" 3 = time_ns_minus_period : Time: Raw value minus one period.\n");
|
||||||
|
printf(" <send_one_cycle_old_data> : Send data from the previous cycle (for scalars). If waveform the elemtes will be shifted one index");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int ecmcAddDAQItem(const char* name, int format) {
|
int ecmcAddDAQItem(const char* name, int format, int oldData) {
|
||||||
if(strcmp(name,"-h") == 0 || strcmp(name,"--help") == 0 ) {
|
if(strcmp(name,"-h") == 0 || strcmp(name,"--help") == 0 ) {
|
||||||
ecmcAddDAQItemHelp();
|
ecmcAddDAQItemHelp();
|
||||||
return asynSuccess;
|
return asynSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return createDAQItem(name,format);
|
return createDAQItem(name,format, oldData);
|
||||||
}
|
}
|
||||||
catch(std::exception& e) {
|
catch(std::exception& e) {
|
||||||
printf("Exception: %s. Create DAQ item failed.\n",e.what());
|
printf("Exception: %s. Create DAQ item failed.\n",e.what());
|
||||||
@@ -296,12 +297,16 @@ static const iocshArg initArg0_2 =
|
|||||||
static const iocshArg initArg1_2 =
|
static const iocshArg initArg1_2 =
|
||||||
{ "Type", iocshArgInt };
|
{ "Type", iocshArgInt };
|
||||||
|
|
||||||
static const iocshArg *const initArgs_2[] = { &initArg0_2,
|
static const iocshArg initArg2_2 =
|
||||||
&initArg1_2};
|
{ "Old value", iocshArgInt };
|
||||||
|
|
||||||
static const iocshFuncDef initFuncDef_2 = { "ecmcDAQAddItem", 2, initArgs_2};
|
static const iocshArg *const initArgs_2[] = { &initArg0_2,
|
||||||
|
&initArg1_2,
|
||||||
|
&initArg2_2};
|
||||||
|
|
||||||
|
static const iocshFuncDef initFuncDef_2 = { "ecmcDAQAddItem", 3, initArgs_2};
|
||||||
static void initCallFunc_2(const iocshArgBuf *args) {
|
static void initCallFunc_2(const iocshArgBuf *args) {
|
||||||
ecmcAddDAQItem(args[0].sval,args[1].ival);
|
ecmcAddDAQItem(args[0].sval, args[1].ival, args[2].ival);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ static char* lastConfStr = NULL;
|
|||||||
static int alreadyLoaded = 0;
|
static int alreadyLoaded = 0;
|
||||||
|
|
||||||
/** Optional.
|
/** Optional.
|
||||||
* Will be called once after successfull load into ecmc.
|
* Will be called once after successful load into ecmc.
|
||||||
* Return value other than 0 will be considered error.
|
* Return value other than 0 will be considered error.
|
||||||
* configStr can be used for configuration parameters.
|
* configStr can be used for configuration parameters.
|
||||||
**/
|
**/
|
||||||
int daqConstruct(char *configStr)
|
static int daqConstruct(char *configStr)
|
||||||
{
|
{
|
||||||
if(alreadyLoaded) {
|
if(alreadyLoaded) {
|
||||||
printf("Error: Plugin ecmc_plugin_daq already loaded and can only be loaded once.");
|
printf("Error: Plugin ecmc_plugin_daq already loaded and can only be loaded once.");
|
||||||
@@ -51,28 +51,29 @@ int daqConstruct(char *configStr)
|
|||||||
/** Optional function.
|
/** Optional function.
|
||||||
* Will be called once at unload.
|
* Will be called once at unload.
|
||||||
**/
|
**/
|
||||||
void daqDestruct(void)
|
static void daqDestruct(void)
|
||||||
{
|
{
|
||||||
deleteAllDAQs();
|
// Segfaults here during destruction?! need to check..
|
||||||
if(lastConfStr){
|
//deleteAllDAQs();
|
||||||
free(lastConfStr);
|
//if(lastConfStr){
|
||||||
}
|
// free(lastConfStr);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Optional function.
|
/** Optional function.
|
||||||
* Will be called each realtime cycle if definded
|
* Will be called each realtime cycle if defined
|
||||||
* ecmcError: Error code of ecmc. Makes it posible for
|
* ecmcError: Error code of ecmc. Makes it possible for
|
||||||
* this plugin to react on ecmc errors
|
* this plugin to react on ecmc errors
|
||||||
* Return value other than 0 will be considered to be an error code in ecmc.
|
* Return value other than 0 will be considered to be an error code in ecmc.
|
||||||
**/
|
**/
|
||||||
int daqRealtime(int ecmcError)
|
static int daqRealtime(int ecmcError)
|
||||||
{
|
{
|
||||||
lastEcmcError = ecmcError;
|
lastEcmcError = ecmcError;
|
||||||
return executeDAQs();
|
return executeDAQs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int daqEnterRT(){
|
static int daqEnterRT(){
|
||||||
return validateDAQs(); //linkDataToDAQs();
|
return validateDAQs(); //linkDataToDAQs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,31 +81,16 @@ int daqEnterRT(){
|
|||||||
* Will be called once just before leaving realtime mode
|
* Will be called once just before leaving realtime mode
|
||||||
* Return value other than 0 will be considered error.
|
* Return value other than 0 will be considered error.
|
||||||
**/
|
**/
|
||||||
int daqExitRT(void){
|
static int daqExitRT(void){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Plc function for clear of buffers
|
|
||||||
// double daq_clear(double index) {
|
|
||||||
// return (double)clearDAQ((int)index);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Plc function for enable
|
|
||||||
//double daq_enable(double index, double enable) {
|
|
||||||
// return 0; //(double)enableDAQ((int)index, (int)enable);
|
|
||||||
//}
|
|
||||||
|
|
||||||
// // Plc function for trigg new measurement (will clear buffers)
|
|
||||||
// double daq_trigg(double index) {
|
|
||||||
// return (double)triggDAQ((int)index);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Register data for plugin so ecmc know what to use
|
// Register data for plugin so ecmc know what to use
|
||||||
struct ecmcPluginData pluginDataDef = {
|
static struct ecmcPluginData pluginDataDef = {
|
||||||
// Allways use ECMC_PLUG_VERSION_MAGIC
|
// Allways use ECMC_PLUG_VERSION_MAGIC
|
||||||
.ifVersion = ECMC_PLUG_VERSION_MAGIC,
|
.ifVersion = ECMC_PLUG_VERSION_MAGIC,
|
||||||
// Name
|
// Name
|
||||||
.name = "ecmcPlugin_DAQ",
|
.name = "ecmc_plugin_daq",
|
||||||
// Description
|
// Description
|
||||||
.desc = "DAQ plugin for use with ecmc.",
|
.desc = "DAQ plugin for use with ecmc.",
|
||||||
// Option description
|
// Option description
|
||||||
@@ -123,28 +109,6 @@ struct ecmcPluginData pluginDataDef = {
|
|||||||
.realtimeExitFnc = daqExitRT,
|
.realtimeExitFnc = daqExitRT,
|
||||||
// PLC funcs
|
// PLC funcs
|
||||||
.funcs[0] = {0},
|
.funcs[0] = {0},
|
||||||
// { /*----fft_clear----*/
|
|
||||||
// // Function name (this is the name you use in ecmc plc-code)
|
|
||||||
// .funcName = "daq_enable",
|
|
||||||
// // Function description
|
|
||||||
// .funcDesc = "daq_enable(index,enable) : Enable/disaable daq[index].",
|
|
||||||
// /**
|
|
||||||
// * 12 different prototypes allowed (only doubles since reg in plc).
|
|
||||||
// * Only funcArg${argCount} func shall be assigned the rest set to NULL.
|
|
||||||
// **/
|
|
||||||
// .funcArg0 = NULL,
|
|
||||||
// .funcArg1 = NULL,
|
|
||||||
// .funcArg2 = daq_enable,
|
|
||||||
// .funcArg3 = NULL,
|
|
||||||
// .funcArg4 = NULL,
|
|
||||||
// .funcArg5 = NULL,
|
|
||||||
// .funcArg6 = NULL,
|
|
||||||
// .funcArg7 = NULL,
|
|
||||||
// .funcArg8 = NULL,
|
|
||||||
// .funcArg9 = NULL,
|
|
||||||
// .funcArg10 = NULL,
|
|
||||||
// .funcGenericObj = NULL,
|
|
||||||
// },
|
|
||||||
.consts[0] = {0}, // last element set all to zero..
|
.consts[0] = {0}, // last element set all to zero..
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,15 @@
|
|||||||
#-###############################################################################
|
#-###############################################################################
|
||||||
#-
|
#-
|
||||||
#- Arguments
|
#- Arguments
|
||||||
#- PLUGIN_ID : Id of plugin to load (mandatory)
|
#- PLUGIN_ID : Id of plugin to load (optional)
|
||||||
#-
|
#-
|
||||||
#################################################################################
|
#################################################################################
|
||||||
|
|
||||||
#- Load plugin:
|
#- Load plugin:
|
||||||
|
|
||||||
epicsEnvSet(ECMC_PLUGIN_FILNAME,"$(ecmc_plugin_daq_DIR)lib/${EPICS_HOST_ARCH=linux-x86_64}/libecmc_plugin_daq.so")
|
epicsEnvSet(ECMC_PLUGIN_FILNAME,"$(ecmc_plugin_daq_DIR)lib/${EPICS_HOST_ARCH=linux-x86_64}/libecmc_plugin_daq.so")
|
||||||
${SCRIPTEXEC} ${ecmccfg_DIR}loadPlugin.cmd, "PLUGIN_ID=${PLUGIN_ID}, FILE='${ECMC_PLUGIN_FILNAME}' , CONFIG='NOT USED',REPORT=1"
|
ecmcIf("${PLUGIN_ID=-1}=-1")
|
||||||
|
${IF_TRUE}${SCRIPTEXEC} ${ecmccfg_DIR}loadPlugin.cmd, "FILE='${ECMC_PLUGIN_FILNAME}' , CONFIG='NOT USED',REPORT=1"
|
||||||
|
#else
|
||||||
|
${IF_FALSE}${SCRIPTEXEC} ${ecmccfg_DIR}loadPlugin.cmd, "PLUGIN_ID=${PLUGIN_ID}, FILE='${ECMC_PLUGIN_FILNAME}' , CONFIG='NOT USED',REPORT=1"
|
||||||
|
ecmcEndIf()
|
||||||
|
|||||||
Reference in New Issue
Block a user