121 lines
4.9 KiB
C++
121 lines
4.9 KiB
C++
/*
|
|
This class contains the necessary changes to have an additional text fields
|
|
for messages with each axis.
|
|
|
|
Code lifted from Torsten Boegershausen ESS code.
|
|
|
|
Mark Koennecke, March 2017
|
|
|
|
Added code to manage an interMessageSleep
|
|
|
|
Mark Koennecke, February 2024
|
|
*/
|
|
|
|
#include "sinqController.h"
|
|
#include "asynMotorController.h"
|
|
#include "epicsExport.h"
|
|
#include "iocsh.h"
|
|
#include <errlog.h>
|
|
|
|
sinqController::sinqController(const char *portName, const char *SINQPortName,
|
|
int numAxes, const int &extraParams)
|
|
: asynMotorController(
|
|
portName, numAxes + 1, NUM_MOTOR_DRIVER_PARAMS + extraParams,
|
|
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
|
|
{
|
|
createParam(motorMessageTextString, asynParamOctet, &motorMessageText_);
|
|
}
|
|
|
|
asynStatus sinqController::errMsgCouldNotParseResponse(const char *command,
|
|
const char *response,
|
|
int axisNo_,
|
|
const char *functionName,
|
|
int lineNumber) {
|
|
asynPrint(lowLevelPortUser_, ASYN_TRACE_ERROR,
|
|
"%s => line %d:\n Could not interpret response %s for "
|
|
"command %s.\n",
|
|
functionName, lineNumber, response, command);
|
|
|
|
setStringParam(motorMessageText_,
|
|
"Could not interpret MCU response. Please "
|
|
"call the software support");
|
|
setIntegerParam(motorStatusCommsError_, 1);
|
|
return asynError;
|
|
}
|
|
|
|
asynStatus sinqController::paramLibAccessFailed(asynStatus status,
|
|
const char *parameter,
|
|
const char *functionName,
|
|
int lineNumber) {
|
|
|
|
if (status != asynSuccess) {
|
|
// Log the error message and try to propagate it
|
|
asynPrint(lowLevelPortUser_, ASYN_TRACE_ERROR,
|
|
"%s => line %d:\n Accessing the parameter library failed for "
|
|
"parameter %s",
|
|
functionName, lineNumber, parameter);
|
|
setStringParam(
|
|
motorMessageText_,
|
|
"Accessing paramLib failed. Please call the software support.");
|
|
}
|
|
|
|
return status;
|
|
}
|
|
|
|
// Static pointers (valid for the entire lifetime of the IOC). The number behind
|
|
// the strings gives the integer number of each variant (see also method
|
|
// stringifyAsynStatus)
|
|
const char *asynSuccessStringified = "success"; // 0
|
|
const char *asynTimeoutStringified = "timeout"; // 1
|
|
const char *asynOverflowStringified = "overflow"; // 2
|
|
const char *asynErrorStringified = "error"; // 3
|
|
const char *asynDisconnectedStringified = "disconnected"; // 4
|
|
const char *asynDisabledStringified = "disabled"; // 5
|
|
const char *asynParamAlreadyExistsStringified = "parameter already exists"; // 6
|
|
const char *asynParamNotFoundStringified = "parameter not found"; // 7
|
|
const char *asynParamWrongTypeStringified = "wrong type"; // 8
|
|
const char *asynParamBadIndexStringified = "bad index"; // 9
|
|
const char *asynParamUndefinedStringified = "parameter undefined"; // 10
|
|
const char *asynParamInvalidListStringified = "invalid list"; // 11
|
|
|
|
const char *sinqController::stringifyAsynStatus(asynStatus status) {
|
|
// See
|
|
// https://github.com/epics-modules/asyn/blob/master/asyn/asynDriver/asynDriver.h
|
|
// and
|
|
// https://github.com/epics-modules/asyn/blob/master/asyn/asynPortDriver/paramErrors.h
|
|
// for the definition of the error codes
|
|
switch (status) {
|
|
case asynSuccess:
|
|
return asynSuccessStringified;
|
|
case asynTimeout:
|
|
return asynTimeoutStringified;
|
|
case asynOverflow:
|
|
return asynOverflowStringified;
|
|
case asynError:
|
|
return asynErrorStringified;
|
|
case asynDisconnected:
|
|
return asynDisconnectedStringified;
|
|
case asynDisabled:
|
|
return asynDisabledStringified;
|
|
case asynParamAlreadyExists:
|
|
return asynParamAlreadyExistsStringified;
|
|
case asynParamNotFound:
|
|
return asynParamNotFoundStringified;
|
|
case asynParamWrongType:
|
|
return asynParamWrongTypeStringified;
|
|
case asynParamBadIndex:
|
|
return asynParamBadIndexStringified;
|
|
case asynParamUndefined:
|
|
return asynParamUndefinedStringified;
|
|
case asynParamInvalidList:
|
|
return asynParamInvalidListStringified;
|
|
}
|
|
|
|
errlogPrintf("%s => line %d:\nReached unreachable code.",
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
return "unreachable code reached";
|
|
} |