15 template <
class EnvPeriodPolicy>
19 std::ostringstream message;
42 {15,
"",
"Reset Period card" },
43 {13,
"",
"Clear Period Counters" },
44 {11,
"",
"Muon MS Mode" },
48 {7,
"",
"Multiple Period sequence complete" },
49 {6,
"Single period sequence mode",
"Multiple period sequence mode" },
50 {5,
"Internal period control mode",
"External period control mode" },
51 {4,
"Non-period mode",
"Period mode"},
52 {3,
"",
"Run ended AND period sequence completed" },
53 {2,
"",
"Period sequence complete" },
54 {1,
"",
"End after period sequence complete has been requested" },
57 template <
class EnvPeriodPolicy>
66 os <<
"This is a " << EnvPeriodPolicy::card_type <<
" combined ENVIRONMENT and PERIOD card" << std::endl;
67 readRegister(ALT1SFV, &value32, status);
69 os <<
"ALT1 firmware version = " << (value32 >> 4) <<
"." << (value32 & 0x0f) << std::endl;
70 os <<
"Current period number = " << getCurrentPeriodNumber(status) << (inDwellPeriod(status) ?
" (DWELL)" :
" (DAQ)") << std::endl;
71 nper = getNumberOfPeriods(status);
72 os <<
"Number of periods = " << nper << std::endl;
73 readRegister(
PSCNT, &value32, status);
74 os <<
"Period sequence number = " << value32 << std::endl;
79 readRegister(
PCREG, &value16, status);
82 os <<
"Summary of period control register, value = 0x" << std::hex << value16 << std::dec << std::endl;
85 if (value16 & (1 << mode_list[i].bit))
87 os <<
"Bit " << mode_list[i].
bit <<
" is SET (" << mode_list[i].
set <<
")" << std::endl;
91 os <<
"Bit " << mode_list[i].
bit <<
" is CLEAR (" << mode_list[i].
unset <<
")" << std::endl;
104 readPERLUT(dwell_flags, frames_needed, nper, status);
105 readOUTLUT(outputs, nper, status);
106 getRawFrames(0, nper, raw_frames, status);
107 getGoodFrames(0, nper, good_frames, status);
108 os <<
"Summary of period card programming (1st 16 max)" << std::endl;
109 for(i=0; i< (nper < 16 ? nper : 16); i++)
111 os <<
"Period " << i << (dwell_flags[i] != 0 ?
" (DWELL)" :
" (DAQ)") << std::endl;
112 os <<
"\tRequested frames = " << frames_needed[i] <<
" logic signal output = 0x" << std::hex << outputs[i] << std::dec << std::endl;
113 os <<
"\tCurrent counters (should always be ZERO for DWELL): raw = " << raw_frames[i] <<
" good = " << good_frames[i] << std::endl;
115 delete[] frames_needed;
116 delete[] good_frames;
119 delete[] dwell_flags;
120 readRegister(RCONTROL, &value, status);
121 os <<
"RC register value = " << std::hex <<
"0x" << value << std::dec << std::endl;
122 os <<
"Status: " << (value & RCSTART ?
"Running" :
"Stopped") << std::endl;
123 os <<
"Event mode: " << (value & RCEVENTMODE ?
"Enabled" :
"Disabled") << std::endl;
124 os <<
"Frame Sync: ";
125 switch(value & RCFSSEL)
137 os <<
"ISIS TOF (1st pulse)";
140 os <<
"Muon Cerenkov";
141 if (value & RCFSSCH2)
143 os <<
" (2nd pulse)";
147 os <<
" (1st pulse)";
151 os <<
"Muon MS mode";
159 getFrameSyncDelay(&value1, status);
160 os <<
"Frame sync delay: " << value1 <<
"\n";
161 printVetoDetails(os, status);
163 getGoodFrames(&value1, status);
164 getRawFrames(&value, status);
165 os <<
"GOOD/RAW frames: " << value1 <<
"/" << value <<
"\n";
166 os <<
"GOOD/TOTAL uamph: " << getGoodUAmpHours(status) <<
"/" << getGoodUAmpHours(status) <<
"\n";
167 os <<
"Period Type: " << (usingHardwarePeriods(status) ?
"Hardware" :
"Software") <<
"\n";
168 if (checkOptions(RotateFrameCountersRight))
170 os <<
"Single frame workaround enabled\n";
172 os <<
"Current DAE frame time drift (icp - dae) = " << frameTimerDrift(status) / 1000.0 <<
" ms\n";
173 if (checkOptions(NoCheckSRAM))
175 os <<
"WARNING: SRAM memory checking is DISABLED\n";
180 template <
class EnvPeriodPolicy>
185 readRegister(RVETO, &veto_reg, status);
186 for(i=0; veto_details[i].name != NULL; i++)
188 readRegister(veto_details[i].counter_addr, &frames, status);
189 os << veto_details[i].name <<
" is " << ((veto_reg & veto_details[i].mask) != 0 ?
"ENABLED (vetoed " :
"DISABLED (counted ") << frames <<
") frames\n";
194 template <
class EnvPeriodPolicy>
197 return clearRunControlBits(RCPERSZEQZERO, status);
200 template <
class EnvPeriodPolicy>
203 return setRunControlBits(RCPERSZEQZERO,
true, status);
207 template <
class EnvPeriodPolicy>
210 static time_t last_call;
213 isisU32_t veto_reg, rf2, vframes2[100], poll_time;
216 for(nveto = 0; veto_details[nveto].name != NULL; ++nveto)
218 readRegister(RVETO, &veto_reg, status);
219 for(i=0; i < nveto; i++)
221 readRegister(veto_details[i].counter_addr, &(vframes2[i]), status);
223 getRawFrames(&rf2, status);
231 poll_time = time(NULL) - last_call;
233 for(i=0; i < nveto; i++)
235 if ((veto_reg & veto_details[i].mask) != 0)
237 os << veto_details[i].name <<
" vetoed " <<
238 (int)(100.0 * (vframes2[i] - vframes1[i]) / rfdiff) <<
239 "% (last " << poll_time <<
" seconds), " <<
240 (
int)(100.0 * vframes2[i] / rf2) <<
241 "% (since run start)\n";
243 vframes1[i] = vframes2[i];
248 template <
class EnvPeriodPolicy>
251 return setRegisterBits(
PCREG, mask, preserve, status);
254 template <
class EnvPeriodPolicy>
257 return clearRegisterBits(
PCREG, mask, status);
260 template <
class EnvPeriodPolicy>
263 return setAndClearRegisterBits(
PCREG, mask, preserve, status);
296 template <
class EnvPeriodPolicy>
302 template <
class EnvPeriodPolicy>
308 template <
class EnvPeriodPolicy>
311 return writeRegister16(
LOOKTAR, 0, status);
314 template <
class EnvPeriodPolicy>
318 int stat = readRegister(
MPCNT, &period, status);
323 template <
class EnvPeriodPolicy>
327 readRegister(
MPCNT, &period, status);
328 return ((period & (1 << 14)) != 0);
331 template <
class EnvPeriodPolicy>
334 return writeRegister16(
MPLIM, n, status);
337 template <
class EnvPeriodPolicy>
341 readRegister(
MPLIM, &n, status);
356 template <
class EnvPeriodPolicy>
360 readRegister(
PSCNT, &n, status);
364 template <
class EnvPeriodPolicy>
367 return setAndClearPeriodControlBits(
PCRESET,
true, status);
370 template <
class EnvPeriodPolicy>
374 return setAndClearPeriodControlBits(
PCCLRPC,
true, status);
397 template <
class EnvPeriodPolicy>
400 return clearPeriodControlBits(
PCMULENAB, status);
403 template <
class EnvPeriodPolicy>
406 writeRegister(
PSLR, nseq, status);
407 return setPeriodControlBits(
PCMULENAB,
true, status);
410 template <
class EnvPeriodPolicy>
419 clearPeriodControlBits(
PCEXTENAB, status);
420 return setPeriodControlBits(
PCENAB,
true, status);
424 template <
class EnvPeriodPolicy>
427 return clearPeriodControlBits(
PCENAB, status);
430 template <
class EnvPeriodPolicy>
434 return setPeriodControlBits(PCMSM,
true, status);
437 template <
class EnvPeriodPolicy>
440 clearOptions(MSMode);
441 return clearPeriodControlBits(PCMSM, status);
445 template <
class EnvPeriodPolicy>
448 return setPeriodControlBits(
PCENDAFTER,
true, status);
451 template <
class EnvPeriodPolicy>
455 readRegister(
PCREG, &value, status);
467 template <
class EnvPeriodPolicy>
471 readRegister(
PCREG, &value, status);
482 template <
class EnvPeriodPolicy>
495 template <
class EnvPeriodPolicy>
502 template <
class EnvPeriodPolicy>
508 bool single_frames_only =
true;
509 for(i=0; i<nperiod; i++)
513 single_frames_only =
false;
515 pdata[i] = ((frames[i]) & 0xffff) + (dwell_flags[i] != 0 ? (1 << 31) : 0);
518 single_frames_only =
false;
519 if (single_frames_only && checkOptions(MSMode))
521 setOptions(RotateFrameCountersRight);
525 clearOptions(RotateFrameCountersRight);
527 lookupAccessPERLUT(status);
529 writeMemory(PERLUTSTART, pdata, nperiod, 0xffffffff, props, status);
530 lookupFinished(status);
535 template <
class EnvPeriodPolicy>
541 lookupAccessPERLUT(status);
542 readMemory(
PERLUTSTART, pdata, nperiod, props, status);
543 lookupFinished(status);
544 for(i=0; i<nperiod; i++)
546 frames[i] = (
isisU16_t)(pdata[i] & 0xffff);
547 dwell_flags[i] = ( (pdata[i] & (1 << 31)) ? 1 : 0 );
555 template <
class EnvPeriodPolicy>
558 lookupAccessOUTLUT(status);
561 writeMemory(OUTLUTSTART, outputs, nperiod, OUTLUTMASK, props, status);
566 lookupFinished(status);
570 template <
class EnvPeriodPolicy>
575 lookupAccessOUTLUT(status);
577 readMemory(
OUTLUTSTART, outputs, nperiod, props, status);
578 lookupFinished(status);
579 for(i=0; i<nperiod; i++)
581 outputs[i] &= OUTLUTMASK;
586 template <
class EnvPeriodPolicy>
590 uint32_t check_mask0 = (checkOptions(NoCheckSRAM) ? 0x0 : 0xffffffff);
596 template <
class EnvPeriodPolicy>
600 EnvPeriodPolicy::ppp_memory_t check_mask0 = ( checkOptions(NoCheckSRAM) ? 0x0 : ~(
static_cast<EnvPeriodPolicy::ppp_memory_t
>(0)) );
601 uint32_t check_mask1 = (checkOptions(NoCheckSRAM) ? 0x0 : 0x0000ffff);
602 zeroMemory<EnvPeriodPolicy::ppp_memory_t>(
RPCNT0START, RPCNT0SIZE, check_mask0, props, status);
603 zeroMemory<EnvPeriodPolicy::ppp_memory_t>(
GPCNT0START, GPCNT0SIZE, check_mask0, props, status);
605 if (RPCNT1START != RPCNT0START && RPCNT1SIZE > 0)
607 zeroMemory(RPCNT1START, RPCNT1SIZE, check_mask1,
false,
false, status);
608 zeroMemory(GPCNT1START, GPCNT1SIZE, check_mask1,
false,
false, status);
615 template <
class EnvPeriodPolicy>
619 uint32_t check_mask0 = (checkOptions(NoCheckSRAM) ? 0x0 : 0xffffffff);
620 uint32_t check_mask1 = (checkOptions(NoCheckSRAM) ? 0x0 : 0x0000ffff);
623 zeroMemory<isisU32_t>(SPARE0START, SPARE0SIZE, check_mask0, props, status);
627 zeroMemory<isisU32_t>(SPARE1START, SPARE1SIZE, check_mask1, props, status);
632 template <
class EnvPeriodPolicy>
635 return getRawFrames(period, 1, frames, status);
638 template <
class EnvPeriodPolicy>
641 return getGoodFrames(period, 1, frames, status);
644 template <
class EnvPeriodPolicy>
647 return getRequestedFrames(period, 1, frames, status);
650 template <
class EnvPeriodPolicy>
655 lookupAccessPERLUT(status);
656 readMemory(
PERLUTSTART+4*period_start, frames, nperiod, props, status);
657 lookupFinished(status);
658 for(i=0; i<nperiod; i++)
660 frames[i] = (frames[i] & 0xffff);
666 template <
class EnvPeriodPolicy>
674 if (!checkOptions(RotateFrameCountersRight))
676 readMemory(
RFCNT0START + 4*period_start, frames, nperiod, props, status);
682 n = getNumberOfPeriods(status);
685 for(i = 0; i < nperiod; i++)
687 frames[i] = tmp_f[(i + period_start + 1) % n];
700 template <
class EnvPeriodPolicy>
708 if (!checkOptions(RotateFrameCountersRight))
717 n = getNumberOfPeriods(status);
722 int seq = getCurrentPeriodSequence(status);
723 readPERLUT(dwell_flags, frames_requested, n, status);
727 if ( (dwell_flags[i] == 0) && (dwell_flags[j] != 0) && (tmp_f[j] > seq) )
729 tmp_f[i] = tmp_f[i] + (tmp_f[j] - seq);
732 for(i=0; i<nperiod; i++)
734 frames[i] = tmp_f[i+period_start];
736 delete[] dwell_flags;
737 delete[] frames_requested;
744 n = getNumberOfPeriods(status);
747 for(i = 0; i < nperiod; i++)
749 frames[i] = tmp_f[(i + period_start + 1) % n];
762 template <
class EnvPeriodPolicy>
765 if ((delay >> 18) != 0)
769 return writeRegister(PEROUTDEL, delay, status);
788 template <
class EnvPeriodPolicy>
791 return setRegisterBits(RVETO, mask, preserve, status);
794 template <
class EnvPeriodPolicy>
797 return clearRegisterBits(RVETO, mask, status);
800 template <
class EnvPeriodPolicy>
803 return setRegisterBits(RCONTROL, mask, preserve, status);
806 template <
class EnvPeriodPolicy>
809 return clearRegisterBits(RCONTROL, mask, status);
812 template <
class EnvPeriodPolicy>
815 return setAndClearRegisterBits(RCONTROL, mask, preserve, status);
818 template <
class EnvPeriodPolicy>
821 resetRunController(status);
822 syncFrameTimer(status);
823 return setRunControlBits(RCSTART,
true, status);
826 template <
class EnvPeriodPolicy>
829 clearRunControlBits(RCSTART, status);
830 return resetRunController(status);
833 template <
class EnvPeriodPolicy>
839 return setAndClearRegisterBits(RCONTROL, RCFCLEAR | RCPCLEAR,
true, status);
842 template <
class EnvPeriodPolicy>
845 return setAndClearRegisterBits(RCONTROL, RCPCLEAR,
true, status);
848 template <
class EnvPeriodPolicy>
852 readRegister(RCONTROL, &value, status);
853 switch(value & RCFSSEL)
880 template <
class EnvPeriodPolicy>
883 int stat = clearRunControlBits(RCFSSEL, status);
884 disableMSMode(status);
892 return setRunControlBits(RCFSTOF,
true, status);
896 return setRunControlBits(RCFSTOF1P,
true, status);
900 return setRunControlBits(RCFSSMP,
true, status);
904 return setRunControlBits(RCFSMUONCK,
true, status);
908 enableMSMode(status);
909 return setRunControlBits(RCFSMUONMS,
true, status);
919 template <
class EnvPeriodPolicy>
924 return clearRunControlBits(RCFSSCH2, status);
928 return setRunControlBits(RCFSSCH2,
true, status);
937 template <
class EnvPeriodPolicy>
941 readRegister(RCONTROL, &value, status);
952 template <
class EnvPeriodPolicy>
955 return readRegister(FCOUNTR, value, status);
958 template <
class EnvPeriodPolicy>
962 if (checkOptions(MSMode))
964 return readRegister(SCHPULSE, value, status);
968 return readRegister(FCOUNTG, value, status);
972 template <
class EnvPeriodPolicy>
975 readRegister(PCOUNTR0, value, status);
979 template <
class EnvPeriodPolicy>
982 readRegister(PCOUNTR1, value, status);
986 template <
class EnvPeriodPolicy>
990 readRegister(PCOUNTR0, &value0, status);
991 readRegister(PCOUNTR1, &value1, status);
996 template <
class EnvPeriodPolicy>
999 readRegister(PCOUNTG0, value, status);
1003 template <
class EnvPeriodPolicy>
1006 readRegister(PCOUNTG1, value, status);
1010 template <
class EnvPeriodPolicy>
1014 readRegister(PCOUNTG0, &value0, status);
1015 readRegister(PCOUNTG1, &value1, status);
1020 template <
class EnvPeriodPolicy>
1023 return setAndClearRunControlBits(RCRESET,
true, status);
1026 template <
class EnvPeriodPolicy>
1029 return setVetoRegisterBits(RVSMP,
true, status);
1032 template <
class EnvPeriodPolicy>
1038 return setVetoRegisterBits(RVEXT0,
true, status);
1041 return setVetoRegisterBits(RVEXT1,
true, status);
1044 return setVetoRegisterBits(RVEXT2,
true, status);
1047 return setVetoRegisterBits(RVEXT3,
true, status);
1056 template <
class EnvPeriodPolicy>
1059 return setVetoRegisterBits(RVINT,
true, status);
1062 template <
class EnvPeriodPolicy>
1065 return setVetoRegisterBits(RVFIFO,
true, status);
1068 template <
class EnvPeriodPolicy>
1071 return enableFChopperVeto(chopper_number, delay, width, status);
1074 template <
class EnvPeriodPolicy>
1077 return setVetoRegisterBits(RVTS2P,
true, status);
1080 template <
class EnvPeriodPolicy>
1083 return setVetoRegisterBits(RVHZ50,
true, status);
1086 template <
class EnvPeriodPolicy>
1089 return clearVetoRegisterBits(RVSMP, status);
1092 template <
class EnvPeriodPolicy>
1098 return clearVetoRegisterBits(RVEXT0, status);
1101 return clearVetoRegisterBits(RVEXT1, status);
1104 return clearVetoRegisterBits(RVEXT2, status);
1107 return clearVetoRegisterBits(RVEXT3, status);
1110 status.
addWarningVa(
FAC_DAE,
"Attempting to disable invalid veto number %d", veto_number);
1116 template <
class EnvPeriodPolicy>
1119 return clearVetoRegisterBits(RVINT, status);
1122 template <
class EnvPeriodPolicy>
1125 return clearVetoRegisterBits(RVFIFO, status);
1128 template <
class EnvPeriodPolicy>
1135 template <
class EnvPeriodPolicy>
1138 static const isisU32_t mapping[] = { RVFCHOP0, RVFCHOP1, RVFCHOP2, RVFCHOP3 };
1139 if ( chopper_number >= 0 && chopper_number <
array_length(mapping) )
1141 return func(mapping[chopper_number], status);
1145 status.
addWarningVa(
FAC_DAE,
"Attempting to process invalid fermi chopper number %d", chopper_number);
1150 template <
class EnvPeriodPolicy>
1153 return clearVetoRegisterBits(RVTS2P, status);
1156 template <
class EnvPeriodPolicy>
1159 return clearVetoRegisterBits(RVHZ50, status);
1162 template <
class EnvPeriodPolicy>
1165 return readRegister(SMPVETFRM, value, status);
1168 template <
class EnvPeriodPolicy>
1175 return readRegister(EXT0VETFRM, value, status);
1178 return readRegister(EXT1VETFRM, value, status);
1181 return readRegister(EXT2VETFRM, value, status);
1184 return readRegister(EXT3VETFRM, value, status);
1187 status.
addWarningVa(
FAC_DAE,
"Attempting to read invalid external veto number %d", veto_number);
1193 template <
class EnvPeriodPolicy>
1196 return readRegister(MSMVETFRM, value, status);
1199 template <
class EnvPeriodPolicy>
1202 return readRegister(FIFOVETFRM, value, status);
1205 template <
class EnvPeriodPolicy>
1208 return readRegister(INTVETFRM, value, status);
1212 template <
class EnvPeriodPolicy>
1215 static const isisU32_t mapping[] = { FC0VETFRM, FC1VETFRM, FC2VETFRM, FC3VETFRM };
1216 if ( chopper_number >=0 && chopper_number <
array_length(mapping) )
1218 return readRegister(mapping[chopper_number], value, status);
1222 status.
addWarningVa(
FAC_DAE,
"Attempting to read invalid fermi chopper number %d", chopper_number);
1227 template <
class EnvPeriodPolicy>
1230 return readRegister(TS2PVETFRM, value, status);
1233 template <
class EnvPeriodPolicy>
1236 return readRegister(HZ50VETFRM, value, status);
1264 template <
class EnvPeriodPolicy>
1277 if ((value >> 18) != 0)
1281 clearRunControlBits(RCFSENABLEOUT, status);
1282 setAndClearRunControlBits(RCDELFSFIFORS,
true, status);
1283 writeRegister(FSDELAY, value, status);
1284 setRunControlBits(RCFSENABLEOUT,
true, status);
1288 template <
class EnvPeriodPolicy>
1292 readRegister(FSDELAY, value, status);
1297 template <
class EnvPeriodPolicy>
1300 return clearRunControlBits(RCPERSZEQZERO, status);
1303 template <
class EnvPeriodPolicy>
1306 return setRunControlBits(RCPERSZEQZERO,
true, status);
1309 template <
class EnvPeriodPolicy>
1323 readRegister(
PCREG, &value, status);
1341 #define PPP_TO_UAMPH 1.738E-6
1343 template <
class EnvPeriodPolicy>
1346 float good_uamps = 0.0;
1348 getGoodPPPLower(&low, status);
1349 getGoodPPPUpper(&upper, status);
1350 good_uamps =
static_cast<float>((65536.0 * 65536.0 * upper + low) *
PPP_TO_UAMPH);
1354 template <
class EnvPeriodPolicy>
1357 float raw_uamps = 0.0;
1358 isisU32_t low = 0, middle = 0, upper = 0;
1359 getRawPPPLower(&low, status);
1360 getRawPPPUpper(&upper, status);
1361 raw_uamps =
static_cast<float>((65536.0 * 65536.0 * upper + low) *
PPP_TO_UAMPH);
1365 template <
class EnvPeriodPolicy>
1372 setOptions(NoCheckSRAM);
1373 readRegister(
PCREG, &value16, status);
1374 (value16 & PCMSM) ? setOptions(MSMode) : clearOptions(MSMode);
1375 readRegister(
MPLIM, &nperiod, status);
1377 getRequestedFrames(0, nperiod, req_frames, status);
1378 bool single_frames_only =
true;
1379 for(i=0; i<nperiod; i++)
1381 if (req_frames[i] != 1)
1383 single_frames_only =
false;
1387 single_frames_only =
false;
1388 (single_frames_only) ? setOptions(RotateFrameCountersRight) : clearOptions(RotateFrameCountersRight);
1389 delete[] req_frames;
1392 if (readRegister(FRAMETIME0, &ft0, temp_status) == 1)
1395 setOptions(EventModeTimer);
1397 if (readRegister(FC0WINDLY, &ft0, temp_status) == 1)
1399 status.
addInfo(
FAC_DAE,
"This card supports fermi chopper veto");
1400 setOptions(FChopperVeto);
1406 template <
class EnvPeriodPolicy>
1409 static const isisU32_t delay_mapping[] = { FC0WINDLY, FC1WINDLY, FC2WINDLY, FC3WINDLY };
1410 static const isisU32_t window_mapping[] = { FC0WINWTH, FC1WINWTH, FC2WINWTH, FC3WINWTH };
1411 static const isisU32_t veto_mapping[] = { RVFCHOP0, RVFCHOP1, RVFCHOP2, RVFCHOP3 };
1415 writeRegister(delay_mapping[chopper_number], delay, status);
1416 writeRegister(window_mapping[chopper_number], width, status);
1417 status.
addInfoVa(
FAC_DAE,
"Fermi chopper %d setting delay,width (us) = %f,%f\n", chopper_number, delay / 50.0, width / 50.0);
1418 return setVetoRegisterBits(veto_mapping[chopper_number],
true, status);
1427 template <
class EnvPeriodPolicy>
1430 return disableFermiChopperVeto(chopper_number, status);
1433 template <
class EnvPeriodPolicy>
1436 return getFermiChopperVetoedFrames(chopper_number, value, status);
1439 template <
class EnvPeriodPolicy>
1442 float raw_uamps = 0.0;
1443 isisU32_t low = 0, middle = 0, upper = 0;
1444 getRawPPPLowerPeriod(period, &low, status);
1445 getRawPPPUpperPeriod(period, &upper, status);
1446 raw_uamps =
static_cast<float>((65536.0 * 65536.0 * upper + low) *
PPP_TO_UAMPH);
1450 template <
class EnvPeriodPolicy>
1453 float good_uamps = 0.0;
1455 getGoodPPPLowerPeriod(period, &low, status);
1456 getGoodPPPUpperPeriod(period, &upper, status);
1457 good_uamps =
static_cast<float>((65536.0 * 65536.0 * upper + low) *
PPP_TO_UAMPH);
1461 template <
class EnvPeriodPolicy>
1465 EnvPeriodPolicy::ppp_memory_t val;
1466 int stat = readMemory(
RPCNT0START +
sizeof(val)*period, &val, 1, props, status);
1471 template <
class EnvPeriodPolicy>
1476 int stat = readMemory(RPCNT1START + 4*period, value, 1,
false,
false, status);
1484 template <
class EnvPeriodPolicy>
1487 EnvPeriodPolicy::ppp_memory_t val;
1489 int stat = readMemory(
GPCNT0START +
sizeof(val)*period, &val, 1, props, status);
1494 template <
class EnvPeriodPolicy>
1499 int stat = readMemory(GPCNT1START + 4*period, value, 1,
false,
false, status);
1511 template <
class EnvPeriodPolicy>
1514 if (!checkOptions(EventModeTimer))
1519 m_vme->lockInterface(0, status);
1522 status.
addInfoVa(
FAC_DAE,
"Previous DAE time drift (icp - dae) = %f ms", frameTimerDrift(status) / 1000.0);
1525 computeTimeOffsetDelay(delay, status);
1530 writeRegister(FRAMETIME0, 0, status);
1533 g_icp_clock.get()->getCurrentTimeAsFiletime(filetime);
1535 writeRegister(FRAMETIME1, daetime.
high, status);
1536 writeRegister(FRAMETIME0, daetime.
low, status);
1537 status.
addInfoVa(
FAC_DAE,
"DAE time drift (icp - dae) = %f ms", frameTimerDrift(status) / 1000.0);
1538 m_vme->unlockInterface(status);
1539 timer.
info(
"Time to compute and set new DAE time values", status);
1545 template <
class EnvPeriodPolicy>
1548 FILETIME filetime1, filetime2;
1549 m_vme->lockInterface(0, status);
1551 readFrameTimer(filetime1, status);
1553 g_icp_clock.get()->getCurrentTimeAsFiletime(filetime2);
1554 m_vme->unlockInterface(status);
1558 template <
class EnvPeriodPolicy>
1561 if (!checkOptions(EventModeTimer))
1563 memset(&ft, 0,
sizeof(FILETIME));
1568 readRegister(FRAMETIME0, &temp32, status);
1569 readRegister(FRAMETIME1, &ft1, status);
1570 readRegister(FRAMETIME0, &ft0, status);
1573 readRegister(FRAMETIME1, &ft1, status);
1574 readRegister(FRAMETIME0, &ft0, status);
1583 template <
class EnvPeriodPolicy>
1586 writeRegister(FRAMETIME0, 0, status);
1587 readRegister(FRAMETIME0, &delay, status);
1591 template <
class EnvPeriodPolicy>
1594 return setRunControlBits(RCEVENTMODE,
true, status);
1597 template <
class EnvPeriodPolicy>
1600 return clearRunControlBits(RCEVENTMODE, status);
1626 template <
class EnvPeriodPolicy>
1633 uint32_t check_mask0 = 0x0;
1634 uint32_t check_mask1 = 0x0;
1636 writeRegister(FSDELAY, 0x1, status);
1637 writeRegister(FC0WINDLY, 0xfa0, status);
1638 writeRegister(FC0WINWTH, 0x5dc, status);
1641 writeRegister(
MPCNT, 0x0, status);
1642 writeRegister(
MPLIM, 0x0, status);
1643 writeRegister(
PSCNT, 0x0, status);
1644 writeRegister(
PSLR, 0x0, status);
1645 writeRegister(PERINCTOT, 0x0, status);
1646 writeRegister(PEROUTDEL, 0x0, status);
1648 writeRegister(
LOOKTAR, 0x0, status);
1649 writeRegister(RVETO, 0x0, status);
1650 writeRegister(RCONTROL, 0xc006, status);
1651 writeRegister(
PCREG, 0x8000, status);
1652 writeRegister(RCONTROL, 0x100008, status);
1653 writeRegister(
PCREG, 0x0, status);
1671 {
"FIFO Veto", RVFIFO, FIFOVETFRM,
false },
1672 {
"SMP (chopper) Veto", RVSMP, SMPVETFRM,
false },
1673 {
"Internal Veto", RVINT, INTVETFRM,
true },
1674 {
"Fermi Chopper0 Veto", RVFCHOP0, FC0VETFRM,
false },
1678 {
"TS2 Pulse Veto", RVTS2P, TS2PVETFRM,
false },
1679 {
"ISIS 50 Hz Veto", RVHZ50, HZ50VETFRM,
false },
1680 {
"MS Mode Veto", RVMSM, MSMVETFRM,
true },
1681 {
"External Veto 0", RVEXT0, EXT0VETFRM,
false },
1682 {
"External Veto 1", RVEXT1, EXT1VETFRM,
false },
1683 {
"External Veto 2", RVEXT2, EXT2VETFRM,
false },
1684 {
"External Veto 3", RVEXT3, EXT3VETFRM,
false },
1685 { NULL, 0, 0,
false }
1689 {
"FIFO Veto", RVFIFO, FIFOVETFRM,
false },
1690 {
"SMP (chopper) Veto", RVSMP, SMPVETFRM,
false },
1691 {
"Internal Veto", RVINT, INTVETFRM,
true },
1692 {
"Fermi Chopper0 Veto", RVFCHOP0, FC0VETFRM,
false },
1696 {
"TS2 Pulse Veto", RVTS2P, TS2PVETFRM,
false },
1697 {
"ISIS 50 Hz Veto", RVHZ50, HZ50VETFRM,
false },
1698 {
"MS Mode Veto", RVMSM, MSMVETFRM,
true },
1699 {
"External Veto 0", RVEXT0, EXT0VETFRM,
false },
1700 {
"External Veto 1", RVEXT1, EXT1VETFRM,
false },
1701 {
"External Veto 2", RVEXT2, EXT2VETFRM,
false },
1702 {
"External Veto 3", RVEXT3, EXT3VETFRM,
false },
1703 { NULL, 0, 0,
false }
int enableEventMode(DAEstatus &status)
int processFermiChopperVeto(int chopper_number, boost::function< int(isisU32_t, DAEstatus &)> func, DAEstatus &status)
int disablePeriodMode(DAEstatus &status)
int setVetoRegisterBits(isisU32_t mask, bool preserve, DAEstatus &status)
uint32_t TransferProps
combination of TransferProp values
int getPeriodGoodFrames(int period, isisU32_t *frames, DAEstatus &status)
LONGLONG diffFileTimes(const FILETIME &start, const FILETIME &finish)
finish - start, returned in 100ns units
int disableSMPVeto(DAEstatus &status)
int endRunAfterSequenceCompletes(DAEstatus &status)
int addVa(int facility, int severity, int errtype, const char *format,...)
int enableISIS50HzVeto(DAEstatus &status)
int enableExternalVeto(int veto_number, DAEstatus &status)
int disableTS2PulseVeto(DAEstatus &status)
int getSMPVetoedFrames(isisU32_t *value, DAEstatus &status)
static const period_modes mode_list[]
int whichVeto(std::ostream &os, DAEstatus &status)
keeps a static variable count of last values, should be safe as only one environment card ...
int clearVetoRegisterBits(isisU32_t mask, DAEstatus &status)
int getRawPPPUpperPeriod(int period, isisU32_t *value, DAEstatus &status)
int resetRunController(DAEstatus &status)
int disableDelayedStart(DAEstatus &status)
int getInternalVetoedFrames(isisU32_t *value, DAEstatus &status)
int disableExternalVeto(int veto_number, DAEstatus &status)
int clearPeriodControlBits(isisU32_t mask, DAEstatus &status)
int readPERLUT(isisU16_t *dwell_flags, isisU16_t *frames, int nperiod, DAEstatus &status)
double frameTimerDrift(DAEstatus &status)
return drift in microseconds, icp - dae
int getRawPPPLowerPeriod(int period, isisU32_t *value, DAEstatus &status)
int getPeriodRawFrames(int period, isisU32_t *frames, DAEstatus &status)
int enableFermiChopperVeto(int chopper_number, int delay, int width, DAEstatus &status)
int add(DAEstatus &dstatus, bool clear)
int getGoodFrames(int period_start, int nperiod, isisU32_t frames[], DAEstatus &status)
int setMuonPulse(int pulse, DAEstatus &status)
int getRawFrames(int period_start, int nperiod, isisU32_t frames[], DAEstatus &status)
int clearPeriodCounters(DAEstatus &status)
int disableMSMode(DAEstatus &status)
int enableMSMode(DAEstatus &status)
bool usingHardwarePeriods(DAEstatus &status)
int lookupFinished(DAEstatus &status)
int getRawPPPLower(isisU32_t *value, DAEstatus &status)
int getPeriodRequestedFrames(int period, isisU32_t *frames, DAEstatus &status)
int getGoodPPPLower(isisU32_t *value, DAEstatus &status)
int disableInternalVeto(DAEstatus &status)
virtual void printStatus(std::ostream &os, DAEstatus &dstatus)
int getRawPPP(isisU64_t *value, DAEstatus &status)
int getExternalVetoedFrames(int veto_number, isisU32_t *value, DAEstatus &status)
float getGoodUAmpHoursPeriod(int period, DAEstatus &status)
int disableFChopperVeto(int chopper_number, DAEstatus &status)
int enableFIFOVeto(DAEstatus &status)
size_t array_length(const T &)
calculate number of elements in a fixed array e.g. int something[10] ot int s[] = { "a"...
int updateOptions(DAEstatus &status)
#define LOGSTR_WARNING(__arg)
void printStatus(std::ostream &os, DAEstatus &status)
FrameSync getFrameSync(DAEstatus &status)
int disableFermiChopperVeto(int chopper_number, DAEstatus &status)
float getRawUAmpHoursPeriod(int period, DAEstatus &status)
static void DAETimeToFILETIME(const DAEEventHeader::DAETime &daetime, FILETIME &filetime)
int getGoodPPPUpperPeriod(int period, isisU32_t *value, DAEstatus &status)
int disableHardwarePeriods(DAEstatus &status)
bool isMultipleSequenceComplete(DAEstatus &status)
int zeroPeriodFrameCounters(DAEstatus &status)
int getMSModeVetoedFrames(isisU32_t *value, DAEstatus &status)
EnvPeriodCard(int position, ISISVME *vme, DAEstatus &status)
int getGoodPPPLowerPeriod(int period, isisU32_t *value, DAEstatus &status)
int setRunControlBits(isisU32_t mask, bool preserve, DAEstatus &status)
int syncFrameTimer(DAEstatus &status)
int enableTS2PulseVeto(DAEstatus &status)
int zeroPeriodProtonCounters(DAEstatus &status)
int setFrameSyncDelay(isisU32_t value, DAEstatus &status)
int disableEventMode(DAEstatus &status)
int resetPeriodCard(DAEstatus &status)
int setMultiplePeriodSequenceMode(int nseq, DAEstatus &status)
int readOUTLUT(isisU32_t *outputs, int nperiod, DAEstatus &status)
#define LOGSTR_INFORMATION(__arg)
int programPERLUT(isisU16_t *dwell_flags, isisU16_t *frames, int nperiod, DAEstatus &status)
bool isRunEndedAndSequenceComplete(DAEstatus &status)
do not check SRAM areas after zeroing - workaround for broken cards
int setNumberOfPeriods(isisU16_t n, DAEstatus &status)
int setPeriodControlBits(isisU32_t mask, bool preserve, DAEstatus &status)
int getCurrentPeriodSequence(DAEstatus &status)
int getFrameSyncDelay(isisU32_t *value, DAEstatus &status)
int lookupAccessOUTLUT(DAEstatus &status)
float getRawUAmpHours(DAEstatus &status)
int enableDelayedStart(DAEstatus &status)
double info(const char *title, std::ostream &os, bool add_nl=true)
static std::string DAETimeAsString(const DAEEventHeader::DAETime &daetime)
return as ISO8601 format string
Poco::SingletonHolder< ICPClock > g_icp_clock
int enableInternalVeto(DAEstatus &status)
int addWarningVa(int facility, const char *format,...)
bool isRunning(DAEstatus &status)
int enableFChopperVeto(int chopper_number, int delay, int width, DAEstatus &status)
int startRun(DAEstatus &status)
static const veto_detail veto_details[]
int enablePeriodMode(bool external_mode, DAEstatus &status)
static void FILETIMEToDAETime(const FILETIME &filetime, DAEEventHeader::DAETime &daetime)
int getCurrentPeriodNumber(DAEstatus &status)
int setPeriodOutputDelay(isisU32_t delay, DAEstatus &status)
int getGoodPPPUpper(isisU32_t *value, DAEstatus &status)
int getGoodPPP(isisU64_t *value, DAEstatus &status)
int getFChopperVetoedFrames(int chopper_number, isisU32_t *value, DAEstatus &status)
int setFrameSync(FrameSync fs, DAEstatus &status)
int stopRun(DAEstatus &status)
int printVetoDetails(std::ostream &os, DAEstatus &status)
int computeTimeOffsetDelay(isisU32_t &delay, DAEstatus &status)
compute the delay in reading or writing a value in DAE time units (20ns)
void setLoggerName(const std::string &logger_name)
int setAndClearPeriodControlBits(isisU32_t mask, bool preserve, DAEstatus &status)
int getISIS50HzVetoedFrames(isisU32_t *value, DAEstatus &status)
float getGoodUAmpHours(DAEstatus &status)
int disableFIFOVeto(DAEstatus &status)
int setSinglePeriodSequenceMode(DAEstatus &status)
int clearRunControlBits(isisU32_t mask, DAEstatus &status)
int disableISIS50HzVeto(DAEstatus &status)
int ClearFramesAndPPP(DAEstatus &status)
int lookupAccessPERLUT(DAEstatus &status)
int addInfo(int facility, const std::string &text)
int getFermiChopperVetoedFrames(int chopper_number, isisU32_t *value, DAEstatus &status)
void abortSequenceCompleteWait(DAEstatus &status)
int clearPPP(DAEstatus &status)
int getNumberOfPeriods(DAEstatus &status)
bool checkOptions(EnvPCOptions opts)
int getFIFOVetoedFrames(isisU32_t *value, DAEstatus &status)
int getRawPPPUpper(isisU32_t *value, DAEstatus &status)
int enableHardwarePeriods(DAEstatus &status)
int addInfoVa(int facility, const char *format,...)
int getTS2PulseVetoedFrames(isisU32_t *value, DAEstatus &status)
int getRequestedFrames(int period_start, int nperiod, isisU32_t frames[], DAEstatus &status)
int zeroPeriodExtraCounters(DAEstatus &status)
int readFrameTimer(FILETIME &ft, DAEstatus &status)
int programOUTLUT(isisU32_t *outputs, int nperiod, DAEstatus &status)
bool isEndRunAfterSequenceCompletesInProgress(DAEstatus &status)
static const veto_detail veto_details[]
virtual int resetCardState(DAEstatus &status)
int enableSMPVeto(DAEstatus &status)
int setAndClearRunControlBits(isisU32_t mask, bool preserve, DAEstatus &status)
bool inDwellPeriod(DAEstatus &status)