37 #ifndef __VDCBTDE_CHANNEL_MAP_H__ 38 #define __VDCBTDE_CHANNEL_MAP_H__ 44 #include <boost/multi_index_container.hpp> 45 #include <boost/multi_index/ordered_index.hpp> 46 #include <boost/multi_index/composite_key.hpp> 47 #include <boost/multi_index/hashed_index.hpp> 48 #include <boost/multi_index/identity.hpp> 49 #include <boost/multi_index/mem_fun.hpp> 50 #include <boost/range/iterator_range.hpp> 51 #include <boost/tuple/tuple.hpp> 52 #include <boost/optional.hpp> 72 unsigned short crate_, card_, cardch_;
81 unsigned short crate,
unsigned short card,
unsigned short cardch,
82 unsigned short crp,
unsigned short view,
unsigned short viewch,
83 unsigned short state = 0 ) :
84 seqn_(seqn), crate_(crate), card_(card), cardch_(cardch), crp_(crp), view_(view), viewch_(viewch), state_(state) {;}
88 const unsigned seqn()
const {
return seqn_; }
89 const unsigned short crate()
const {
return crate_; }
90 const unsigned short card()
const {
return card_; }
91 const unsigned short cardch()
const {
return cardch_; }
92 const unsigned short crp()
const {
return crp_; }
93 const unsigned short view()
const {
return view_; }
94 const unsigned short viewch()
const {
return viewch_; }
95 const unsigned short state()
const {
return state_; }
96 const bool exists()
const {
return (state_ == 0); }
117 typedef multi_index_container<
120 ordered_unique< tag<IndexRawSeqn>, const_mem_fun< ChannelId, const unsigned, &ChannelId::seqn > >,
121 hashed_unique< tag<IndexRawSeqnHash>, const_mem_fun< ChannelId, const unsigned, &ChannelId::seqn > >,
122 hashed_non_unique< tag<IndexCrate>, const_mem_fun< ChannelId, const unsigned short, &ChannelId::crate > >,
123 hashed_non_unique< tag<IndexCrateCard>, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short, &ChannelId::crate >, const_mem_fun< ChannelId, const unsigned short, &ChannelId::card > > >,
124 ordered_unique< tag<IndexCrateCardChan>, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short, &ChannelId::crate >, const_mem_fun< ChannelId, const unsigned short, &ChannelId::card >, const_mem_fun< ChannelId, const unsigned short, &ChannelId::cardch > > >,
125 hashed_unique< tag<IndexCrateCardChanHash>, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short, &ChannelId::crate >, const_mem_fun< ChannelId, const unsigned short, &ChannelId::card >, const_mem_fun< ChannelId, const unsigned short, &ChannelId::cardch > > >,
126 hashed_non_unique< tag<IndexCrp>, const_mem_fun< ChannelId, const unsigned short, &ChannelId::crp > >,
127 hashed_non_unique< tag<IndexCrpView>, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short, &ChannelId::crp >, const_mem_fun< ChannelId, const unsigned short, &ChannelId::view > > >,
128 ordered_unique< tag<IndexCrpViewChan>, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short, &ChannelId::crp >, const_mem_fun< ChannelId, const unsigned short, &ChannelId::view >, const_mem_fun< ChannelId, const unsigned short, &ChannelId::viewch > > >,
129 hashed_unique< tag<IndexCrpViewChanHash>, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short, &ChannelId::crp >, const_mem_fun< ChannelId, const unsigned short, &ChannelId::view >, const_mem_fun< ChannelId, const unsigned short, &ChannelId::viewch > > >
148 int MapToCRP(
int seqch,
int &crp,
int &view,
int &chv)
const;
149 int MapToDAQ(
int crp,
int view,
int chv,
int &seqch)
const;
156 boost::optional<tde::ChannelId> find_by_seqn(
unsigned seqn )
const;
157 std::vector<tde::ChannelId> find_by_seqn(
unsigned from,
unsigned to )
const;
160 std::vector<tde::ChannelId> find_by_crate(
unsigned crate,
bool ordered =
true )
const;
161 std::vector<tde::ChannelId> find_by_crate_card(
unsigned crate,
unsigned card,
162 bool ordered =
true )
const;
163 boost::optional<tde::ChannelId> find_by_crate_card_chan(
unsigned crate,
164 unsigned card,
unsigned chan )
const;
166 std::vector<tde::ChannelId> find_by_crp(
unsigned crp,
bool ordered =
true )
const;
167 std::vector<tde::ChannelId> find_by_crp_view(
unsigned crp,
unsigned view,
bool ordered =
true )
const;
168 boost::optional<tde::ChannelId> find_by_crp_view_chan(
unsigned crp,
169 unsigned view,
unsigned chan )
const;
172 unsigned ncrps()
const {
return ncrps_; }
173 unsigned ntot()
const {
return ntot_; }
174 unsigned ncards(
unsigned crate )
const;
175 unsigned nviews(
unsigned crp )
const;
178 void print( std::vector<tde::ChannelId> &vec );
188 void initMap(
std::string mapname,
unsigned ncrates = 1,
189 unsigned ncards = 10,
unsigned nviews = 1 );
191 void add(
unsigned seq,
unsigned crate,
unsigned card,
unsigned cch,
192 unsigned crp,
unsigned view,
unsigned vch,
unsigned short state = 0);
194 template<
typename Index,
typename KeyExtractor>
198 for(
auto it=i.begin(),it_end=i.end();it!=it_end;)
201 it = i.upper_bound(
key(*it) );
207 void simpleMap(
unsigned ncrates,
unsigned ncards,
unsigned nviews );
214 std::vector<tde::ChannelId>
filter( std::vector<tde::ChannelId> &sel )
const 216 std::vector<tde::ChannelId> res;
218 if(
c.exists() ) res.push_back(
c );
const unsigned short cardch() const
const unsigned seqn() const
const unsigned short crp() const
const bool exists() const
Coord add(Coord c1, Coord c2)
tde::ChannelTable chanTable
std::vector< tde::ChannelId > filter(std::vector< tde::ChannelId > &sel) const
bool operator<(const ChannelId &rhs) const
const unsigned short viewch() const
std::string getMapName() const
std::set< unsigned > get_crpidx()
struct dune::tde::crate crate
#define DECLARE_ART_SERVICE(svc, scope)
multi_index_container< ChannelId, indexed_by< ordered_unique< tag< IndexRawSeqn >, const_mem_fun< ChannelId, const unsigned,&ChannelId::seqn > >, hashed_unique< tag< IndexRawSeqnHash >, const_mem_fun< ChannelId, const unsigned,&ChannelId::seqn > >, hashed_non_unique< tag< IndexCrate >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::crate > >, hashed_non_unique< tag< IndexCrateCard >, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short,&ChannelId::crate >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::card > > >, ordered_unique< tag< IndexCrateCardChan >, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short,&ChannelId::crate >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::card >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::cardch > > >, hashed_unique< tag< IndexCrateCardChanHash >, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short,&ChannelId::crate >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::card >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::cardch > > >, hashed_non_unique< tag< IndexCrp >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::crp > >, hashed_non_unique< tag< IndexCrpView >, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short,&ChannelId::crp >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::view > > >, ordered_unique< tag< IndexCrpViewChan >, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short,&ChannelId::crp >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::view >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::viewch > > >, hashed_unique< tag< IndexCrpViewChanHash >, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short,&ChannelId::crp >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::view >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::viewch > > > > > ChannelTable
const unsigned short crate() const
const unsigned short view() const
std::set< unsigned > get_crateidx()
const unsigned short card() const
std::set< unsigned > crpidx_
std::set< unsigned > crateidx_
const unsigned short state() const
ChannelId(unsigned seqn, unsigned short crate, unsigned short card, unsigned short cardch, unsigned short crp, unsigned short view, unsigned short viewch, unsigned short state=0)
std::size_t cdistinct(const Index &i, KeyExtractor key)