diff --git a/src/sinqAxis.cpp b/src/sinqAxis.cpp index 9c68aa2..7a0e361 100644 --- a/src/sinqAxis.cpp +++ b/src/sinqAxis.cpp @@ -8,6 +8,17 @@ #include #include +// Generic fallback - if the compiler tries to compile this function, it fails. +template +asynStatus setAxisParam(sinqAxis *axis, const char *indexName, + int (sinqController::*func)(), T writeValue, + const char *callerFunctionName, int lineNumber) { + static_assert( + sizeof(T) == 0, + "no specialization of setAxisParam exists for the given type"); + return asynError; +} + template <> asynStatus setAxisParam(sinqAxis *axis, const char *indexName, int (sinqController::*func)(), int writeValue, @@ -43,6 +54,20 @@ setAxisParam(sinqAxis *axis, const char *indexName, return asynSuccess; } +template <> +asynStatus setAxisParam(sinqAxis *axis, const char *indexName, + int (sinqController::*func)(), char *writeValue, + const char *callerFunctionName, + int lineNumber) { + int indexValue = (axis->pController()->*func)(); + asynStatus status = axis->setStringParam(indexValue, writeValue); + if (status != asynSuccess) { + return axis->pController()->paramLibAccessFailed( + status, indexName, axis->axisNo(), callerFunctionName, lineNumber); + } + return asynSuccess; +} + template <> asynStatus setAxisParam(sinqAxis *axis, const char *indexName, int (sinqController::*func)(), @@ -58,6 +83,17 @@ asynStatus setAxisParam(sinqAxis *axis, const char *indexName, return asynSuccess; } +// Generic fallback - if the compiler tries to compile this function, it fails. +template +asynStatus getAxisParam(sinqAxis *axis, const char *indexName, + int (sinqController::*func)(), T *readValue, + const char *callerFunctionName, int lineNumber) { + static_assert( + sizeof(T) == 0, + "no specialization of getAxisParam exists for the given type"); + return asynError; +} + template <> asynStatus getAxisParam(sinqAxis *axis, const char *indexName, int (sinqController::*func)(), int *readValue, @@ -112,6 +148,16 @@ asynStatus getAxisParam(sinqAxis *axis, const char *indexName, return asynSuccess; } +template +asynStatus getAxisParam(sinqAxis *axis, const char *indexName, + int (sinqController::*func)(), char (&readValue)[N], + const char *callerFunctionName, int lineNumber) { + // Decay the array to char* + return getAxisParam(axis, indexName, func, + static_cast(readValue), + callerFunctionName, lineNumber); +} + template <> asynStatus getAxisParam(sinqAxis *axis, const char *indexName, @@ -309,7 +355,8 @@ asynStatus sinqAxis::poll(bool *moving) { "waitingMessage" is briefly put into the paramLib again, then the PVs are updated and then the message text is cleared again. */ - getAxisParamChecked(this, motorMessageText, &waitingMessage); + getAxisParamChecked(this, motorMessageText, + static_cast(waitingMessage)); // Clear the communication setAxisParamChecked(this, motorStatusCommsError, false); @@ -331,9 +378,11 @@ asynStatus sinqAxis::poll(bool *moving) { If doPoll cleared the error message paramLib entry, but an old message is still waiting, set the old message. */ - getAxisParamChecked(this, motorMessageText, &newMessage); + getAxisParamChecked(this, motorMessageText, + static_cast(newMessage)); if (newMessage[0] == '\0') { - setAxisParamChecked(this, motorMessageText, waitingMessage); + setAxisParamChecked(this, motorMessageText, + static_cast(waitingMessage)); } setAxisParamChecked(this, motorStatusProblem, true); } else {