Commit of first version which passes basic tests
Some checks failed
Test And Build / Lint (push) Failing after 4s
Test And Build / Build (push) Successful in 9s

This commit is contained in:
2025-11-04 08:06:08 +01:00
parent 89f820e1bf
commit 19c9c00b73
2 changed files with 50 additions and 30 deletions

View File

@@ -144,6 +144,8 @@ asynStatus el734Axis::init() {
char response[pC_->MAXBUF_] = {0};
double motorRecResolution = 0.0;
double motorPos = 0.0;
double motorVelocity = 0.0;
int nvals = 0;
// The parameter library takes some time to be initialized. Therefore we
// wait until the status is not asynParamUndefined anymore.
@@ -176,7 +178,23 @@ asynStatus el734Axis::init() {
if (status != asynSuccess) {
return status;
}
sscanf(response, "%lf", &motorPos);
nvals = sscanf(response, "%lf", &motorPos);
if (nvals != 1) {
return pC_->couldNotParseResponse(command, response, axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
// Read out the current velocity
snprintf(command, sizeof(command), "J %d", axisNo_);
status = pC_->writeRead(axisNo_, command, response);
if (status != asynSuccess) {
return status;
}
nvals = sscanf(response, "%lf", &motorVelocity);
if (nvals != 1) {
return pC_->couldNotParseResponse(command, response, axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
// Store these values in the parameter library
status = setMotorPosition(motorPos);
@@ -184,6 +202,12 @@ asynStatus el734Axis::init() {
return status;
}
// Limits directly taken from el734_manual.pdf, p. 66.
status = setVeloFields(motorVelocity, 33.0, 2000.0);
if (status != asynSuccess) {
return status;
}
// Initial motor status is idle
setAxisParamChecked(this, motorStatusDone, 1);
@@ -210,6 +234,11 @@ asynStatus el734Axis::init() {
// Motor cannot be disabled
setAxisParamChecked(this, motorCanDisable, false);
status = this->readEncoderType();
if (status != asynSuccess) {
return status;
}
return status;
}

View File

@@ -32,17 +32,14 @@ el734Controller::el734Controller(const char *portName,
double movingPollPeriod, double idlePollPeriod,
double comTimeout, int numExtraParams)
: sinqController(portName, ipPortConfigName, numAxes, movingPollPeriod,
idlePollPeriod, numExtraParams + NUM_el734_DRIVER_PARAMS)
idlePollPeriod, numExtraParams + NUM_el734_DRIVER_PARAMS),
pEl734C_(std::make_unique<el734ControllerImpl>((el734ControllerImpl){
.comTimeout = comTimeout,
.lastResponse = {0},
.limFromHardware = 0,
}))
{
// The paramLib indices are populated with the calls to createParam
pEl734C_ = std::make_unique<el734ControllerImpl>((el734ControllerImpl){
.comTimeout = comTimeout,
.lastResponse = {0},
.limFromHardware = 0,
});
// Initialization of local variables
asynStatus status = asynSuccess;
@@ -68,7 +65,8 @@ el734Controller::el734Controller(const char *portName,
The el734 controller expects a carriage return as terminator and terminates
each reply with a carriage return (el734_manual.pdf, p. 58).
*/
pasynOctetSyncIO->setOutputEos(pasynUserController_, "\r", strlen("\r"));
pasynOctetSyncIO->setOutputEos(pasynOctetSyncIOipPort(), "\r",
strlen("\r"));
if (status != asynSuccess) {
asynPrint(this->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\" => %s, line %d\nFATAL ERROR "
@@ -79,7 +77,7 @@ el734Controller::el734Controller(const char *portName,
exit(-1);
}
pasynOctetSyncIO->setInputEos(pasynUserController_, "\r", strlen("\r"));
pasynOctetSyncIO->setInputEos(pasynOctetSyncIOipPort(), "\r", strlen("\r"));
if (status != asynSuccess) {
asynPrint(this->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\" => %s, line %d\nFATAL ERROR "
@@ -101,23 +99,6 @@ el734Controller::el734Controller(const char *portName,
pasynOctetSyncIO->disconnect(pasynOctetSyncIOipPort());
exit(-1);
}
// =========================================================================;
/*
We try to connect to the port via the port name provided by the constructor.
If this fails, the function is terminated via exit.
*/
pasynInt32SyncIO->connect(ipPortConfigName, 0,
&pEl734C_->pasynInt32SyncIOipPort, NULL);
if (status != asynSuccess || pEl734C_->pasynInt32SyncIOipPort == nullptr) {
errlogPrintf("Controller \"%s\" => %s, line %d:\nFATAL ERROR (cannot "
"connect to MCU controller).\n"
"Terminating IOC",
portName, __PRETTY_FUNCTION__, __LINE__);
pasynOctetSyncIO->disconnect(pasynOctetSyncIOipPort());
exit(-1);
}
}
el734Controller::~el734Controller() {}
@@ -337,6 +318,7 @@ asynStatus el734CreateController(const char *portName,
*/
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#pragma GCC diagnostic ignored "-Wunused-variable"
el734Controller *pController =
new el734Controller(portName, ipPortConfigName, numAxes,
movingPollPeriod, idlePollPeriod, comTimeout);
@@ -344,6 +326,13 @@ asynStatus el734CreateController(const char *portName,
return asynSuccess;
}
/*
This is boilerplate code which is used to make the FFI functions
CreateController and CreateAxis "known" to the IOC shell (iocsh).
*/
#ifndef vxWorks
/*
Define name and type of the arguments for the CreateController function
in the iocsh. This is done by creating structs with the argument names and
@@ -372,7 +361,7 @@ static void configEl734CreateControllerCallFunc(const iocshArgBuf *args) {
args[3].dval, args[4].dval, args[5].dval);
}
// This function is made known to EPICS in turboPmac.dbd and is called by
// This function is made known to EPICS in el734.dbd and is called by
// EPICS in order to register both functions in the IOC shell
static void el734ControllerRegister(void) {
iocshRegister(&configEl734CreateController,
@@ -380,4 +369,6 @@ static void el734ControllerRegister(void) {
}
epicsExportRegistrar(el734ControllerRegister);
#endif
} // extern "C"