Compare commits
10 Commits
1.1.0
...
new_plg_co
| Author | SHA1 | Date | |
|---|---|---|---|
| b0a55c7409 | |||
| 66f0001a39 | |||
| e6d5589df7 | |||
| 3eccabce12 | |||
| ffc0add235 | |||
| 520521e07c | |||
| 1cd2c32b2d | |||
| 7963eccabf | |||
| fab4050ff4 | |||
| f9a1db806c |
@@ -2,12 +2,12 @@
|
||||
record(waveform,"$(P)DAQ-${Name}-DataAct"){
|
||||
info(asyn:FIFO, "1000")
|
||||
field(DESC, "Data")
|
||||
field(PINI, "1")
|
||||
field(DTYP, "asynFloat64ArrayIn")
|
||||
field(INP, "@asyn(${PORT},$(ADDR=0),$(TIMEOUT=1000))plugin.daq.${Name}.data")
|
||||
field(FTVL, "DOUBLE")
|
||||
field(NELM, "${NELM}")
|
||||
field(SCAN, "I/O Intr")
|
||||
field(FLNK, "${FLNK=''}")
|
||||
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}")
|
||||
}
|
||||
@@ -2,6 +2,9 @@ include /ioc/tools/driver.makefile
|
||||
|
||||
MODULE = ecmc_plugin_daq
|
||||
|
||||
# "Transfer" module name to plugin
|
||||
USR_CFLAGS +=-DECMC_PLUGIN_MODULE_NAME=${MODULE}
|
||||
|
||||
BUILDCLASSES = Linux
|
||||
ARCH_FILTER = deb10%
|
||||
|
||||
@@ -16,7 +19,7 @@ OPT_CXXFLAGS_YES = -O3
|
||||
|
||||
# dependencies
|
||||
ECmasterECMC_VERSION = v1.1.0
|
||||
ecmc_VERSION = 9.4.0
|
||||
ecmc_VERSION = v10.0.0_RC1
|
||||
|
||||
BASE_DIR = .
|
||||
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
|
||||
|
||||
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,...
|
||||
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.
|
||||
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
|
||||
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").
|
||||
|
||||
@@ -49,40 +49,40 @@ epicsEnvSet(NAME,ToEdwin) # PREFIX:DAQ-ToEdwin-DataAct
|
||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddArray.cmd, "NAME=${NAME}"
|
||||
|
||||
#- 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"
|
||||
|
||||
#- 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, SEND_OLD=1"
|
||||
${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"
|
||||
|
||||
#- 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"
|
||||
|
||||
#- 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=1"
|
||||
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd, "PARAM=ec0.s4.mm.positionActualArray01"
|
||||
|
||||
#- 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.timestampLatchNegative01 ,FORMAT=1"
|
||||
|
||||
#- 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=1"
|
||||
${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
|
||||
|
||||
|
||||
@@ -17,3 +17,4 @@
|
||||
|
||||
#- Name , Asyn port name
|
||||
ecmcDAQAddArray(${NAME},ECMC.PLUGIN.DAQ.${NAME})
|
||||
epicsEnvSet(ECMC_DAQ_CURR_CH,-1)
|
||||
|
||||
@@ -12,7 +12,12 @@
|
||||
#-
|
||||
#- Arguments
|
||||
#- TYPE : Type (number of data type)
|
||||
#- NAME : Name of DAQ array object
|
||||
#- DESC : Optional description of channel
|
||||
#-
|
||||
#-################################################################################
|
||||
|
||||
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=}")
|
||||
|
||||
@@ -20,7 +20,10 @@
|
||||
#- 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");
|
||||
#- 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},${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,8 +11,9 @@
|
||||
#-###############################################################################
|
||||
#-
|
||||
#- Arguments
|
||||
#- NAME : Name of DAQ array
|
||||
#-
|
||||
#- NAME : Name of DAQ array
|
||||
#- DATA_FLNK : Forward link from data array (optional, default to '')
|
||||
#-
|
||||
#-################################################################################
|
||||
|
||||
#- Connect to sources in order to know NELM.. Data sources must be known before added with the scripts..
|
||||
@@ -24,5 +25,7 @@ ecmcIf("${DAQ_NELM=-1}<0")
|
||||
${IF_TRUE}ecmcExit : Failed read DAQ array NELM
|
||||
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(ECMC_DAQ_CURR_CH)
|
||||
epicsEnvUnset(ECMC_DAQ_CURR_ITM)
|
||||
|
||||
@@ -32,11 +32,11 @@ static char* lastConfStr = NULL;
|
||||
static int alreadyLoaded = 0;
|
||||
|
||||
/** 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.
|
||||
* configStr can be used for configuration parameters.
|
||||
**/
|
||||
int daqConstruct(char *configStr)
|
||||
static int daqConstruct(char *configStr)
|
||||
{
|
||||
if(alreadyLoaded) {
|
||||
printf("Error: Plugin ecmc_plugin_daq already loaded and can only be loaded once.");
|
||||
@@ -51,28 +51,29 @@ int daqConstruct(char *configStr)
|
||||
/** Optional function.
|
||||
* Will be called once at unload.
|
||||
**/
|
||||
void daqDestruct(void)
|
||||
static void daqDestruct(void)
|
||||
{
|
||||
deleteAllDAQs();
|
||||
if(lastConfStr){
|
||||
free(lastConfStr);
|
||||
}
|
||||
// Segfaults here during destruction?! need to check..
|
||||
//deleteAllDAQs();
|
||||
//if(lastConfStr){
|
||||
// free(lastConfStr);
|
||||
//}
|
||||
}
|
||||
|
||||
/** Optional function.
|
||||
* Will be called each realtime cycle if definded
|
||||
* ecmcError: Error code of ecmc. Makes it posible for
|
||||
* Will be called each realtime cycle if defined
|
||||
* ecmcError: Error code of ecmc. Makes it possible for
|
||||
* this plugin to react on ecmc errors
|
||||
* 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;
|
||||
return executeDAQs();
|
||||
}
|
||||
|
||||
|
||||
int daqEnterRT(){
|
||||
static int daqEnterRT(){
|
||||
return validateDAQs(); //linkDataToDAQs();
|
||||
}
|
||||
|
||||
@@ -80,31 +81,16 @@ int daqEnterRT(){
|
||||
* Will be called once just before leaving realtime mode
|
||||
* Return value other than 0 will be considered error.
|
||||
**/
|
||||
int daqExitRT(void){
|
||||
static int daqExitRT(void){
|
||||
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
|
||||
struct ecmcPluginData pluginDataDef = {
|
||||
static struct ecmcPluginData pluginDataDef = {
|
||||
// Allways use ECMC_PLUG_VERSION_MAGIC
|
||||
.ifVersion = ECMC_PLUG_VERSION_MAGIC,
|
||||
// Name
|
||||
.name = "ecmcPlugin_DAQ",
|
||||
.name = "ecmc_plugin_daq",
|
||||
// Description
|
||||
.desc = "DAQ plugin for use with ecmc.",
|
||||
// Option description
|
||||
@@ -123,28 +109,6 @@ struct ecmcPluginData pluginDataDef = {
|
||||
.realtimeExitFnc = daqExitRT,
|
||||
// PLC funcs
|
||||
.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..
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user