Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
c334ed9f04 | |||
4b0031c3af | |||
61335970ce | |||
081a21073b | |||
f2e8eb2762 | |||
e93f11e779 | |||
989410474e | |||
8d8561d833 | |||
a56a8cf646 | |||
cd57409f3c | |||
21ffcba8be |
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "sinqMotor"]
|
||||
path = sinqMotor
|
||||
url = https://gitea.psi.ch/lin-epics-modules/sinqMotor
|
13
Makefile
13
Makefile
@ -12,18 +12,23 @@ REQUIRED+=sinqMotor
|
||||
# Specify the version of asynMotor we want to build against
|
||||
motorBase_VERSION=7.2.2
|
||||
|
||||
# Specify the version of sinqMotor we want to build against
|
||||
sinqMotor_VERSION=0.13.0
|
||||
|
||||
# These headers allow to depend on this library for derived drivers.
|
||||
HEADERS += src/masterMacsAxis.h
|
||||
HEADERS += src/masterMacsController.h
|
||||
|
||||
# Source files to build
|
||||
SOURCES += sinqMotor/src/msgPrintControl.cpp
|
||||
SOURCES += sinqMotor/src/sinqAxis.cpp
|
||||
SOURCES += sinqMotor/src/sinqController.cpp
|
||||
SOURCES += src/masterMacsAxis.cpp
|
||||
SOURCES += src/masterMacsController.cpp
|
||||
|
||||
# Store the record files
|
||||
TEMPLATES += sinqMotor/db/asynRecord.db
|
||||
TEMPLATES += sinqMotor/db/sinqMotor.db
|
||||
|
||||
# This file registers the motor-specific functions in the IOC shell.
|
||||
DBDS += sinqMotor/src/sinqMotor.dbd
|
||||
DBDS += src/masterMacs.dbd
|
||||
|
||||
USR_CFLAGS += -Wall -Wextra -Weffc++ -Wunused-result -Wpedantic -Wextra -Werror
|
||||
USR_CFLAGS += -Wall -Wextra -Weffc++ -Wunused-result -Wextra -Werror
|
||||
|
1
sinqMotor
Submodule
1
sinqMotor
Submodule
Submodule sinqMotor added at e088bfbbcb
@ -138,6 +138,20 @@ masterMacsAxis::masterMacsAxis(masterMacsController *pC, int axisNo)
|
||||
pC_->portName, axisNo, __PRETTY_FUNCTION__, __LINE__,
|
||||
pC_->stringifyAsynStatus(status));
|
||||
}
|
||||
|
||||
// Even though this happens already in sinqAxis, a default value for
|
||||
// motorMessageText is set here again, because apparently the sinqAxis
|
||||
// constructor is not run before the string is accessed?
|
||||
status = setStringParam(pC_->motorMessageText(), "");
|
||||
if (status != asynSuccess) {
|
||||
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
|
||||
"Controller \"%s\", axis %d => %s, line %d:\nFATAL ERROR "
|
||||
"(setting a parameter value failed "
|
||||
"with %s)\n. Terminating IOC",
|
||||
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
||||
pC_->stringifyAsynStatus(status));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
masterMacsAxis::~masterMacsAxis(void) {
|
||||
@ -460,7 +474,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
|
||||
|
||||
// This buffer must be initialized to zero because we build the
|
||||
// error message by appending strings.
|
||||
char userMessage[pC_->MAXBUF_] = {0};
|
||||
char errorMessage[pC_->MAXBUF_] = {0};
|
||||
char shellMessage[pC_->MAXBUF_] = {0};
|
||||
|
||||
// Concatenate all other errors
|
||||
@ -468,7 +482,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
|
||||
appendErrorMessage(shellMessage, sizeof(shellMessage),
|
||||
"Short circuit fault.");
|
||||
appendErrorMessage(
|
||||
userMessage, sizeof(userMessage),
|
||||
errorMessage, sizeof(errorMessage),
|
||||
"Short circuit error. Please call the support.");
|
||||
|
||||
poll_status = asynError;
|
||||
@ -477,7 +491,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
|
||||
if (encoderError()) {
|
||||
appendErrorMessage(shellMessage, sizeof(shellMessage),
|
||||
"Encoder error.");
|
||||
appendErrorMessage(userMessage, sizeof(userMessage),
|
||||
appendErrorMessage(errorMessage, sizeof(errorMessage),
|
||||
"Encoder error. Please call the support.");
|
||||
|
||||
poll_status = asynError;
|
||||
@ -488,7 +502,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
|
||||
shellMessage, sizeof(shellMessage),
|
||||
"Maximum callowed following error exceeded.");
|
||||
appendErrorMessage(
|
||||
userMessage, sizeof(userMessage),
|
||||
errorMessage, sizeof(errorMessage),
|
||||
"Maximum allowed following error exceeded.Check if "
|
||||
"movement range is blocked. Otherwise please call the "
|
||||
"support.");
|
||||
@ -499,7 +513,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
|
||||
if (feedbackError()) {
|
||||
appendErrorMessage(shellMessage, sizeof(shellMessage),
|
||||
"Feedback error.");
|
||||
appendErrorMessage(userMessage, sizeof(userMessage),
|
||||
appendErrorMessage(errorMessage, sizeof(errorMessage),
|
||||
"Feedback error. Please call the support.");
|
||||
|
||||
poll_status = asynError;
|
||||
@ -535,7 +549,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
|
||||
|
||||
// Generic error message for user
|
||||
appendErrorMessage(
|
||||
userMessage, sizeof(userMessage),
|
||||
errorMessage, sizeof(errorMessage),
|
||||
"Software limits or end switch hit. Try homing the motor, "
|
||||
"moving in the opposite direction or check the SPS for "
|
||||
"errors (if available). Otherwise please call the "
|
||||
@ -548,7 +562,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
|
||||
appendErrorMessage(shellMessage, sizeof(shellMessage),
|
||||
"Overcurrent error.");
|
||||
appendErrorMessage(
|
||||
userMessage, sizeof(userMessage),
|
||||
errorMessage, sizeof(errorMessage),
|
||||
"Overcurrent error. Please call the support.");
|
||||
|
||||
poll_status = asynError;
|
||||
@ -558,7 +572,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
|
||||
appendErrorMessage(shellMessage, sizeof(shellMessage),
|
||||
"Overtemperature error.");
|
||||
appendErrorMessage(
|
||||
userMessage, sizeof(userMessage),
|
||||
errorMessage, sizeof(errorMessage),
|
||||
"Overtemperature error. Please call the support.");
|
||||
|
||||
poll_status = asynError;
|
||||
@ -568,7 +582,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
|
||||
appendErrorMessage(shellMessage, sizeof(shellMessage),
|
||||
"Overvoltage error.");
|
||||
appendErrorMessage(
|
||||
userMessage, sizeof(userMessage),
|
||||
errorMessage, sizeof(errorMessage),
|
||||
"Overvoltage error. Please call the support.");
|
||||
|
||||
poll_status = asynError;
|
||||
@ -578,7 +592,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
|
||||
appendErrorMessage(shellMessage, sizeof(shellMessage),
|
||||
"Undervoltage error.");
|
||||
appendErrorMessage(
|
||||
userMessage, sizeof(userMessage),
|
||||
errorMessage, sizeof(errorMessage),
|
||||
"Undervoltage error. Please call the support.");
|
||||
|
||||
poll_status = asynError;
|
||||
@ -587,7 +601,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
|
||||
if (stoFault()) {
|
||||
appendErrorMessage(shellMessage, sizeof(shellMessage),
|
||||
"STO input is on disable state.");
|
||||
appendErrorMessage(userMessage, sizeof(userMessage),
|
||||
appendErrorMessage(errorMessage, sizeof(errorMessage),
|
||||
"STO fault. Please call the support.");
|
||||
|
||||
poll_status = asynError;
|
||||
@ -605,7 +619,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
|
||||
}
|
||||
}
|
||||
|
||||
pl_status = setStringParam(pC_->motorMessageText(), userMessage);
|
||||
pl_status = setStringParam(pC_->motorMessageText(), errorMessage);
|
||||
if (pl_status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
||||
axisNo_, __PRETTY_FUNCTION__,
|
||||
@ -1035,8 +1049,6 @@ asynStatus masterMacsAxis::enable(bool on) {
|
||||
// Status of parameter library operations
|
||||
asynStatus pl_status = asynSuccess;
|
||||
|
||||
bool moving = false;
|
||||
|
||||
// =========================================================================
|
||||
|
||||
/*
|
||||
@ -1046,6 +1058,13 @@ asynStatus masterMacsAxis::enable(bool on) {
|
||||
*/
|
||||
targetReachedUninitialized_ = true;
|
||||
|
||||
/*
|
||||
Continue regardless of the status returned by the poll; we just want to
|
||||
find out whether the motor is currently moving or not. If the poll
|
||||
function fails before it can determine that, it is assumed that the motor
|
||||
is not moving.
|
||||
*/
|
||||
bool moving = false;
|
||||
doPoll(&moving);
|
||||
|
||||
// If the axis is currently moving, it cannot be disabled. Ignore the
|
||||
@ -1088,16 +1107,6 @@ asynStatus masterMacsAxis::enable(bool on) {
|
||||
"Controller \"%s\", axis %d => %s, line %d:\n%s axis.\n",
|
||||
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
||||
on ? "Enable" : "Disable");
|
||||
if (on == 0) {
|
||||
pl_status = setStringParam(pC_->motorMessageText(), "Disabling ...");
|
||||
} else {
|
||||
pl_status = setStringParam(pC_->motorMessageText(), "Enabling ...");
|
||||
}
|
||||
if (pl_status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
||||
axisNo_, __PRETTY_FUNCTION__,
|
||||
__LINE__);
|
||||
}
|
||||
|
||||
// The answer to the enable command on MasterMACS might take some time,
|
||||
// hence we wait for a custom timespan in seconds instead of
|
||||
@ -1143,7 +1152,7 @@ asynStatus masterMacsAxis::enable(bool on) {
|
||||
// Output message to user
|
||||
snprintf(value, sizeof(value), "Failed to %s within %d seconds",
|
||||
on ? "enable" : "disable", timeout_enable_disable);
|
||||
pl_status = setStringParam(pC_->motorMessageText(), "Enabling ...");
|
||||
pl_status = setStringParam(pC_->motorMessageText(), value);
|
||||
if (pl_status != asynSuccess) {
|
||||
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
||||
axisNo_, __PRETTY_FUNCTION__,
|
||||
|
@ -305,12 +305,21 @@ asynStatus masterMacsController::parseResponse(
|
||||
|
||||
bool responseValid = false;
|
||||
int responseStart = 0;
|
||||
asynStatus status = asynSuccess;
|
||||
int prevConnected = 0;
|
||||
char printableCommand[MAXBUF_] = {0};
|
||||
char printableResponse[MAXBUF_] = {0};
|
||||
|
||||
msgPrintControlKey parseKey =
|
||||
msgPrintControlKey(portName, axisNo, __PRETTY_FUNCTION__, __LINE__);
|
||||
|
||||
// Was the motor previously connected?
|
||||
status = getIntegerParam(axisNo, motorConnected(), &prevConnected);
|
||||
if (status != asynSuccess) {
|
||||
return paramLibAccessFailed(status, "motorConnected", axisNo,
|
||||
__PRETTY_FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
// We don't use strlen here since the C string terminator 0x00
|
||||
// occurs in the middle of the char array.
|
||||
for (uint32_t i = 0; i < MAXBUF_; i++) {
|
||||
@ -319,20 +328,75 @@ asynStatus masterMacsController::parseResponse(
|
||||
} else if (fullResponse[i] == '=') {
|
||||
*valueStart = i + 1;
|
||||
} else if (fullResponse[i] == '\x06') {
|
||||
// ACK
|
||||
*valueStop = i;
|
||||
responseValid = true;
|
||||
break;
|
||||
} else if (fullResponse[i] == '\x15') {
|
||||
// NAK
|
||||
snprintf(drvMessageText, MAXBUF_, "Communication failed.");
|
||||
|
||||
if (msgPrintControl_.shouldBePrinted(parseKey, true,
|
||||
pasynUserSelf)) {
|
||||
// Motor wasn't connected before -> Update the paramLib entry and PV
|
||||
// to show it is now connected.
|
||||
if (prevConnected == 0) {
|
||||
|
||||
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
|
||||
"Controller \"%s\", axis %d => %s, line "
|
||||
"%d:\nCommunication failed.%s\n",
|
||||
portName, axisNo, __PRETTY_FUNCTION__, __LINE__,
|
||||
msgPrintControl_.getSuffix());
|
||||
"%d:\nAxis connection status has changed to "
|
||||
"connected.\n",
|
||||
portName, axisNo, __PRETTY_FUNCTION__, __LINE__);
|
||||
|
||||
masterMacsAxis *axis = getMasterMacsAxis(axisNo);
|
||||
if (axis == nullptr) {
|
||||
return asynError;
|
||||
}
|
||||
status = axis->setIntegerParam(motorConnected(), 1);
|
||||
if (status != asynSuccess) {
|
||||
return paramLibAccessFailed(status, "motorConnected",
|
||||
axisNo, __PRETTY_FUNCTION__,
|
||||
__LINE__);
|
||||
}
|
||||
status = callParamCallbacks();
|
||||
if (status != asynSuccess) {
|
||||
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
|
||||
"Controller \"%s\", axis %d => %s, line "
|
||||
"%d:\nCould not update parameter library\n",
|
||||
portName, axisNo, __PRETTY_FUNCTION__, __LINE__);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
} else if (fullResponse[i] == '\x15') {
|
||||
/*
|
||||
NAK
|
||||
This indicates that the axis is not connected. This is not an error!
|
||||
*/
|
||||
snprintf(drvMessageText, MAXBUF_, "Axis not connected.");
|
||||
|
||||
// Motor was connected before -> Update the paramLib entry and PV
|
||||
// to show it is now disconnected.
|
||||
if (prevConnected == 1) {
|
||||
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
|
||||
"Controller \"%s\", axis %d => %s, line "
|
||||
"%d:\nAxis connection status has changed to "
|
||||
"disconnected.\n",
|
||||
portName, axisNo, __PRETTY_FUNCTION__, __LINE__);
|
||||
|
||||
masterMacsAxis *axis = getMasterMacsAxis(axisNo);
|
||||
if (axis == nullptr) {
|
||||
return asynError;
|
||||
}
|
||||
status = axis->setIntegerParam(motorConnected(), 0);
|
||||
if (status != asynSuccess) {
|
||||
return paramLibAccessFailed(status, "motorConnected",
|
||||
axisNo, __PRETTY_FUNCTION__,
|
||||
__LINE__);
|
||||
}
|
||||
status = callParamCallbacks();
|
||||
if (status != asynSuccess) {
|
||||
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
|
||||
"Controller \"%s\", axis %d => %s, line "
|
||||
"%d:\nCould not update parameter library\n",
|
||||
portName, axisNo, __PRETTY_FUNCTION__, __LINE__);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else if (fullResponse[i] == '\x18') {
|
||||
@ -404,7 +468,8 @@ asynStatus masterMacsController::parseResponse(
|
||||
return asynSuccess;
|
||||
}
|
||||
|
||||
asynStatus sinqController::readInt32(asynUser *pasynUser, epicsInt32 *value) {
|
||||
asynStatus masterMacsController::readInt32(asynUser *pasynUser,
|
||||
epicsInt32 *value) {
|
||||
// masterMacs can be disabled
|
||||
if (pasynUser->reason == motorCanDisable_) {
|
||||
*value = 1;
|
||||
|
@ -31,6 +31,15 @@ class masterMacsController : public sinqController {
|
||||
int numAxes, double movingPollPeriod,
|
||||
double idlePollPeriod, double comTimeout);
|
||||
|
||||
/**
|
||||
* @brief Overloaded version of the sinqController version
|
||||
*
|
||||
* @param pasynUser
|
||||
* @param value
|
||||
* @return asynStatus
|
||||
*/
|
||||
asynStatus readInt32(asynUser *pasynUser, epicsInt32 *value);
|
||||
|
||||
/**
|
||||
* @brief Get the axis object
|
||||
*
|
||||
|
Reference in New Issue
Block a user