Add more validation:

* ensure group is not empty
* ensure axis group with same name is created twice
* ensure group exists when adding axis
This commit is contained in:
2024-02-21 09:15:38 +01:00
parent f49a9d0ec4
commit 9dad4609d6
9 changed files with 56 additions and 50 deletions

View File

@@ -182,8 +182,7 @@ void ecmcSS1SafetyGroup::validateCfgs() {
}
}
void ecmcSS1SafetyGroup::validateAxes() {
void ecmcSS1SafetyGroup::validateAxes() {
// Ensure that axis is not linked twice to group
for(std::vector<safetyAxis*>::iterator iaxis = axes_.begin(); iaxis != axes_.end(); ++iaxis) {
int axisLinkedCounter = 0;
@@ -213,11 +212,19 @@ void ecmcSS1SafetyGroup::validateAxes() {
}
}
int axisCounter = 0;
// Check axis object exists and valid
for(std::vector<safetyAxis*>::iterator saxis = axes_.begin(); saxis != axes_.end(); ++saxis) {
if(!getAxisValid((*saxis)->axisId_)) {
throw std::runtime_error( "Safety: Ecmc Axis object not valid.");
}
axisCounter++;
}
// do not allow empty group
if(axisCounter == 0) {
printf("Safety %s: Error, group empty (axis count zero)\n",sName_);
throw std::runtime_error( "Safety: Error, empty group not allowed.");
}
}