#include "CEventMsgInfo.h" #include #include "CEventDataCollect.h" #include CEventMsgInfo::CEventMsgInfo() { alm_type = -1; alm_style = AS_EVENT_ONLY; time_stamp = 1000; domain_id = -1; location_id = -1; app_id = -1; content = QString(""); priority = -1; dev_type = -1; region_id = -1; key_id_tag = QString(); uuid_base64 = QString(); priorityOrder = -1; deleted = false; filterDelete = false; wave_file = QString(); } CEventMsgInfo::CEventMsgInfo(const CEventMsgInfo &other) { alm_type = other.alm_type; alm_style = other.alm_style; time_stamp = other.time_stamp; domain_id = other.domain_id; location_id = other.location_id; app_id = other.app_id; content = other.content; priority = other.priority; dev_type = other.dev_type; key_id_tag = other.key_id_tag; uuid_base64 = other.uuid_base64; region_id = other.region_id; deleted = other.deleted; filterDelete = other.filterDelete; wave_file = other.wave_file; } void CEventMsgInfo::initialize(const iot_idl::SEvtInfoToEvtClt &eventInfo) { alm_type = eventInfo.alm_type(); E_ALARM_LOGICSTATE logic = (E_ALARM_LOGICSTATE)eventInfo.logic_state(); if(logic == E_ALS_ALARM || logic == E_ALS_ALARM_CFM || logic == E_ALS_ALARM_DEL || logic == E_ALS_ALARM_CFM_DEL) { alm_style = AS_ALARM; }else if(logic == E_ALS_RETURN || logic == E_ALS_RETURN_CFM || logic == E_ALS_RETURN_DEL || logic == E_ALS_RETURN_CFM_DEL) { alm_style = AS_ALARM_RTN; }else{ alm_style = AS_EVENT_ONLY; } time_stamp = eventInfo.time_stamp(); alm_status = eventInfo.alm_status(); domain_id = eventInfo.domain_id(); location_id = eventInfo.location_id(); app_id = eventInfo.app_id(); content = QString::fromStdString(eventInfo.content()); priority = eventInfo.priority(); dev_type = eventInfo.dev_type(); key_id_tag = QString::fromStdString(eventInfo.key_id_tag()); uuid_base64 = QString::fromStdString(eventInfo.uuid_base64()); if(eventInfo.has_region_id() && eventInfo.region_id() > 0) { region_id = eventInfo.region_id(); } else { region_id = -1; } wave_file = QString::fromStdString(eventInfo.wave_file()); } bool CEventMsgInfo::lessThan(EventMsgPtr info, E_ALARM_SORTKEY sortkey) { switch (sortkey) { case E_SORT_PRIORITY: { if(priorityOrder < info->priorityOrder) { return true; } else if(priorityOrder > info->priorityOrder) { return false; } else if(priorityOrder == info->priorityOrder) { if(time_stamp <= info->time_stamp) { return false; } return true; } break; } case E_SORT_TIME: { if(time_stamp < info->time_stamp) { return true; } if(time_stamp > info->time_stamp) { return false; } else if(time_stamp == info->time_stamp) { if(priorityOrder <= info->priorityOrder) { return true; } return false; } break; } case E_SORT_LOCATION: { if(location_id < info->location_id) { return true; } else if(location_id > info->location_id) { return false; } else if(location_id == info->location_id) { if(time_stamp <= info->time_stamp) { return false; } return true; } break; } case E_SORT_REGION: { if(region_id < info->region_id) { return true; } else if(region_id > info->region_id) { return false; } else if(region_id == info->region_id) { if(time_stamp <= info->time_stamp) { return false; } return true; } break; } case E_SORT_TYPE: { if(alm_type < info->alm_type) { return true; } else if(alm_type > info->alm_type) { return false; } else if(alm_type == info->alm_type) { if(time_stamp <= info->time_stamp) { return false; } return true; } break; } case E_SORT_STATUS: { if(alm_status < info->alm_status) { return true; } else if(alm_status > info->alm_status) { return false; } else if(alm_status == info->alm_status) { if(time_stamp <= info->time_stamp) { return false; } return true; } break; } case E_SORT_STYLE: { if(alm_style alm_style) { return true; } else if(alm_style >info->alm_style) { return false; } else { if(time_stamp < info->time_stamp) { return true; } return false; } break; } case E_SORT_CONTENT: { if(content.isEmpty() && info->content.isEmpty()) { return false; } else if(content.isEmpty() && (!info->content.isEmpty())) { return true; } else if((!content.isEmpty()) && info->content.isEmpty()) { return false; } else if(content < info->content) { return true; } else if(content > info->content) { return false; } else if(content == info->content) { if(time_stamp < info->time_stamp) { return false; } return true; } break; } default: break; } return false; } bool CEventMsgInfo::moreThan(EventMsgPtr info, E_ALARM_SORTKEY sortkey) { switch (sortkey) { case E_SORT_PRIORITY: { if(priorityOrder > info->priorityOrder) { return true; } else if(priorityOrder < info->priorityOrder) { return false; } else if(priorityOrder == info->priorityOrder) { if(time_stamp >= info->time_stamp) { return true; } return false; } break; } case E_SORT_TIME: { if(time_stamp > info->time_stamp) { return true; } if(time_stamp < info->time_stamp) { return false; } else if(time_stamp == info->time_stamp) { if(priorityOrder < info->priorityOrder) { return true; } return false; } break; } case E_SORT_LOCATION: { if(location_id > info->location_id) { return true; } else if(location_id < info->location_id) { return false; } else if(location_id == info->location_id) { if(time_stamp <= info->time_stamp) { return false; } return true; } break; } case E_SORT_REGION: { if(region_id > info->region_id) { return true; } else if(region_id < info->region_id) { return false; } else if(region_id == info->region_id) { if(time_stamp <= info->time_stamp) { return false; } return true; } break; } case E_SORT_TYPE: { if(alm_type > info->alm_type) { return true; } else if(alm_type < info->alm_type) { return false; } else if(alm_type == info->alm_type) { if(time_stamp <= info->time_stamp) { return false; } return true; } break; } case E_SORT_STATUS: { if(alm_status > info->alm_status) { return true; } else if(alm_status < info->alm_status) { return false; } else if(alm_status == info->alm_status) { if(time_stamp <= info->time_stamp) { return false; } return true; } break; } case E_SORT_STYLE: { if(alm_style alm_style) { return false; } else if(alm_style >info->alm_style) { return true; } else { if(time_stamp < info->time_stamp) { return false; } return true; } break; } case E_SORT_CONTENT: { if(content.isEmpty() && info->content.isEmpty()) { return true; } else if(content.isEmpty() && (!info->content.isEmpty())) { return false; } else if((!content.isEmpty()) && info->content.isEmpty()) { return true; } else if(content > info->content) { return true; } else if(content < info->content) { return false; } else if(content == info->content) { if(time_stamp < info->time_stamp) { return false; } return true; } break; } default: break; } return false; } bool CEventMsgInfo::operator==(const EventMsgPtr &target) { return uuid_base64 == target->uuid_base64; }