void MyMonitorRequester::monitorEvent(MonitorPtr const & monitor) { shared_ptr<MonitorElement> update; while ((update = monitor->poll())) { // TODO Simulate slow client -> overruns on client side // epicsThreadSleep(0.1); ++updates; checkUpdate(update->pvStructurePtr); // update->changedBitSet indicates which elements have changed. // update->overrunBitSet indicates which elements have changed more than once, // i.e. we missed one (or more !) updates. if (! update->overrunBitSet->isEmpty()) ++overruns; if (quiet) { epicsTime now(epicsTime::getCurrent()); if (now >= next_run) { double received_perc = 100.0 * updates / (updates + missing_pulses); cout << updates << " updates, " << overruns << " overruns, " << missing_pulses << " missing pulses, " << array_size_differences << " array size differences, " << "received " << fixed << setprecision(1) << received_perc << "%" << endl; overruns = 0; missing_pulses = 0; updates = 0; array_size_differences = 0; # ifdef TIME_IT cout << "Time for value lookup: " << value_timer << endl; # endif next_run = now + 10.0; } } else { cout << "Monitor:\n"; cout << "Changed: " << *update->changedBitSet.get() << endl; cout << "Overrun: " << *update->overrunBitSet.get() << endl; update->pvStructurePtr->dumpValue(cout); cout << endl; } monitor->release(update); } ++ monitors; if (limit > 0 && monitors >= limit) { cout << "Received " << monitors << " monitors" << endl; done_event.signal(); } }
void oleaClient::monitorEvent (MonitorPtr const & monitor) { const char *functionName = "monitorEvent"; MonitorElementPtr update; while ((update = monitor->poll())) { if(!update->overrunBitSet->isEmpty()) { int overrunCounter; } monitor->release(update); } }
void pvaDriver::monitorConnect (Status const & status, MonitorPtr const & monitor, StructureConstPtr const & structure) { const char *functionName = "monitorConnect"; asynPrint(pasynUserSelf, ASYN_TRACE_FLOW, "%s::%s monitor connects [type=%s]\n", driverName, functionName, Status::StatusTypeName[status.getType()]); if (status.isSuccess()) { PVDataCreatePtr PVDC = getPVDataCreate(); if(!NTNDArray::isCompatible(PVDC->createPVStructure(structure))) { asynPrint(pasynUserSelf, ASYN_TRACE_ERROR, "%s::%s incompatible PVStructure. Not starting monitor\n", driverName, functionName); return; } asynPrint(pasynUserSelf, ASYN_TRACE_FLOW, "%s::%s starting monitor\n", driverName, functionName); monitor->start(); } }
void oleaClient::monitorConnect (Status const & status, MonitorPtr const & monitor, StructureConstPtr const & structure) { if (status.isSuccess()) { PVDataCreatePtr PVDC = getPVDataCreate(); if(!NTTable::isCompatible(PVDC->createPVStructure(structure))) { cout << "No NTTable support" << endl; return; } monitor->start(); } }
void MyMonitorRequester::monitorConnect(Status const & status, MonitorPtr const & monitor, StructureConstPtr const & structure) { cout << "Monitor connects, " << status << endl; if (status.isSuccess()) { // Check the structure by using only the Structure API? // Need to navigate the hierarchy, won't get the overall PVStructure offset. // Easier: Create temporary PVStructure PVStructurePtr pvStructure = getPVDataCreate()->createPVStructure(structure); shared_ptr<PVInt> user_tag = pvStructure->getSubField<PVInt>("timeStamp.userTag"); if (! user_tag) { cout << "No 'timeStamp.userTag'" << endl; return; } user_tag_offset = user_tag->getFieldOffset(); shared_ptr<PVUIntArray> tof = pvStructure->getSubField<PVUIntArray>("time_of_flight.value"); if (! tof) { cout << "No 'time_of_flight'" << endl; return; } tof_offset = tof->getFieldOffset(); shared_ptr<PVUIntArray> pixel = pvStructure->getSubField<PVUIntArray>("pixel.value"); if (! pixel) { cout << "No 'pixel'" << endl; return; } pixel_offset = pixel->getFieldOffset(); // pvStructure is disposed; keep value_offset to read data from monitor's pvStructure monitor->start(); } }
void pvaDriver::monitorEvent (MonitorPtr const & monitor) { const char *functionName = "monitorEvent"; asynPrint(pasynUserSelf, ASYN_TRACE_FLOW, "%s::%s Event!\n", driverName, functionName); lock(); MonitorElementPtr update; while ((update = monitor->poll())) { asynPrint(pasynUserSelf, ASYN_TRACE_FLOW, "%s::%s update!\n", driverName, functionName); if(!update->overrunBitSet->isEmpty()) { int overrunCounter; getIntegerParam(PVAOverrunCounter, &overrunCounter); setIntegerParam(PVAOverrunCounter, overrunCounter + 1); callParamCallbacks(); } NTNDArrayConverter converter(NTNDArray::wrap(update->pvStructurePtr)); NTNDArrayInfo_t info; try { info = converter.getInfo(); } catch(...) { asynPrint(pasynUserSelf, ASYN_TRACE_ERROR, "%s::%s failed to get info from NTNDArray\n", driverName, functionName); monitor->release(update); continue; } NDArray *pImage = pNDArrayPool->alloc(info.ndims, (size_t*) &info.dims, info.dataType, info.totalBytes, NULL); if(!pImage) { asynPrint(pasynUserSelf, ASYN_TRACE_ERROR, "%s::%s failed to alloc new NDArray" " - memory pool exhausted? (free: %d)\n", driverName, functionName, pNDArrayPool->numFree()); monitor->release(update); continue; } unlock(); try { asynPrint(pasynUserSelf, ASYN_TRACE_FLOW, "%s::%s Converting to NDArray\n", driverName, functionName); converter.toArray(pImage); } catch(...) { asynPrint(pasynUserSelf, ASYN_TRACE_ERROR, "%s::%s failed to convert NTNDArray into NDArray\n", driverName, functionName); pImage->release(); monitor->release(update); lock(); continue; } lock(); int xSize = pImage->dims[info.x.dim].size; int ySize = pImage->dims[info.y.dim].size; setIntegerParam(ADMaxSizeX, xSize); setIntegerParam(ADMaxSizeY, ySize); setIntegerParam(ADSizeX, xSize); setIntegerParam(ADSizeY, ySize); setIntegerParam(NDArraySizeX, xSize); setIntegerParam(NDArraySizeY, ySize); setIntegerParam(NDArraySizeZ, pImage->dims[info.color.dim].size); setIntegerParam(ADMinX, pImage->dims[info.x.dim].offset); setIntegerParam(ADMinY, pImage->dims[info.y.dim].offset); setIntegerParam(ADBinX, pImage->dims[info.x.dim].binning); setIntegerParam(ADBinY, pImage->dims[info.y.dim].binning); setIntegerParam(ADReverseX, pImage->dims[info.x.dim].reverse); setIntegerParam(ADReverseY, pImage->dims[info.y.dim].reverse); setIntegerParam(NDArraySize, (int) info.totalBytes); setIntegerParam(NDDataType, (int) info.dataType); setIntegerParam(NDColorMode, (int) info.colorMode); callParamCallbacks(); int arrayCallbacks; getIntegerParam(NDArrayCallbacks, &arrayCallbacks); if(arrayCallbacks) { asynPrint(pasynUserSelf, ASYN_TRACE_FLOW, "%s::%s Callback with NDArray (%p)\n", driverName, functionName, pImage); unlock(); doCallbacksGenericPointer(pImage, NDArrayData, 0); lock(); } // Update the counters after doCallbacksGenericPointer() int imageCounter; getIntegerParam(NDArrayCounter, &imageCounter); setIntegerParam(NDArrayCounter, imageCounter+1); getIntegerParam(ADNumImagesCounter, &imageCounter); setIntegerParam(ADNumImagesCounter, imageCounter+1); callParamCallbacks(); pImage->release(); monitor->release(update); } unlock(); }