Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 59a5ba452f | |||
| 6dc2b131f7 | |||
| 902b18d038 | |||
| 0e10bcf69d | |||
| cb4adb068c | |||
| d7c9d009ee |
@@ -5,21 +5,19 @@
|
||||
|
||||
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_);
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
msgPrintControl::msgPrintControl() : map_(), suffix_{} {}
|
||||
|
||||
msgPrintControl::~msgPrintControl() = default;
|
||||
|
||||
bool msgPrintControl::shouldBePrinted(msgPrintControlKey &key, bool wantToPrint,
|
||||
@@ -78,8 +76,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;
|
||||
}
|
||||
@@ -107,7 +105,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;
|
||||
}
|
||||
|
||||
@@ -5,8 +5,15 @@
|
||||
|
||||
#define DefaultMaxRepetitions 4
|
||||
|
||||
#include <asynDriver.h>
|
||||
#include <macros.h>
|
||||
// The EPICS libaries do not follow -Weffc++
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
|
||||
#include "asynDriver.h"
|
||||
#include "macros.h"
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
@@ -18,12 +25,23 @@
|
||||
*/
|
||||
class HIDDEN msgPrintControlKey {
|
||||
public:
|
||||
msgPrintControlKey(char *controller_, int axisNo, const char *fileName,
|
||||
int line, size_t maxRepetitions = DefaultMaxRepetitions);
|
||||
|
||||
bool operator==(const msgPrintControlKey &other) const {
|
||||
return axisNo_ == other.axisNo_ && line_ == other.line_ &&
|
||||
functionName_ == other.functionName_ &&
|
||||
controller_ == other.controller_;
|
||||
}
|
||||
|
||||
void format(char *buffer, size_t bufferSize);
|
||||
|
||||
std::string controller_;
|
||||
|
||||
// -1 indicates a non-axis specific message
|
||||
int axisNo_;
|
||||
|
||||
const char *functionName_;
|
||||
std::string functionName_;
|
||||
int line_;
|
||||
|
||||
/**
|
||||
@@ -32,17 +50,6 @@ class HIDDEN msgPrintControlKey {
|
||||
*
|
||||
*/
|
||||
size_t maxRepetitions_;
|
||||
|
||||
msgPrintControlKey(char *controller_, int axisNo, const char *fileName,
|
||||
int line, size_t maxRepetitions = DefaultMaxRepetitions);
|
||||
|
||||
bool operator==(const msgPrintControlKey &other) const {
|
||||
return axisNo_ == other.axisNo_ && line_ == other.line_ &&
|
||||
strcmp(functionName_, other.functionName_) == 0 &&
|
||||
controller_ == other.controller_;
|
||||
}
|
||||
|
||||
void format(char *buffer, size_t bufferSize);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -55,7 +62,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);
|
||||
@@ -85,6 +92,12 @@ template <> struct hash<msgPrintControlKey> {
|
||||
*/
|
||||
class HIDDEN msgPrintControl {
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new msgPrintControl object
|
||||
*
|
||||
*/
|
||||
msgPrintControl();
|
||||
|
||||
/**
|
||||
* @brief Destroy the msgPrintControl object
|
||||
*
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include "sinqAxis.h"
|
||||
// The EPICS libaries do not follow -Weffc++
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
|
||||
#include "epicsExport.h"
|
||||
#include "iocsh.h"
|
||||
#include "msgPrintControl.h"
|
||||
#include "sinqController.h"
|
||||
#include <epicsTime.h>
|
||||
#include <errlog.h>
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include "msgPrintControl.h"
|
||||
#include "sinqAxis.h"
|
||||
#include "sinqController.h"
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -31,21 +38,22 @@ struct sinqAxisImpl {
|
||||
};
|
||||
|
||||
sinqAxis::sinqAxis(class sinqController *pC, int axisNo)
|
||||
: asynMotorAxis((asynMotorController *)pC, axisNo), pC_(pC) {
|
||||
: asynMotorAxis((asynMotorController *)pC, axisNo), pC_(pC), pSinqA_([] {
|
||||
epicsTimeStamp lastPollTime;
|
||||
epicsTimeGetCurrent(&lastPollTime);
|
||||
return std::make_unique<sinqAxisImpl>(sinqAxisImpl{
|
||||
.expectedArrivalTime = 0,
|
||||
.offsetMovTimeout = 30,
|
||||
.scaleMovTimeout = 2.0,
|
||||
.watchdogMovActive = false,
|
||||
.targetPosition = 0.0,
|
||||
.wasMoving = false,
|
||||
.lastPollTime = lastPollTime,
|
||||
});
|
||||
}()) {
|
||||
|
||||
asynStatus status = asynSuccess;
|
||||
|
||||
epicsTimeStamp lastPollTime;
|
||||
epicsTimeGetCurrent(&lastPollTime);
|
||||
|
||||
pSinqA_ = std::make_unique<sinqAxisImpl>(
|
||||
(sinqAxisImpl){.expectedArrivalTime = 0,
|
||||
.offsetMovTimeout = 30,
|
||||
.scaleMovTimeout = 2.0,
|
||||
.watchdogMovActive = false,
|
||||
.targetPosition = 0.0,
|
||||
.wasMoving = false,
|
||||
.lastPollTime = lastPollTime});
|
||||
|
||||
/*
|
||||
This check is also done in asynMotorAxis, but there the IOC continues
|
||||
running even though the configuration is incorrect. When failing this check,
|
||||
@@ -318,7 +326,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) {
|
||||
@@ -354,9 +367,15 @@ asynStatus sinqAxis::move(double position, int relative, double minVelocity,
|
||||
return pC_->callParamCallbacks();
|
||||
}
|
||||
|
||||
asynStatus sinqAxis::doMove(double /*position*/, int /*relative*/,
|
||||
double /*minVelocity*/, double /*maxVelocity*/,
|
||||
double /*acceleration*/) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -398,8 +417,14 @@ asynStatus sinqAxis::home(double minVelocity, double maxVelocity,
|
||||
}
|
||||
}
|
||||
|
||||
asynStatus sinqAxis::doHome(double /*minVelocity*/, double /*maxVelocity*/,
|
||||
double /*acceleration*/, int /*forwards*/) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -421,7 +446,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;
|
||||
|
||||
@@ -8,8 +8,16 @@ Stefan Mathis, November 2024
|
||||
|
||||
#ifndef sinqAxis_H
|
||||
#define sinqAxis_H
|
||||
|
||||
// The EPICS libaries do not follow -Weffc++
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
|
||||
#include "asynMotorAxis.h"
|
||||
#include <macros.h>
|
||||
#include "macros.h"
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
@@ -32,6 +40,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`.
|
||||
*
|
||||
@@ -435,8 +450,10 @@ class HIDDEN sinqAxis : public asynMotorAxis {
|
||||
void setTargetPosition(double targetPosition);
|
||||
|
||||
private:
|
||||
std::unique_ptr<sinqAxisImpl> pSinqA_;
|
||||
// Ordering matters because pC_ is initialized before pSinqA_ in the
|
||||
// constructor
|
||||
sinqController *pC_;
|
||||
std::unique_ptr<sinqAxisImpl> pSinqA_;
|
||||
};
|
||||
|
||||
// =============================================================================
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include "sinqController.h"
|
||||
// The EPICS libaries do not follow -Weffc++
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
|
||||
#include "asynMotorController.h"
|
||||
#include "asynOctetSyncIO.h"
|
||||
#include "epicsExport.h"
|
||||
#include "iocsh.h"
|
||||
#include "msgPrintControl.h"
|
||||
#include "sinqAxis.h"
|
||||
#include <deque>
|
||||
#include <errlog.h>
|
||||
#include <initHooks.h>
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include "msgPrintControl.h"
|
||||
#include "sinqAxis.h"
|
||||
#include "sinqController.h"
|
||||
#include <deque>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
@@ -112,43 +119,40 @@ sinqController::sinqController(const char *portName,
|
||||
0, // No additional interfaces beyond those in base class
|
||||
0, // No additional callback interfaces beyond those in base class
|
||||
ASYN_CANBLOCK | ASYN_MULTIDEVICE,
|
||||
1, // autoconnect
|
||||
0, 0) // Default priority and stack size
|
||||
{
|
||||
1, // autoconnect
|
||||
0, 0), // Default priority and stack size
|
||||
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,
|
||||
})) {
|
||||
|
||||
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,
|
||||
.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)
|
||||
movingPollPeriod_ = movingPollPeriod;
|
||||
|
||||
@@ -9,10 +9,18 @@ Stefan Mathis, November 2024
|
||||
|
||||
#ifndef sinqController_H
|
||||
#define sinqController_H
|
||||
|
||||
// The EPICS libaries do not follow -Weffc++
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
|
||||
#include "asynMotorController.h"
|
||||
#include "msgPrintControl.h"
|
||||
#include <initHooks.h>
|
||||
#include <macros.h>
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include <memory>
|
||||
|
||||
#define motorMessageIsFromDriverString "MOTOR_MESSAGE_DRIVER"
|
||||
@@ -58,6 +66,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