Changeset 11627
- Timestamp:
- 07/26/11 21:03:07 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/fadctrl.cc
r11609 r11627 373 373 case FAD::kCmdDwrite: fBufEventHeader.Enable(FAD::EventHeader::kDwrite, on); break; 374 374 case FAD::kCmdTriggerLine: fBufEventHeader.Enable(FAD::EventHeader::kTriggerLine, on); break; 375 case FAD::kCmdBusy: fBufEventHeader.Enable(FAD::EventHeader::kBusy, on); break; 375 case FAD::kCmdBusyOn: fBufEventHeader.Enable(FAD::EventHeader::kBusyOn, on); break; 376 case FAD::kCmdBusyOff: fBufEventHeader.Enable(FAD::EventHeader::kBusyOff, on); break; 376 377 case FAD::kCmdContTrigger: fBufEventHeader.Enable(FAD::EventHeader::kContTrigger, on); break; 377 378 case FAD::kCmdSocket: fBufEventHeader.Enable(FAD::EventHeader::kSock17, !on); break; … … 1083 1084 T::Message(str.str()); 1084 1085 1086 const FAD::Configuration &conf = fTargetConfig->second; 1087 1085 1088 for (BoardList::iterator it=fBoards.begin(); it!=fBoards.end(); it++) 1086 1089 { 1087 const FAD::Configuration &conf = fTargetConfig->second;1088 1089 1090 ConnectionFAD &fad = *it->second; 1090 1091 1092 fad.Cmd(FAD::kCmdBusyOn, true); // continously on 1091 1093 fad.Cmd(FAD::kCmdTriggerLine, false); 1092 1094 fad.Cmd(FAD::kCmdContTrigger, false); 1093 1095 fad.Cmd(FAD::kCmdSocket, true); 1094 fad.Cmd(FAD::kCmdBusy , true);1096 fad.Cmd(FAD::kCmdBusyOff, true); // normal when BusyOn==0 1095 1097 1096 1098 fad.Cmd(FAD::kCmdDwrite, conf.fDwrite); 1097 1099 fad.Cmd(FAD::kCmdDrsEnable, conf.fDenable); 1098 fad.Cmd(FAD::kCmdContTrigger, conf.fContinousTrigger); 1099 1100 for (int i=0; i<FAD::kNumDac; i++) 1100 1101 for (int i=1; i<4/*FAD::kNumDac*/; i++) 1101 1102 fad.CmdSetDacValue(i, conf.fDac[i]); 1102 1103 … … 1109 1110 fad.Cmd(FAD::kCmdResetEventCounter); 1110 1111 //fad.Cmd(FAD::kCmdSingleTrigger); 1111 } 1112 1113 return FAD::kConfiguring; 1112 //fad.Cmd(FAD::kCmdTriggerLine, true); 1113 } 1114 1115 // Now the old run is stopped already. So all other servers can start a new run 1116 // (Note that we might need another step which only checks if the continous trigger 1117 // is wwitched off, too) 1118 fDimStartRun.Update(int64_t(runno)); 1119 1120 T::Info(" ==> TODO: Insert/update run configuration in database!"); 1121 1122 fConfigTimer = Time(); 1123 1124 return FAD::kConfiguring1; 1114 1125 } 1115 1126 … … 1412 1423 if (nconnecting1==0 && nconnected1>0 && nconnected2==nconnected1) 1413 1424 { 1414 if (T::GetCurrentState()==FAD::kConfigured && IsRunStarted()) 1415 return FAD::kConnected; 1416 1417 if (nconfigured!=nconnected1) 1418 { 1419 1420 if (T::GetCurrentState()==FAD::kConfiguring || 1421 T::GetCurrentState()==FAD::kConfigured) 1422 // Stay in Configured until at least one new 1423 // event has been received 1424 return T::GetCurrentState(); 1425 1426 return FAD::kConnected; 1427 } 1428 1429 if (T::GetCurrentState()==FAD::kConfiguring) 1430 { 1425 if (T::GetCurrentState()==FAD::kConfiguring1) 1426 { 1427 // We need some delay so that the FAD is not busy anymore 1428 // and really sees the software trigger 1429 // FIXME: Do we need this to be configurable? 1430 if (Time()-fConfigTimer<boost::posix_time::milliseconds(100)) 1431 return FAD::kConfiguring1; 1432 1433 for (BoardList::iterator it=fBoards.begin(); it!=fBoards.end(); it++) 1434 it->second->Cmd(FAD::kCmdSingleTrigger); 1435 1436 return FAD::kConfiguring2; 1437 } 1438 1439 // If all boards are configured and we are configuring 1440 // go on and start the FADs 1441 if (T::GetCurrentState()==FAD::kConfiguring2) 1442 { 1443 // If not all boards have yet received the proper 1444 // configuration 1445 if (nconfigured!=nconnected1) 1446 return FAD::kConfiguring2; 1447 1448 // FIXME: Distinguish between not all boards have received 1449 // the configuration and the configuration is not consistent 1450 1431 1451 for (BoardList::iterator it=fBoards.begin(); it!=fBoards.end(); it++) 1432 1452 { 1433 //const Configuration &conf = fTargetConfig->second;1434 1435 1453 ConnectionFAD &fad = *it->second; 1436 1454 1455 // Make sure that after switching on the trigger line 1456 // there needs to be some waiting before all boards 1457 // can be assumed to be listening 1437 1458 fad.Cmd(FAD::kCmdResetEventCounter); 1438 1459 fad.Cmd(FAD::kCmdSocket, false); 1439 1460 fad.Cmd(FAD::kCmdTriggerLine, true); 1461 if (fTargetConfig->second.fContinousTrigger) 1462 fad.Cmd(FAD::kCmdContTrigger, true); 1463 fad.Cmd(FAD::kCmdBusyOn, false); // continously on 1440 1464 1441 1465 // FIXME: How do we find out when the FADs … … 1443 1467 } 1444 1468 return FAD::kConfigured; 1469 } 1470 1471 if (T::GetCurrentState()==FAD::kConfigured) 1472 { 1473 // Stay in Configured as long as we have a valid 1474 // configuration and the run has not yet been started 1475 // (means the the event builder has received its 1476 // first event) 1477 if (!IsRunStarted() && nconfigured==nconnected1) 1478 return FAD::kConfigured; 1445 1479 } 1446 1480 … … 1483 1517 1484 1518 1519 DimDescribedService fDimStartRun; 1485 1520 DimDescribedService fDimConnection; 1486 1521 … … 1502 1537 T(out, "FAD_CONTROL"), EventBuilderWrapper(*static_cast<MessageImp*>(this)), ba::io_service::work(static_cast<ba::io_service&>(*this)), 1503 1538 fStatus1(40), fStatus2(40), fStatusC(40), fStatusT(false), 1539 fDimStartRun("FAD_CONTROL/START_RUN", "X:1", ""), 1504 1540 fDimConnection("FAD_CONTROL/CONNECTIONS", "C:40;C:1", "") 1505 1541 { … … 1511 1547 // deletion and creation of threads and more. 1512 1548 1549 fDimStartRun.Update(int64_t(-1)); 1550 1513 1551 // State names 1514 1552 T::AddStateName(FAD::kOffline, "Disengaged", … … 1524 1562 "All enabled FAD boards are connected.."); 1525 1563 1526 T::AddStateName(FAD::kConfiguring, "Configuring", 1564 T::AddStateName(FAD::kConfiguring1, "Configuring1", 1565 "."); 1566 1567 T::AddStateName(FAD::kConfiguring2, "Configuring2", 1527 1568 "."); 1528 1569 … … 1544 1585 (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdSrclk)) 1545 1586 ("Set SRCLK"); 1546 T::AddEvent("ENABLE_BUSY", "B:1", FAD::kConnecting, FAD::kConnected) 1547 (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdBusy)) 1548 ("Set BUSY"); 1587 T::AddEvent("ENABLE_BUSY_OFF", "B:1", FAD::kConnecting, FAD::kConnected) 1588 (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdBusyOff)) 1589 ("Set BUSY continously low"); 1590 T::AddEvent("ENABLE_BUSY_ON", "B:1", FAD::kConnecting, FAD::kConnected) 1591 (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdBusyOn)) 1592 ("Set BUSY constantly high (has priority over BUSY_OFF)"); 1549 1593 T::AddEvent("ENABLE_SCLK", "B:1", FAD::kConnecting, FAD::kConnected) 1550 1594 (bind(&StateMachineFAD::CmdEnable, this, placeholders::_1, FAD::kCmdSclk)) … … 1622 1666 (""); 1623 1667 1624 T::AddEvent("RESET_CONFIGURE", FAD::kConfiguring , FAD::kConfigured)1668 T::AddEvent("RESET_CONFIGURE", FAD::kConfiguring1, FAD::kConfiguring2, FAD::kConfigured) 1625 1669 (bind(&StateMachineFAD::ResetConfig, this)) 1626 1670 (""); … … 1789 1833 Configs fConfigs; 1790 1834 Configs::const_iterator fTargetConfig; 1835 1836 Time fConfigTimer; 1791 1837 1792 1838
Note:
See TracChangeset
for help on using the changeset viewer.