|
@@ -4,6 +4,7 @@
|
|
|
#include <card.h>
|
|
|
#include <zloop.h>
|
|
|
#include <ev++.h>
|
|
|
+#include <message.h>
|
|
|
|
|
|
struct card_location_base
|
|
|
{
|
|
@@ -21,15 +22,10 @@ struct one_ct_message_handle
|
|
|
const algo_config*m_ac=nullptr;
|
|
|
int m_ct;
|
|
|
bool m_min_timeout=false;
|
|
|
- one_ct_message_handle(ev::dynamic_loop&loop,card_location_base*card)
|
|
|
+ one_ct_message_handle(card_location_base*card)
|
|
|
{
|
|
|
m_card=card;
|
|
|
m_ct=-1;
|
|
|
-
|
|
|
- m_min_timer.set(loop);
|
|
|
- m_min_timer.set<one_ct_message_handle,&one_ct_message_handle::on_min_timer>(this);
|
|
|
- m_max_timer.set(loop);
|
|
|
- m_max_timer.set<one_ct_message_handle,&one_ct_message_handle::on_max_timer>(this);
|
|
|
}
|
|
|
|
|
|
void reset()
|
|
@@ -56,12 +52,32 @@ struct one_ct_message_handle
|
|
|
calc_location();
|
|
|
}
|
|
|
|
|
|
- void on_message(const message_locinfo&loc)
|
|
|
+ bool once_flag=false;
|
|
|
+ void once_init(ev::dynamic_loop&loop)
|
|
|
{
|
|
|
+ if(once_flag)
|
|
|
+ return;
|
|
|
+
|
|
|
+ once_flag=true;
|
|
|
+ m_min_timer.set(loop);
|
|
|
+ m_min_timer.set<one_ct_message_handle,&one_ct_message_handle::on_min_timer>(this);
|
|
|
+ m_max_timer.set(loop);
|
|
|
+ m_max_timer.set<one_ct_message_handle,&one_ct_message_handle::on_max_timer>(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ void on_message(ev::dynamic_loop&loop, const message_locinfo&loc)
|
|
|
+ {
|
|
|
+ once_init(loop);
|
|
|
+
|
|
|
if(!m_msg_list.empty()&& m_ct!=loc.m_card_ct)
|
|
|
+ {
|
|
|
m_msg_list.clear();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
ant*a=ant_list::instance()->get(loc.m_site_id, loc.m_ant_id);
|
|
|
+
|
|
|
+ m_loc_tool.on_loc_message(a, loc);
|
|
|
if(m_msg_list.empty())
|
|
|
{
|
|
|
m_ct=loc.m_card_ct;
|
|
@@ -101,17 +117,17 @@ struct card_message_handle
|
|
|
std::vector<loc_message> m_msg_list;
|
|
|
std::array<one_ct_message_handle*,16> m_ct_list;
|
|
|
|
|
|
- card_message_handle(zloop_base&loop,card_location_base*card)
|
|
|
+ card_message_handle(card_location_base*card)
|
|
|
{
|
|
|
m_card=card;
|
|
|
|
|
|
for(size_t i=0;i<m_ct_list.size();i++)
|
|
|
{
|
|
|
- m_ct_list[i]=new one_ct_message_handle(loop,card);
|
|
|
+ m_ct_list[i]=new one_ct_message_handle(card);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- void on_message(const message_locinfo&loc,bool is_history)
|
|
|
+ void on_message(ev::dynamic_loop&loop, const message_locinfo&loc,bool is_history)
|
|
|
{
|
|
|
if(is_history)
|
|
|
{
|
|
@@ -119,44 +135,44 @@ struct card_message_handle
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- m_ct_list[loc.m_card_ct&(m_ct_list.size()-1)]->on_message(loc);
|
|
|
+ m_ct_list[loc.m_card_ct&(m_ct_list.size()-1)]->on_message(loop, loc);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
struct card:card_location_base
|
|
|
{
|
|
|
card_message_handle m_message_handle;
|
|
|
- card(zloop_base&loop)
|
|
|
- :m_message_handle(loop,this)
|
|
|
+
|
|
|
+ card()
|
|
|
+ :m_message_handle(this)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
- void on_message(const message_locinfo&loc,bool is_history)
|
|
|
+ ~card()
|
|
|
{
|
|
|
- m_message_handle.on_message(loc,is_history);
|
|
|
}
|
|
|
|
|
|
- void on_location(const std::vector<point>&points)
|
|
|
+ void on_message(ev::dynamic_loop&loop, const message_locinfo&loc,bool is_history)
|
|
|
{
|
|
|
+ m_message_handle.on_message(loop, loc, is_history);
|
|
|
}
|
|
|
|
|
|
- ~card(){}
|
|
|
+ void on_location(const std::vector<point>&points)
|
|
|
+ {
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
loc_tool_main one_ct_message_handle::m_loc_tool;
|
|
|
struct card_list_impl:card_list
|
|
|
{
|
|
|
- zloop<task*>&m_loop;
|
|
|
std::vector<card*> m_list;
|
|
|
- card_list_impl(zloop<task*>&loop)
|
|
|
- :m_loop(loop)
|
|
|
+ card_list_impl()
|
|
|
{
|
|
|
m_list.reserve(1<<16);
|
|
|
}
|
|
|
|
|
|
void init_card_from_db()
|
|
|
{
|
|
|
- card _(m_loop);
|
|
|
}
|
|
|
|
|
|
card*get(uint64_t card_id)const
|
|
@@ -169,7 +185,7 @@ struct card_list_impl:card_list
|
|
|
return m_list[cid];
|
|
|
}
|
|
|
|
|
|
- void on_message(const message_locinfo&loc,bool is_history)
|
|
|
+ void on_message(ev::dynamic_loop&loop, const message_locinfo&loc,bool is_history)
|
|
|
{
|
|
|
card*c=get(loc.m_card_id);
|
|
|
|
|
@@ -179,16 +195,13 @@ struct card_list_impl:card_list
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- log_info("card message:site=%d,ant=%d,card=%d,tof=%lld,rav=%02X,acc=%02X,rssi=%d",
|
|
|
- loc.m_site_id,loc.m_ant_id,loc.m_card_id,loc.m_tof,loc.m_rav,loc.m_acc,loc.m_rssi);
|
|
|
-
|
|
|
- c->on_message(loc,is_history);
|
|
|
+ c->on_message(loop, loc, is_history);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-card_list *card_list::instance(zloop<task*>&loop)
|
|
|
+card_list *card_list::instance()
|
|
|
{
|
|
|
- static card_list_impl _impl(loop);
|
|
|
+ static card_list_impl _impl;
|
|
|
return &_impl;
|
|
|
}
|
|
|
|