Browse Source

修改 module_other_alarm

daiyueteng 6 years ago
parent
commit
b73c40c56d
2 changed files with 24 additions and 42 deletions
  1. 20 0
      module_service/module_other_alarm.cpp
  2. 4 42
      module_service/module_other_alarm.h

+ 20 - 0
module_service/module_other_alarm.cpp

@@ -0,0 +1,20 @@
+#include"module_other_alarm.h"
+
+#include"event.h"
+#include"common_tool.h"
+#include"log.h"
+
+
+void module_other_alarm::power_lower_serious(std::shared_ptr<card_location_base> card_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_LOW_POWER_SERIOUS, id, 0, 0, true);
+}
+
+void module_other_alarm::power_nomarl(std::shared_ptr<card_location_base> card_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_LOW_POWER_SERIOUS, id, 0, 0, false);
+}
+
+

+ 4 - 42
module_service/module_other_alarm.h

@@ -6,12 +6,8 @@
  * @date 2018-10-11
  */
 
-#include <string>
-#include <memory>
-#include <atomic>
-#include <mutex>
-#include <map>
-#include "module_const.h"
+#include "module_singleton_base.h"
+#include "card.h"
 
 
 class module_other_alarm:public singleton_base<module_other_alarm>
@@ -23,43 +19,9 @@ private:
     }
 
 public:
-    static void power_lower_serious(std::shared_ptr<card_location_base> card_ptr)
-    {
-        auto ev_ptr = event_list::instance()->get_event_card(card_ptr->m_id, card_ptr->m_type, ET_CARD_LOW_POWER_SERIOUS);
-        if(ev_ptr)
-        {
-            event_list::copy_event(card_ptr, ev_ptr);
-        }
-        else//从没有告警状态转化为告警状态
-        {
-            ev_ptr = event_list::create_event_card(card_ptr->m_id, card_ptr->m_type, ET_CARD_LOW_POWER_SERIOUS);
-
-            event_list::copy_event(card_ptr, ev_ptr);
-
-            //保存到数据库
-            event_list::save_event(ev_ptr);
-
-            event_list::instance()->add(ev_ptr->get_list_id(),ev_ptr);
-
-            log_info("电量极低告警开始:卡id=%d,卡type=%d", card_ptr->m_id, card_ptr->m_type);
-        }
-    }
+    static void power_lower_serious(std::shared_ptr<card_location_base> card_ptr);
 
-    static void power_nomarl(std::shared_ptr<card_location_base> card_ptr)
-    {
-        auto ev_ptr = event_list::instance()->get_event_card(card_ptr->m_id, card_ptr->m_type, ET_CARD_LOW_POWER_SERIOUS);
-        if(ev_ptr  && !ev_ptr->is_end())
-        {
-            event_list::copy_event(card_ptr, ev_ptr);
-
-            ev_ptr->m_status = ES_END;
-
-            //保存到数据库
-            event_list::save_event(ev_ptr);
-
-            log_info("电量极低告警结束:卡id=%d,卡type=%d", card_ptr->m_id, card_ptr->m_type);
-        }
-    }
+    static void power_nomarl(std::shared_ptr<card_location_base> card_ptr);
 };
 
 #endif // MODULE_OTHER_ALARM_H