Changeset 10623
- Timestamp:
- 05/08/11 16:49:34 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/ftmctrl.cc
r10613 r10623 157 157 Out() << "D=" << fCounter[kDynamicData] << " "; 158 158 Out() << "F=" << fCounter[kFtuList] << " "; 159 Out() << "E=" << fCounter[kError ] << " ";159 Out() << "E=" << fCounter[kErrorList] << " "; 160 160 Out() << "R=" << fCounter[kRegister] << endl; 161 } 162 163 void CheckConsistency() 164 { 165 if (fStaticData.IsEnabled(StaticData::kPedestal) != (fStaticData.GetSequencePed() >0) || 166 fStaticData.IsEnabled(StaticData::kLPint) != (fStaticData.GetSequenceLPint()>0) || 167 fStaticData.IsEnabled(StaticData::kLPext) != (fStaticData.GetSequenceLPext()>0)) 168 { 169 Warn("GeneralSettings not consistent with trigger sequence."); 170 } 171 172 const uint16_t ref = fStaticData[0].fPrescaling; 173 for (int i=1; i<40; i++) 174 { 175 if (fStaticData[i].fPrescaling != ref) 176 { 177 Warn("Prescaling not consistent for all boards."); 178 break; 179 } 180 } 181 161 182 } 162 183 … … 292 313 293 314 case kStaticData: 294 cout << fBuffer.size() << " " << sizeof(fStaticData) << endl;295 315 fStaticData = fBuffer; 316 317 if (fCounter[kStaticData]==1) 318 CheckConsistency(); 319 296 320 UpdateStaticData(); 297 321 break; … … 306 330 { 307 331 Out() << endl << kBold << "Register received: " << endl; 308 Out() << "Value: " << ntohs(fBuffer[0]) << endl; 332 Out() << "Addr: " << ntohs(fBuffer[0]) << endl; 333 Out() << "Value: " << ntohs(fBuffer[1]) << endl; 309 334 } 310 335 break; … … 477 502 // Request the changed configuration to ensure the 478 503 // change is distributed in the network 479 CmdReqStatDat();504 //CmdReqStatDat(); 480 505 } 481 506 … … 735 760 } 736 761 762 void Enable(FTM::StaticData::GeneralSettings type, bool enable) 763 { 764 fStaticData.Enable(type, enable); 765 } 766 767 bool SetTriggerSeq(const uint8_t d[3]) 768 { 769 const uint16_t oldset = fStaticData.fGeneralSettings; 770 const uint16_t oldseq = fStaticData.fTriggerSequence; 771 772 fStaticData.Enable(StaticData::kPedestal, d[0]>0); 773 fStaticData.Enable(StaticData::kLPext, d[1]>0); 774 fStaticData.Enable(StaticData::kLPint, d[2]>0); 775 776 if (d[0]>StaticData::kMaxSequence || 777 d[1]>StaticData::kMaxSequence || 778 d[2]>StaticData::kMaxSequence) 779 return false; 780 781 fStaticData.fTriggerSequence = 782 (d[0]<<10) | (d[1]<<5) || d[2]; 783 784 if (oldseq!=fStaticData.fTriggerSequence || oldset!=fStaticData.fGeneralSettings) 785 CmdSendStatDat(); 786 787 return true; 788 } 789 790 bool SetTriggerCoincidence(uint16_t n, uint16_t win) 791 { 792 if (n==0 || n>StaticData::kMaxCoincidence || win>StaticData::kMaxWindow) 793 return false; 794 795 if (n ==fStaticData.fCoincidencePhysics && 796 win==fStaticData.fWindowPhysics) 797 return true; 798 799 fStaticData.fCoincidencePhysics = n; 800 fStaticData.fWindowPhysics = win; 801 802 CmdSendStatDat(); 803 804 return true; 805 } 806 807 bool SetCalibCoincidence(uint16_t n, uint16_t win) 808 { 809 if (n==0 || n>StaticData::kMaxCoincidence || win>StaticData::kMaxWindow) 810 return false; 811 812 if (n ==fStaticData.fCoincidenceCalib && 813 win==fStaticData.fWindowCalib) 814 return true; 815 816 fStaticData.fCoincidenceCalib = n; 817 fStaticData.fWindowCalib = win; 818 819 CmdSendStatDat(); 820 821 return true; 822 } 823 737 824 int GetState() const { return IsConnected() ? fState : (int)FTM::kDisconnected; } 738 825 }; … … 822 909 fCounter[kDynamicData], 823 910 fCounter[kFtuList], 824 fCounter[kError ],911 fCounter[kErrorList], 825 912 fCounter[kRegister], 826 913 }; … … 835 922 fDimTriggerCounter("FTM_CONTROL/TRIGGER_COUNTER", "X:1;L:1", NULL, 0, ""), 836 923 fDimError ("FTM_CONTROL/ERROR", "X:1;S:1;S:28", NULL, 0, ""), 837 fDimFtuList ("FTM_CONTROL/FTU_LIST", "X:1;X:1;S:1;C:4;X:40;C:40;C:40", NULL, 0, ""),924 fDimFtuList ("FTM_CONTROL/FTU_LIST", "X:1;X:1;S:1;C:4;X:40;C:40;C:40", NULL, 0, ""), 838 925 fDimStaticData ("FTM_CONTROL/STATIC_DATA", "X:1;S:1;S:1;X:1;S:1;S:3;S:1;S:1;S:1;S:1;S:1;S:1;I:1;S:8;S:80;S:160;S:40;S:40", NULL, 0, ""), 839 926 fDimDynamicData ("FTM_CONTROL/DYNAMIC_DATA", "X:1;X:1;F:4;I:160;I:40;S:40;S:40", NULL, 0, ""), … … 1102 1189 } 1103 1190 1191 int SetTriggerSeq(const EventImp &evt) 1192 { 1193 if (!CheckEventSize(evt.GetSize(), "SetTriggerSeq", 3)) 1194 return T::kSM_FatalError; 1195 1196 const uint8_t *data = reinterpret_cast<const uint8_t*>(evt.GetData()); 1197 1198 if (!fFTM.SetTriggerSeq(data)) 1199 T::Warn("SetTriggerSeq - Value out of range."); 1200 1201 return T::GetCurrentState(); 1202 } 1203 1104 1204 int SetDeadTime(const EventImp &evt) 1105 1205 { … … 1109 1209 if (!fFTM.SetDeadTime(evt.GetInt())) 1110 1210 T::Warn("SetDeadTime - Value out of range."); 1211 1212 return T::GetCurrentState(); 1213 } 1214 1215 int SetTriggerCoincidence(const EventImp &evt) 1216 { 1217 if (!CheckEventSize(evt.GetSize(), "SetTriggerCoincidence", 4)) 1218 return T::kSM_FatalError; 1219 1220 const uint16_t *d = reinterpret_cast<const uint16_t*>(evt.GetText());; 1221 1222 if (!fFTM.SetTriggerCoincidence(d[0], d[1])) 1223 T::Warn("SetTriggerCoincidence - Value out of range."); 1224 1225 return T::GetCurrentState(); 1226 } 1227 1228 int SetCalibCoincidence(const EventImp &evt) 1229 { 1230 if (!CheckEventSize(evt.GetSize(), "SetCalibCoincidence", 4)) 1231 return T::kSM_FatalError; 1232 1233 const uint16_t *d = reinterpret_cast<const uint16_t*>(evt.GetText());; 1234 1235 if (!fFTM.SetCalibCoincidence(d[0], d[1])) 1236 T::Warn("SetCalibCoincidence - Value out of range."); 1237 1238 return T::GetCurrentState(); 1239 } 1240 1241 int Enable(const EventImp &evt, FTM::StaticData::GeneralSettings type) 1242 { 1243 if (!CheckEventSize(evt.GetSize(), "Enable", 1)) 1244 return T::kSM_FatalError; 1245 1246 fFTM.Enable(type, evt.GetText()[0]!=0); 1111 1247 1112 1248 return T::GetCurrentState(); … … 1281 1417 "|[]:"); 1282 1418 1419 AddConfiguration("ENABLE_TRIGGER", "B:1", kStateIdle) 1420 (boost::bind(&StateMachineFTM::Enable, this, _1, FTM::StaticData::kTrigger)) 1421 ("" 1422 "|[]:"); 1423 1424 // FIXME: Switch on/off depending on sequence 1425 AddConfiguration("ENABLE_EXT1", "B:1", kStateIdle) 1426 (boost::bind(&StateMachineFTM::Enable, this, _1, FTM::StaticData::kExt1)) 1427 ("" 1428 "|[]:"); 1429 1430 // FIXME: Switch on/off depending on sequence 1431 AddConfiguration("ENABLE_EXT2", "B:1", kStateIdle) 1432 (boost::bind(&StateMachineFTM::Enable, this, _1, FTM::StaticData::kExt2)) 1433 ("" 1434 "|[]:"); 1435 1436 AddConfiguration("ENABLE_VETO", "B:1", kStateIdle) 1437 (boost::bind(&StateMachineFTM::Enable, this, _1, FTM::StaticData::kVeto)) 1438 ("" 1439 "|[]:"); 1440 1441 AddConfiguration("SET_TRIGGER_SEQUENCE", "C:3", kStateIdle) 1442 (boost::bind(&StateMachineFTM::SetTriggerSeq, this, _1)) 1443 ("" 1444 "|[]:"); 1445 1446 AddConfiguration("SET_TRIGGER_COINCIDENCE", "S:2", kStateIdle) 1447 (boost::bind(&StateMachineFTM::SetTriggerCoincidence, this, _1)) 1448 ("" 1449 "|[]:"); 1450 1451 AddConfiguration("SET_CALIBRATION_COINCIDENCE", "S:2", kStateIdle) 1452 (boost::bind(&StateMachineFTM::SetCalibCoincidence, this, _1)) 1453 ("" 1454 "|[]:"); 1283 1455 1284 1456 … … 1329 1501 1330 1502 fFTM.StartConnect(); 1331 1332 1333 // ENABLE_TRIGGER bool1334 // ENABLE_EXT1 bool1335 // ENABLE_EXT2 bool1336 // ENABLE_VETO bool1337 // ---> Enable(bit, bool)1338 1339 // SET_TRIGGER_SEQUENCE val val val1340 // ---> SetTriggerSequence(val, val, val)1341 1342 // SET_PRESCALING idx val1343 // ---> SetPrescaling(idx==-1, val)1344 1503 } 1345 1504
Note:
See TracChangeset
for help on using the changeset viewer.