Add template. add asyn params
This commit is contained in:
@@ -62,7 +62,8 @@ ecmcSS1SafetyGroup::ecmcSS1SafetyGroup(const char *name,
|
||||
sEcAxesStandStillStatStrip_ = strdup(ec_standstill_status);
|
||||
sConfig_ = strdup(cfg_string);
|
||||
delayMs_ = time_delay_ms;
|
||||
status_ = 0;
|
||||
memset(&status_,0,sizeof(status_));
|
||||
ptrStatus_ = (int*)&status_;
|
||||
asynStatusId_ = -1;
|
||||
axesCounter_ = 0;
|
||||
ecmcSampleRateHz_ = getEcmcSampleRate();
|
||||
@@ -273,16 +274,31 @@ void ecmcSS1SafetyGroup::connectToDataSources() {
|
||||
//dataSourcesLinked_ = 1;
|
||||
}
|
||||
|
||||
void ecmcSS1SafetyGroup::refreshAsyn() {
|
||||
setIntegerParam(asynStatusId_, (epicsInt32)*ptrStatus_);
|
||||
callParamCallbacks();
|
||||
}
|
||||
|
||||
asynStatus ecmcSS1SafetyGroup::readInt32(asynUser *pasynUser, epicsInt32 *value) {
|
||||
int function = pasynUser->reason;
|
||||
if( function == asynStatusId_ ) {
|
||||
*value = (epicsInt32)*ptrStatus_;
|
||||
return asynSuccess;
|
||||
}
|
||||
|
||||
return asynError;
|
||||
}
|
||||
|
||||
void ecmcSS1SafetyGroup::initAsyn() {
|
||||
|
||||
// Add motion "plugin.motion%d.status"
|
||||
std::string paramName = ECMC_PLUGIN_ASYN_PREFIX "_" + to_string(objectId_) +
|
||||
// Add motion "plugin.safety.ss1.<grp_name>.status"
|
||||
std::string paramName = ECMC_PLUGIN_ASYN_PREFIX "." ECMC_PLUGIN_ASYN_SS1 "." + std::string(sName_) +
|
||||
"." + ECMC_PLUGIN_ASYN_SAFETY_STAT;
|
||||
int *paramId = &asynStatusId_;
|
||||
if( createParam(0, paramName.c_str(), asynParamInt32, paramId ) != asynSuccess ) {
|
||||
throw std::runtime_error("Safety: Failed create asyn parameter mode");
|
||||
}
|
||||
setIntegerParam(*paramId, (epicsInt32)status_);
|
||||
setIntegerParam(asynStatusId_, (epicsInt32)*ptrStatus_);
|
||||
|
||||
// Update integers
|
||||
callParamCallbacks();
|
||||
@@ -313,6 +329,11 @@ void ecmcSS1SafetyGroup::execute() {
|
||||
rampDownCmd_ = data == 0;
|
||||
|
||||
if(rampDownCmdOld_ != rampDownCmd_) {
|
||||
|
||||
// Update asyn status wd
|
||||
status_.rampDownCmdActive = rampDownCmd_;
|
||||
refreshAsyn();
|
||||
|
||||
resetPrintoutStatus();
|
||||
if(cfgDbgMode_) {
|
||||
if(rampDownCmd_) {
|
||||
@@ -351,6 +372,10 @@ void ecmcSS1SafetyGroup::setAxesStandstillStatus(int standstill) {
|
||||
} else {
|
||||
printf("Safety %s: Axes are moving\n",sName_);
|
||||
}
|
||||
|
||||
// Update asyn status wd
|
||||
status_.axesAtStandstill = standstill;
|
||||
refreshAsyn();
|
||||
}
|
||||
|
||||
if(ecEntryStandstill_->writeBit(bitStandStill_,
|
||||
@@ -426,16 +451,6 @@ void ecmcSS1SafetyGroup::setAxesSafetyInterlocks(int stop) {
|
||||
}
|
||||
}
|
||||
|
||||
asynStatus ecmcSS1SafetyGroup::readInt32(asynUser *pasynUser, epicsInt32 *value) {
|
||||
int function = pasynUser->reason;
|
||||
if( function == asynStatusId_ ){
|
||||
*value = (epicsInt32)status_;
|
||||
return asynSuccess;
|
||||
}
|
||||
|
||||
return asynError;
|
||||
}
|
||||
|
||||
void ecmcSS1SafetyGroup::addAxis(int axisId, double veloLimit,int standStillTimeMs) {
|
||||
|
||||
if(!getAxisValid(axisId)) {
|
||||
@@ -456,122 +471,3 @@ void ecmcSS1SafetyGroup::addAxis(int axisId, double veloLimit,int standStillTime
|
||||
std::string ecmcSS1SafetyGroup::getName() {
|
||||
return sName_;
|
||||
}
|
||||
|
||||
uint8_t ecmcSS1SafetyGroup::getUint8(uint8_t* data) {
|
||||
return *data;
|
||||
}
|
||||
|
||||
int8_t ecmcSS1SafetyGroup::getInt8(uint8_t* data) {
|
||||
int8_t* p=(int8_t*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
uint16_t ecmcSS1SafetyGroup::getUint16(uint8_t* data) {
|
||||
uint16_t* p=(uint16_t*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
int16_t ecmcSS1SafetyGroup::getInt16(uint8_t* data) {
|
||||
int16_t* p=(int16_t*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
uint32_t ecmcSS1SafetyGroup::getUint32(uint8_t* data) {
|
||||
uint32_t* p=(uint32_t*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
int32_t ecmcSS1SafetyGroup::getInt32(uint8_t* data) {
|
||||
int32_t* p=(int32_t*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
uint64_t ecmcSS1SafetyGroup::getUint64(uint8_t* data) {
|
||||
uint64_t* p=(uint64_t*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
int64_t ecmcSS1SafetyGroup::getInt64(uint8_t* data) {
|
||||
int64_t* p=(int64_t*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
float ecmcSS1SafetyGroup::getFloat32(uint8_t* data) {
|
||||
float* p=(float*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
double ecmcSS1SafetyGroup::getFloat64(uint8_t* data) {
|
||||
double* p=(double*)data;
|
||||
return *p;
|
||||
}
|
||||
|
||||
size_t ecmcSS1SafetyGroup::getEcDataTypeByteSize(ecmcEcDataType dt){
|
||||
switch(dt) {
|
||||
case ECMC_EC_NONE:
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case ECMC_EC_B1:
|
||||
return 1;
|
||||
break;
|
||||
|
||||
case ECMC_EC_B2:
|
||||
return 1;
|
||||
break;
|
||||
|
||||
case ECMC_EC_B3:
|
||||
return 1;
|
||||
break;
|
||||
|
||||
case ECMC_EC_B4:
|
||||
return 1;
|
||||
break;
|
||||
|
||||
case ECMC_EC_U8:
|
||||
return 1;
|
||||
break;
|
||||
|
||||
case ECMC_EC_S8:
|
||||
return 1;
|
||||
break;
|
||||
|
||||
case ECMC_EC_U16:
|
||||
return 2;
|
||||
break;
|
||||
|
||||
case ECMC_EC_S16:
|
||||
return 2;
|
||||
break;
|
||||
|
||||
case ECMC_EC_U32:
|
||||
return 4;
|
||||
break;
|
||||
|
||||
case ECMC_EC_S32:
|
||||
return 4;
|
||||
break;
|
||||
|
||||
case ECMC_EC_U64:
|
||||
return 8;
|
||||
break;
|
||||
|
||||
case ECMC_EC_S64:
|
||||
return 8;
|
||||
break;
|
||||
|
||||
case ECMC_EC_F32:
|
||||
return 4;
|
||||
break;
|
||||
|
||||
case ECMC_EC_F64:
|
||||
return 8;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user