Changeset 10986 for trunk/FACT++/src/fadctrl.cc
- Timestamp:
- 06/10/11 16:15:47 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/fadctrl.cc
r10978 r10986 523 523 private: 524 524 typedef pair<tcp::endpoint, ConnectionFAD*> Connection; 525 typedef vector<Connection> BoardList;525 typedef map<uint8_t, Connection> BoardList; 526 526 527 527 BoardList fBoards; … … 545 545 { 546 546 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 547 i->second ->Cmd(command);547 i->second.second->Cmd(command); 548 548 549 549 return T::GetCurrentState(); … … 556 556 557 557 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 558 i->second ->Cmd(command, evt.GetBool());558 i->second.second->Cmd(command, evt.GetBool()); 559 559 560 560 return T::GetCurrentState(); … … 593 593 594 594 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 595 i->second ->CmdSetRegister(dat[0], dat[1]);595 i->second.second->CmdSetRegister(dat[0], dat[1]); 596 596 597 597 return T::GetCurrentState(); … … 611 611 612 612 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 613 i->second ->CmdSetRoi(dat[0], dat[1]);613 i->second.second->CmdSetRoi(dat[0], dat[1]); 614 614 615 615 return T::GetCurrentState(); … … 627 627 628 628 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 629 i->second ->CmdSetDacValue(dat[0], dat[1]);629 i->second.second->CmdSetDacValue(dat[0], dat[1]); 630 630 631 631 return T::GetCurrentState(); … … 636 636 for (int nn=0; nn<n; nn++) 637 637 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 638 i->second ->Cmd(FAD::kCmdSingleTrigger);638 i->second.second->Cmd(FAD::kCmdSingleTrigger); 639 639 640 640 return T::GetCurrentState(); … … 657 657 658 658 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 659 i->second ->Cmd(FAD::kCmdRun, start);659 i->second.second->Cmd(FAD::kCmdRun, start); 660 660 661 661 return T::GetCurrentState(); … … 668 668 669 669 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 670 i->second ->CmdPhaseShift(evt.GetShort());670 i->second.second->CmdPhaseShift(evt.GetShort()); 671 671 672 672 return T::GetCurrentState(); … … 687 687 688 688 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 689 i->second ->CmdSetTriggerRate(evt.GetUInt());689 i->second.second->CmdSetTriggerRate(evt.GetUInt()); 690 690 691 691 return T::GetCurrentState(); … … 708 708 709 709 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 710 i->second ->CmdSetRunNumber(num);710 i->second.second->CmdSetRunNumber(num); 711 711 712 712 return T::GetCurrentState(); … … 731 731 732 732 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 733 i->second ->SetVerbose(evt.GetBool());733 i->second.second->SetVerbose(evt.GetBool()); 734 734 735 735 return T::GetCurrentState(); … … 742 742 743 743 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 744 i->second ->SetHexOutput(evt.GetBool());744 i->second.second->SetHexOutput(evt.GetBool()); 745 745 746 746 return T::GetCurrentState(); … … 753 753 754 754 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 755 i->second ->SetDataOutput(evt.GetBool());755 i->second.second->SetDataOutput(evt.GetBool()); 756 756 757 757 return T::GetCurrentState(); … … 768 768 for (BoardList::const_iterator i=fBoards.begin(); i!=fBoards.end(); i++) 769 769 { 770 if (i-> first==endpoint)770 if (i->second.first==endpoint) 771 771 { 772 772 T::Warn("Address "+addr+" already known.... ignored."); … … 787 787 const int16_t slot = evt.GetShort(); 788 788 789 if (fBoards[slot].first==tcp::endpoint()) 789 const BoardList::iterator it = fBoards.find(slot); 790 791 if (it==fBoards.end()) 790 792 { 791 793 ostringstream str; … … 795 797 } 796 798 797 delete fBoards[slot].second;798 fBoards [slot] = make_pair(tcp::endpoint(), (ConnectionFAD*)NULL);799 delete it->second.second; 800 fBoards.erase(it); 799 801 800 802 return T::GetCurrentState(); … … 803 805 int ListSlots() 804 806 { 805 for ( int i=0; i<40; i++)806 { 807 if (fBoards[i].first==tcp::endpoint())808 continue;807 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 808 { 809 const int &idx = i->first; 810 const Connection &slot = i->second; 809 811 810 812 ostringstream str; 811 str << "Slot " << setw(2) << i << ": " << fBoards[i].first;812 813 const ConnectionFAD *c = fBoards[i].second;813 str << "Slot " << setw(2) << idx << ": " << slot.first; 814 815 const ConnectionFAD *c = slot.second; 814 816 815 817 if (c->IsConnecting()) … … 823 825 } 824 826 825 switch (fStatus2[i ])827 switch (fStatus2[idx]) 826 828 { 827 829 case 0: str << "1-7:not connected)"; break; 828 830 case 7: str << "1-7:connected)"; break; 829 default: str << "1-7:connecting [" << fStatus2[i ] << "])"; break;831 default: str << "1-7:connecting [" << fStatus2[idx] << "])"; break; 830 832 } 831 833 … … 843 845 } 844 846 845 void EnableSlot(int i, bool enable=true) 846 { 847 if (fBoards[i].first==tcp::endpoint()) 848 return; 849 850 ConnectionFAD* &ptr = fBoards[i].second; 847 void EnableSlot(Connection &c, bool enable=true) 848 { 849 ConnectionFAD *ptr = c.second; 851 850 if (!ptr) 852 851 return; … … 857 856 { 858 857 ostringstream str; 859 str << fBoards[i].first;858 str << c.first; 860 859 ptr->SetEndpoint(str.str()); 861 860 ptr->StartConnect(); … … 865 864 void EnableAll(bool enable=true) 866 865 { 867 for ( int i=0; i<40; i++)868 EnableSlot(i , enable);866 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 867 EnableSlot(i->second, enable); 869 868 } 870 869 … … 893 892 vector<tcp::endpoint> addr(40); 894 893 895 for ( int i=0; i<40; i++)896 addr[i ] = fBoards[i].first;894 for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++) 895 addr[i->first] = i->second.first; 897 896 898 897 Start(addr); … … 929 928 { 930 929 // ----- Command socket ----- 931 if (fBoards[idx].first!=tcp::endpoint()) 930 const BoardList::const_iterator &slot = fBoards.find(idx); 931 if (slot!=fBoards.end()) 932 932 { 933 const ConnectionFAD *c = fBoards[idx].second;933 const ConnectionFAD *c = slot->second.second; 934 934 if (c->IsConnecting()) 935 935 { … … 986 986 while (i<40) 987 987 { 988 if (fBoards [i].first==tcp::endpoint())988 if (fBoards.find(i)==fBoards.end()) 989 989 break; 990 990 i++; … … 1028 1028 StateMachineFAD(ostream &out=cout) : 1029 1029 T(out, "FAD_CONTROL"), EventBuilderWrapper(static_cast<MessageImp&>(*this)), ba::io_service::work(static_cast<ba::io_service&>(*this)), 1030 f Boards(40), fStatus1(40), fStatus2(40),1030 fStatus1(40), fStatus2(40), 1031 1031 fDimConnection("FAD_CONTROL/CONNECTIONS", "C:41", "") 1032 1032 { … … 1181 1181 { 1182 1182 for (BoardList::const_iterator i=fBoards.begin(); i!=fBoards.end(); i++) 1183 delete i->second ;1183 delete i->second.second; 1184 1184 fBoards.clear(); 1185 1185 }
Note:
See TracChangeset
for help on using the changeset viewer.