6 template <
class EnvPeriodPolicy>
10 std::ostringstream message;
14 message <<
"This Card Supports Fast (Fermi) Chopper Vetos\n";
21 template <
class EnvPeriodPolicy>
24 return setRegisterBits(RCONTROL, mask, preserve, status);
27 template <
class EnvPeriodPolicy>
30 return clearRegisterBits(RCONTROL, mask, status);
33 template <
class EnvPeriodPolicy>
36 return setAndClearRegisterBits(RCONTROL, mask, preserve, status);
39 template <
class EnvPeriodPolicy>
42 resetRunController(status);
43 return setRunControlBits(RCSTART,
true, status);
46 template <
class EnvPeriodPolicy>
49 clearRunControlBits(RCSTART, status);
50 return resetRunController(status);
53 template <
class EnvPeriodPolicy>
59 return setAndClearRegisterBits(RCONTROL, RCFCLEAR | RCPCLEAR,
true, status);
62 template <
class EnvPeriodPolicy>
65 return setAndClearRegisterBits(RCONTROL, RCPCLEAR,
true, status);
68 template <
class EnvPeriodPolicy>
71 int stat = clearRunControlBits(RCFSSEL, status);
79 return setRunControlBits(RCFSTOF,
true, status);
83 return setRunControlBits(RCFSTOF1P,
true, status);
87 return setRunControlBits(RCFSSMP,
true, status);
97 template <
class EnvPeriodPolicy>
101 readRegister(RCONTROL, &value, status);
112 template <
class EnvPeriodPolicy>
117 os <<
"This is an ENVIRONMENT card" << std::endl;
118 readRegister(RCONTROL, &value, status);
119 os <<
"RC register value = " << std::hex <<
"0x" << value << std::dec << std::endl;
120 os <<
"Status: " << (value & RCSTART ?
"Running" :
"Stopped") << std::endl;
121 os <<
"Frame Sync: " << ( value & RCFSSEL ?
"External" :
"Internal" ) << std::endl;
122 os <<
"Delayed start: " << (value & RCPERSZEQZERO ?
"disabled" :
"enabled") << std::endl;
123 getFrameSyncDelay(&value1, status);
124 os <<
"Frame sync delay: " << value1 <<
"\n";
125 readRegister(RVETO, &veto_reg, status);
126 printVetoDetails(os, status);
127 getGoodFrames(&value1, status);
128 getRawFrames(&value, status);
129 os <<
"GOOD/RAW frames: " << value1 <<
"/" << value <<
"\n";
130 os <<
"GOOD/RAW uamph: " << getGoodUAmpHours(status) <<
"/" << getRawUAmpHours(status) <<
"\n";
131 os <<
"Period Type: " << (usingHardwarePeriods(status) ?
"Hardware" :
"Software") << std::endl;
147 template <
class EnvPeriodPolicy>
150 return readRegister(FCOUNTR, value, status);
165 template <
class EnvPeriodPolicy>
168 return readRegister(FCOUNTG, value, status);
171 template <
class EnvPeriodPolicy>
174 return readRegister(PCOUNTR0, value, status);
177 template <
class EnvPeriodPolicy>
181 readRegister(PCOUNTR1, &value1, status);
182 *value = value1 & 0xffff;
186 template <
class EnvPeriodPolicy>
190 readRegister(PCOUNTR0, &value0, status);
191 readRegister(PCOUNTR1, &value1, status);
197 template <
class EnvPeriodPolicy>
200 return readRegister(PCOUNTG0, value, status);
203 template <
class EnvPeriodPolicy>
207 readRegister(PCOUNTG1, &value1, status);
208 *value = value1 & 0xffff;
212 template <
class EnvPeriodPolicy>
216 readRegister(PCOUNTG0, &value0, status);
217 readRegister(PCOUNTG1, &value1, status);
222 template <
class EnvPeriodPolicy>
225 return setAndClearRunControlBits(RCRESET,
true, status);
228 template <
class EnvPeriodPolicy>
231 return setVetoRegisterBits(RVSMP,
true, status);
234 template <
class EnvPeriodPolicy>
240 return setVetoRegisterBits(RVEXT0,
true, status);
243 return setVetoRegisterBits(RVEXT1,
true, status);
246 return setVetoRegisterBits(RVEXT2,
true, status);
249 return setVetoRegisterBits(RVEXT3,
true, status);
258 template <
class EnvPeriodPolicy>
261 return setVetoRegisterBits(RVINT,
true, status);
264 template <
class EnvPeriodPolicy>
267 return setVetoRegisterBits(RVFIFO,
true, status);
270 template <
class EnvPeriodPolicy>
273 return setVetoRegisterBits(RVTS2P,
true, status);
276 template <
class EnvPeriodPolicy>
279 return setVetoRegisterBits(RVHZ50,
true, status);
282 template <
class EnvPeriodPolicy>
285 return clearVetoRegisterBits(RVSMP, status);
288 template <
class EnvPeriodPolicy>
294 return clearVetoRegisterBits(RVEXT0, status);
297 return clearVetoRegisterBits(RVEXT1, status);
300 return clearVetoRegisterBits(RVEXT2, status);
303 return clearVetoRegisterBits(RVEXT3, status);
312 template <
class EnvPeriodPolicy>
315 return clearVetoRegisterBits(RVINT, status);
318 template <
class EnvPeriodPolicy>
321 return clearVetoRegisterBits(RVFIFO, status);
324 template <
class EnvPeriodPolicy>
327 return clearVetoRegisterBits(RVTS2P, status);
330 template <
class EnvPeriodPolicy>
333 return clearVetoRegisterBits(RVHZ50, status);
336 template <
class EnvPeriodPolicy>
339 return readRegister(SMPVETFRM, value, status);
342 template <
class EnvPeriodPolicy>
349 return readRegister(EXT0VETFRM, value, status);
352 return readRegister(EXT1VETFRM, value, status);
355 return readRegister(EXT2VETFRM, value, status);
358 return readRegister(EXT3VETFRM, value, status);
367 template <
class EnvPeriodPolicy>
370 return readRegister(FIFOVETFRM, value, status);
373 template <
class EnvPeriodPolicy>
376 return readRegister(TS2PVETFRM, value, status);
379 template <
class EnvPeriodPolicy>
382 return readRegister(HZ50VETFRM, value, status);
385 template <
class EnvPeriodPolicy>
389 writeRegister(SMPVETFRM, value, status);
393 template <
class EnvPeriodPolicy>
397 writeRegister(EXT0VETFRM, value, status);
401 template <
class EnvPeriodPolicy>
405 writeRegister(FIFOVETFRM, value, status);
409 template <
class EnvPeriodPolicy>
416 if ((value >> 19) != 0)
420 clearRunControlBits(RCFSENABLEOUT, status);
421 setAndClearRunControlBits(RCDELFSFIFORS,
true, status);
422 writeRegister(FSDELAY, value, status);
423 setRunControlBits(RCFSENABLEOUT,
true, status);
427 template <
class EnvPeriodPolicy>
430 return readRegister(FSDELAY, value, status);
433 template <
class EnvPeriodPolicy>
436 return clearRunControlBits(RCPERSZEQZERO, status);
439 template <
class EnvPeriodPolicy>
442 return setRunControlBits(RCPERSZEQZERO,
true, status);
445 template <
class EnvPeriodPolicy>
449 readRegister(RCONTROL, &value, status);
450 if (value & RCPERSZEQZERO)
467 #define PPP_TO_UAMPH 1.738E-6
469 template <
class EnvPeriodPolicy>
474 getGoodPPPLower(&low, status);
475 getGoodPPPUpper(&upper, status);
476 good_uamps =
static_cast<float>(((65536.0 * 65536.0 * upper) + low) *
PPP_TO_UAMPH);
480 template <
class EnvPeriodPolicy>
485 getRawPPPLower(&low, status);
486 getRawPPPUpper(&upper, status);
487 raw_uamps =
static_cast<float>(((65536.0 * 65536.0 * upper) + low) *
PPP_TO_UAMPH);
492 template <
class EnvPeriodPolicy>
495 static const isisU32_t delay_mapping[] = { FC0WINDLY, FC1WINDLY, FC2WINDLY, FC3WINDLY };
496 static const isisU32_t window_mapping[] = { FC0WINWTH, FC1WINWTH, FC2WINWTH, FC3WINWTH };
497 static const isisU32_t veto_mapping[] = { RVFCHOP0, RVFCHOP1, RVFCHOP2, RVFCHOP3 };
501 writeRegister(delay_mapping[chopper_number], delay, status);
502 writeRegister(window_mapping[chopper_number], width, status);
503 status.
addInfoVa(
FAC_DAE,
"Fermi chopper %d delay,width (us) = %f,%f\n", chopper_number, delay / 50.0, width / 50.0);
504 return setVetoRegisterBits(veto_mapping[chopper_number],
true, status);
513 template <
class EnvPeriodPolicy>
516 static const isisU32_t veto_mapping[] = { RVFCHOP0, RVFCHOP1, RVFCHOP2, RVFCHOP3 };
519 return clearVetoRegisterBits(veto_mapping[chopper_number], status);
527 template <
class EnvPeriodPolicy>
531 static const isisU32_t mapping[] = { FC0VETFRM, FC1VETFRM, FC2VETFRM, FC3VETFRM };
534 readRegister(mapping[chopper_number], value, status);
539 template <
class EnvPeriodPolicy>
542 return setRegisterBits(RVETO, mask, preserve, status);
545 template <
class EnvPeriodPolicy>
548 return clearRegisterBits(RVETO, mask, status);
551 template <
class EnvPeriodPolicy>
556 readRegister(RVETO, &veto_reg, status);
557 for(i=0; veto_details[i].name != NULL; i++)
559 if (!veto_details[i].pc_only)
561 readRegister(veto_details[i].counter_addr, &frames, status);
562 os << veto_details[i].name <<
" is " << ((veto_reg & veto_details[i].mask) != 0 ?
"ENABLED (vetoed " :
"DISABLED (counted ") << frames <<
") frames\n";
568 template <
class EnvPeriodPolicy>
572 isisU32_t veto_reg = 0, rf1 = 0, rf2 = 0;
576 for(nveto = 0; veto_details[nveto].name != NULL; ++nveto)
580 readRegister(RVETO, &veto_reg, status);
581 getRawFrames(&rf1, status);
582 for(i=0; i < nveto; i++)
584 if (!veto_details[i].pc_only)
587 readRegister(veto_details[i].counter_addr, &(vframes1[i]), status);
590 Sleep(poll_time * 1000);
591 for(i=0; i < nveto; i++)
593 if (!veto_details[i].pc_only)
596 readRegister(veto_details[i].counter_addr, &(vframes2[i]), status);
599 getRawFrames(&rf2, status);
601 for(i=0; i < nveto; i++)
603 if ( ((veto_reg & veto_details[i].mask) != 0) && !veto_details[i].pc_only )
605 os << veto_details[i].name <<
" vetoed ";
608 os << (int)(100.0 * (vframes2[i] - vframes1[i]) / rfdiff);
614 os <<
"% (last " << poll_time <<
" seconds), ";
617 os << (int)(100.0 * vframes2[i] / rf2);
623 os <<
"% (since run start)\n";
631 template <
class EnvPeriodPolicy>
int ClearFramesAndPPP(DAEstatus &status)
int getISIS50HzVetoedFrames(isisU32_t *value, DAEstatus &status)
int clearSMPVetoedFrames(DAEstatus &status)
float getGoodUAmpHours(DAEstatus &status)
int clearPPP(DAEstatus &status)
int addVa(int facility, int severity, int errtype, const char *format,...)
int getFIFOVetoedFrames(isisU32_t *value, DAEstatus &status)
float getRawUAmpHours(DAEstatus &status)
int clearRunControlBits(isisU32_t mask, DAEstatus &status)
int disableISIS50HzVeto(DAEstatus &status)
int enableInternalVeto(DAEstatus &status)
int getTS2PulseVetoedFrames(isisU32_t *value, DAEstatus &status)
EnvironmentCard(int position, ISISVME *vme, DAEstatus &status)
bool isRunning(DAEstatus &status)
int getGoodFrames(isisU32_t *value, DAEstatus &status)
int disableSMPVeto(DAEstatus &status)
int setRunControlBits(isisU32_t mask, bool preserve, DAEstatus &status)
int enableFIFOVeto(DAEstatus &status)
int setAndClearRunControlBits(isisU32_t mask, bool preserve, DAEstatus &status)
int add(DAEstatus &dstatus, bool clear)
bool usingHardwarePeriods(DAEstatus &status)
int getGoodPPP(isisU64_t *value, DAEstatus &status)
int getFChopperVetoedFrames(int chopper_number, isisU32_t *value, DAEstatus &status)
int getRawFrames(isisU32_t *value, DAEstatus &status)
virtual void printStatus(std::ostream &os, DAEstatus &dstatus)
int disableTS2PulseVeto(DAEstatus &status)
int clearExternalVetoedFrames(DAEstatus &status)
int getRawPPPUpper(isisU32_t *value, DAEstatus &status)
int disableExternalVeto(int veto_number, DAEstatus &status)
int disableFIFOVeto(DAEstatus &status)
int whichVeto(std::ostream &os, DAEstatus &status)
int startRun(DAEstatus &status)
#define LOGSTR_INFORMATION(__arg)
int readRegister(unsigned long address, isisU32_t *value, DAEstatus &status, bool little_endian=false, bool retry=true)
int clearVetoRegisterBits(isisU32_t mask, DAEstatus &status)
virtual int resetCardState(DAEstatus &status)
void printStatus(std::ostream &os, DAEstatus &status)
int setVetoRegisterBits(isisU32_t mask, bool preserve, DAEstatus &status)
int enableSMPVeto(DAEstatus &status)
int printVetoDetails(std::ostream &os, DAEstatus &status)
int addWarningVa(int facility, const char *format,...)
int disableFChopperVeto(int chopper_number, DAEstatus &status)
int getSMPVetoedFrames(isisU32_t *value, DAEstatus &status)
int getGoodPPPUpper(isisU32_t *value, DAEstatus &status)
int setFrameSync(FrameSync fs, DAEstatus &status)
int disableInternalVeto(DAEstatus &status)
int getGoodPPPLower(isisU32_t *value, DAEstatus &status)
int enableISIS50HzVeto(DAEstatus &status)
int clearFIFOVetoedFrames(DAEstatus &status)
int resetRunController(DAEstatus &status)
int getExternalVetoedFrames(int veto_number, isisU32_t *value, DAEstatus &status)
int getRawPPPLower(isisU32_t *value, DAEstatus &status)
int getFrameSyncDelay(isisU32_t *value, DAEstatus &status)
void setLoggerName(const std::string &logger_name)
int enableFChopperVeto(int chopper_number, int delay, int width, DAEstatus &status)
int enableExternalVeto(int veto_number, DAEstatus &status)
int disableHardwarePeriods(DAEstatus &status)
int addInfo(int facility, const std::string &text)
int setFrameSyncDelay(isisU32_t value, DAEstatus &status)
int enableTS2PulseVeto(DAEstatus &status)
int stopRun(DAEstatus &status)
int addInfoVa(int facility, const char *format,...)
int enableHardwarePeriods(DAEstatus &status)
int getRawPPP(isisU64_t *value, DAEstatus &status)