Changeset 11079 for trunk/FACT++/src
- Timestamp:
- 06/20/11 16:07:09 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/fadctrl.cc
r11056 r11079 51 51 52 52 protected: 53 virtual void UpdateFirstHeader() 54 { 55 } 56 57 virtual void UpdateEventHeader() 58 { 59 // emit service with trigger counter from header 60 if (!fIsVerbose) 61 return; 62 53 void PrintEventHeader() 54 { 63 55 Out() << endl << kBold << "Header received (N=" << dec << fCounter << "):" << endl; 64 56 Out() << fEventHeader; … … 67 59 } 68 60 69 /* 70 virtual void UpdateChannelHeader(int i) 71 { 72 // emit service with trigger counter from header 73 if (!fIsVerbose) 74 return; 75 76 Out() << fChannelHeader[i]; 77 if (fIsHexOutput) 78 Out() << Converter::GetHex<uint16_t>(fChannelHeader, 16) << endl; 79 } 80 */ 81 82 virtual void UpdateChannelHeaders() 83 { 84 // emit service with trigger counter from header 85 if (!fIsVerbose) 86 return; 87 61 void PrintChannelHeaders() 62 { 88 63 Out() << dec << endl; 89 64 90 Out() << kBold << "ID: Crate=" << fEventHeader.Crate() << " Board=" << fEventHeader.Board() << endl;91 65 for (unsigned int c=0; c<FAD::kNumChips; c++) 92 66 { 93 Out() << "R eadoutWin #" << c << ":";67 Out() << "ROI" << fEventHeader.Crate() << ":" << fEventHeader.Board() << ":" << c << ":"; 94 68 for (unsigned int ch=0; ch<FAD::kNumChannelsPerChip; ch++) 95 69 Out() << " " << setw(4) << fChannelHeader[c*FAD::kNumChannelsPerChip+ch].fRegionOfInterest; … … 97 71 } 98 72 73 Out() << "CEL" << fEventHeader.Crate() << ":" << fEventHeader.Board() << ":"; 99 74 for (unsigned int c=0; c<FAD::kNumChips; c++) 100 75 { 101 Out() << "StartCells #" << c << ":"; 102 for (unsigned int ch=0; ch<FAD::kNumChannelsPerChip; ch++) 103 Out() << " " << setw(4) << fChannelHeader[c*FAD::kNumChannelsPerChip+ch].fStartCell; 104 Out() << endl; 105 } 76 if (0)//fIsFullChannelHeader) 77 { 78 for (unsigned int ch=0; ch<FAD::kNumChannelsPerChip; ch++) 79 Out() << " " << setw(4) << fChannelHeader[c*FAD::kNumChannelsPerChip+ch].fStartCell; 80 Out() << endl; 81 } 82 else 83 { 84 Out() << " "; 85 const uint16_t cel = fChannelHeader[c*FAD::kNumChannelsPerChip].fStartCell; 86 for (unsigned int ch=1; ch<FAD::kNumChannelsPerChip; ch++) 87 if (cel!=fChannelHeader[c*FAD::kNumChannelsPerChip+ch].fStartCell) 88 { 89 Out() << "!"; 90 break; 91 } 92 Out() << cel; 93 } 94 } 95 Out() << endl; 106 96 107 97 if (fIsHexOutput) 108 98 Out() << Converter::GetHex<uint16_t>(fChannelHeader, 16) << endl; 99 100 } 101 102 virtual void UpdateFirstHeader() 103 { 104 } 105 106 virtual void UpdateEventHeader() 107 { 108 // emit service with trigger counter from header 109 if (fIsVerbose) 110 PrintEventHeader(); 111 } 112 113 virtual void UpdateChannelHeaders() 114 { 115 // emit service with trigger counter from header 116 if (fIsVerbose) 117 PrintChannelHeaders(); 118 109 119 } 110 120 … … 173 183 UpdateEventHeader(); 174 184 175 fCounter++;176 177 185 fBuffer.resize(fEventHeader.fPackageLength-sizeof(FAD::EventHeader)/2); 178 186 AsyncRead(ba::buffer(fBuffer), kReadData); … … 246 254 } 247 255 248 UpdateChannelHeaders(); 256 if (fIsVerbose) 257 UpdateChannelHeaders(); 258 259 fCounter++; 249 260 250 261 fBuffer.resize(sizeof(FAD::EventHeader)/2); … … 532 543 } 533 544 545 void PrintEvent() 546 { 547 if (fCounter>0) 548 { 549 PrintEventHeader(); 550 PrintChannelHeaders(); 551 } 552 else 553 Out() << "No event received yet." << endl; 554 } 555 534 556 }; 535 557 … … 824 846 } 825 847 848 int PrintEvent(const EventImp &evt) 849 { 850 if (!CheckEventSize(evt.GetSize(), "PrintEvent", 2)) 851 return T::kSM_FatalError; 852 853 const int16_t slot = evt.Get<int16_t>(); 854 855 if (slot<0) 856 { 857 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 858 i->second.second->PrintEvent(); 859 } 860 else 861 { 862 const BoardList::iterator it=fBoards.find(slot); 863 if (it!=fBoards.end()) 864 { 865 it->second.second->PrintEvent(); 866 return T::GetCurrentState(); 867 } 868 869 ostringstream str; 870 str << "Slot " << slot << " not found."; 871 T::Warn(str); 872 } 873 874 return T::GetCurrentState(); 875 } 876 826 877 int SetBlockTransmission(const EventImp &evt) 827 878 { 828 if (!CheckEventSize(evt.GetSize(), "SetBlockTransmission", 5))829 return T::kSM_FatalError; 830 831 const int 32_t slot = evt.Get<int32_t>();879 if (!CheckEventSize(evt.GetSize(), "SetBlockTransmission", 3)) 880 return T::kSM_FatalError; 881 882 const int16_t slot = evt.Get<int32_t>(); 832 883 833 884 const BoardList::iterator it=fBoards.find(slot); … … 841 892 842 893 it->second.second->SetBlockTransmission(evt.Get<uint8_t>(4)); 894 895 return T::GetCurrentState(); 896 } 897 898 int SetBlockTransmissionRange(const EventImp &evt) 899 { 900 if (!CheckEventSize(evt.GetSize(), "SetBlockTransmissionRange", 5)) 901 return T::kSM_FatalError; 902 903 const int16_t *slot = evt.Ptr<int16_t>(); 904 const bool block = evt.Get<uint8_t>(8); 905 906 for (int i=slot[0]; i<=slot[1]; i++) 907 { 908 const BoardList::iterator it=fBoards.find(i); 909 if (it==fBoards.end()) 910 { 911 ostringstream str; 912 str << "Slot " << i << " not found."; 913 T::Warn(str); 914 continue; 915 } 916 it->second.second->SetBlockTransmission(block); 917 } 843 918 844 919 return T::GetCurrentState(); … … 1239 1314 (""); 1240 1315 1241 T::AddEvent("BLOCK_TRANSMISSION", "I:1;B:1") 1316 T::AddEvent("PRINT_EVENT", "I") 1317 (boost::bind(&StateMachineFAD::PrintEvent, this, _1)) 1318 ("Print (last) event" 1319 "|board[int]:slot from which the event should be printed (-1 for all)"); 1320 1321 T::AddEvent("BLOCK_TRANSMISSION", "S:1;B:1") 1242 1322 (boost::bind(&StateMachineFAD::SetBlockTransmission, this, _1)) 1243 1323 ("Blocks the transmission of commands to the given slot. Use with care! For debugging pupose only!" 1244 "|slot[int]:Slot to which the command transmission should be blocked (0-39)" 1324 "|slot[short]:Slot to which the command transmission should be blocked (0-39)" 1325 "|enable[bool]:Whether the command transmission should be blockes (yes) or allowed (no)"); 1326 1327 T::AddEvent("BLOCK_TRANSMISSION_RANGE", "S:2;B:1") 1328 (boost::bind(&StateMachineFAD::SetBlockTransmissionRange, this, _1)) 1329 ("Blocks the transmission of commands to the given range of slots. Use with care! For debugging pupose only!" 1330 "|first[short]:First slot to which the command transmission should be blocked (0-39)" 1331 "|last[short]:Last slot to which the command transmission should be blocked (0-39)" 1245 1332 "|enable[bool]:Whether the command transmission should be blockes (yes) or allowed (no)"); 1246 1333 … … 1278 1365 (boost::bind(&StateMachineFAD::RemoveSlot, this, _1)) 1279 1366 ("Remove the Iaddress in slot n. For a list see LIST" 1280 "|slot[ int]:Remove the address in slot n from the list");1367 "|slot[short]:Remove the address in slot n from the list"); 1281 1368 T::AddEvent("LIST_SLOTS") 1282 1369 (boost::bind(&StateMachineFAD::ListSlots, this))
Note:
See TracChangeset
for help on using the changeset viewer.