can readback correlation unit status
This commit is contained in:
@@ -162,7 +162,9 @@ asynStreamGeneratorDriver::asynStreamGeneratorDriver(
|
||||
asynStatus status = asynSuccess;
|
||||
|
||||
status = createInt32Param(status, P_EnableElectronicsString,
|
||||
&P_EnableElectronics);
|
||||
&P_EnableElectronics, 1);
|
||||
status = createInt32Param(status, P_EnableElectronicsRBVString,
|
||||
&P_EnableElectronicsRBV);
|
||||
status = createInt32Param(status, P_StatusString, &P_Status, STATUS_IDLE);
|
||||
status = createInt32Param(status, P_ResetString, &P_Reset);
|
||||
status = createInt32Param(status, P_StopString, &P_Stop);
|
||||
@@ -395,10 +397,10 @@ asynStatus asynStreamGeneratorDriver::writeInt32(asynUser *pasynUser,
|
||||
// TODO should check everything...
|
||||
if (function == P_CountPreset) {
|
||||
if (!currentStatus) {
|
||||
// slightly longer than the status update frequency
|
||||
// i.e. "$(INSTR)$(NAME):RAW-STATUS" SCAN seconds
|
||||
// to ensure that the counts have all had a chance
|
||||
// to update their values before starting a count
|
||||
// slightly longer than the status update frequency
|
||||
// i.e. "$(INSTR)$(NAME):RAW-STATUS" SCAN seconds
|
||||
// to ensure that the counts have all had a chance
|
||||
// to update their values before starting a count
|
||||
epicsThreadSleep(0.12); // seconds
|
||||
setIntegerParam(function, value);
|
||||
setIntegerParam(P_Status, STATUS_COUNTING);
|
||||
@@ -407,10 +409,10 @@ asynStatus asynStreamGeneratorDriver::writeInt32(asynUser *pasynUser,
|
||||
}
|
||||
} else if (function == P_TimePreset) {
|
||||
if (!currentStatus) {
|
||||
// slightly longer than the status update frequency
|
||||
// i.e. "$(INSTR)$(NAME):RAW-STATUS" SCAN seconds
|
||||
// to ensure that the counts have all had a chance
|
||||
// to update their values before starting a count
|
||||
// slightly longer than the status update frequency
|
||||
// i.e. "$(INSTR)$(NAME):RAW-STATUS" SCAN seconds
|
||||
// to ensure that the counts have all had a chance
|
||||
// to update their values before starting a count
|
||||
epicsThreadSleep(0.12); // seconds
|
||||
setIntegerParam(function, value);
|
||||
setIntegerParam(P_Status, STATUS_COUNTING);
|
||||
@@ -456,7 +458,7 @@ asynStatus asynStreamGeneratorDriver::writeInt32(asynUser *pasynUser,
|
||||
}
|
||||
} else {
|
||||
setIntegerParam(function, value);
|
||||
//status = (asynStatus)callParamCallbacks();
|
||||
// status = (asynStatus)callParamCallbacks();
|
||||
}
|
||||
|
||||
if (status)
|
||||
@@ -492,16 +494,32 @@ void asynStreamGeneratorDriver::receiveUDP() {
|
||||
|
||||
if (received) {
|
||||
const uint16_t bufferLength = ((uint16_t *)buffer)[0];
|
||||
const std::size_t headerLength = 42;
|
||||
const bool isCmdBuffer = ((uint16_t *)buffer)[1] && 0x8000;
|
||||
const std::size_t minDataBufferHeaderLength = 42;
|
||||
const std::size_t minCmdBufferHeaderLength = 20;
|
||||
|
||||
if (received >= headerLength && received == bufferLength * 2) {
|
||||
if (received >= minDataBufferHeaderLength &&
|
||||
received == bufferLength * 2 && !isCmdBuffer) {
|
||||
|
||||
epicsRingBytesPut(this->udpQueue, (char *)buffer, bufferSize);
|
||||
|
||||
} else if (received >= minCmdBufferHeaderLength && isCmdBuffer) {
|
||||
|
||||
const CommandId cmd =
|
||||
static_cast<CommandId>(((uint16_t *)buffer)[4]);
|
||||
|
||||
if (cmd == CommandId::start) {
|
||||
setIntegerParam(this->P_EnableElectronicsRBV, 1);
|
||||
} else if (cmd == CommandId::stop) {
|
||||
setIntegerParam(this->P_EnableElectronicsRBV, 0);
|
||||
}
|
||||
|
||||
} else {
|
||||
asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
|
||||
"%s:%s: invalid UDP packet\n", driverName,
|
||||
functionName);
|
||||
"%s:%s: invalid UDP packet of length %" PRIu64
|
||||
" (cmd_id %d)\n",
|
||||
driverName, functionName, received,
|
||||
((uint16_t *)buffer)[4]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -704,12 +722,12 @@ void asynStreamGeneratorDriver::processEvents() {
|
||||
|
||||
// wait for mininmum packet frequency or enough packets to ensure we
|
||||
// could potentially have at least 1 packet per mcpdid
|
||||
// IMPORTANT: if you start counts faster than this poll period (so
|
||||
// either the time or number of events incoming below), you will
|
||||
// find that it doesn't have time to switch back to idle within
|
||||
// this loop and so will just keep counting. If you need counts
|
||||
// that are started more often than the below currently 250ms
|
||||
// then that value will need to be adjusted.
|
||||
// IMPORTANT: if you start counts faster than this poll period (so
|
||||
// either the time or number of events incoming below), you will
|
||||
// find that it doesn't have time to switch back to idle within
|
||||
// this loop and so will just keep counting. If you need counts
|
||||
// that are started more often than the below currently 250ms
|
||||
// then that value will need to be adjusted.
|
||||
while (queuedEvents < bufferedEvents &&
|
||||
epicsTimeDiffInNS(¤tTime, &lastProcess) < 250'000'000ll) {
|
||||
epicsThreadSleep(0.0001); // seconds
|
||||
@@ -758,7 +776,6 @@ void asynStreamGeneratorDriver::processEvents() {
|
||||
for (std::size_t i = 0; i < this->num_channels; ++i) {
|
||||
counts[i] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (currStatus == STATUS_COUNTING) {
|
||||
|
||||
Reference in New Issue
Block a user