123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- #include"area_business_motionless_persion.h"
- #include"common_tool.h"
- #include"log.h"
- #include"area.h"
- #include"event.h"
- #include"tool_time.h"
- #include"area_business.h"
- #include"card.h"
- struct motionless_data:business_data
- {
- motionless_data()
- {
- m_acc_0count=0;
- // m_acc_start_time=0;
- }
- ///;检测到多少次之后定位完全静止
- std::atomic<int> m_acc_0count;
- // ///检测到多久之后告警
- // time_t m_acc_start_time;
- };
- void area_business_motionless_persion::on_enter(const std::shared_ptr<area_hover>&a,
- const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data>&ptr)
- {
- auto ptr_temp = std::make_shared<motionless_data>();
- ptr = ptr_temp;
- }
- void area_business_motionless_persion::on_hover(const std::shared_ptr<area_hover>&area_hover_ptr,
- const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data> ptr)
- {
- auto ptr_temp = static_cast<motionless_data*>(ptr.get());
- if(0 == static_cast<int>(card_ptr->m_acc))
- {
- ptr_temp->m_acc_0count++;
- }
- else
- {
- ptr_temp->m_acc_0count=0;
- }
- if(ptr_temp->m_acc_0count >= _acc_0count_limit)
- {
- ptr_temp->m_acc_0count = _acc_0count_limit;
- }
- bool is_alarm = ptr_temp->m_acc_0count >= _acc_0count_limit;
- uint64_t id = tool_other::type_id_to_u64(card_ptr->m_type, card_ptr->m_id);
- event_tool::instance()->handle_event(OT_CARD, ET_CARD_MOTIONLESS, id, 0, 0, is_alarm);
- }
- void area_business_motionless_persion::on_leave(const std::shared_ptr<area_hover>&area_hover_ptr,
- const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data> ptr)
- {
- uint64_t id = tool_other::type_id_to_u64(card_ptr->m_type, card_ptr->m_id);
- event_tool::instance()->handle_event(OT_CARD, ET_CARD_MOTIONLESS, id, 0, 0, false);
- }
- int area_business_motionless_persion::_acc_0count_limit;
- //void module_motionless_persion::deal_alarm(std::shared_ptr<card_location_base>& card_ptr)
- //{
- // auto area_hover_ptr = card_ptr->get_area_hover();
- // if(!area_hover_ptr)
- // {
- // log_error("if(!area_hover_ptr)==true");
- // return;
- // }
- // auto arr = area_hover_ptr->m_data;
- // int index = 1;
- // if(arr.size()<2 || !arr[index])
- // {
- // return;
- // }
- // auto ptr = static_cast<motionless_data*>(area_hover_ptr->m_data[index].get());
- // if(ptr->m_acc_0count >= _acc_0count_limit)
- // {
- // ptr->m_acc_0count = _acc_0count_limit;
- // if(0 == ptr->m_acc_start_time)
- // {
- // ptr->m_acc_start_time = tool_time::now_to_seconds();
- // }
- // }
- // else
- // {
- // ptr->m_acc_start_time=0;
- // }
- // bool is_alarm = (0 != ptr->m_acc_start_time
- // &&tool_time::elapse_seconds(ptr->m_acc_start_time)> _acc_seconds_limit);
- // uint64_t id = tool_other::type_id_to_u64(card_ptr->m_type, card_ptr->m_id);
- // event_tool::instance()->handle_event(OT_CARD, ET_CARD_MOTIONLESS, id, 0, 0, is_alarm);
- //}
|