New plg concept and cleanup

This commit is contained in:
2024-12-13 16:27:11 +01:00
parent a84383815d
commit fcee0a8ff4
50 changed files with 58 additions and 109 deletions

3
.gitignore vendored
View File

@@ -14,4 +14,5 @@ core.*
*PVs.list
*-loc/*.Makefile
ecmc_plugin_fft/*.Makefile
*__*
*__*
O.*

36
GNUmakefile Normal file
View File

@@ -0,0 +1,36 @@
include /ioc/tools/driver.makefile
MODULE = ecmc_plugin_fft
# "Transfer" module name to plugin
USR_CFLAGS +=-DECMC_PLUGIN_MODULE_NAME=${MODULE}
BUILDCLASSES = Linux
ARCH_FILTER = deb10%
# Run 7.0.6 for now
EXCLUDE_VERSIONS+=3 7.0.5 7.0.6
IGNORE_MODULES += asynMotor
IGNORE_MODULES += motorBase
USR_CXXFLAGS += -std=c++17
OPT_CXXFLAGS_YES = -O3
# dependencies
ECmasterECMC_VERSION = v1.1.0
ecmc_VERSION = sandst_a
APP:=src
APPDB:=$(APP)/Db
APPSRC:=$(APP)/src
USR_CFLAGS += -shared -fPIC -Wall -Wextra
USR_LDFLAGS += -lstdc++
USR_INCLUDES += -I$(where_am_I)$(APPSRC)
TEMPLATES += $(wildcard $(APPDB)/*.db)
TEMPLATES += $(wildcard $(APPDB)/*.template)
SOURCES += $(APPSRC)/ecmcPluginFFT.c
SOURCES += $(APPSRC)/ecmcFFTWrap.cpp
SOURCES += $(APPSRC)/ecmcFFT.cpp

View File

@@ -1,28 +0,0 @@
#
# Copyright (c) 2018 - 2019 European Spallation Source ERIC
#
# The program is free software: you can redistribute
# it and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 2 of the
# License, or any newer version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see https://www.gnu.org/licenses/gpl-2.0.txt
#
#
# Author : Jeong Han Lee
# email : han.lee@esss.se
# Date : 2020Mar22-1607-33CET
# version : 1.0.0
TOP:=$(CURDIR)
include $(TOP)/configure/CONFIG
include $(TOP)/configure/RULES

View File

@@ -1,62 +0,0 @@
#
# Copyright (c) 2019 European Spallation Source ERIC
#
# The program is free software: you can redistribute
# it and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 2 of the
# License, or any newer version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see https://www.gnu.org/licenses/gpl-2.0.txt
#
#
# Author : anderssandstrom
# email : anderssandstrom@esss.se
# Date : 2020Mar22-1607-33CET
# version : 0.0.0
#
# template file is generated by ./e3TemplateGenerator.bash with bf03d40
# Please look at many other _module_.Makefile in e3-* repository
#
## The following lines are mandatory, please don't change them.
where_am_I := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
include $(E3_REQUIRE_TOOLS)/driver.makefile
include $(E3_REQUIRE_CONFIG)/DECOUPLE_FLAGS
ifneq ($(strip $(ASYN_DEP_VERSION)),)
asyn_VERSION=$(ASYN_DEP_VERSION)
endif
ifneq ($(strip $(ECMC_DEP_VERSION)),)
ecmc_VERSION=$(ECMC_DEP_VERSION)
endif
APP:=ecmc_plugin_fftApp
APPDB:=$(APP)/Db
APPSRC:=$(APP)/src
USR_CFLAGS += -shared -fPIC -Wall -Wextra
USR_LDFLAGS += -lstdc++
USR_INCLUDES += -I$(where_am_I)$(APPSRC)
TEMPLATES += $(wildcard $(APPDB)/*.db)
TEMPLATES += $(wildcard $(APPDB)/*.template)
SOURCES += $(APPSRC)/ecmcPluginFFT.c
SOURCES += $(APPSRC)/ecmcFFTWrap.cpp
SOURCES += $(APPSRC)/ecmcFFT.cpp
db:
.PHONY: db
vlibs:
.PHONY: vlibs
###

View File

@@ -830,7 +830,7 @@ void ecmcFFT::initAsyn() {
if( createParam(0, paramName.c_str(), asynParamInt8Array, &asynSourceId_ ) != asynSuccess ) {
throw std::runtime_error("Failed create asyn parameter source");
}
doCallbacksInt8Array(cfgDataSourceStr_, strlen(cfgDataSourceStr_), asynSourceId_,0);
doCallbacksInt8Array((epicsInt8*)cfgDataSourceStr_, strlen(cfgDataSourceStr_), asynSourceId_,0);
// Add fft "plugin.fft%d.trigg"
paramName = ECMC_PLUGIN_ASYN_PREFIX + to_string(objectId_) +

View File

@@ -3,11 +3,13 @@
* ecmc is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*
* ecmcPluginExample.cpp
* ecmcPluginFFT.cpp
*
* Created on: Mar 21, 2020
* Author: anderssandstrom
*
* Instructions:
* - IMPORTANT: Add "USR_CFLAGS +=-DECMC_PLUGIN_MODULE_NAME=${MODULE}" to GNUMakefile
* - All functions and ecmcPluginData struct must be declared static
\*************************************************************************/
// Needed to get headers in ecmc right...
@@ -30,11 +32,11 @@ static int lastEcmcError = 0;
static char* lastConfStr = NULL;
/** 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 fftConstruct(char *configStr)
static int fftConstruct(char *configStr)
{
//This module is allowed to load several times so no need to check if loaded
@@ -46,7 +48,7 @@ int fftConstruct(char *configStr)
/** Optional function.
* Will be called once at unload.
**/
void fftDestruct(void)
static void fftDestruct(void)
{
deleteAllFFTs();
if(lastConfStr){
@@ -55,12 +57,12 @@ void fftDestruct(void)
}
/** 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 fftRealtime(int ecmcError)
static int fftRealtime(int ecmcError)
{
lastEcmcError = ecmcError;
return 0;
@@ -69,7 +71,7 @@ int fftRealtime(int ecmcError)
/** Link to data source here since all sources should be availabe at this stage
* (for example ecmc PLC variables are defined only at enter of realtime)
**/
int fftEnterRT(){
static int fftEnterRT(){
return linkDataToFFTs();
}
@@ -77,41 +79,41 @@ int fftEnterRT(){
* Will be called once just before leaving realtime mode
* Return value other than 0 will be considered error.
**/
int fftExitRT(void){
static int fftExitRT(void){
return 0;
}
// Plc function for clear of buffers
double fft_clear(double index) {
static double fft_clear(double index) {
return (double)clearFFT((int)index);
}
// Plc function for enable
double fft_enable(double index, double enable) {
static double fft_enable(double index, double enable) {
return (double)enableFFT((int)index, (int)enable);
}
// Plc function for trigg new measurement (will clear buffers)
double fft_trigg(double index) {
static double fft_trigg(double index) {
return (double)triggFFT((int)index);
}
// Plc function for enable
double fft_mode(double index, double mode) {
static double fft_mode(double index, double mode) {
return (double)modeFFT((int)index, (FFT_MODE)((int)mode));
}
// Plc function for enable
double fft_stat(double index) {
static double fft_stat(double index) {
return (double)statFFT((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_FFT",
.name = "ecmc_plugin_fft",
// Description
.desc = "FFT plugin for use with ecmc.",
// Option description