From a7d1d216c1c10804529501bf050ed4188dcacd07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Sandstr=C3=B6m?= Date: Tue, 12 May 2020 18:04:53 +0200 Subject: [PATCH 1/6] Try add generic exprtk function interface WIP --- devEcmcSup/plc/ecmcPLCTask.cpp | 78 ++++++++++++++++++----------- devEcmcSup/plugin/ecmcPluginDefs.h | 1 + devEcmcSup/plugin/ecmcPluginLib.cpp | 74 ++++++++++++++++----------- 3 files changed, 96 insertions(+), 57 deletions(-) diff --git a/devEcmcSup/plc/ecmcPLCTask.cpp b/devEcmcSup/plc/ecmcPLCTask.cpp index a03455c7..1a6ba70b 100644 --- a/devEcmcSup/plc/ecmcPLCTask.cpp +++ b/devEcmcSup/plc/ecmcPLCTask.cpp @@ -593,8 +593,9 @@ bool ecmcPLCTask::findPluginFunction(ecmcPluginLib* plugin, const char *exprStr) int argCount = plugin->findArgCount(data->funcs[i]); if(!data->funcs[i].funcName || strlen(data->funcs[i].funcName) == 0 || - argCount < 0 || - argCount > ECMC_PLUGIN_MAX_PLC_ARG_COUNT ){ + ((argCount < 0 || + argCount > ECMC_PLUGIN_MAX_PLC_ARG_COUNT) && + data->funcs[i].funcGenericObj==NULL)){ break; } @@ -644,39 +645,58 @@ int ecmcPLCTask::loadPluginLib(ecmcPluginLib* plugin){ } for(int i = 0; i < ECMC_PLUGIN_MAX_PLC_FUNC_COUNT; ++i){ - int argCount = plugin->findArgCount(data->funcs[i]); if(!data->funcs[i].funcName || strlen(data->funcs[i].funcName) == 0 || - argCount < 0 || - argCount > ECMC_PLUGIN_MAX_PLC_ARG_COUNT ){ + ((argCount < 0 || + argCount > ECMC_PLUGIN_MAX_PLC_ARG_COUNT) && + data->funcs[i].funcGenericObj==NULL)){ break; } - switch(argCount) { - case 0: - ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg0); - break; - case 1: - ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg1); - break; - case 2: - ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg2); - break; - case 3: - ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg3); - break; - case 4: - ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg4); - break; - case 5: - ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg5); - break; - case 6: - ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg6); - break; - default: - break; + + if(data->funcs[i].funcGenericObj && strlen(data->funcs[i].funcName) > 0) { + // load generic_function_t generic func object (allow strings) + ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcGenericObj); } + else { + switch(argCount) { + case 0: + ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg0); + break; + case 1: + ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg1); + break; + case 2: + ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg2); + break; + case 3: + ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg3); + break; + case 4: + ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg4); + break; + case 5: + ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg5); + break; + case 6: + ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg6); + break; + case 7: + ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg7); + break; + case 8: + ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg8); + break; + case 9: + ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg9); + break; + case 10: + ecmcPLCTaskAddFunction(data->funcs[i].funcName,data->funcs[i].funcArg10); + break; + default: + break; + } + } } // Load constants diff --git a/devEcmcSup/plugin/ecmcPluginDefs.h b/devEcmcSup/plugin/ecmcPluginDefs.h index 75c1909a..10bd7bf6 100644 --- a/devEcmcSup/plugin/ecmcPluginDefs.h +++ b/devEcmcSup/plugin/ecmcPluginDefs.h @@ -42,6 +42,7 @@ struct ecmcOnePlcFunc { double (*funcArg8)(double,double,double,double,double,double,double,double); double (*funcArg9)(double,double,double,double,double,double,double,double,double); double (*funcArg10)(double,double,double,double,double,double,double,double,double,double); + void* funcGenericObj; // generic_function_t generic Func object (allow strings) }; // Structure for defining one custom plc constant diff --git a/devEcmcSup/plugin/ecmcPluginLib.cpp b/devEcmcSup/plugin/ecmcPluginLib.cpp index 41e7635e..71b63085 100644 --- a/devEcmcSup/plugin/ecmcPluginLib.cpp +++ b/devEcmcSup/plugin/ecmcPluginLib.cpp @@ -49,7 +49,7 @@ int ecmcPluginLib::load(const char* libFilenameWP, const char* libConfigStr) { // Ensure that file exist if(access( libFilenameWP, 0 )!= 0){ - LOGERR("%s/%s:%d: Error: PllibFilenameWP_gin %s: File not found (0x%x) .\n", + LOGERR("%s/%s:%d: Error: Plugin %s: File not found (0x%x) .\n", __FILE__, __FUNCTION__, __LINE__, libFilenameWP,ERROR_PLUGIN_FLIE_NOT_FOUND); return setErrorID(ERROR_PLUGIN_FLIE_NOT_FOUND); @@ -175,8 +175,8 @@ void ecmcPluginLib::report() { int argCount = findArgCount(data_->funcs[i]); if(!data_->funcs[i].funcName || strlen(data_->funcs[i].funcName) == 0 || - argCount > ECMC_PLUGIN_MAX_PLC_ARG_COUNT || - argCount < 0){ + ((argCount > ECMC_PLUGIN_MAX_PLC_ARG_COUNT || + argCount < 0) && data_->funcs[i].funcGenericObj==NULL)){ break; } @@ -198,31 +198,49 @@ void ecmcPluginLib::report() { data_->funcs[i].funcName, protoBuffer); printf(" Desc = %s\n",data_->funcs[i].funcDesc); - printf(" Arg count = %d\n",argCount); - switch(argCount) { - case 0: - printf(" func = @%p\n",data_->funcs[i].funcArg0); - break; - case 1: - printf(" func = @%p\n",data_->funcs[i].funcArg1); - break; - case 2: - printf(" func = @%p\n",data_->funcs[i].funcArg2); - break; - case 3: - printf(" func = @%p\n",data_->funcs[i].funcArg3); - break; - case 4: - printf(" func = @%p\n",data_->funcs[i].funcArg4); - break; - case 5: - printf(" func = @%p\n",data_->funcs[i].funcArg5); - break; - case 6: - printf(" func = @%p\n",data_->funcs[i].funcArg6); - break; - default: - break; + // generic_function_t generic func object (allow strings) + if(data_->funcs[i].funcGenericObj) { + printf(" func = @%p\n",data_->funcs[i].funcGenericObj); + } + else { + printf(" Arg count = %d\n",argCount); + switch(argCount) { + case 0: + printf(" func = @%p\n",data_->funcs[i].funcArg0); + break; + case 1: + printf(" func = @%p\n",data_->funcs[i].funcArg1); + break; + case 2: + printf(" func = @%p\n",data_->funcs[i].funcArg2); + break; + case 3: + printf(" func = @%p\n",data_->funcs[i].funcArg3); + break; + case 4: + printf(" func = @%p\n",data_->funcs[i].funcArg4); + break; + case 5: + printf(" func = @%p\n",data_->funcs[i].funcArg5); + break; + case 6: + printf(" func = @%p\n",data_->funcs[i].funcArg6); + break; + case 7: + printf(" func = @%p\n",data_->funcs[i].funcArg7); + break; + case 8: + printf(" func = @%p\n",data_->funcs[i].funcArg8); + break; + case 9: + printf(" func = @%p\n",data_->funcs[i].funcArg9); + break; + case 10: + printf(" func = @%p\n",data_->funcs[i].funcArg10); + break; + default: + break; + } } } From 7caa44bcb23ae8b41c91e60c26b018b9ca50b6c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Sandstr=C3=B6m?= Date: Wed, 13 May 2020 21:56:55 +0200 Subject: [PATCH 2/6] Add possablity to get ecmc epics ioc state to plugins. --- devEcmcSup/plugin/ecmcPluginClient.cpp | 8 ++++++++ devEcmcSup/plugin/ecmcPluginClient.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/devEcmcSup/plugin/ecmcPluginClient.cpp b/devEcmcSup/plugin/ecmcPluginClient.cpp index d89a28fd..9b08ab07 100644 --- a/devEcmcSup/plugin/ecmcPluginClient.cpp +++ b/devEcmcSup/plugin/ecmcPluginClient.cpp @@ -64,3 +64,11 @@ double getEcmcSampleTimeMS() { //mcuPeriod is in nano seconds return mcuPeriod/1000; } + +int getEcmcEpicsIOCState() { + if(!asynPort) { + return -1; + } + return asynPort->getEpicsState(); +} + \ No newline at end of file diff --git a/devEcmcSup/plugin/ecmcPluginClient.h b/devEcmcSup/plugin/ecmcPluginClient.h index b592e43b..63c31c47 100644 --- a/devEcmcSup/plugin/ecmcPluginClient.h +++ b/devEcmcSup/plugin/ecmcPluginClient.h @@ -84,6 +84,14 @@ double getEcmcSampleRate(); */ double getEcmcSampleTimeMS(); +/** \brief Get ecmc IOC state (hook) + * + * \return IOC state as int \n + * + * \note There's no ascii command in ecmcCmdParser.c for this method.\n + */ +int getEcmcEpicsIOCState(); + # ifdef __cplusplus } # endif // ifdef __cplusplus From 7568e033bd6c6deae7be799d4ab75f2e69105e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Sandstr=C3=B6m?= Date: Mon, 18 May 2020 17:32:20 +0200 Subject: [PATCH 3/6] Update plugin interface version to 1.0.0. --- devEcmcSup/plugin/ecmcPluginDefs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devEcmcSup/plugin/ecmcPluginDefs.h b/devEcmcSup/plugin/ecmcPluginDefs.h index 10bd7bf6..eccd7705 100644 --- a/devEcmcSup/plugin/ecmcPluginDefs.h +++ b/devEcmcSup/plugin/ecmcPluginDefs.h @@ -15,8 +15,8 @@ #define ECMC_PLUGIN_MAX_PLC_FUNC_COUNT 64 #define ECMC_PLUGIN_MAX_PLC_CONST_COUNT 64 #define ECMC_PLUGIN_MAX_PLC_ARG_COUNT 10 -#define ECMC_PLUG_VER_MAJOR 0 -#define ECMC_PLUG_VER_MINOR 2 +#define ECMC_PLUG_VER_MAJOR 1 +#define ECMC_PLUG_VER_MINOR 0 #define ECMC_PLUG_VER_PATCH 0 #define ECMC_PLUG_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c)) #define ECMC_PLUG_VERSION_MAGIC ECMC_PLUG_VERSION(ECMC_PLUG_VER_MAJOR, ECMC_PLUG_VER_MINOR, ECMC_PLUG_VER_PATCH) From 30ad82e4b0c3423f5e62fcb25143dbe503912b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Sandstr=C3=B6m?= Date: Wed, 27 May 2020 21:27:53 +0200 Subject: [PATCH 4/6] Update release notes --- RELEASE.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/RELEASE.md b/RELEASE.md index b8ce00d3..9c109c89 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,5 +1,10 @@ Release Notes === +# ECMC 6.2.1 +* Add exprtk support for plc functions with stings as args (need ess-exprtk 1.2.1) +* Add possabilty ti use plc-functions with strings a sarguments in plugins +* Expose ecmc epics ioc state to plugins + # ECMC 6.2 ### Add plugin support From 67c41f7de89cc3b5273d26e872016d83aa20f0ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Sandstr=C3=B6m?= Date: Wed, 27 May 2020 21:34:49 +0200 Subject: [PATCH 5/6] Update release notes --- RELEASE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE.md b/RELEASE.md index 9c109c89..06d7391b 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -4,6 +4,7 @@ Release Notes * Add exprtk support for plc functions with stings as args (need ess-exprtk 1.2.1) * Add possabilty ti use plc-functions with strings a sarguments in plugins * Expose ecmc epics ioc state to plugins +* Add plugin for pvAccess in ecmc plc:s: https://github.com/anderssandstrom/e3-ecmcPlugin_Utils # ECMC 6.2 From a12ab867d1e6522925fb4ad2b7f0a2b3de5380d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Sandstr=C3=B6m?= Date: Wed, 27 May 2020 21:46:33 +0200 Subject: [PATCH 6/6] Use exprtk v1.2.1 --- exprtkSupport | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exprtkSupport b/exprtkSupport index d4070a69..f9b0f2eb 160000 --- a/exprtkSupport +++ b/exprtkSupport @@ -1 +1 @@ -Subproject commit d4070a69207ebbcd55cc1c48e0f99d3daf728f67 +Subproject commit f9b0f2ebe3ef2001488b1d547963911b62459d02