Compiles but no functionality

This commit is contained in:
2024-01-29 12:20:28 +01:00
parent 387fc5e6a8
commit 51f4b7dfed
10 changed files with 75 additions and 85 deletions

View File

@@ -15,7 +15,7 @@ USR_CXXFLAGS += -std=c++17
OPT_CXXFLAGS_YES = -O3
# dependencies
# ECmasterECMC_VERSION = v1.1.0
ECmasterECMC_VERSION = v1.1.0
# motorECMC_VERSION = 7.0.7-ESS
ecmc_VERSION = v9.0.1_RC4
@@ -35,12 +35,11 @@ DB_DIR = $(BASE_DIR)/Db
SOURCES += $(SRC_DIR)/ecmcPluginSafety.c
SOURCES += $(SRC_DIR)/ecmcSafetyPlgWrap.cpp
SOURCES += $(SRC_DIR)/ecmcSafetyPlg.cpp
SOURCES += $(SRC_DIR)/ecmcSafetyGroup.cpp
#SOURCES += $(foreach d,${SRC_DIR}, $(wildcard $d/*.c) $(wildcard $d/*.cpp))
HEADERS += $(foreach d,${SRC_DIR}, $(wildcard $d/*.h))
DBDS += $(foreach d,${SRC_DIR}, $(wildcard $d/*.dbd))
SCRIPTS += $(BASE_DIR)/startup.cmd
SCRIPTS += $(BASE_DIR)/addMotionObj.cmd
SCRIPTS += $(BASE_DIR)/scripts/startup.cmd
SCRIPTS += $(BASE_DIR)/scripts/addSafetyAxisToGroup.cmd
TEMPLATES += $(wildcard $(DB_DIR)/*.template)

View File

@@ -1,40 +0,0 @@
#==============================================================================
# addMotionObj.cmd
#-------------- Information:
#- Description: ecmc_plugin_motion startup.cmd
#-
#- by Anders Sandström, Paul Scherrer Institute, 2023
#- email: anders.sandstroem@psi.ch
#-
#-###############################################################################
#-
#- Arguments
#- [mandatory]
#- PLUGIN_ID = Plugin instansiation index, must be unique for each call
#-
#- [optional]
#- AX = Axis id, default 1
#- BUFF_SIZE = Buffer size, default 1000
#- DBG = Debug mode, default 1
#- ENA = Enable operation, default 1
#- REPORT = Printout plugin details, default 1
#################################################################################
#- Load plugin: MOTION
#- Note: ECMC_PLG_MOTION_OBJ_INDEX is the index of motion object in motion plugin and not PLUGIN_ID.
#- First loaded object will therefore have index
epicsEnvSet(ECMC_PLG_MOTION_OBJ_INDEX,${ECMC_PLG_MOTION_OBJ_INDEX=0})
# Might need differet paths for PSI and ESS.. must check
epicsEnvSet(ECMC_PLUGIN_FILNAME,"$(ecmc_plugin_motion_DIR)/lib/${EPICS_HOST_ARCH=linux-x86_64}/libecmc_plugin_motion.so")
epicsEnvSet(ECMC_PLUGIN_CONFIG,"AXIS=${AX};BUFFER_SIZE=${BUFF_SIZE};DBG_PRINT=${DBG=1};ENABLE=${ENA=1};")
${SCRIPTEXEC} ${ecmccfg_DIR}loadPlugin.cmd, "PLUGIN_ID=${PLUGIN_ID},FILE=${ECMC_PLUGIN_FILNAME},CONFIG='${ECMC_PLUGIN_CONFIG}', REPORT=${REPORT=1}"
dbLoadRecords(${ecmc_plugin_motion_TEMPLATES}ecmcPluginMotion.template,"P=$(IOC):,INDEX=${ECMC_PLG_MOTION_OBJ_INDEX=0},NELM=${BUFF_SIZE=1000}")
#- Increase of index (need to keep track in order to load correct db)
ecmcEpicsEnvSetCalc("ECMC_PLG_MOTION_OBJ_INDEX" ,${ECMC_PLG_MOTION_OBJ_INDEX=0}+1)

View File

@@ -0,0 +1,19 @@
#==============================================================================
# addSafetyAxisToGroup.cmd
#-------------- Information:
#- Description: ecmc_plugin_safety addSafetyAxisToGroup
#-
#- by Anders Sandström, Paul Scherrer Institute, 2024
#- email: anders.sandstroem@psi.ch
#-
#-###############################################################################
#-
#- Arguments
#- [mandatory]
#- GROUP = Safety group index
#- AXIS = Axis index
#-
#################################################################################
xxxx

View File

@@ -12,7 +12,7 @@
// Needed to get headers in ecmc right...
#define ECMC_IS_PLUGIN
#define ECMC_EXAMPLE_PLUGIN_VERSION 0
#define ECMC_PLUGIN_VERSION 0
#ifdef __cplusplus
extern "C" {
@@ -40,7 +40,7 @@ int safetyConstruct(char *configStr)
// create FFT object and register data callback
lastConfStr = strdup(configStr);
return createSafetyObj(configStr);
return createSafetyGroup(configStr);
}
/** Optional function.
@@ -48,7 +48,7 @@ int safetyConstruct(char *configStr)
**/
void safetyDestruct(void)
{
deleteAllSafetyObjs();
deleteAllSafetyGroups();
if(lastConfStr){
free(lastConfStr);
}
@@ -62,7 +62,7 @@ void safetyDestruct(void)
**/
int safetyRealtime(int ecmcError)
{
executeSafetyObjs();
executeSafetyGroups();
lastEcmcError = ecmcError;
return 0;
}
@@ -116,12 +116,12 @@ struct ecmcPluginData pluginDataDef = {
// Description
.desc = "Safety plugin.",
// Option description
.optionDesc = "\n "ECMC_PLUGIN_DBG_PRINT_OPTION_CMD"<1/0> : Enables/disables printouts from plugin, default = disabled.\n"
" "ECMC_PLUGIN_RAMP_DOWN_INPUT_CMD_ENTRY_OPTION_CMD"<ec entry> : EtherCat entry input for ramp down cmd (bit).\n"
" "ECMC_PLUGIN_AXES_STANDSTILL_OUTPUT_STAT_ENTRY_OPTION_CMD"<ec entry> : EtherCat entry output for all axes standstill status (bit).\n"
,
.optionDesc = "\n "ECMC_PLUGIN_DBG_PRINT_OPTION_CMD"<1/0> : Enables/disables printouts from plugin, default = disabled.\n"
" "ECMC_PLUGIN_RAMP_DOWN_ENTRY_OPTION_CMD"<ec entry> : EtherCat entry input for ramp down cmd (bit).\n"
" "ECMC_PLUGIN_AXES_STANDSTILL_ENTRY_OPTION_CMD"<ec entry> : EtherCat entry output for all axes standstill status (bit).\n"
,
// Plugin version
.version = ECMC_EXAMPLE_PLUGIN_VERSION,
.version = ECMC_PLUGIN_VERSION,
// Optional construct func, called once at load. NULL if not definded.
.constructFnc = safetyConstruct,
// Optional destruct func, called once at unload. NULL if not definded.

View File

@@ -17,7 +17,7 @@
#define ECMC_PLUGIN_ASYN_SAFETY_STAT "status"
#include <sstream>
#include "ecmcSafetyPlg.h"
#include "ecmcSafetyGroup.h"
#include "ecmcPluginClient.h"
#include "ecmcAsynPortDriver.h"
#include "ecmcAsynPortDriverUtils.h"
@@ -88,7 +88,21 @@ void ecmcSafetyGroup::parseConfigStr(char *configStr) {
pThisOption += strlen(ECMC_PLUGIN_DBG_PRINT_OPTION_CMD);
cfgDbgMode_ = atoi(pThisOption);
}
// ECMC_PLUGIN_RAMP_DOWN_ENTRY_OPTION_CMD (string)
if (!strncmp(pThisOption, ECMC_PLUGIN_RAMP_DOWN_ENTRY_OPTION_CMD, strlen(ECMC_PLUGIN_RAMP_DOWN_ENTRY_OPTION_CMD))) {
pThisOption += strlen(ECMC_PLUGIN_RAMP_DOWN_ENTRY_OPTION_CMD);
printf("RAMP_DOWN_CMD=%s",pThisOption);
//cfgDbgMode_ = atoi(pThisOption);
}
// ECMC_PLUGIN_AXES_STANDSTILL_ENTRY_OPTION_CMD (string)
if (!strncmp(pThisOption, ECMC_PLUGIN_AXES_STANDSTILL_ENTRY_OPTION_CMD, strlen(ECMC_PLUGIN_AXES_STANDSTILL_ENTRY_OPTION_CMD))) {
pThisOption += strlen(ECMC_PLUGIN_AXES_STANDSTILL_ENTRY_OPTION_CMD);
printf("STANDSTILL_STAT=%s",pThisOption);
//cfgDbgMode_ = atoi(pThisOption);
}
pThisOption = pNextOption;
}
free(pOptions);
@@ -135,9 +149,9 @@ void ecmcSafetyGroup::connectToDataSource() {
void ecmcSafetyGroup::initAsyn() {
// Add motion "plugin.motion%d.status"
paramName = ECMC_PLUGIN_ASYN_PREFIX "_" + to_string(objectId_) +
std::string paramName = ECMC_PLUGIN_ASYN_PREFIX "_" + to_string(objectId_) +
"." + ECMC_PLUGIN_ASYN_SAFETY_STAT;
paramId = &asynStatusId_;
int *paramId = &asynStatusId_;
if( createParam(0, paramName.c_str(), asynParamInt32, paramId ) != asynSuccess ) {
throw std::runtime_error("Failed create asyn parameter mode");
}
@@ -169,17 +183,17 @@ asynStatus ecmcSafetyGroup::readInt32(asynUser *pasynUser, epicsInt32 *value) {
return asynError;
}
int ecmcSafetyGroup::addAxis(int axisId) {
void ecmcSafetyGroup::addAxis(int axisId) {
ecmcAxisBase *axis= (ecmcAxisBase*) getAxisPointer(axisId);
if(temp) {
axes_->push_back(axis);
if(axis) {
axes_.push_back(axis);
axesCounter_++;
} else {
throw std::out_of_range("Invalid axis id");
}
return 0;
return;
}
uint8_t ecmcSafetyGroup::getUint8(uint8_t* data) {

View File

@@ -15,7 +15,7 @@
#include <stdexcept>
#include "ecmcDataItem.h"
#include "ecmcAsynPortDriver.h"
#include "ecmcSafetyGroupDefs.h"
#include "ecmcSafetyPlgDefs.h"
#include <string>
#include "ecmcAxisBase.h"
#include <vector>
@@ -39,12 +39,11 @@ class ecmcSafetyGroup : public asynPortDriver {
void execute();
virtual asynStatus readInt32(asynUser *pasynUser, epicsInt32 *value);
private:
void parseConfigStr(char *configStr);
void initAsyn();
double ecmcSampleRateHz_
int dataSourceLinked_; // To avoid link several times
double ecmcSampleRateHz_;
int dataSourcesLinked_; // To avoid link several times
int objectId_; // Unique object id
int cycleCounter_;
@@ -56,9 +55,9 @@ class ecmcSafetyGroup : public asynPortDriver {
//
int status_;
static std::vector<ecmcAxisBase*> axes_;
int axesCounter_;
static std::vector<ecmcAxisBase*> axes_;
// Some generic utility functions
static uint8_t getUint8(uint8_t* data);
static int8_t getInt8(uint8_t* data);
@@ -71,7 +70,6 @@ class ecmcSafetyGroup : public asynPortDriver {
static float getFloat32(uint8_t* data);
static double getFloat64(uint8_t* data);
static size_t getEcDataTypeByteSize(ecmcEcDataType dt);
int objId);
static std::string to_string(int value);
};

View File

@@ -17,9 +17,9 @@
#define ECMC_PLUGIN_ASYN_PREFIX "plugin.safety"
// Options
#define ECMC_PLUGIN_DBG_PRINT_OPTION_CMD "DBG_PRINT="
#define ECMC_PLUGIN_RAMP_DOWN_INPUT_CMD_ENTRY_OPTION_CMD "RAMP_DOWN_INPUT_CMD_ENTRY="
#define ECMC_PLUGIN_AXES_STANDSTILL_OUTPUT_STAT_ENTRY_OPTION_CMD "AXES_STANDSTILL_OUTPUT_STAT_ENTRY="
#define ECMC_PLUGIN_DBG_PRINT_OPTION_CMD "DBG_PRINT="
#define ECMC_PLUGIN_RAMP_DOWN_ENTRY_OPTION_CMD "RAMP_DOWN_ENTRY="
#define ECMC_PLUGIN_AXES_STANDSTILL_ENTRY_OPTION_CMD "AXES_STANDSTILL_ENTRY="
/** Just one error code in "c" part of plugin
(error handled with exceptions i c++ part) */

View File

@@ -17,27 +17,27 @@
#include <vector>
#include <stdexcept>
#include <string>
#include "ecmcSafetyGroupPlgWrap.h"
#include "ecmcSafetyGroupPlg.h"
#include "ecmcSafetyPlgWrap.h"
#include "ecmcSafetyGroup.h"
#define ECMC_PLUGIN_MAX_PORTNAME_CHARS 64
#define ECMC_PLUGIN_PORTNAME_PREFIX "PLUGIN.SAFETY"
static std::vector<ecmcSafetyGroupPlg*> safetyGroups;
static std::vector<ecmcSafetyGroup*> safetyGroups;
static int safetyGroupsCounter = 0;
static char portNameBuffer[ECMC_PLUGIN_MAX_PORTNAME_CHARS];
int createSafetyGroup(char* configStr) {
// create new ecmcSafetyGroupPlg object
ecmcSafetyGroupPlg* safetyGroup = NULL;
// create new ecmcSafetyGroup object
ecmcSafetyGroup* safetyGroup = NULL;
// create asynport name for new object ()
memset(portNameBuffer, 0, ECMC_PLUGIN_MAX_PORTNAME_CHARS);
snprintf (portNameBuffer, ECMC_PLUGIN_MAX_PORTNAME_CHARS,
ECMC_PLUGIN_PORTNAME_PREFIX "_%d", safetyGroupsCounter);
try {
safetyGroup = new ecmcSafetyGroupPlg(safetyGroupsCounter, configStr, portNameBuffer);
safetyGroup = new ecmcSafetyGroup(safetyGroupsCounter, configStr, portNameBuffer);
}
catch(std::exception& e) {
if(safetyGroup) {
@@ -53,8 +53,8 @@ int createSafetyGroup(char* configStr) {
return 0;
}
void deleteAllsafetyGroups() {
for(std::vector<ecmcSafetyGroupPlg*>::iterator psafetyGroup = safetyGroups.begin(); psafetyGroup != safetyGroups.end(); ++psafetyGroup) {
void deleteAllSafetyGroups() {
for(std::vector<ecmcSafetyGroup*>::iterator psafetyGroup = safetyGroups.begin(); psafetyGroup != safetyGroups.end(); ++psafetyGroup) {
if(*psafetyGroup) {
delete (*psafetyGroup);
}
@@ -73,7 +73,7 @@ int addMotionAxis(int safetyGroupIndex, int axisIndex) {
}
int linkDataToSafetyGroups() {
for(std::vector<ecmcSafetyGroupPlg*>::iterator psafetyGroup = safetyGroups.begin(); psafetyGroup != safetyGroups.end(); ++psafetyGroup) {
for(std::vector<ecmcSafetyGroup*>::iterator psafetyGroup = safetyGroups.begin(); psafetyGroup != safetyGroups.end(); ++psafetyGroup) {
if(*psafetyGroup) {
try {
(*psafetyGroup)->connectToDataSource();
@@ -89,14 +89,14 @@ int linkDataToSafetyGroups() {
int executeSafetyGroups() {
for(std::vector<ecmcSafetyGroupPlg*>::iterator psafetyGroup = safetyGroups.begin(); psafetyGroup != safetyGroups.end(); ++psafetyGroup) {
for(std::vector<ecmcSafetyGroup*>::iterator psafetyGroup = safetyGroups.begin(); psafetyGroup != safetyGroups.end(); ++psafetyGroup) {
if(*psafetyGroup) {
try {
(*psafetyGroup)->execute();
}
catch(std::exception& e) {
printf("Exception: %s. Plugin will unload.\n",e.what());
return ECMC_PLUGIN_MOTION_ERROR_CODE;
return ECMC_PLUGIN_SAFETY_ERROR_CODE;
}
}
}

View File

@@ -38,7 +38,7 @@ int addMotionAxis(int safetyGroupIndex, int axisIndex);
*
* Should be called when destructs.\n
*/
void deleteAll();
void deleteAllSafetyGroups();
/** \brief Link data to _all_ safety objects
*
@@ -54,7 +54,7 @@ int linkDataToSafetyObjs();
*
* \return 0 if success or otherwise an error code.\n
*/
int executeSafetyGroups() {
int executeSafetyGroups();
# ifdef __cplusplus
}