- Timestamp:
- 11/26/12 12:11:47 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/fadctrl.cc
r14366 r14701 680 680 msg << hex << "Channel " << dat[0] << " or Value " << dat[1] << " out of range."; 681 681 T::Error(msg); 682 return false;682 return T::GetCurrentState(); 683 683 } 684 684 … … 700 700 msg << hex << "Channel " << dat[0] << " or Value " << dat[1] << " out of range."; 701 701 T::Error(msg); 702 return false;702 return T::GetCurrentState(); 703 703 } 704 704 … … 757 757 msg << hex << "Value " << evt.GetUShort() << " out of range, max=" << 0xffff << "(?)"; 758 758 T::Error(msg); 759 return false;759 return T::GetCurrentState(); 760 760 } 761 761 … … 773 773 const uint64_t num = evt.GetUXtra(); 774 774 775 if (num >FAD::kMaxRunNumber)775 if (num<=0 || num>FAD::kMaxRunNumber) 776 776 { 777 777 ostringstream msg; 778 msg << "Run number " << num << " out of range (max=" << FAD::kMaxRunNumber << ")";778 msg << "Run number " << num << " out of range [1;" << FAD::kMaxRunNumber << "]"; 779 779 T::Error(msg); 780 return false; 781 } 782 783 if (num>0 && num<GetRunNumber()) 784 { 785 ostringstream msg; 786 msg << "Given run number (" << num << ") smaller than next run number (" << GetRunNumber() << ") which will be opened by the event builder"; 787 T::Error(msg); 788 return false; 789 } 790 791 IncreaseRunNumber(num); 780 return T::GetCurrentState(); 781 } 782 783 if (!IncreaseRunNumber(num)) 784 return T::GetCurrentState(); 792 785 793 786 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 794 i->second->CmdSetRunNumber( num);787 i->second->CmdSetRunNumber(GetRunNumber()); 795 788 796 789 return T::GetCurrentState(); … … 809 802 msg << hex << "Value " << mem << " out of range."; 810 803 T::Error(msg); 811 return false;804 return T::GetCurrentState(); 812 805 } 813 806 … … 838 831 default: 839 832 T::Error("File format unknonw."); 840 return false;833 return T::GetCurrentState(); 841 834 } 842 835 … … 1064 1057 } 1065 1058 1066 if (fNightAsInt!=Time().NightAsInt()) 1067 { 1068 ostringstream out; 1069 out << "Night changed from " << fNightAsInt << " to " << Time().NightAsInt() << "... determining new run-number."; 1070 T::Info(out); 1071 1072 // FIXME: What about an error state? 1073 fNightAsInt = InitRunNumber(); 1074 if (fNightAsInt<0) 1075 return FAD::State::kConnected; 1076 } 1077 1059 // FIXME: What about an error state? 1078 1060 const uint32_t runno = StartNewRun(evt.Get<int64_t>(), evt.Get<int64_t>(8), *fTargetConfig); 1061 if (runno==0) 1062 return FAD::State::kConnected; 1079 1063 1080 1064 ostringstream str; … … 1333 1317 return T::GetCurrentState(); 1334 1318 } 1319 1320 // ============================================================================ 1321 /* 1322 bool ProcessReconnection(const list<ReconnectionSlot>::iterator &it) 1323 { 1324 auto board = GetSlot(it->slot); 1325 if (board==fBoards.end()) 1326 return false; 1327 1328 ConnectionFAD *fad = board->second; 1329 1330 // ---------------------------------------------- 1331 // Disconnect 1332 // ---------------------------------------------- 1333 if (it->state==0) 1334 { 1335 if (!fad->IsConnected()) 1336 return false; 1337 1338 EnableConnection(fad, false); 1339 ConnectSlot(it->slot, tcp::endpoint()); 1340 1341 it->time = Time(); 1342 it->state = 1; 1343 1344 return true; 1345 } 1346 1347 // ---------------------------------------------- 1348 // Wait for disconnect or timeout 1349 // ---------------------------------------------- 1350 if (it->state==1) 1351 { 1352 if (!fad->IsDisconnected() && it->time+boost::posix_time::seconds(10)>Time()) 1353 return true; 1354 1355 it->time = Time(); 1356 it->state = 2; 1357 1358 return true; 1359 } 1360 1361 // ---------------------------------------------- 1362 // Wait for timeout after disconnect / Re-connect 1363 // ---------------------------------------------- 1364 if (it->state==2) 1365 { 1366 if (it->time+boost::posix_time::seconds(3)>Time()) 1367 return true; 1368 1369 EnableConnection(fad, true); 1370 ConnectSlot(it->slot, fad->GetEndpoint()); 1371 1372 it->time = Time(); 1373 it->state = 3; 1374 1375 return true; 1376 } 1377 1378 // ---------------------------------------------- 1379 // Wait for connect or timeout / Re-start 1380 // ---------------------------------------------- 1381 if (!fad->IsConnected() && it->time+boost::posix_time::seconds(10)>Time()) 1382 return true; 1383 1384 // 'Fix' the information which got lost during re-connection 1385 fad->Cmd(FAD::kCmdBusyOff, false); 1386 fad->Cmd(FAD::kCmdSocket, false); 1387 fad->Cmd(FAD::kCmdTriggerLine, true); 1388 1389 return false; 1390 } 1391 */ 1392 // ============================================================================ 1335 1393 1336 1394 vector<uint8_t> fStatus1; … … 1430 1488 // ===== Return connection status ===== 1431 1489 1490 // Keep the state during reconnection (theoretically, can only be WritingData) 1491 if (fReconnectionList.size()>0) 1492 { 1493 bool isnew = true; 1494 for (auto it=fReconnectionList.begin(); it!=fReconnectionList.end(); it++) 1495 if (it->state>0) 1496 { 1497 isnew = false; 1498 break; 1499 } 1500 1501 if (isnew) 1502 { 1503 for (BoardList::iterator it=fBoards.begin(); it!=fBoards.end(); it++) 1504 it->second->Cmd(FAD::kCmdBusyOn, true); // continously on 1505 } 1506 1507 // Loop over all scheduled re-connections 1508 for (auto it=fReconnectionList.begin(); it!=fReconnectionList.end(); it++) 1509 { 1510 if (ProcessReconnection(it)) 1511 continue; 1512 1513 const lock_guard<mutex> guard(fMutexReconnect); 1514 fReconnectionList.erase(it); 1515 } 1516 1517 if (fReconnectionList.size()==0) 1518 { 1519 for (BoardList::iterator it=fBoards.begin(); it!=fBoards.end(); it++) 1520 it->second->Cmd(FAD::kCmdBusyOff, false); 1521 } 1522 1523 return T::GetCurrentState(); 1524 } 1525 1432 1526 // fadctrl: Always connecting if not disabled 1433 1527 // event builder: … … 1477 1571 // successfully enabled the trigger lines? 1478 1572 } 1573 1574 const lock_guard<mutex> guard(fMutexReconnect); 1575 fReconnectionList.clear(); 1576 1479 1577 return FAD::State::kConfigured; 1480 1578 } … … 1559 1657 "Connection status of FAD boards" 1560 1658 "|status[bitpattern]:lower bits stat1, upper bits stat2, for every board. 40=thread" 1561 "| char[unknown]:to be completed")1659 "|status[bool]:tue or false whether the event builder threads are running") 1562 1660 { 1563 1661 // ba::io_service::work is a kind of keep_alive for the loop. … … 1905 2003 } 1906 2004 1907 int64_t fNightAsInt;1908 1909 2005 int EvalOptions(Configuration &conf) 1910 2006 { … … 1918 2014 SetMaxMemory(conf.Get<unsigned int>("max-mem")); 1919 2015 1920 fNightAsInt = InitRunNumber(conf.Get<string>("destination-folder")); 1921 if (fNightAsInt<0) 2016 if (!InitRunNumber(conf.Get<string>("destination-folder"))) 1922 2017 return 1; 1923 2018
Note:
See TracChangeset
for help on using the changeset viewer.