Changeset 10679
- Timestamp:
- 05/12/11 19:05:36 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/ftmctrl.cc
r10661 r10679 44 44 bool fIsDynamicOut; 45 45 bool fIsHexOutput; 46 47 // string fDefaultSetup; 46 48 47 49 // --verbose … … 197 199 void HandleReceivedData(const bs::error_code& err, size_t bytes_received, int /*type*/) 198 200 { 199 cout << "Data received " << err << " " << bytes_received << endl;200 201 201 // Do not schedule a new read if the connection failed. 202 202 if (bytes_received==0 || err) … … 315 315 UpdateCounter(); 316 316 317 cout << "TYPE=" << fHeader.fType << endl;318 319 317 switch (fHeader.fType) 320 318 { … … 391 389 fBuffer.resize(sizeof(FTM::Header)/2); 392 390 AsyncRead(ba::buffer(fBuffer)); 391 392 // if (!fDefaultSetup.empty()) 393 // LoadStaticData(fDefaultSetup); 393 394 394 395 // Get a header and configdata! … … 592 593 fIsDynamicOut = b; 593 594 } 594 595 /* 596 void SetDefaultSetup(const string &file) 597 { 598 fDefaultSetup = file; 599 } 600 */ 595 601 bool LoadStaticData(string name) 596 602 { … … 799 805 800 806 fStaticData.fTriggerSequence = 801 ( d[0]<<10) | (d[1]<<5) || d[2];807 (uint16_t(d[0])<<10) | (uint16_t(d[1])<<5) | uint16_t(d[2]); 802 808 803 809 if (oldseq!=fStaticData.fTriggerSequence || oldset!=fStaticData.fGeneralSettings) … … 807 813 } 808 814 809 bool SetTriggerCoincidence(uint16_t n, uint16_t win) 810 { 811 if (n==0 || n>FTM::StaticData::kMaxCoincidence || 812 win>FTM::StaticData::kMaxWindow) 815 bool SetTriggerCoincidence(uint16_t n) 816 { 817 if (n==0 || n>FTM::StaticData::kMaxCoincidence) 813 818 return false; 814 819 815 if (n ==fStaticData.fCoincidencePhysics && 816 win==fStaticData.fWindowPhysics) 820 if (n==fStaticData.fCoincidencePhysics) 817 821 return true; 818 822 819 823 fStaticData.fCoincidencePhysics = n; 820 fStaticData.fWindowPhysics = win;821 824 822 825 CmdSendStatDat(); … … 825 828 } 826 829 827 bool SetCalibCoincidence(uint16_t n, uint16_t win) 828 { 829 if (n==0 || n>FTM::StaticData::kMaxCoincidence || 830 win>FTM::StaticData::kMaxWindow) 830 bool SetTriggerWindow(uint16_t win) 831 { 832 if (win>FTM::StaticData::kMaxWindow) 831 833 return false; 832 834 833 if (n ==fStaticData.fCoincidenceCalib && 834 win==fStaticData.fWindowCalib) 835 if (win==fStaticData.fWindowPhysics) 835 836 return true; 836 837 838 fStaticData.fWindowPhysics = win; 839 840 CmdSendStatDat(); 841 842 return true; 843 } 844 845 bool SetCalibCoincidence(uint16_t n) 846 { 847 if (n==0 || n>FTM::StaticData::kMaxCoincidence) 848 return false; 849 850 if (n==fStaticData.fCoincidenceCalib) 851 return true; 852 837 853 fStaticData.fCoincidenceCalib = n; 838 fStaticData.fWindowCalib = win; 854 855 CmdSendStatDat(); 856 857 return true; 858 } 859 860 bool SetCalibWindow(uint16_t win) 861 { 862 if (win>FTM::StaticData::kMaxWindow) 863 return false; 864 865 if (win==fStaticData.fWindowCalib) 866 return true; 867 868 fStaticData.fWindowCalib = win; 839 869 840 870 CmdSendStatDat(); … … 1236 1266 int SetTriggerCoincidence(const EventImp &evt) 1237 1267 { 1238 if (!CheckEventSize(evt.GetSize(), "SetTriggerCoincidence", 4)) 1239 return T::kSM_FatalError; 1240 1241 const uint16_t *d = reinterpret_cast<const uint16_t*>(evt.GetText());; 1242 1243 if (!fFTM.SetTriggerCoincidence(d[0], d[1])) 1268 if (!CheckEventSize(evt.GetSize(), "SetTriggerCoincidence", 2)) 1269 return T::kSM_FatalError; 1270 1271 if (!fFTM.SetTriggerCoincidence(evt.GetUShort())) 1244 1272 T::Warn("SetTriggerCoincidence - Value out of range."); 1245 1273 … … 1249 1277 int SetCalibCoincidence(const EventImp &evt) 1250 1278 { 1251 if (!CheckEventSize(evt.GetSize(), "SetCalibCoincidence", 4)) 1252 return T::kSM_FatalError; 1253 1254 const uint16_t *d = reinterpret_cast<const uint16_t*>(evt.GetText());; 1255 1256 if (!fFTM.SetCalibCoincidence(d[0], d[1])) 1279 if (!CheckEventSize(evt.GetSize(), "SetCalibCoincidence", 2)) 1280 return T::kSM_FatalError; 1281 1282 if (!fFTM.SetCalibCoincidence(evt.GetUShort())) 1257 1283 T::Warn("SetCalibCoincidence - Value out of range."); 1258 1284 1259 1285 return T::GetCurrentState(); 1260 1286 } 1287 1288 int SetTriggerWindow(const EventImp &evt) 1289 { 1290 if (!CheckEventSize(evt.GetSize(), "SetTriggerWindow", 2)) 1291 return T::kSM_FatalError; 1292 1293 if (!fFTM.SetTriggerWindow(evt.GetUShort())) 1294 T::Warn("SetTriggerWindow - Value out of range."); 1295 1296 return T::GetCurrentState(); 1297 } 1298 1299 int SetCalibWindow(const EventImp &evt) 1300 { 1301 if (!CheckEventSize(evt.GetSize(), "SetCalibWindow", 2)) 1302 return T::kSM_FatalError; 1303 1304 if (!fFTM.SetCalibWindow(evt.GetUShort())) 1305 T::Warn("SetCalibWindow - Value out of range."); 1306 1307 return T::GetCurrentState(); 1308 } 1309 1261 1310 1262 1311 int Enable(const EventImp &evt, FTM::StaticData::GeneralSettings type) … … 1467 1516 "|LPext[int]:number of triggers of the external light pulser"); 1468 1517 1469 AddConfiguration("SET_TRIGGER_COINCIDENCE", "S: 2", kStateIdle)1518 AddConfiguration("SET_TRIGGER_COINCIDENCE", "S:1", kStateIdle) 1470 1519 (boost::bind(&StateMachineFTM::SetTriggerCoincidence, this, _1)) 1471 1520 ("Setup the coincidence condition for physcis triggers" 1472 1521 "|N[int]:Number of requirered coincident triggers from sum-patches (1-40)"); 1473 1522 1474 AddConfiguration("SET_CALIBRATION_COINCIDENCE", "S:2", kStateIdle) 1523 AddConfiguration("SET_TRIGGER_WINDOW", "S:1", kStateIdle) 1524 (boost::bind(&StateMachineFTM::SetTriggerWindow, this, _1)) 1525 (""); 1526 1527 AddConfiguration("SET_CALIBRATION_COINCIDENCE", "S:1", kStateIdle) 1475 1528 (boost::bind(&StateMachineFTM::SetCalibCoincidence, this, _1)) 1476 1529 ("Setup the coincidence condition for artificial (calibration) triggers" 1477 1530 "|N[int]:Number of requirered coincident triggers from sum-patches (1-40)"); 1531 1532 AddConfiguration("SET_CALIBRATION_WINDOW", "S:1", kStateIdle) 1533 (boost::bind(&StateMachineFTM::SetCalibWindow, this, _1)) 1534 (""); 1478 1535 1479 1536 … … 1549 1606 fFTM.SetHexOutput(conf.Get<bool>("hex-out")); 1550 1607 fFTM.SetDynamicOut(conf.Get<bool>("dynamic-out")); 1608 1609 // fFTM.SetDefaultSetup(conf.Get<string>("default-setup")); 1551 1610 1552 1611 return true; … … 1654 1713 po::options_description control("FTM control options"); 1655 1714 control.add_options() 1656 ("addr,a", var<string>("localhost:5000"), "Network address of FTM") 1657 ("quiet,q", po_switch(), "Disable printing contents of all received messages (except dynamic data) in clear text.") 1658 ("hex-out", po_switch(), "Enable printing contents of all printed messages also as hex data.") 1659 ("dynamic-out", po_switch(), "Enable printing received dynamic data.") 1715 ("addr,a", var<string>("localhost:5000"), "Network address of FTM") 1716 ("quiet,q", po_switch(), "Disable printing contents of all received messages (except dynamic data) in clear text.") 1717 ("hex-out", po_switch(), "Enable printing contents of all printed messages also as hex data.") 1718 ("dynamic-out", po_switch(), "Enable printing received dynamic data.") 1719 // ("default-setup", var<string>(), "Binary file with static data loaded whenever a connection to the FTM was established.") 1660 1720 ; 1661 1721
Note:
See TracChangeset
for help on using the changeset viewer.