Removed friend class declaration and replaced access to private,properties with accessors

This commit is contained in:
2025-03-10 17:07:33 +01:00
parent cf9899062a
commit 631ee46a50
4 changed files with 78 additions and 113 deletions

View File

@@ -49,14 +49,10 @@ masterMacsController::masterMacsController(const char *portName,
int numAxes, double movingPollPeriod,
double idlePollPeriod,
double comTimeout)
: sinqController(
portName, ipPortConfigName, numAxes, movingPollPeriod, idlePollPeriod,
/*
The following parameter library entries are added in this driver:
- REREAD_ENCODER_POSITION
- READ_CONFIG
*/
NUM_masterMacs_DRIVER_PARAMS)
: sinqController(portName, ipPortConfigName, numAxes, movingPollPeriod,
idlePollPeriod,
// No additional parameter library entries
0)
{
@@ -64,22 +60,9 @@ masterMacsController::masterMacsController(const char *portName,
asynStatus status = asynSuccess;
// Initialization of all member variables
lowLevelPortUser_ = nullptr;
comTimeout_ = comTimeout;
// =========================================================================;
/*
We try to connect to the port via the port name provided by the constructor.
If this fails, the function is terminated via exit
*/
pasynOctetSyncIO->connect(ipPortConfigName, 0, &lowLevelPortUser_, NULL);
if (status != asynSuccess || lowLevelPortUser_ == nullptr) {
errlogPrintf("Controller \"%s\" => %s, line %d:\nFATAL ERROR (cannot "
"connect to MCU controller).\nTerminating IOC",
portName, __PRETTY_FUNCTION__, __LINE__);
exit(-1);
}
// =========================================================================
/*
Define the end-of-string of a message coming from the device to EPICS.
@@ -87,15 +70,15 @@ masterMacsController::masterMacsController(const char *portName,
the message length is encoded in the message header.
*/
const char *message_from_device = "\x0D"; // Hex-code for CR
status = pasynOctetSyncIO->setInputEos(
lowLevelPortUser_, message_from_device, strlen(message_from_device));
status = pasynOctetSyncIO->setInputEos(ipPortUser_, message_from_device,
strlen(message_from_device));
if (status != asynSuccess) {
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"Controller \"%s\" => %s, line %d:\nFATAL ERROR (setting "
"input EOS failed with %s).\nTerminating IOC",
portName, __PRETTY_FUNCTION__, __LINE__,
stringifyAsynStatus(status));
pasynOctetSyncIO->disconnect(lowLevelPortUser_);
pasynOctetSyncIO->disconnect(ipPortUser_);
exit(-1);
}
@@ -106,7 +89,7 @@ masterMacsController::masterMacsController(const char *portName,
"ParamLib callbacks failed with %s).\nTerminating IOC",
portName, __PRETTY_FUNCTION__, __LINE__,
stringifyAsynStatus(status));
pasynOctetSyncIO->disconnect(lowLevelPortUser_);
pasynOctetSyncIO->disconnect(ipPortUser_);
exit(-1);
}
}
@@ -193,9 +176,8 @@ asynStatus masterMacsController::writeRead(int axisNo, int tcpCmd,
adjustForPrint(printableCommand, fullCommand, MAXBUF_);
// Send out the command
status =
pasynOctetSyncIO->write(lowLevelPortUser_, fullCommand,
fullCommandLength, comTimeout_, &nbytesOut);
status = pasynOctetSyncIO->write(
ipPortUser_, fullCommand, fullCommandLength, comTimeout_, &nbytesOut);
msgPrintControlKey writeKey =
msgPrintControlKey(portName, axisNo, __PRETTY_FUNCTION__, __LINE__);
@@ -221,10 +203,9 @@ asynStatus masterMacsController::writeRead(int axisNo, int tcpCmd,
the return value of flush(), because it is always asynSuccess (see
https://www.slac.stanford.edu/grp/lcls/controls/global/doc/epics-modules/R3-14-12/asyn/asyn-R4-18-lcls2/asyn/interfaces/asynOctetBase.c)
*/
status =
pasynOctetSyncIO->read(lowLevelPortUser_, fullResponse, MAXBUF_,
comTimeout_, &nbytesIn, &eomReason);
pasynOctetSyncIO->flush(lowLevelPortUser_);
status = pasynOctetSyncIO->read(ipPortUser_, fullResponse, MAXBUF_,
comTimeout_, &nbytesIn, &eomReason);
pasynOctetSyncIO->flush(ipPortUser_);
if (status == asynSuccess) {
status = parseResponse(fullCommand, fullResponse,