8 std::string
const& WIBAddressTable,
9 std::string
const& FEMBAddressTable,
11 :
WIBBase(address, WIBAddressTable, FEMBAddressTable)
33 Write(
"POWER.ENABLE.MASTER_BIAS", 1);
54 Write(
"POWER.ENABLE.MASTER_BIAS", 1);
64 BUException::WIB_FEATURE_NOT_SUPPORTED e;
65 e.Append(
"Automatic DAQLink configuration not supported with this firmware.\n");
70 std::string base(
"DAQ_LINK_");
72 base.append(
".CONTROL.");
73 printf(
"%s\n", base.c_str());
76 uint32_t enable_mask = 0;
81 Write(base +
"ENABLE_CDA_STREAM", enable_mask);
83 Write(base +
"ENABLE", 0x1);
92 BUException::WIB_FEATURE_NOT_SUPPORTED e;
93 e.Append(
"Automatic DAQLink configuration not supported with this firmware.\n");
98 std::string base(
"DAQ_LINK_");
100 base.append(
".CONTROL.");
110 Write(base +
"ENABLE_CDA_STREAM", stream);
111 Write(base +
"ENABLE", enable);
147 Write(
"SYSTEM.RESET", 0xFF);
149 Write(
"POWER.ENABLE.MASTER_BIAS", 0x1);
160 Write(
"SYSTEM.RESET.UDP_RESET", 1);
161 }
catch (BUException::BAD_REPLY& e) {
168 Write(
"SYSTEM.RESET.UDP_RESET", 1);
169 }
catch (BUException::BAD_REPLY& e) {
181 Write(
"DAQ.SI5342.RESET", 1);
183 Write(
"DAQ.SI5342.RESET", 0);
185 printf(
"Configuring SI5342 for FELIX\n");
193 Write(
"SYSTEM.RESET.EB_PLL_RESET", 1);
197 Write(
"SYSTEM.RESET.DAQ_PATH_RESET", 1);
202 Write(
"DTS.CMD_COUNT_RESET", 0xFFFFFFFF);
203 Write(
"DTS.CMD_COUNT_RESET", 0);
206 Write(
"DTS.CONVERT_CONTROL.HALT", 1);
207 Write(
"DTS.CONVERT_CONTROL.ENABLE", 0);
210 Write(
"POWER.ENABLE.MASTER_BIAS", 1);
217 BUException::WIB_DAQMODE_UNKNOWN e;
220 if (localClock > 1) {
221 BUException::WIB_BAD_ARGS e;
222 e.Append(
"localClock > 1; must be 0 (for DTS) or 1 (for local clock)\n");
225 if (PDTSsource > 1) {
226 BUException::WIB_BAD_ARGS e;
227 e.Append(
"PDTSsource > 1; must be 0 (for backplane) or 1 (for front panel)\n");
230 if (16 <= PDTS_TGRP) {
231 BUException::WIB_BAD_ARGS e;
232 e.Append(
"PDTS TGRP > 15; must be 0 to 15\n");
237 uint32_t slow_control_dnd =
Read(
"SYSTEM.SLOW_CONTROL_DND");
240 Write(
"SYSTEM.SLOW_CONTROL_DND", 1);
243 for (
size_t iFEMB = 1; iFEMB <= 4; iFEMB++) {
248 Write(
"DTS.CONVERT_CONTROL.HALT", 1);
249 Write(
"DTS.CONVERT_CONTROL.ENABLE", 0);
250 Write(
"DTS.CONVERT_CONTROL.START_SYNC", 0);
253 if (localClock > 0) {
254 printf(
"Configuring local clock\n");
260 Write(
"DTS.CONVERT_CONTROL.EN_FAKE", 1);
261 Write(
"DTS.CONVERT_CONTROL.LOCAL_TIMESTAMP", 1);
262 Write(
"FEMB_CNC.CNC_CLOCK_SELECT", 1);
267 printf(
"Configuring DTS\n");
268 Write(
"DTS.PDTS_TGRP", PDTS_TGRP);
269 printf(
"Using timing group 0x%X\n", PDTS_TGRP);
272 Write(
"FEMB_CNC.CNC_CLOCK_SELECT", 1);
275 Write(
"DTS.PDTS_ENABLE", 1);
280 Write(
"FEMB1.DAQ.ENABLE", 0);
281 Write(
"FEMB2.DAQ.ENABLE", 0);
282 Write(
"FEMB3.DAQ.ENABLE", 0);
283 Write(
"FEMB4.DAQ.ENABLE", 0);
285 Write(
"SYSTEM.SLOW_CONTROL_DND", slow_control_dnd);
292 BUException::WIB_DAQMODE_UNKNOWN e;
295 if (localClock > 1) {
296 BUException::WIB_BAD_ARGS e;
297 e.Append(
"localClock > 1; must be 0 (for DTS) or 1 (for local clock)\n");
300 if (PDTSsource > 1) {
301 BUException::WIB_BAD_ARGS e;
302 e.Append(
"PDTSsource > 1; must be 0 (for backplane) or 1 (for front panel)\n");
305 if (16 <= PDTS_TGRP) {
306 BUException::WIB_BAD_ARGS e;
307 e.Append(
"PDTS TGRP > 15; must be 0 to 15\n");
311 bool reset_check =
false;
313 if (localClock > 0) {
314 printf(
"Checking if locked on local clock\n");
315 reset_check = ((
Read(
"DTS.CONVERT_CONTROL.EN_FAKE") != 1) || (
Read(
"DTS.CCONVERT_CONTROL.LOCAL_TIMESTAMP") != 1) ||
316 (
Read(
"FEMB_CNC.CNC_CLOCK_SELECT") != 1)
318 || (
Read(
"DTS.SI5344.INPUT_SELECT") != 1) || (
Read(
"DTS.SI5344.ENABLE") != 1));
320 printf(
"Already in a good state\n");
322 printf(
"Need to reset for local clocking\n");
325 printf(
"Checking if locked on PDTS\n");
326 reset_check = ((
Read(
"DTS.PDTS_TGRP") != PDTS_TGRP) || (
Read(
"FEMB_CNC.CNC_CLOCK_SELECT") != 1) ||
327 (
Read(
"DTS.PDTS_ENABLE") != 1) || (
Read(
"DTS.CDS.LOL") != 0) || (
Read(
"DTS.CDS.LOS") != 0) ||
332 printf(
"Already in a good state\n");
334 printf(
"Need to reset for PDTS\n");
341 if ((
Read(
"DAQ.SI5342.ENABLE") == 0) || (
Read(
"DAQ.SI5342.INPUT_SELECT") != 1) || (
Read(
"DAQ.SI5342.LOL") == 1) ||
342 (
Read(
"DAQ.SI5342.LOS_XAXB") == 1) || (
Read(
"DAQ.SI5342.LOS_2") == 1)) {
343 printf(
"Need to reset for SI5342\n");
346 printf(
"SI5342 in good state\n");
352 uint32_t slow_control_dnd =
Read(
"SYSTEM.SLOW_CONTROL_DND");
355 Write(
"SYSTEM.SLOW_CONTROL_DND", 1);
357 for (
size_t iFEMB = 1; iFEMB <= 4; iFEMB++) {
362 Write(
"DTS.CONVERT_CONTROL.HALT", 1);
363 Write(
"DTS.CONVERT_CONTROL.ENABLE", 0);
364 Write(
"DTS.CONVERT_CONTROL.START_SYNC", 0);
367 if (localClock > 0) {
368 printf(
"Configuring local clock\n");
374 Write(
"DTS.CONVERT_CONTROL.EN_FAKE", 1);
375 Write(
"DTS.CONVERT_CONTROL.LOCAL_TIMESTAMP", 1);
376 Write(
"FEMB_CNC.CNC_CLOCK_SELECT", 1);
381 printf(
"Configuring DTS\n");
382 Write(
"DTS.PDTS_TGRP", PDTS_TGRP);
383 printf(
"Using timing group 0x%X\n", PDTS_TGRP);
386 Write(
"FEMB_CNC.CNC_CLOCK_SELECT", 1);
389 Write(
"DTS.PDTS_ENABLE", 1);
393 Write(
"SYSTEM.SLOW_CONTROL_DND", slow_control_dnd);
396 std::cout <<
"Resetting DAQ Links" << std::endl;
401 for (
size_t iLink = 1; iLink <= nLinks; ++iLink) {
402 std::cout << iLink << std::endl;
406 Write(
"FEMB1.DAQ.ENABLE", 0);
407 Write(
"FEMB2.DAQ.ENABLE", 0);
408 Write(
"FEMB3.DAQ.ENABLE", 0);
409 Write(
"FEMB4.DAQ.ENABLE", 0);
416 BUException::WIB_DAQMODE_UNKNOWN e;
423 uint32_t slow_control_dnd =
Read(
"SYSTEM.SLOW_CONTROL_DND");
424 Write(
"SYSTEM.SLOW_CONTROL_DND", 1);
427 Write(
"FEMB_CNC.FEMB_STOP", 1);
429 Write(
"SYSTEM.RESET.DAQ_PATH_RESET", 1);
446 Write(
"FEMB1.DAQ.ENABLE", 0xF);
447 Write(
"FEMB2.DAQ.ENABLE", 0xF);
448 Write(
"FEMB3.DAQ.ENABLE", 0xF);
449 Write(
"FEMB4.DAQ.ENABLE", 0xF);
452 Write(
"FEMB_CNC.ENABLE_DTS_CMDS", 1);
458 Write(
"SYSTEM.SLOW_CONTROL_DND", slow_control_dnd);
464 std::string reg =
"POWER.ENABLE.FEMB";
509 Write(
"FEMB_CNC.CNC_CLOCK_SELECT", 1);
510 Write(
"FEMB_CNC.CNC_COMMAND_SELECT", 1);
516 Write(
"FEMB_CNC.CNC_CLOCK_SELECT", 0);
517 Write(
"FEMB_CNC.CNC_COMMAND_SELECT", 0);
524 BUException::WIB_INDEX_OUT_OF_RANGE e;
525 e.Append(
"DAQ Link\n");
552 BUException::WIB_INDEX_OUT_OF_RANGE e;
553 e.Append(
"DAQ Link\n");
565 if (!((iFEMB > 0) && (iFEMB <=
FEMBCount))) {
566 BUException::WIB_INDEX_OUT_OF_RANGE e;
594 BUException::WIB_INDEX_OUT_OF_RANGE e;
608 BUException::WIB_INDEX_OUT_OF_RANGE e;
609 e.Append(
"FEMB Stream");
619 BUException::WIB_INDEX_OUT_OF_RANGE e;
620 e.Append(
"FEMB CDA");
641 BUException::WIB_INDEX_OUT_OF_RANGE e;
642 e.Append(
"FEMB CDA\n");
655 printf(
"FEMB index out of range < 1\n");
666 std::string address(
"FEMB");
668 address.append(
".DAQ.FAKE_CD.FAKE_SOURCE");
669 Write(address, real);
WIBBase(std::string const &address, std::string const &WIBAddressTable, std::string const &FEMBAddressTable)
void WriteWithRetry(uint16_t address, uint32_t value)
uint32_t ReadWithRetry(uint16_t address)
uint32_t Read(uint16_t address)
void Write(uint16_t address, uint32_t value)
bool CheckFEMBStreamInRange(uint8_t iStream)
bool ContinueOnFEMBRegReadError
void ResetWIB(bool reset_udp=false)
void EnableDAQLink(uint8_t iDAQLink)
void LoadConfigDTS_SI5344(std::string const &fileName)
void CheckedResetWIBAndCfgDTS(uint8_t localClock, uint8_t PDTS_TGRP, uint8_t PDTSsource=0, uint32_t PDTSAlignment_timeout=0)
bool ContinueOnFEMBSyncError
char GetFEMBCDChar(uint8_t iCD)
void InitializeDTS(uint8_t PDTSsource=0, uint8_t clockSource=0, uint32_t PDTSAlignment_timeout=0)
bool ContinueOnFEMBSPIError
void ResetWIBAndCfgDTS(uint8_t localClock, uint8_t PDTS_TGRP, uint8_t PDTSsource=0, uint32_t PDTSAlignment_timeout=0)
char GetDAQLinkChar(uint8_t iDAQLink)
void EnableDAQLink_Lite(uint8_t iDAQLink, uint8_t enable)
void SelectSI5344(uint64_t input, bool enable)
void SelectSI5342(uint64_t input, bool enable)
void FEMBPower(uint8_t iFEMB, bool turnOn)
void SourceFEMB(uint64_t iDAQLink, uint64_t real)
bool ContinueIfListOfFEMBClockPhasesDontSync
bool CheckFEMBCDInRange(uint8_t iCD)
bool CheckDAQLinkInRange(uint8_t iDAQLink)
void LoadConfigDAQ_SI5342(std::string const &fileName)
char GetFEMBChar(uint8_t iFEMB)
void StartStreamToDAQ(bool l1=true, bool l2=true, bool l3=false, bool l4=false)
bool CheckFEMBInRange(uint8_t iFEMB)