Merge branch 'master' of git.psi.ch:epics_ioc_modules/ecmc_plugin_safety
This commit is contained in:
@@ -36,7 +36,7 @@ DB_DIR = $(BASE_DIR)/Db
|
||||
|
||||
SOURCES += $(SRC_DIR)/ecmcPluginSafety.c
|
||||
SOURCES += $(SRC_DIR)/ecmcSafetyPlgWrap.cpp
|
||||
SOURCES += $(SRC_DIR)/ecmcSafetyGroup.cpp
|
||||
SOURCES += $(SRC_DIR)/ecmcSS1SafetyGroup.cpp
|
||||
|
||||
#SOURCES += $(foreach d,${SRC_DIR}, $(wildcard $d/*.c) $(wildcard $d/*.cpp))
|
||||
HEADERS += $(foreach d,${SRC_DIR}, $(wildcard $d/*.h))
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* ecmc is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*
|
||||
* ecmcSafetyGroup.cpp
|
||||
* ecmcSS1SafetyGroup.cpp
|
||||
*
|
||||
* Created on: July 10, 2023
|
||||
* Author: anderssandstrom
|
||||
@@ -17,7 +17,7 @@
|
||||
#define ECMC_PLUGIN_ASYN_SAFETY_STAT "status"
|
||||
|
||||
#include <sstream>
|
||||
#include "ecmcSafetyGroup.h"
|
||||
#include "ecmcSS1SafetyGroup.h"
|
||||
#include "ecmcPluginClient.h"
|
||||
#include "ecmcAsynPortDriver.h"
|
||||
#include "ecmcAsynPortDriverUtils.h"
|
||||
@@ -34,7 +34,7 @@ extern DBBASE *pdbbase;
|
||||
* - invalid_argument
|
||||
* - runtime_error
|
||||
*/
|
||||
ecmcSafetyGroup::ecmcSafetyGroup(const char *name,
|
||||
ecmcSS1SafetyGroup::ecmcSS1SafetyGroup(const char *name,
|
||||
const char *ec_rampdown_cmd,
|
||||
const char *ec_standstill_status,
|
||||
int time_delay_ms,
|
||||
@@ -89,6 +89,7 @@ ecmcSafetyGroup::ecmcSafetyGroup(const char *name,
|
||||
initAsyn();
|
||||
if(cfgDbgMode_) {
|
||||
printf("Safety %s: Safety group created:\n"
|
||||
" Type: SS1\n"
|
||||
" Name: %s\n"
|
||||
" I/O for rampdown command from saftey PLC: %s\n"
|
||||
" I/O for axes standstill status: %s\n"
|
||||
@@ -99,7 +100,7 @@ ecmcSafetyGroup::ecmcSafetyGroup(const char *name,
|
||||
}
|
||||
}
|
||||
|
||||
ecmcSafetyGroup::~ecmcSafetyGroup() {
|
||||
ecmcSS1SafetyGroup::~ecmcSS1SafetyGroup() {
|
||||
if(cfgDbgMode_) {
|
||||
printf("Safety %s: Cleanup\n",sName_);
|
||||
}
|
||||
@@ -112,7 +113,7 @@ ecmcSafetyGroup::~ecmcSafetyGroup() {
|
||||
free(sConfig_);
|
||||
}
|
||||
|
||||
void ecmcSafetyGroup::parseConfigStr(const char *configStr) {
|
||||
void ecmcSS1SafetyGroup::parseConfigStr(const char *configStr) {
|
||||
|
||||
// check config parameters
|
||||
if (configStr && configStr[0]) {
|
||||
@@ -139,13 +140,13 @@ void ecmcSafetyGroup::parseConfigStr(const char *configStr) {
|
||||
}
|
||||
}
|
||||
|
||||
void ecmcSafetyGroup::validate() {
|
||||
void ecmcSS1SafetyGroup::validate() {
|
||||
validateCfgs();
|
||||
connectToDataSources();
|
||||
validateAxes();
|
||||
}
|
||||
|
||||
void ecmcSafetyGroup::validateCfgs() {
|
||||
void ecmcSS1SafetyGroup::validateCfgs() {
|
||||
|
||||
// Validate data sources
|
||||
int masterIdRampDown=-1;
|
||||
@@ -178,85 +179,21 @@ void ecmcSafetyGroup::validateCfgs() {
|
||||
if(bitStandStill_ < 0) {
|
||||
throw std::runtime_error( "Safety: Parse error: Standstill status, bit invalid.");
|
||||
}
|
||||
|
||||
if(cfgDbgMode_) {
|
||||
printf("Safety %s: I/O link parsed:\n"
|
||||
" name: %s\n"
|
||||
" masterid: %d\n"
|
||||
" slaveid: %d\n"
|
||||
" alias: %s\n"
|
||||
" bit: %d\n",
|
||||
sName_,
|
||||
sEcRampDownCmdNameOrg_,
|
||||
masterIdRampDown,
|
||||
slaveIdRampDown_,
|
||||
aliasRampDown_,
|
||||
bitRampDown_);
|
||||
|
||||
printf("Safety %s: I/O link parsed:\n"
|
||||
" name: %s\n"
|
||||
" masterid: %d\n"
|
||||
" slaveid: %d\n"
|
||||
" alias: %s\n"
|
||||
" bit: %d\n",
|
||||
sName_,
|
||||
sEcAxesStandStillStatOrg_,
|
||||
masterIdStandStill,
|
||||
slaveIdStandStill_,
|
||||
aliasStandStill_,
|
||||
bitStandStill_);
|
||||
}
|
||||
|
||||
// Now bits are idenfied. Now bits need to be removed in order to find data item.
|
||||
stripBits();
|
||||
}
|
||||
|
||||
void ecmcSafetyGroup::stripBits() {
|
||||
char * lastdot = strrchr(sEcRampDownCmdNameStrip_,'.');
|
||||
if(lastdot) {
|
||||
lastdot[0] = 0;
|
||||
}
|
||||
else {
|
||||
throw std::runtime_error( "Safety: Failed trim bit from ramp down I/O link.");
|
||||
}
|
||||
|
||||
if(cfgDbgMode_) {
|
||||
printf("Safety %s: I/O bit removed:\n"
|
||||
" before: %s\n"
|
||||
" after: %s\n",
|
||||
sName_,
|
||||
sEcRampDownCmdNameOrg_,
|
||||
sEcRampDownCmdNameStrip_);
|
||||
}
|
||||
|
||||
lastdot = strrchr(sEcAxesStandStillStatStrip_,'.');
|
||||
if(lastdot) {
|
||||
lastdot[0] = 0;
|
||||
}
|
||||
else {
|
||||
throw std::runtime_error( "Safety: Failed trim bit from stand still I/O link.");
|
||||
}
|
||||
|
||||
if(cfgDbgMode_) {
|
||||
printf("Safety %s: I/O bit removed:\n"
|
||||
" before: %s\n"
|
||||
" after: %s\n",
|
||||
sName_,
|
||||
sEcAxesStandStillStatOrg_,
|
||||
sEcAxesStandStillStatStrip_);
|
||||
}
|
||||
}
|
||||
|
||||
void ecmcSafetyGroup::validateAxes() {
|
||||
void ecmcSS1SafetyGroup::validateAxes() {
|
||||
|
||||
for(std::vector<safetyAxis*>::iterator saxis = axes_.begin(); saxis != axes_.end(); ++saxis) {
|
||||
if(!*saxis) {
|
||||
if(!(*saxis)) {
|
||||
throw std::runtime_error( "Safety: Axis object NULL.");
|
||||
}
|
||||
if(!getAxisValid((*saxis)->axisId_)) {
|
||||
throw std::runtime_error( "Safety: Ecmc Axis object not valid.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ecmcSafetyGroup::connectToDataSources() {
|
||||
void ecmcSS1SafetyGroup::connectToDataSources() {
|
||||
|
||||
ecMaster_ = (ecmcEc*)getEcMaster();
|
||||
|
||||
@@ -309,7 +246,7 @@ void ecmcSafetyGroup::connectToDataSources() {
|
||||
//dataSourcesLinked_ = 1;
|
||||
}
|
||||
|
||||
void ecmcSafetyGroup::initAsyn() {
|
||||
void ecmcSS1SafetyGroup::initAsyn() {
|
||||
|
||||
// Add motion "plugin.motion%d.status"
|
||||
std::string paramName = ECMC_PLUGIN_ASYN_PREFIX "_" + to_string(objectId_) +
|
||||
@@ -325,14 +262,14 @@ void ecmcSafetyGroup::initAsyn() {
|
||||
}
|
||||
|
||||
// Avoid issues with std:to_string()
|
||||
std::string ecmcSafetyGroup::to_string(int value) {
|
||||
std::string ecmcSS1SafetyGroup::to_string(int value) {
|
||||
std::ostringstream os;
|
||||
os << value;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
// Executed by ecmc rt thread.
|
||||
void ecmcSafetyGroup::execute() {
|
||||
void ecmcSS1SafetyGroup::execute() {
|
||||
|
||||
uint64_t data = 0;
|
||||
// Read ramp down command from safety plc
|
||||
@@ -344,46 +281,42 @@ void ecmcSafetyGroup::execute() {
|
||||
setAxesStandstillStatus(0); // set output
|
||||
throw std::out_of_range("Safety: Read rampdown cmd failed");
|
||||
}
|
||||
|
||||
rampDownCmdOld_ = rampDownCmd_;
|
||||
rampDownCmd_ = data == 0;
|
||||
|
||||
if(cfgDbgMode_ && rampDownCmdOld_ != rampDownCmd_) {
|
||||
if(rampDownCmd_) {
|
||||
printf("Safety %s: Ramp down cmd active\n",sName_);
|
||||
} else {
|
||||
printf("Safety %s: Ramp down cmd not active\n",sName_);
|
||||
|
||||
if(rampDownCmdOld_ != rampDownCmd_) {
|
||||
resetPrintoutStatus();
|
||||
if(cfgDbgMode_) {
|
||||
if(rampDownCmd_) {
|
||||
printf("Safety %s: Ramp down cmd active\n",sName_);
|
||||
} else {
|
||||
printf("Safety %s: Ramp down cmd not active\n",sName_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set safety interlock in ecmc
|
||||
setAxesSafetyInterlocks(rampDownCmd_);
|
||||
// check if axes are standstill to safety PLC
|
||||
axesAreStandstill_ = checkAxesStandstill();
|
||||
axesAreStandstill_ = checkAxesStandstillAndDisableIfNeeded();
|
||||
setAxesStandstillStatus(axesAreStandstill_);
|
||||
|
||||
// Disable
|
||||
if(axesAreStandstill_ && rampDownCmd_) {
|
||||
setAxesDisable();
|
||||
} else {
|
||||
printEnableStatus_ = true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
//Needed functions in motion.h
|
||||
int getAxisBusy(int axisIndex,
|
||||
int *value);
|
||||
int getAxisEncVelo(int axisIndex,
|
||||
double *velo);
|
||||
int getAxisTrajVelo(int axisIndex,
|
||||
double *velo);
|
||||
int getAxisEnabled(int axisIndex,
|
||||
int *value);
|
||||
int setAxisEnable(int axisIndex,
|
||||
int value);
|
||||
*/
|
||||
}
|
||||
|
||||
void ecmcSafetyGroup::setAxesStandstillStatus(int standstill) {
|
||||
void ecmcSS1SafetyGroup::resetPrintoutStatus() {
|
||||
for(std::vector<safetyAxis*>::iterator saxis = axes_.begin(); saxis != axes_.end(); ++saxis) {
|
||||
(*saxis)->printEnableStat_ = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void ecmcSS1SafetyGroup::setAxesStandstillStatus(int standstill) {
|
||||
|
||||
if(axesAreStandstillOld_ != standstill) {
|
||||
if(standstill) {
|
||||
@@ -401,50 +334,72 @@ void ecmcSafetyGroup::setAxesStandstillStatus(int standstill) {
|
||||
}
|
||||
|
||||
// Check standstill axes
|
||||
bool ecmcSafetyGroup::checkAxesStandstill() {
|
||||
bool ecmcSS1SafetyGroup::checkAxesStandstill() {
|
||||
bool standstill = 1;
|
||||
for(std::vector<safetyAxis*>::iterator saxis = axes_.begin(); saxis != axes_.end(); ++saxis) {
|
||||
standstill= standstill && checkAxisStandstill((*saxis)->axisIndex_,(*saxis)->veloLimit_);
|
||||
standstill= standstill && checkAxisStandstill((*saxis));
|
||||
}
|
||||
return standstill;
|
||||
}
|
||||
|
||||
// Check standstill axis
|
||||
bool ecmcSafetyGroup::checkAxisStandstill(int axisId, double veloLimit) {
|
||||
bool ecmcSS1SafetyGroup::checkAxisStandstill(safetyAxis* axis) {
|
||||
double velo = 1;
|
||||
int err = getAxisTrajVelo(axisId, &velo);
|
||||
int err = getAxisTrajVelo(axis->axisId_, &velo);
|
||||
if(err) {
|
||||
return 0;
|
||||
}
|
||||
return std::abs(velo) <= veloLimit;
|
||||
return std::abs(velo) <= axis->veloLimit_;
|
||||
}
|
||||
|
||||
// Set safety interlock
|
||||
void ecmcSafetyGroup::setAxesDisable() {
|
||||
// Check standstill and disable
|
||||
bool ecmcSS1SafetyGroup::checkAxesStandstillAndDisableIfNeeded() {
|
||||
bool standstill = 1;
|
||||
for(std::vector<safetyAxis*>::iterator saxis = axes_.begin(); saxis != axes_.end(); ++saxis) {
|
||||
standstill = standstill && checkAxisStandstillAndDisableIfNeeded((*saxis));
|
||||
}
|
||||
return standstill;
|
||||
}
|
||||
|
||||
// Check standstill and disable
|
||||
bool ecmcSS1SafetyGroup::checkAxisStandstillAndDisableIfNeeded(safetyAxis* axis) {
|
||||
bool standstill = checkAxisStandstill(axis);
|
||||
if( standstill && rampDownCmd_) {
|
||||
setAxisEnable(axis->axisId_,0);
|
||||
if(cfgDbgMode_ && axis->printEnableStat_) {
|
||||
printf("Safety %s: Disabling axis %d\n",sName_,axis->axisId_);
|
||||
axis->printEnableStat_ = 0;
|
||||
}
|
||||
}
|
||||
return standstill;
|
||||
}
|
||||
|
||||
// Disable all axes
|
||||
void ecmcSS1SafetyGroup::setAxesDisable() {
|
||||
for(std::vector<safetyAxis*>::iterator saxis = axes_.begin(); saxis != axes_.end(); ++saxis) {
|
||||
if(!*saxis) {
|
||||
throw std::runtime_error("Safety: Axis object NULL.");
|
||||
}
|
||||
setAxisEnable((*saxis)->axisIndex_,0);
|
||||
setAxisEnable((*saxis)->axisId_,0);
|
||||
}
|
||||
|
||||
if(printEnableStatus_ && cfgDbgMode_) {
|
||||
printf("Safety %s: Axes are beeing disabled\n",sName_);
|
||||
printf("Safety %s: All axes in group are beeing disabled\n",sName_);
|
||||
}
|
||||
printEnableStatus_ = 0;
|
||||
}
|
||||
|
||||
// Set safety interlock
|
||||
void ecmcSafetyGroup::setAxesSafetyInterlocks(int stop) {
|
||||
void ecmcSS1SafetyGroup::setAxesSafetyInterlocks(int stop) {
|
||||
for(std::vector<safetyAxis*>::iterator saxis = axes_.begin(); saxis != axes_.end(); ++saxis) {
|
||||
if(!*saxis) {
|
||||
throw std::runtime_error( "Safety: Axis object NULL.");
|
||||
}
|
||||
setAxisEmergencyStopInterlock((*saxis)->axisIndex_,stop, 1000);
|
||||
setAxisEmergencyStopInterlock((*saxis)->axisId_,stop);
|
||||
}
|
||||
}
|
||||
|
||||
asynStatus ecmcSafetyGroup::readInt32(asynUser *pasynUser, epicsInt32 *value) {
|
||||
asynStatus ecmcSS1SafetyGroup::readInt32(asynUser *pasynUser, epicsInt32 *value) {
|
||||
int function = pasynUser->reason;
|
||||
if( function == asynStatusId_ ){
|
||||
*value = (epicsInt32)status_;
|
||||
@@ -454,15 +409,16 @@ asynStatus ecmcSafetyGroup::readInt32(asynUser *pasynUser, epicsInt32 *value) {
|
||||
return asynError;
|
||||
}
|
||||
|
||||
void ecmcSafetyGroup::addAxis(int axisId, double veloLimit,int standStillTimeMs) {
|
||||
void ecmcSS1SafetyGroup::addAxis(int axisId, double veloLimit,int standStillTimeMs) {
|
||||
|
||||
if(!getAxisValid(axisId)) {
|
||||
throw std::out_of_range("Safety: Invalid axis id");
|
||||
}
|
||||
|
||||
axes_.push_back(new safetyAxis(axisId, veloLimit, standStillTimeMs));
|
||||
axes_.push_back(new safetyAxis(axisId, veloLimit, standStillTimeMs));
|
||||
axesCounter_++;
|
||||
|
||||
|
||||
if(cfgDbgMode_) {
|
||||
printf("Safety %s: Added axis %d to safety group\n",sName_,axisId);
|
||||
}
|
||||
@@ -470,60 +426,60 @@ void ecmcSafetyGroup::addAxis(int axisId, double veloLimit,int standStillTimeMs)
|
||||
return;
|
||||
}
|
||||
|
||||
std::string ecmcSafetyGroup::getName() {
|
||||
std::string ecmcSS1SafetyGroup::getName() {
|
||||
return sName_;
|
||||
}
|
||||
|
||||
uint8_t ecmcSafetyGroup::getUint8(uint8_t* data) {
|
||||
uint8_t ecmcSS1SafetyGroup::getUint8(uint8_t* data) {
|
||||
return *data;
|
||||
}
|
||||
|
||||
int8_t ecmcSafetyGroup::getInt8(uint8_t* data) {
|
||||
int8_t ecmcSS1SafetyGroup::getInt8(uint8_t* data) {
|
||||
int8_t* p=(int8_t*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
uint16_t ecmcSafetyGroup::getUint16(uint8_t* data) {
|
||||
uint16_t ecmcSS1SafetyGroup::getUint16(uint8_t* data) {
|
||||
uint16_t* p=(uint16_t*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
int16_t ecmcSafetyGroup::getInt16(uint8_t* data) {
|
||||
int16_t ecmcSS1SafetyGroup::getInt16(uint8_t* data) {
|
||||
int16_t* p=(int16_t*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
uint32_t ecmcSafetyGroup::getUint32(uint8_t* data) {
|
||||
uint32_t ecmcSS1SafetyGroup::getUint32(uint8_t* data) {
|
||||
uint32_t* p=(uint32_t*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
int32_t ecmcSafetyGroup::getInt32(uint8_t* data) {
|
||||
int32_t ecmcSS1SafetyGroup::getInt32(uint8_t* data) {
|
||||
int32_t* p=(int32_t*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
uint64_t ecmcSafetyGroup::getUint64(uint8_t* data) {
|
||||
uint64_t ecmcSS1SafetyGroup::getUint64(uint8_t* data) {
|
||||
uint64_t* p=(uint64_t*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
int64_t ecmcSafetyGroup::getInt64(uint8_t* data) {
|
||||
int64_t ecmcSS1SafetyGroup::getInt64(uint8_t* data) {
|
||||
int64_t* p=(int64_t*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
float ecmcSafetyGroup::getFloat32(uint8_t* data) {
|
||||
float ecmcSS1SafetyGroup::getFloat32(uint8_t* data) {
|
||||
float* p=(float*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
double ecmcSafetyGroup::getFloat64(uint8_t* data) {
|
||||
double ecmcSS1SafetyGroup::getFloat64(uint8_t* data) {
|
||||
double* p=(double*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
size_t ecmcSafetyGroup::getEcDataTypeByteSize(ecmcEcDataType dt){
|
||||
size_t ecmcSS1SafetyGroup::getEcDataTypeByteSize(ecmcEcDataType dt){
|
||||
switch(dt) {
|
||||
case ECMC_EC_NONE:
|
||||
return 0;
|
||||
@@ -23,19 +23,22 @@
|
||||
|
||||
class safetyAxis {
|
||||
public:
|
||||
safetyAxis(int axisIndex,
|
||||
safetyAxis(int axisId,
|
||||
double veloLimit,
|
||||
int standStillTimeMs) {
|
||||
veloLimit_ = veloLimit;
|
||||
axisIndex_ = axisIndex;
|
||||
veloLimit_ = veloLimit;
|
||||
axisId_ = axisId;
|
||||
standStillTimeMs_ = standStillTimeMs;
|
||||
printEnableStat_ = 1;
|
||||
}
|
||||
double veloLimit_;
|
||||
int axisIndex_;
|
||||
int standStillTimeMs_;
|
||||
|
||||
double veloLimit_;
|
||||
int axisId_;
|
||||
int standStillTimeMs_;
|
||||
int printEnableStat_;
|
||||
};
|
||||
|
||||
class ecmcSafetyGroup : public asynPortDriver {
|
||||
class ecmcSS1SafetyGroup : public asynPortDriver {
|
||||
public:
|
||||
|
||||
/** ecmc Safty Plg class
|
||||
@@ -43,14 +46,14 @@ class ecmcSafetyGroup : public asynPortDriver {
|
||||
* - bad_alloc
|
||||
* - out_of_range
|
||||
*/
|
||||
ecmcSafetyGroup(const char *name,
|
||||
ecmcSS1SafetyGroup(const char *name,
|
||||
const char *ec_rampdown_cmd,
|
||||
const char *ec_standstill_status,
|
||||
int time_delay_ms,
|
||||
const char *cfg_string,
|
||||
char* portName);
|
||||
|
||||
~ecmcSafetyGroup();
|
||||
~ecmcSS1SafetyGroup();
|
||||
|
||||
// Call just before realtime because then all data sources should be available
|
||||
void validate();
|
||||
@@ -62,13 +65,15 @@ class ecmcSafetyGroup : public asynPortDriver {
|
||||
private:
|
||||
void validateCfgs();
|
||||
void validateAxes();
|
||||
void stripBits();
|
||||
void connectToDataSources();
|
||||
void setAxesSafetyInterlocks(int stop);
|
||||
void setAxesDisable();
|
||||
void setAxesStandstillStatus(int standstill);
|
||||
bool checkAxesStandstill();
|
||||
bool checkAxisStandstill(int axisId, double veloLimit);
|
||||
bool checkAxisStandstill(safetyAxis* axis);
|
||||
bool checkAxisStandstillAndDisableIfNeeded(safetyAxis* axis);
|
||||
bool checkAxesStandstillAndDisableIfNeeded();
|
||||
void resetPrintoutStatus();
|
||||
void parseConfigStr(const char *configStr);
|
||||
void initAsyn();
|
||||
double ecmcSampleRateHz_;
|
||||
@@ -21,12 +21,12 @@
|
||||
|
||||
#include <iocsh.h>
|
||||
#include "ecmcSafetyPlgWrap.h"
|
||||
#include "ecmcSafetyGroup.h"
|
||||
#include "ecmcSS1SafetyGroup.h"
|
||||
|
||||
#define ECMC_PLUGIN_MAX_PORTNAME_CHARS 64
|
||||
#define ECMC_PLUGIN_PORTNAME_PREFIX "PLUGIN.SAFETY"
|
||||
|
||||
static std::vector<ecmcSafetyGroup*> safetyGroups;
|
||||
static std::vector<ecmcSS1SafetyGroup*> safetyGroups;
|
||||
static int safetyGroupsCounter = 0;
|
||||
static char portNameBuffer[ECMC_PLUGIN_MAX_PORTNAME_CHARS];
|
||||
|
||||
@@ -42,15 +42,15 @@ int createSafetyGroup(const char *name,
|
||||
const char *ec_standstill_status,
|
||||
int time_delay_ms) {
|
||||
|
||||
// create new ecmcSafetyGroup object
|
||||
ecmcSafetyGroup* safetyGroup = NULL;
|
||||
// create new ecmcSS1SafetyGroup object
|
||||
ecmcSS1SafetyGroup* 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 ecmcSafetyGroup(name,
|
||||
safetyGroup = new ecmcSS1SafetyGroup(name,
|
||||
ec_rampdown_cmd,
|
||||
ec_standstill_status,
|
||||
time_delay_ms,
|
||||
@@ -75,7 +75,7 @@ int addAxisToSafetyGroup(const char *groupName,
|
||||
double veloLimit,
|
||||
int standStillTimeMs) {
|
||||
// Find group by name
|
||||
for(std::vector<ecmcSafetyGroup*>::iterator psafetyGroup = safetyGroups.begin(); psafetyGroup != safetyGroups.end(); ++psafetyGroup) {
|
||||
for(std::vector<ecmcSS1SafetyGroup*>::iterator psafetyGroup = safetyGroups.begin(); psafetyGroup != safetyGroups.end(); ++psafetyGroup) {
|
||||
bool found = strcmp(groupName, (*psafetyGroup)->getName().c_str()) == 0;
|
||||
if(found) {
|
||||
(*psafetyGroup)->addAxis(axisId,veloLimit,standStillTimeMs);
|
||||
@@ -90,7 +90,7 @@ void deleteAllSafetyGroups() {
|
||||
|
||||
return; // The delete process results in seg fault.. need to investigate..
|
||||
|
||||
for(std::vector<ecmcSafetyGroup*>::iterator psafetyGroup = safetyGroups.begin(); psafetyGroup != safetyGroups.end(); ++psafetyGroup) {
|
||||
for(std::vector<ecmcSS1SafetyGroup*>::iterator psafetyGroup = safetyGroups.begin(); psafetyGroup != safetyGroups.end(); ++psafetyGroup) {
|
||||
if(*psafetyGroup) {
|
||||
delete (*psafetyGroup);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ void deleteAllSafetyGroups() {
|
||||
}
|
||||
|
||||
int validate() {
|
||||
for(std::vector<ecmcSafetyGroup*>::iterator psafetyGroup = safetyGroups.begin(); psafetyGroup != safetyGroups.end(); ++psafetyGroup) {
|
||||
for(std::vector<ecmcSS1SafetyGroup*>::iterator psafetyGroup = safetyGroups.begin(); psafetyGroup != safetyGroups.end(); ++psafetyGroup) {
|
||||
if(*psafetyGroup) {
|
||||
try {
|
||||
(*psafetyGroup)->validate();
|
||||
@@ -114,7 +114,7 @@ int validate() {
|
||||
|
||||
int executeSafetyGroups() {
|
||||
|
||||
for(std::vector<ecmcSafetyGroup*>::iterator psafetyGroup = safetyGroups.begin(); psafetyGroup != safetyGroups.end(); ++psafetyGroup) {
|
||||
for(std::vector<ecmcSS1SafetyGroup*>::iterator psafetyGroup = safetyGroups.begin(); psafetyGroup != safetyGroups.end(); ++psafetyGroup) {
|
||||
if(*psafetyGroup) {
|
||||
try {
|
||||
(*psafetyGroup)->execute();
|
||||
@@ -129,11 +129,11 @@ int executeSafetyGroups() {
|
||||
}
|
||||
|
||||
/**
|
||||
* EPICS iocsh shell command: ecmcAddSafetyGroup
|
||||
* EPICS iocsh shell command: ecmcAddSS1SafetyGroup
|
||||
*/
|
||||
void ecmcAddSafetyGroupPrintHelp() {
|
||||
void ecmcAddSS1SafetyGroupPrintHelp() {
|
||||
printf("\n");
|
||||
printf(" Use ecmcAddSafetyGroup(<name>, <ec_rampdown_cmd>, <ec_standstill_status>,<time_delay_ms>)\n");
|
||||
printf(" Use ecmcAddSS1SafetyGroup(<name>, <ec_rampdown_cmd>, <ec_standstill_status>,<time_delay_ms>)\n");
|
||||
printf(" <name> : Name of group.\n");
|
||||
printf(" <ec_rampdown_cmd> : Ethercat entry input for rampdown cmd.\n");
|
||||
printf(" <ec_standstill_status> : Ethercat entry output for group standstill status.\n");
|
||||
@@ -141,27 +141,26 @@ void ecmcAddSafetyGroupPrintHelp() {
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int ecmcAddSafetyGroup(const char* name, const char* ec_rampdown_cmd,const char* ec_standstill_status,int time_delay_ms) {
|
||||
int ecmcAddSS1SafetyGroup(const char* name, const char* ec_rampdown_cmd,const char* ec_standstill_status,int time_delay_ms) {
|
||||
if(!name) {
|
||||
printf("Error: name.\n");
|
||||
ecmcAddSafetyGroupPrintHelp();
|
||||
ecmcAddSS1SafetyGroupPrintHelp();
|
||||
return asynError;
|
||||
}
|
||||
|
||||
if(strcmp(name,"-h") == 0 || strcmp(name,"--help") == 0 ) {
|
||||
ecmcAddSafetyGroupPrintHelp();
|
||||
ecmcAddSS1SafetyGroupPrintHelp();
|
||||
return asynSuccess;
|
||||
}
|
||||
|
||||
if(!ec_rampdown_cmd) {
|
||||
printf("Error: ec_rampdown_cmd ethercat entry not defined.\n");
|
||||
ecmcAddSafetyGroupPrintHelp();
|
||||
ecmcAddSS1SafetyGroupPrintHelp();
|
||||
return asynError;
|
||||
}
|
||||
|
||||
if(!ec_standstill_status) {
|
||||
printf("Error: ec_standstill_status ethercat entry not defined.\n");
|
||||
ecmcAddSafetyGroupPrintHelp();
|
||||
ecmcAddSS1SafetyGroupPrintHelp();
|
||||
return asynError;
|
||||
}
|
||||
if(time_delay_ms <= 0) {
|
||||
@@ -194,9 +193,9 @@ static const iocshArg *const initArgs_1[] = { &initArg0_1,
|
||||
&initArg2_1,
|
||||
&initArg3_1};
|
||||
|
||||
static const iocshFuncDef initFuncDef_1 = { "ecmcAddSafetyGroup", 4, initArgs_1 };
|
||||
static const iocshFuncDef initFuncDef_1 = { "ecmcAddSS1SafetyGroup", 4, initArgs_1 };
|
||||
static void initCallFunc_1(const iocshArgBuf *args) {
|
||||
ecmcAddSafetyGroup(args[0].sval, args[1].sval, args[2].sval, args[3].ival);
|
||||
ecmcAddSS1SafetyGroup(args[0].sval, args[1].sval, args[2].sval, args[3].ival);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,8 +212,7 @@ void ecmcAddAxisToSafetyGroupPrintHelp() {
|
||||
}
|
||||
|
||||
int ecmcAddAxisToSafetyGroup(const char* name, int axis_id, double velo_lim, int stand_still_time) {
|
||||
if(!name) {
|
||||
printf("Error: name.\n");
|
||||
if(!name) {
|
||||
ecmcAddAxisToSafetyGroupPrintHelp();
|
||||
return asynError;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user