Skip to content

Commit 32d0680

Browse files
Provide spec integrals PV for POLREF
1 parent 3054278 commit 32d0680

File tree

5 files changed

+84
-14
lines changed

5 files changed

+84
-14
lines changed

isisdaeApp/Db/ADisisdae.template

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,15 @@ record(longin, "$(P)$(R)INTG:SPEC:SIZEY")
253253
info(archive, "VAL")
254254
}
255255

256+
# there can only be one cutoff value sent to ISISICP, so
257+
# c++ code send value for ADDR==0 and though you can set a differnt
258+
# value for each detector we set all readbacks to use addr==0 to
259+
# reflect all same isisicp spectrum integrals cutoff
256260
record(ai, "$(P)$(R)INTG:TMIN")
257261
{
258262
field(DESC, "Integrals TMIN")
259263
field(DTYP, "asynFloat64")
260-
field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))INTG_TMIN")
264+
field(INP, "@asyn($(PORT),0,$(TIMEOUT))INTG_TMIN")
261265
field(SCAN, "I/O Intr")
262266
info(archive, "VAL")
263267
}
@@ -275,7 +279,7 @@ record(ai, "$(P)$(R)INTG:TMAX")
275279
{
276280
field(DESC, "Integrals TMAX")
277281
field(DTYP, "asynFloat64")
278-
field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))INTG_TMAX")
282+
field(INP, "@asyn($(PORT),0,$(TIMEOUT))INTG_TMAX")
279283
field(SCAN, "I/O Intr")
280284
info(archive, "VAL")
281285
}
@@ -309,6 +313,7 @@ record(ai, "$(P)$(R)INTG:RATE")
309313
field(SIOL, "$(P)$(R)SIM:INTG:RATE CP")
310314
field(HSV, "MINOR")
311315
field(HIGH, "1e100")
316+
field(UDFS, "NO_ALARM")
312317
info(INTEREST, "HIGH")
313318
info(autosaveFields, "HIGH")
314319
info(alarm, "ISISDAE_01")
@@ -325,6 +330,7 @@ record(ai, "$(P)$(R)INTG:SPEC:RATE")
325330
field(SIOL, "$(P)$(R)SIM:INTG:SPEC:RATE CP")
326331
field(HSV, "MINOR")
327332
field(HIGH, "1e100")
333+
field(UDFS, "NO_ALARM")
328334
info(INTEREST, "HIGH")
329335
info(autosaveFields, "HIGH")
330336
info(alarm, "ISISDAE_01")

isisdaeApp/Db/isisdae.db

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,3 +1574,24 @@ record(bi, "$(P)$(Q)BLOCKSPECZERO")
15741574
field(ZNAM, "No")
15751575
field(ONAM, "Yes")
15761576
}
1577+
1578+
record(waveform, "$(P)$(Q)SPECINTEGRALS")
1579+
{
1580+
field(DESC, "Spec Integrals")
1581+
field(NELM, "$(SPECINTG_SIZE=1000000)")
1582+
field(FTVL, "LONG")
1583+
field(DTYP, "asynInt32ArrayIn")
1584+
field(INP, "@asyn(icp,0,0)SPECTRUM_INTEGRALS")
1585+
field(SCAN, "I/O Intr")
1586+
}
1587+
1588+
# Normally Passive SCAN and force a scan/read by writing to .PROC
1589+
record(waveform, "$(P)$(Q)SPECDATA")
1590+
{
1591+
field(DESC, "Spec Data")
1592+
field(NELM, "$(SPECDATA_SIZE=5000000)")
1593+
field(SCAN, "$(SPECDATA_SCAN=Passive)")
1594+
field(FTVL, "LONG")
1595+
field(DTYP, "asynInt32ArrayIn")
1596+
field(INP, "@asyn(icp,0,0)SPECTRUM_DATA")
1597+
}

isisdaeApp/src/exServer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ void exServer::show (unsigned level) const
315315
if (this->stringResTbl.lookup(id) == NULL) {
316316
std::cerr << "ERROR: PV is not in string lookup table" << std::endl;
317317
}
318-
#endif
318+
#endif
319319
}
320320
//
321321
// print information about ca server libarary

isisdaeApp/src/isisdaeDriver.cpp

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ static epicsThreadOnceId onceId = EPICS_THREAD_ONCE_INIT;
4343

4444
static 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

22292263
template <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
{

isisdaeApp/src/isisdaeDriver.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ class isisdaeDriver : public ADDriver
139139
int P_diagSpecIntHigh; // float
140140
int P_diagSum; // int
141141
int P_simulationMode; // int
142+
143+
int P_spectrumIntegrals; // int array
144+
int P_spectrumData; // int array
145+
142146
// create area detector views of intregrals of spectra in event mode
143147
int P_integralsSpecStart; // int
144148
int P_integralsSpecMode; // int
@@ -332,6 +336,9 @@ class isisdaeDriver : public ADDriver
332336

333337
#define P_simulationModeString "SIM_MODE"
334338

339+
#define P_spectrumIntegralsString "SPECTRUM_INTEGRALS"
340+
#define P_spectrumDataString "SPECTRUM_DATA"
341+
335342
#define P_vetoEnableString "VETO_ENABLE"
336343
#define P_vetoDisableString "VETO_DISABLE"
337344

0 commit comments

Comments
 (0)