Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0e10bcf69d | |||
| cb4adb068c | |||
| d7c9d009ee | |||
| 3ab40a8bf5 | |||
| 0478854007 | |||
| 9a32532c22 |
3
Makefile
3
Makefile
@@ -26,6 +26,7 @@ TEMPLATES += db/sinqMotor.db
|
||||
# This file registers the motor-specific functions in the IOC shell.
|
||||
DBDS += src/sinqMotor.dbd
|
||||
|
||||
USR_CFLAGS += -Wall -Wextra -Weffc++ -Wunused-result # -Werror
|
||||
USR_CFLAGS += -Wall -Wextra -Wunused-result # -Werror
|
||||
USR_CXXFLAGS += -Wall -Wextra -Wunused-result
|
||||
|
||||
# MISCS would be the place to keep the stream device template files
|
||||
|
||||
@@ -5,17 +5,13 @@
|
||||
|
||||
msgPrintControlKey::msgPrintControlKey(char *controller, int axisNo,
|
||||
const char *functionName, int line,
|
||||
size_t maxRepetitions) {
|
||||
controller_ = controller;
|
||||
axisNo_ = axisNo;
|
||||
line_ = line;
|
||||
functionName_ = functionName;
|
||||
maxRepetitions_ = maxRepetitions;
|
||||
}
|
||||
size_t maxRepetitions)
|
||||
: controller_(controller), axisNo_(axisNo), functionName_(functionName),
|
||||
line_(line), maxRepetitions_(maxRepetitions) {}
|
||||
|
||||
void msgPrintControlKey::format(char *buffer, size_t bufferSize) {
|
||||
snprintf(buffer, bufferSize, "controller %s, axis %d, function %s, line %d",
|
||||
controller_.c_str(), axisNo_, functionName_, line_);
|
||||
controller_.c_str(), axisNo_, functionName_.c_str(), line_);
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
@@ -78,8 +74,8 @@ bool msgPrintControl::shouldBePrinted(msgPrintControlKey &key, bool wantToPrint,
|
||||
pasynUser, ASYN_TRACE_ERROR,
|
||||
"Controller \"%s\", axis %d => %s, line %d\nError "
|
||||
"associated with key \"%s\" has been resolved.\n",
|
||||
key.controller_.c_str(), key.axisNo_, key.functionName_,
|
||||
key.line_, formattedKey);
|
||||
key.controller_.c_str(), key.axisNo_,
|
||||
key.functionName_.c_str(), key.line_, formattedKey);
|
||||
}
|
||||
map_[key] = 0;
|
||||
}
|
||||
@@ -92,8 +88,8 @@ bool msgPrintControl::shouldBePrinted(char *portName, int axisNo,
|
||||
const char *functionName, int line,
|
||||
bool wantToPrint, asynUser *pasynUser,
|
||||
size_t maxRepetitions) {
|
||||
msgPrintControlKey key =
|
||||
msgPrintControlKey(portName, axisNo, functionName, __LINE__);
|
||||
msgPrintControlKey key = msgPrintControlKey(portName, axisNo, functionName,
|
||||
line, maxRepetitions);
|
||||
return shouldBePrinted(key, wantToPrint, pasynUser);
|
||||
}
|
||||
|
||||
@@ -107,7 +103,7 @@ void msgPrintControl::resetCount(msgPrintControlKey &key, asynUser *pasynUser) {
|
||||
"Controller \"%s\", axis %d => %s, line %d\nError "
|
||||
"associated with key \"%s\" has been resolved.\n",
|
||||
key.controller_.c_str(), key.axisNo_,
|
||||
key.functionName_, key.line_, formattedKey);
|
||||
key.functionName_.c_str(), key.line_, formattedKey);
|
||||
}
|
||||
map_[key] = 0;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class HIDDEN msgPrintControlKey {
|
||||
// -1 indicates a non-axis specific message
|
||||
int axisNo_;
|
||||
|
||||
const char *functionName_;
|
||||
std::string functionName_;
|
||||
int line_;
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ class HIDDEN msgPrintControlKey {
|
||||
|
||||
bool operator==(const msgPrintControlKey &other) const {
|
||||
return axisNo_ == other.axisNo_ && line_ == other.line_ &&
|
||||
strcmp(functionName_, other.functionName_) == 0 &&
|
||||
functionName_ == other.functionName_ &&
|
||||
controller_ == other.controller_;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ template <> struct hash<msgPrintControlKey> {
|
||||
// Combine the hashes of the members (x and y)
|
||||
size_t h1 = std::hash<std::string>{}(obj.controller_);
|
||||
size_t h2 = hash<int>{}(obj.axisNo_);
|
||||
size_t h3 = std::hash<const char *>{}(obj.functionName_);
|
||||
size_t h3 = std::hash<std::string>{}(obj.functionName_);
|
||||
size_t h4 = hash<int>{}(obj.line_);
|
||||
// Combine the hashes (simple XOR and shifting technique)
|
||||
return h1 ^ (h2 << 1) ^ (h3 << 2) ^ (h4 << 3);
|
||||
|
||||
@@ -318,7 +318,12 @@ asynStatus sinqAxis::forcedPoll(bool *moving) {
|
||||
return poll_status;
|
||||
}
|
||||
|
||||
asynStatus sinqAxis::doPoll(bool *moving) { return asynSuccess; }
|
||||
asynStatus sinqAxis::doPoll(bool *moving) {
|
||||
// Suppress unused variable warning - this is just a default fallback
|
||||
// function.
|
||||
(void)moving;
|
||||
return asynSuccess;
|
||||
}
|
||||
|
||||
asynStatus sinqAxis::move(double position, int relative, double minVelocity,
|
||||
double maxVelocity, double acceleration) {
|
||||
@@ -356,6 +361,13 @@ asynStatus sinqAxis::move(double position, int relative, double minVelocity,
|
||||
|
||||
asynStatus sinqAxis::doMove(double position, int relative, double minVelocity,
|
||||
double maxVelocity, double acceleration) {
|
||||
// Suppress unused variable warning - this is just a default fallback
|
||||
// function.
|
||||
(void)position;
|
||||
(void)relative;
|
||||
(void)minVelocity;
|
||||
(void)maxVelocity;
|
||||
(void)acceleration;
|
||||
return asynSuccess;
|
||||
}
|
||||
|
||||
@@ -399,6 +411,12 @@ asynStatus sinqAxis::home(double minVelocity, double maxVelocity,
|
||||
|
||||
asynStatus sinqAxis::doHome(double minVelocity, double maxVelocity,
|
||||
double acceleration, int forwards) {
|
||||
// Suppress unused variable warning - this is just a default fallback
|
||||
// function.
|
||||
(void)minVelocity;
|
||||
(void)maxVelocity;
|
||||
(void)acceleration;
|
||||
(void)forwards;
|
||||
return asynSuccess;
|
||||
}
|
||||
|
||||
@@ -420,7 +438,12 @@ asynStatus sinqAxis::reset() {
|
||||
|
||||
asynStatus sinqAxis::doReset() { return asynError; }
|
||||
|
||||
asynStatus sinqAxis::enable(bool on) { return asynSuccess; }
|
||||
asynStatus sinqAxis::enable(bool on) {
|
||||
// Suppress unused variable warning - this is just a default fallback
|
||||
// function.
|
||||
(void)on;
|
||||
return asynSuccess;
|
||||
}
|
||||
|
||||
asynStatus sinqAxis::motorPosition(double *motorPos) {
|
||||
asynStatus status = asynSuccess;
|
||||
@@ -482,9 +505,9 @@ asynStatus sinqAxis::setVeloFields(double velo, double vbas, double vmax) {
|
||||
"vmax=%lf.\n",
|
||||
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
||||
vbas, vmax);
|
||||
setAxisParamChecked(
|
||||
this, motorMessageText,
|
||||
"Lower speed limit must not be smaller than upper speed limit");
|
||||
setAxisParamChecked(this, motorMessageText,
|
||||
"Lower speed limit must not be smaller than "
|
||||
"upper speed limit. Please call the support.");
|
||||
return asynError;
|
||||
}
|
||||
if (velo < vbas || velo > vmax) {
|
||||
@@ -495,8 +518,10 @@ asynStatus sinqAxis::setVeloFields(double velo, double vbas, double vmax) {
|
||||
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
||||
velo, vbas, vmax);
|
||||
|
||||
setAxisParamChecked(this, motorMessageText,
|
||||
"Speed is not inside limits");
|
||||
setAxisParamChecked(
|
||||
this, motorMessageText,
|
||||
"Speed is not inside limits. Set a new valid speed and try "
|
||||
"to move the motor. Otherwise, please call the support.");
|
||||
return asynError;
|
||||
}
|
||||
|
||||
@@ -709,8 +734,9 @@ static const iocshArg setWatchdogEnabledArg2 = {
|
||||
"Enabling / disabling the watchdog", iocshArgInt};
|
||||
static const iocshArg *const setWatchdogEnabledArgs[] = {
|
||||
&setWatchdogEnabledArg0, &setWatchdogEnabledArg1, &setWatchdogEnabledArg2};
|
||||
static const iocshFuncDef setWatchdogEnabledDef = {"setWatchdogEnabled", 3,
|
||||
setWatchdogEnabledArgs};
|
||||
static const iocshFuncDef setWatchdogEnabledDef = {
|
||||
"setWatchdogEnabled", 3, setWatchdogEnabledArgs,
|
||||
"Set to 0 to disable the watchdog and to any other value to enable it."};
|
||||
|
||||
static void setWatchdogEnabledCallFunc(const iocshArgBuf *args) {
|
||||
setWatchdogEnabled(args[0].sval, args[1].ival, args[2].ival);
|
||||
@@ -756,8 +782,9 @@ static const iocshArg setOffsetMovTimeoutArg2 = {"Offset timeout for movement",
|
||||
static const iocshArg *const setOffsetMovTimeoutArgs[] = {
|
||||
&setOffsetMovTimeoutArg0, &setOffsetMovTimeoutArg1,
|
||||
&setOffsetMovTimeoutArg2};
|
||||
static const iocshFuncDef setOffsetMovTimeoutDef = {"setOffsetMovTimeout", 3,
|
||||
setOffsetMovTimeoutArgs};
|
||||
static const iocshFuncDef setOffsetMovTimeoutDef = {
|
||||
"setOffsetMovTimeout", 3, setOffsetMovTimeoutArgs,
|
||||
"Specify an offset (in seconds) for the movement timeout watchdog"};
|
||||
|
||||
static void setOffsetMovTimeoutCallFunc(const iocshArgBuf *args) {
|
||||
setOffsetMovTimeout(args[0].sval, args[1].ival, args[2].dval);
|
||||
@@ -803,8 +830,9 @@ static const iocshArg setScaleMovTimeoutArg2 = {
|
||||
"Multiplier for calculated move time", iocshArgDouble};
|
||||
static const iocshArg *const setScaleMovTimeoutArgs[] = {
|
||||
&setScaleMovTimeoutArg0, &setScaleMovTimeoutArg1, &setScaleMovTimeoutArg2};
|
||||
static const iocshFuncDef setScaleMovTimeoutDef = {"setScaleMovTimeout", 3,
|
||||
setScaleMovTimeoutArgs};
|
||||
static const iocshFuncDef setScaleMovTimeoutDef = {
|
||||
"setScaleMovTimeout", 3, setScaleMovTimeoutArgs,
|
||||
"Set a scaling factor for the maximum expected movement time."};
|
||||
|
||||
static void setScaleMovTimeoutCallFunc(const iocshArgBuf *args) {
|
||||
setScaleMovTimeout(args[0].sval, args[1].ival, args[2].dval);
|
||||
|
||||
@@ -32,6 +32,13 @@ class HIDDEN sinqAxis : public asynMotorAxis {
|
||||
*/
|
||||
~sinqAxis();
|
||||
|
||||
/**
|
||||
* @brief Delete the copy and copy assignment constructors, because this
|
||||
* class should not be copied (it is tied to hardware!)
|
||||
*/
|
||||
sinqAxis(const sinqAxis &) = delete;
|
||||
sinqAxis &operator=(const sinqAxis &) = delete;
|
||||
|
||||
/**
|
||||
* @brief Check if a poll should be performed. If yes, call `forcedPoll`.
|
||||
*
|
||||
@@ -606,7 +613,7 @@ template <typename A, typename C>
|
||||
asynStatus getAxisParamImpl(A *axis, C *controller, const char *indexName,
|
||||
int (C::*func)(), int *readValue,
|
||||
const char *callerFunctionName, int lineNumber,
|
||||
size_t msgSize, TypeTag<int>) {
|
||||
size_t /*msgSize*/, TypeTag<int>) {
|
||||
int indexValue = (controller->*func)();
|
||||
asynStatus status =
|
||||
controller->getIntegerParam(axis->axisNo(), indexValue, readValue);
|
||||
@@ -634,7 +641,7 @@ template <typename A, typename C>
|
||||
asynStatus getAxisParamImpl(A *axis, C *controller, const char *indexName,
|
||||
int (C::*func)(), double *readValue,
|
||||
const char *callerFunctionName, int lineNumber,
|
||||
size_t msgSize, TypeTag<double>) {
|
||||
size_t /*msgSize*/, TypeTag<double>) {
|
||||
int indexValue = (controller->*func)();
|
||||
asynStatus status =
|
||||
controller->getDoubleParam(axis->axisNo(), indexValue, readValue);
|
||||
@@ -665,7 +672,7 @@ template <typename A, typename C>
|
||||
asynStatus getAxisParamImpl(A *axis, C *controller, const char *indexName,
|
||||
int (C::*func)(), std::string *readValue,
|
||||
const char *callerFunctionName, int lineNumber,
|
||||
size_t msgSize, TypeTag<std::string>) {
|
||||
size_t /*msgSize*/, TypeTag<std::string>) {
|
||||
int indexValue = (controller->*func)();
|
||||
|
||||
// Convert the pointer to a reference, since getStringParam expects the
|
||||
|
||||
@@ -119,15 +119,35 @@ sinqController::sinqController(const char *portName,
|
||||
asynStatus status = asynSuccess;
|
||||
|
||||
// The paramLib indices are populated with the calls to createParam
|
||||
pSinqC_ = std::make_unique<sinqControllerImpl>(
|
||||
(sinqControllerImpl){.outstandingForcedFastPolls = 0,
|
||||
.pasynOctetSyncIOipPort = nullptr,
|
||||
.msgPrintC = msgPrintControl(),
|
||||
.comTimeoutWindow = 3600,
|
||||
.maxNumberTimeouts = 60,
|
||||
.timeoutEvents = {},
|
||||
.maxSubsequentTimeouts = 10,
|
||||
.maxSubsequentTimeoutsExceeded = false});
|
||||
pSinqC_ = std::make_unique<sinqControllerImpl>((sinqControllerImpl){
|
||||
.outstandingForcedFastPolls = 0,
|
||||
.pasynOctetSyncIOipPort = nullptr,
|
||||
.msgPrintC = msgPrintControl(),
|
||||
.comTimeoutWindow = 3600,
|
||||
.maxNumberTimeouts = 60,
|
||||
.timeoutEvents = {},
|
||||
.maxSubsequentTimeouts = 10,
|
||||
.maxSubsequentTimeoutsExceeded = false,
|
||||
.motorMessageText = 0,
|
||||
.motorReset = 0,
|
||||
.motorEnable = 0,
|
||||
.motorEnableRBV = 0,
|
||||
.motorCanDisable = 0,
|
||||
.motorEnableMovWatchdog = 0,
|
||||
.motorCanSetSpeed = 0,
|
||||
.motorLimitsOffset = 0,
|
||||
.motorForceStop = 0,
|
||||
.motorConnected = 0,
|
||||
.motorVeloFromDriver = 0,
|
||||
.motorVbasFromDriver = 0,
|
||||
.motorVmaxFromDriver = 0,
|
||||
.motorAcclFromDriver = 0,
|
||||
.motorHighLimitFromDriver = 0,
|
||||
.motorLowLimitFromDriver = 0,
|
||||
.motorPositionDeadband = 0,
|
||||
.adaptivePolling = 0,
|
||||
.encoderType = 0,
|
||||
});
|
||||
|
||||
// Store the poll period information. The poller itself will be started
|
||||
// later (after the IOC is running in epicsInithookFunction)
|
||||
@@ -824,7 +844,8 @@ static const iocshArg *const setThresholdComTimeoutArgs[] = {
|
||||
&setThresholdComTimeoutArg0, &setThresholdComTimeoutArg1,
|
||||
&setThresholdComTimeoutArg2};
|
||||
static const iocshFuncDef setThresholdComTimeoutDef = {
|
||||
"setThresholdComTimeout", 3, setThresholdComTimeoutArgs};
|
||||
"setThresholdComTimeout", 3, setThresholdComTimeoutArgs,
|
||||
"Set the communication timeout threshold in seconds"};
|
||||
|
||||
static void setThresholdComTimeoutCallFunc(const iocshArgBuf *args) {
|
||||
setThresholdComTimeout(args[0].sval, args[1].ival, args[2].ival);
|
||||
@@ -885,7 +906,9 @@ static const iocshArg SetMaxSubsequentTimeoutsArg1 = {
|
||||
static const iocshArg *const SetMaxSubsequentTimeoutsArgs[] = {
|
||||
&SetMaxSubsequentTimeoutsArg0, &SetMaxSubsequentTimeoutsArg1};
|
||||
static const iocshFuncDef setMaxSubsequentTimeoutsDef = {
|
||||
"setMaxSubsequentTimeouts", 2, SetMaxSubsequentTimeoutsArgs};
|
||||
"setMaxSubsequentTimeouts", 2, SetMaxSubsequentTimeoutsArgs,
|
||||
"Set the maximum number of subsequent timeouts before the user receives an "
|
||||
"error message"};
|
||||
static void setMaxSubsequentTimeoutsCallFunc(const iocshArgBuf *args) {
|
||||
setMaxSubsequentTimeouts(args[0].sval, args[1].ival);
|
||||
}
|
||||
@@ -939,13 +962,15 @@ asynStatus setForcedFastPolls(const char *portName, int forcedFastPolls) {
|
||||
static const iocshArg SetForcedFastPollsArg0 = {"Controller name (e.g. mcu1)",
|
||||
iocshArgString};
|
||||
static const iocshArg SetForcedFastPollsArg1 = {
|
||||
"Number of fast polls after \"waking\" the poller (e.g. after issueing a "
|
||||
"Number of fast polls after \"waking\" the poller (e.g. after issuing a "
|
||||
"move command).",
|
||||
iocshArgInt};
|
||||
static const iocshArg *const SetForcedFastPollsArgs[] = {
|
||||
&SetForcedFastPollsArg0, &SetForcedFastPollsArg1};
|
||||
static const iocshFuncDef setForcedFastPollsDef = {"setForcedFastPolls", 2,
|
||||
SetForcedFastPollsArgs};
|
||||
static const iocshFuncDef setForcedFastPollsDef = {
|
||||
"setForcedFastPolls", 2, SetForcedFastPollsArgs,
|
||||
"Set the number of fast polls after \"waking\" the poller (e.g. after "
|
||||
"issuing a move command)."};
|
||||
static void setForcedFastPollsCallFunc(const iocshArgBuf *args) {
|
||||
setForcedFastPolls(args[0].sval, args[1].ival);
|
||||
}
|
||||
|
||||
@@ -58,6 +58,13 @@ class HIDDEN sinqController : public asynMotorController {
|
||||
*/
|
||||
virtual ~sinqController(void);
|
||||
|
||||
/**
|
||||
* @brief Delete the copy and copy assignment constructors, because this
|
||||
* class should not be copied (it is tied to hardware!)
|
||||
*/
|
||||
sinqController(const sinqController &) = delete;
|
||||
sinqController &operator=(const sinqController &) = delete;
|
||||
|
||||
/**
|
||||
* @brief Overloaded function of asynMotorController
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user