@@ -43,7 +43,11 @@ static epicsThreadOnceId onceId = EPICS_THREAD_ONCE_INIT;
4343
4444static const char *driverName=" isisdaeDriver" ;
4545
46- const char * isisdaeDriver::RunStateNames[] = { " PROCESSING" , " SETUP" , " RUNNING" , " PAUSED" , " WAITING" , " VETOING" , " ENDING" , " SAVING" , " RESUMING" , " PAUSING" , " BEGINNING" , " ABORTING" , " UPDATING" , " STORING" , " CHANGING" };
46+ const char * isisdaeDriver::RunStateNames[] = {
47+ " PROCESSING" , " SETUP" , " RUNNING" , " PAUSED" , " WAITING" , " VETOING" ,
48+ " ENDING" , " SAVING" , " RESUMING" , " PAUSING" , " BEGINNING" , " ABORTING" ,
49+ " UPDATING" , " STORING" , " CHANGING"
50+ };
4751
4852// / An STL exception describing a Win32 Structured Exception.
4953// / Code needs to be compiled with /EHa if you wish to use this via _set_se_translator().
@@ -390,14 +394,18 @@ asynStatus isisdaeDriver::writeValue(asynUser *pasynUser, const char* functionNa
390394 else if (function == P_integralsTMin)
391395 {
392396 double intgTMax (0.0 );
393- getDoubleParam (addr, P_integralsTMax, &intgTMax);
394- m_iface->setSpecIntgCutoff (value, intgTMax);
397+ if (addr == 0 ) {
398+ getDoubleParam (addr, P_integralsTMax, &intgTMax);
399+ m_iface->setSpecIntgCutoff (value, intgTMax);
400+ }
395401 }
396402 else if (function == P_integralsTMax)
397403 {
398404 double intgTMin (0.0 );
399- getDoubleParam (addr, P_integralsTMin, &intgTMin);
400- m_iface->setSpecIntgCutoff (intgTMin, value);
405+ if (addr == 0 ) {
406+ getDoubleParam (addr, P_integralsTMin, &intgTMin);
407+ m_iface->setSpecIntgCutoff (intgTMin, value);
408+ }
401409 }
402410 endStateTransition ();
403411 asynPrint (pasynUser, ASYN_TRACEIO_DRIVER,
@@ -460,7 +468,19 @@ asynStatus isisdaeDriver::readArray(asynUser *pasynUser, const char* functionNam
460468 try
461469 {
462470 m_iface->resetMessages ();
463- if (function == P_VMEReadValueProps || function == P_VMEReadArrayProps || function == P_QXReadArrayProps)
471+ if (function == P_spectrumData)
472+ {
473+ int numSpec = 0 , numPeriods = 0 , ntc = 0 ;
474+ getIntegerParam (0 , P_NumSpectra, &numSpec);
475+ getIntegerParam (0 , P_NumPeriods, &numPeriods);
476+ getIntegerParam (0 , P_NumTimeChannels, &ntc);
477+ const uint32_t * spec_data = m_iface->getData ();
478+ int max_spec_data_size = m_iface->getDataSize ();
479+ int ncopy = std::min ({(int )nElements, (ntc + 1 ) * (numSpec + 1 ) * numPeriods, max_spec_data_size});
480+ std::copy (spec_data, spec_data + ncopy, value);
481+ *nIn = ncopy;
482+ }
483+ else if (function == P_VMEReadValueProps || function == P_VMEReadArrayProps || function == P_QXReadArrayProps)
464484 {
465485 std::vector<epicsInt32>& props = m_directRWProps[function];
466486 if (nElements >= props.size ())
@@ -1190,6 +1210,9 @@ isisdaeDriver::isisdaeDriver(isisdaeInterface* iface, const char *portName, int
11901210 createParam (P_vetoPCExt3String, asynParamFloat64, &P_vetoPCExt3);
11911211
11921212 createParam (P_blockSpecZeroString, asynParamInt32, &P_blockSpecZero);
1213+
1214+ createParam (P_spectrumIntegralsString, asynParamInt32Array, &P_spectrumIntegrals);
1215+ createParam (P_spectrumDataString, asynParamInt32Array, &P_spectrumData);
11931216
11941217 // list commands that are not allowed when you are in the given run state
11951218 m_disallowedStateCommand[RS_SETUP] << P_AbortRun << P_EndRun << P_PauseRun << P_ResumeRun;
@@ -1414,7 +1437,7 @@ void isisdaeDriver::updateRunStatus()
14141437 }
14151438 else
14161439 {
1417- setDoubleParam (P_CountRate, static_cast <double >(tc - old_tc) / tdiff * 3600.0 / 1e6 ); // to make million events per hour
1440+ setDoubleParam (P_CountRate, static_cast <double >(tc - old_tc) / tdiff * 3600.0 / 1e6 ); // to make million events per hour
14181441 setDoubleParam (P_CountRateFrame, static_cast <double >(tc - old_tc) / static_cast <double >(frames - old_frames));
14191442 }
14201443 old_tc_ts = tc_ts;
@@ -1821,11 +1844,22 @@ void isisdaeDriver::pollerThread4()
18211844 memset (&(last_update[0 ]), 0 , maxAddr * sizeof (epicsTimeStamp));
18221845 while (true )
18231846 {
1847+ {
1848+ epicsGuard<isisdaeDriver> _lock (*this );
1849+ int numSpec = 0 , numPeriods = 0 ;
1850+ getIntegerParam (0 , P_NumSpectra, &numSpec);
1851+ getIntegerParam (0 , P_NumPeriods, &numPeriods);
1852+ const uint32_t * spec_integrals = m_iface->getEventSpecIntegrals ();
1853+ int max_spec_int_size = m_iface->getEventSpecIntegralsSize ();
1854+ doCallbacksInt32Array (const_cast <epicsInt32*>(reinterpret_cast <const epicsInt32*>(spec_integrals)),
1855+ std::min (max_spec_int_size, (numSpec + 1 ) * numPeriods),
1856+ P_spectrumIntegrals, 0 );
1857+ }
18241858 all_acquiring = all_enable = 0 ;
18251859 for (int i=0 ; i<maxAddr; ++i)
18261860 {
18271861 epicsGuard<isisdaeDriver> _lock (*this );
1828- try
1862+ try
18291863 {
18301864 acquiring = enable = 0 ;
18311865 getIntegerParam (i, ADAcquire, &acquiring);
@@ -2227,7 +2261,8 @@ void transpose(float *src, float *dst, const int N, const int M) {
22272261#endif
22282262
22292263template <typename epicsType>
2230- int isisdaeDriver::computeArray (int addr, int spec_start, int trans_mode, int maxSizeX, int maxSizeY, double & maxval, long & totalCntsDiff, long & maxSpecCntsDiff, int data_mode, int period)
2264+ int isisdaeDriver::computeArray (int addr, int spec_start, int trans_mode, int maxSizeX, int maxSizeY,
2265+ double & maxval, long & totalCntsDiff, long & maxSpecCntsDiff, int data_mode, int period)
22312266{
22322267 epicsType *pMono=NULL , *pRed=NULL , *pGreen=NULL , *pBlue=NULL ;
22332268 int columnStep=0 , rowStep=0 , colorMode, numSpec;
@@ -2373,7 +2408,8 @@ int isisdaeDriver::computeArray(int addr, int spec_start, int trans_mode, int ma
23732408 if (integSpecMode == 1 )
23742409 {
23752410 try {
2376- max_spec_int_size = m_iface->getEventSpecIntegralsSize (); // in case numPeriods or numSpec changes just use same default as event mode
2411+ // in case numPeriods or numSpec changes just use same default as event mode
2412+ max_spec_int_size = m_iface->getEventSpecIntegralsSize ();
23772413 if (new_integrals[addr] == NULL )
23782414 {
23792415 new_integrals[addr] = new uint32_t [max_spec_int_size];
@@ -2440,7 +2476,7 @@ int isisdaeDriver::computeArray(int addr, int spec_start, int trans_mode, int ma
24402476 double * dintegrals = new double [maxSizeX * maxSizeY];
24412477 for (i=0 ; i < (maxSizeX * maxSizeY); ++i)
24422478 {
2443- dintegrals[i] = 0.0 ;
2479+ dintegrals[i] = 0.0 ;
24442480 }
24452481 for (i=0 ; i<nspec; ++i)
24462482 {
0 commit comments