Playing around with the initHooks.h trying to discover when different things are available and what order things are started
This commit is contained in:
@ -13,7 +13,7 @@ REQUIRED+=scaler
|
||||
REQUIRED+=asynMotor
|
||||
|
||||
# Release version
|
||||
LIBVERSION=2024-v2
|
||||
LIBVERSION=2024-ed-dev2
|
||||
|
||||
# DB files to include in the release
|
||||
TEMPLATES += sinqEPICSApp/Db/dimetix.db
|
||||
@ -36,6 +36,7 @@ SOURCES += sinqEPICSApp/src/pmacAsynIPPort.c
|
||||
SOURCES += sinqEPICSApp/src/pmacAxis.cpp
|
||||
SOURCES += sinqEPICSApp/src/pmacController.cpp
|
||||
SOURCES += sinqEPICSApp/src/MasterMACSDriver.cpp
|
||||
SOURCES += sinqEPICSApp/src/pollerRegister.cpp
|
||||
|
||||
USR_CFLAGS += -Wall -Wextra # -Werror
|
||||
|
||||
|
@ -916,6 +916,7 @@ asynStatus pmacV3Axis::poll(bool *moving) {
|
||||
sprintf(message, "%s: Polling axis: %d", functionName, this->axisNo_);
|
||||
pC_->debugFlow(message);
|
||||
|
||||
|
||||
// Now poll axis status
|
||||
if ((status = this->getAxisStatus(moving)) != asynSuccess) {
|
||||
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
||||
@ -924,6 +925,10 @@ asynStatus pmacV3Axis::poll(bool *moving) {
|
||||
functionName, pC_->portName, axisNo_);
|
||||
}
|
||||
|
||||
double motorRecResolution_ = 0.;
|
||||
pC_->getDoubleParam(this->axisNo_, pC_->motorRecResolution_, &motorRecResolution_);
|
||||
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, "%s: Polling %f\n", functionName, motorRecResolution_);
|
||||
|
||||
callParamCallbacks();
|
||||
return status;
|
||||
|
||||
|
@ -45,6 +45,7 @@ using std::endl;
|
||||
|
||||
#include "pmacController.h"
|
||||
#include "pmacAxis.h"
|
||||
#include "pollerRegister.h"
|
||||
|
||||
#define MULT 1000.
|
||||
|
||||
@ -142,6 +143,7 @@ asynStatus pmacCreateAxis(const char *pmacName, int numAxis);
|
||||
|
||||
}
|
||||
|
||||
|
||||
pmacController::pmacController(const char *portName, const char *lowLevelPortName, int lowLevelPortAddress,
|
||||
int numAxes, double movingPollPeriod, double idlePollPeriod, const int& extraParams)
|
||||
: SINQController(portName, lowLevelPortName, numAxes+1, extraParams)
|
||||
@ -166,7 +168,31 @@ setIntegerParam(PMAC_C_CommsError_, 1);
|
||||
* NOTE: at this point the axis objects don't yet exist, but the poller tolerates this */
|
||||
setIntegerParam(PMAC_C_CommsError_, 0);
|
||||
}
|
||||
startPoller(movingPollPeriod, idlePollPeriod, 10);
|
||||
|
||||
registerFunction(
|
||||
[this](){
|
||||
//startPoller(movingPollPeriod, idlePollPeriod, 0);
|
||||
//
|
||||
|
||||
asynPrint(
|
||||
this->pasynUserSelf,
|
||||
ASYN_TRACE_ERROR,
|
||||
"\n\n\n%s: status %d %d %d %d %d %d\n\n\n",
|
||||
functionName,
|
||||
asynSuccess,asynTimeout,asynOverflow,asynError,asynDisconnected,asynDisabled);
|
||||
|
||||
double motorRecResolution_ = 0.;
|
||||
asynStatus status = this->getDoubleParam(1, this->motorRecResolution_, &motorRecResolution_);
|
||||
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR, "\n\n\n%s: Polling %f, status %d\n\n\n", functionName, motorRecResolution_, status);
|
||||
|
||||
usleep(50000); // slow down communication somewhat
|
||||
|
||||
status = this->getDoubleParam(1, this->motorRecResolution_, &motorRecResolution_);
|
||||
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR, "\n\n\n%s: Polling %f, status %d\n\n\n", functionName, motorRecResolution_, status);
|
||||
}
|
||||
);
|
||||
|
||||
startPoller(movingPollPeriod, idlePollPeriod, 0);
|
||||
|
||||
callParamCallbacks();
|
||||
|
||||
@ -502,6 +528,8 @@ asynStatus pmacController::poll()
|
||||
|
||||
debugFlow(functionName);
|
||||
|
||||
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR, "%s: Polling\n", functionName);
|
||||
|
||||
if (!lowLevelPortUser_) {
|
||||
setIntegerParam(this->motorStatusCommsError_, 1);
|
||||
return asynError;
|
||||
|
@ -41,7 +41,6 @@ class pmacController : public SINQController {
|
||||
pmacAxis* getAxis(int axisNo);
|
||||
asynStatus poll();
|
||||
|
||||
|
||||
protected:
|
||||
pmacAxis **pAxes_; /**< Array of pointers to axis objects */
|
||||
|
||||
|
96
sinqEPICSApp/src/pollerRegister.cpp
Normal file
96
sinqEPICSApp/src/pollerRegister.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
#include "pollerRegister.h"
|
||||
|
||||
#include <vector>
|
||||
#include <cstdio>
|
||||
|
||||
#include "libComAPI.h"
|
||||
#include "initHooks.h"
|
||||
|
||||
static std::vector<std::function<void()>> registeredFunctions;
|
||||
|
||||
static void startPollingHook(initHookState state) {
|
||||
switch (state) {
|
||||
case initHookAtIocBuild:
|
||||
printf("\n\n\ninitHookAtIocBuild\n\n\n");
|
||||
break;
|
||||
|
||||
case initHookAtBeginning:
|
||||
printf("\n\n\ninitHookAtBeginning\n\n\n");
|
||||
break;
|
||||
|
||||
case initHookAfterCallbackInit:
|
||||
printf("\n\n\ninitHookAfterCallbackInit\n\n\n");
|
||||
break;
|
||||
|
||||
case initHookAfterCaLinkInit:
|
||||
printf("\n\n\ninitHookAfterCaLinkInit\n\n\n");
|
||||
break;
|
||||
|
||||
case initHookAfterInitDrvSup:
|
||||
printf("\n\n\ninitHookAfterInitDrvSup\n\n\n");
|
||||
break;
|
||||
|
||||
case initHookAfterInitRecSup:
|
||||
printf("\n\n\ninitHookAfterInitRecSup\n\n\n");
|
||||
break;
|
||||
|
||||
case initHookAfterInitDevSup:
|
||||
printf("\n\n\ninitHookAfterInitDevSup\n\n\n");
|
||||
break;
|
||||
|
||||
case initHookAfterInitDatabase:
|
||||
printf("\n\n\ninitHookAfterInitDatabase\n\n\n");
|
||||
break;
|
||||
|
||||
case initHookAfterFinishDevSup:
|
||||
printf("\n\n\ninitHookAfterFinishDevSup\n\n\n");
|
||||
break;
|
||||
|
||||
case initHookAfterScanInit:
|
||||
printf("\n\n\ninitHookAfterScanInit\n\n\n");
|
||||
break;
|
||||
|
||||
case initHookAfterInitialProcess:
|
||||
printf("\n\n\ninitHookAfterInitialProcess\n\n\n");
|
||||
break;
|
||||
|
||||
case initHookAfterCaServerInit:
|
||||
printf("\n\n\ninitHookAfterCaServerInit\n\n\n");
|
||||
break;
|
||||
|
||||
case initHookAfterIocBuilt:
|
||||
printf("\n\n\ninitHookAfterIocBuilt\n\n\n");
|
||||
break;
|
||||
|
||||
case initHookAtIocRun:
|
||||
printf("\n\n\ninitHookAtIocRun\n\n\n");
|
||||
break;
|
||||
|
||||
case initHookAfterDatabaseRunning:
|
||||
printf("\n\n\ninitHookAfterDatabaseRunning\n\n\n");
|
||||
break;
|
||||
|
||||
case initHookAtEnd:
|
||||
printf("\n\n\ninitHookAtEnd\n\n\n");
|
||||
break;
|
||||
|
||||
case initHookAfterCaServerRunning:
|
||||
printf("\n\n\ninitHookAfterCaServerRunning\n\n\n");
|
||||
break;
|
||||
|
||||
case initHookAfterIocRunning:
|
||||
printf("\n\n\ninitHookAfterIocRunning\n\n\n");
|
||||
for(auto&& fn : registeredFunctions)
|
||||
fn();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int myHookStatus = initHookRegister(startPollingHook);
|
||||
|
||||
void registerFunction(std::function<void()> func) {
|
||||
registeredFunctions.push_back(func);
|
||||
}
|
8
sinqEPICSApp/src/pollerRegister.h
Normal file
8
sinqEPICSApp/src/pollerRegister.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef POLLERREGISTER
|
||||
#define POLLERREGISTER
|
||||
|
||||
#include <functional>
|
||||
|
||||
void registerFunction(std::function<void()> func);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user