|
|
@@ -1132,7 +1132,7 @@ void CResistAlarmMng::JudgeAlarm(CResistAlarmMng* pService, CONVERT_RESIST_OVER_
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void CResistAlarmMng::JudgeAlarm(CResistAlarmMng* pService, RETENSION_FORCE_DROP* pRetensionForceDropInfo, time_t show_time, int show_val, eSuoBiPosi posi, string mo, string mp, uint32_t zzjno)
|
|
|
+void CResistAlarmMng::JudgeAlarm2(CResistAlarmMng* pService, RETENSION_FORCE_DROP* pRetensionForceDropInfo, time_t show_time, int show_val, eSuoBiPosi posi, string mo, string mp, uint32_t zzjno)
|
|
|
{
|
|
|
if (pRetensionForceDropInfo == nullptr || pRetensionForceDropInfo->enable == false) return;
|
|
|
bool bNew = false;
|
|
|
@@ -1285,13 +1285,13 @@ void CResistAlarmMng::JudgeAlarm(CResistAlarmMng* pService, RETENSION_FORCE_DROP
|
|
|
}
|
|
|
|
|
|
void CResistAlarmMng::JudgeAlarm(CResistAlarmMng* pService, RETENSION_FORCE_DROP* pConstRetensionForceWaveInfo,
|
|
|
- time_t show_time, int show_val, eSuoBiPosi posi, string mo, string mp, uint32_t zzjno, void* pInfo)
|
|
|
+ time_t show_time, int show_val, eSuoBiPosi posi, string mo, string mp, void* pInfo)
|
|
|
{
|
|
|
ASSERT(pConstRetensionForceWaveInfo);
|
|
|
ST_MOMP_INFO* pMoMpInfo = (ST_MOMP_INFO*)pInfo;
|
|
|
CTime ctShowTime(show_time / 1000);
|
|
|
bool bSkylight = CSkylightMng::GetInstance()->IsSkylight(&ctShowTime);
|
|
|
- int nOldVal = 0;
|
|
|
+ int nOldVal = INT_MIN;
|
|
|
if (bSkylight && show_val == 0)
|
|
|
{
|
|
|
if (posi == eSuoBiPosi::SB_FIX)
|
|
|
@@ -1311,7 +1311,7 @@ void CResistAlarmMng::JudgeAlarm(CResistAlarmMng* pService, RETENSION_FORCE_DROP
|
|
|
if (nOldVal == INT_MIN)
|
|
|
{
|
|
|
pMoMpInfo->fix_const_retension_force = show_val;
|
|
|
- return;
|
|
|
+ SPDLOG_INFO("[常态保持力]标定{}.{} {} {}N", mo, mp, "定位", show_val);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
@@ -1320,164 +1320,173 @@ void CResistAlarmMng::JudgeAlarm(CResistAlarmMng* pService, RETENSION_FORCE_DROP
|
|
|
if (nOldVal == INT_MIN)
|
|
|
{
|
|
|
pMoMpInfo->invert_const_retension_force = show_val;
|
|
|
- return;
|
|
|
+ SPDLOG_INFO("[常态保持力]标定{}.{} {} {}N", mo, mp, "反位", show_val);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
ASSERT(pConstRetensionForceWaveInfo);
|
|
|
if (pConstRetensionForceWaveInfo->enable == false) return;
|
|
|
-
|
|
|
- if (nOldVal != INT_MIN)
|
|
|
+ if (nOldVal == INT_MIN)
|
|
|
+ return;
|
|
|
+ eLowHigh loworhigh = eLowHigh::LH_UNKNOWN;
|
|
|
+ int alarm_refer = 0, alarm_value = 0;
|
|
|
+ bool bAlarm = false, bWarn = false;
|
|
|
+ if (nOldVal < pConstRetensionForceWaveInfo->dw_alarm_low_drop)
|
|
|
+ {
|
|
|
+ bWarn = true;
|
|
|
+ alarm_refer = pConstRetensionForceWaveInfo->dw_alarm_low_drop;
|
|
|
+ alarm_value = show_val;
|
|
|
+ loworhigh = eLowHigh::LH_LOW;
|
|
|
+ }
|
|
|
+ if (loworhigh == eLowHigh::LH_UNKNOWN && nOldVal != 0)
|
|
|
{
|
|
|
int nRatio = show_val * 100 / nOldVal;
|
|
|
- eLowHigh loworhigh = eLowHigh::LH_UNKNOWN;
|
|
|
- int alarm_refer = 0;
|
|
|
- if (nOldVal != 0)
|
|
|
+ //下降20%或上升40% 进行预警
|
|
|
+ if (nRatio <= (100 - pConstRetensionForceWaveInfo->alarm_low_percent))
|
|
|
{
|
|
|
- //下降20%或上升40% 进行预警
|
|
|
- if (pConstRetensionForceWaveInfo->alarm_low_percent != INT_MIN && nRatio <= (100 - pConstRetensionForceWaveInfo->alarm_low_percent))
|
|
|
- {
|
|
|
- loworhigh = eLowHigh::LH_LOW;
|
|
|
- alarm_refer = nOldVal * (100 - pConstRetensionForceWaveInfo->alarm_low_percent) / 100;
|
|
|
- }
|
|
|
- else if (nRatio >= (100 + pConstRetensionForceWaveInfo->alarm_high_percent))
|
|
|
- {
|
|
|
- loworhigh = eLowHigh::LH_HIGH;
|
|
|
- alarm_refer = nOldVal * (100 + pConstRetensionForceWaveInfo->alarm_high_percent) / 100;
|
|
|
- }
|
|
|
+ bWarn = true;
|
|
|
+ loworhigh = eLowHigh::LH_LOW;
|
|
|
+ alarm_value = show_val;
|
|
|
+ alarm_refer = nOldVal * (100 - pConstRetensionForceWaveInfo->alarm_low_percent) / 100;
|
|
|
}
|
|
|
+ else if (nRatio >= (100 + pConstRetensionForceWaveInfo->alarm_high_percent))
|
|
|
+ {
|
|
|
+ bWarn = true;
|
|
|
+ loworhigh = eLowHigh::LH_HIGH;
|
|
|
+ alarm_value = show_val;
|
|
|
+ alarm_refer = nOldVal * (100 + pConstRetensionForceWaveInfo->alarm_high_percent) / 100;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- ALARM_INFO* pAlarmInfo = nullptr;
|
|
|
- CTime ctAlarmTime(show_time / 1000);
|
|
|
- bool bNew = false;
|
|
|
- //产生预警
|
|
|
- if (loworhigh != eLowHigh::LH_UNKNOWN)
|
|
|
+ ALARM_INFO* pAlarmInfo = nullptr;
|
|
|
+ CTime ctAlarmTime(show_time / 1000);
|
|
|
+ bool bNew = false;
|
|
|
+ //产生预警
|
|
|
+ if (loworhigh != eLowHigh::LH_UNKNOWN)
|
|
|
+ {
|
|
|
+ //查找是否原有的报警已存在
|
|
|
+ int level = bAlarm ? 1 : 0;// 预警
|
|
|
{
|
|
|
- //查找是否原有的报警已存在
|
|
|
- int level = 0;// 预警
|
|
|
+ std::lock_guard<mutex> lock(pService->m_mtxAlarm);
|
|
|
+ for (const auto& alarm : pService->m_lstUnConfirmAlarm)
|
|
|
{
|
|
|
- std::lock_guard<mutex> lock(pService->m_mtxAlarm);
|
|
|
- for (const auto& alarm : pService->m_lstUnConfirmAlarm)
|
|
|
+ if (alarm->no == (uint8_t)posi && alarm->type == eZL_ALARMTYPE::RETENSION_FORCE
|
|
|
+ && level == alarm->level && alarm->recoveryTime.wYear < 2000 //预警和报警单独计算
|
|
|
+ && alarm->mo.compare(mo) == 0 && alarm->mp.compare(mp) == 0)
|
|
|
{
|
|
|
- if (alarm->no == (uint8_t)posi && alarm->type == eZL_ALARMTYPE::RETENSION_FORCE
|
|
|
- && level == alarm->level && alarm->recoveryTime.wYear < 2000 //预警和报警单独计算
|
|
|
- && alarm->mo.compare(mo) == 0 && alarm->mp.compare(mp) == 0)
|
|
|
- {
|
|
|
- pAlarmInfo = alarm;
|
|
|
- break;
|
|
|
- }
|
|
|
+ pAlarmInfo = alarm;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (pAlarmInfo == nullptr)
|
|
|
- {
|
|
|
- bNew = true;
|
|
|
- pAlarmInfo = new ALARM_INFO;
|
|
|
- pAlarmInfo->event_id = hjfunc_GetGUID();
|
|
|
- pAlarmInfo->id = ++pService->m_nAlarmID;
|
|
|
- pAlarmInfo->level = level;// 预警
|
|
|
- pAlarmInfo->mo = mo;
|
|
|
- pAlarmInfo->mp = mp;
|
|
|
- pAlarmInfo->no = (uint8_t)posi;
|
|
|
- ctAlarmTime.GetAsSystemTime(pAlarmInfo->time);
|
|
|
- pAlarmInfo->time.wMilliseconds = show_time % 1000;
|
|
|
- pAlarmInfo->type = eZL_ALARMTYPE::RETENSION_FORCE;
|
|
|
- pAlarmInfo->val = show_val;
|
|
|
- pAlarmInfo->refer_val = alarm_refer;
|
|
|
- pAlarmInfo->posi = (posi == eSuoBiPosi::SB_FIX ? eDaoChaPosi::DCP_FIX : eDaoChaPosi::DCP_INVERT);
|
|
|
- pAlarmInfo->loworhigh = loworhigh;
|
|
|
- pAlarmInfo->zzjno = zzjno;
|
|
|
- pAlarmInfo->sunroof = CSkylightMng::GetInstance()->IsSkylight(&pAlarmInfo->time);
|
|
|
- char szInfo[200] = { 0 };
|
|
|
- sprintf_s(szInfo, sizeof(szInfo), "保持力异常报警,位置:%s, 报警值为%dN, 上一次值:%dN, 参考值为%dN",
|
|
|
- posi == eSuoBiPosi::SB_FIX ? "定位" : "反位", show_val, nOldVal, alarm_refer);
|
|
|
+ if (pAlarmInfo == nullptr)
|
|
|
+ {
|
|
|
+ bNew = true;
|
|
|
+ pAlarmInfo = new ALARM_INFO;
|
|
|
+ pAlarmInfo->event_id = hjfunc_GetGUID();
|
|
|
+ pAlarmInfo->id = ++pService->m_nAlarmID;
|
|
|
+ pAlarmInfo->level = level;// 预警
|
|
|
+ pAlarmInfo->mo = mo;
|
|
|
+ pAlarmInfo->mp = mp;
|
|
|
+ pAlarmInfo->no = (uint8_t)posi;
|
|
|
+ ctAlarmTime.GetAsSystemTime(pAlarmInfo->time);
|
|
|
+ pAlarmInfo->time.wMilliseconds = show_time % 1000;
|
|
|
+ pAlarmInfo->type = eZL_ALARMTYPE::RETENSION_FORCE;
|
|
|
+ pAlarmInfo->val = alarm_value;
|
|
|
+ pAlarmInfo->refer_val = alarm_refer;
|
|
|
+ pAlarmInfo->posi = (posi == eSuoBiPosi::SB_FIX ? eDaoChaPosi::DCP_FIX : eDaoChaPosi::DCP_INVERT);
|
|
|
+ pAlarmInfo->loworhigh = loworhigh;
|
|
|
+ pAlarmInfo->zzjno = pMoMpInfo->zzjno;
|
|
|
+ pAlarmInfo->sunroof = bSkylight;
|
|
|
+ char szInfo[200] = { 0 };
|
|
|
+ sprintf_s(szInfo, sizeof(szInfo), "保持力异常预警,位置:%s, 报警值为%dN, 上一次值:%dN, 参考值为%dN",
|
|
|
+ posi == eSuoBiPosi::SB_FIX ? "定位" : "反位", show_val, nOldVal, alarm_refer);
|
|
|
|
|
|
- pAlarmInfo->desc = szInfo;
|
|
|
- lock_guard<mutex> lock(pService->m_mtxAlarm);
|
|
|
- pService->m_lstUnConfirmAlarm.push_back(pAlarmInfo);
|
|
|
- }
|
|
|
+ pAlarmInfo->desc = szInfo;
|
|
|
+ lock_guard<mutex> lock(pService->m_mtxAlarm);
|
|
|
+ pService->m_lstUnConfirmAlarm.push_back(pAlarmInfo);
|
|
|
+ }
|
|
|
|
|
|
- //主动推送315
|
|
|
- if (bNew)
|
|
|
- {
|
|
|
- g_p315ClientManager->GetTcpClient()->SendAlarmData(zzjno, 1, CTime(pAlarmInfo->time).GetTime(), 0xFFFFFFFF,
|
|
|
- pAlarmInfo->type, posi == eSuoBiPosi::SB_FIX ? eDaoChaPosi::DCP_FIX : eDaoChaPosi::DCP_INVERT, pAlarmInfo->level, loworhigh,
|
|
|
- TIEDA_ACQ_VALUE(pAlarmInfo->val, TIEDA_VAL_STATE::TVS_AFTER_MOVE), TIEDA_ACQ_VALUE(pAlarmInfo->refer_val, TIEDA_VAL_STATE::TVS_AFTER_MOVE), 0);
|
|
|
- }
|
|
|
+ //主动推送315
|
|
|
+ if (bNew)
|
|
|
+ {
|
|
|
+ g_p315ClientManager->GetTcpClient()->SendAlarmData(pAlarmInfo->zzjno, 1, CTime(pAlarmInfo->time).GetTime(), 0xFFFFFFFF,
|
|
|
+ pAlarmInfo->type, posi == eSuoBiPosi::SB_FIX ? eDaoChaPosi::DCP_FIX : eDaoChaPosi::DCP_INVERT, pAlarmInfo->level, loworhigh,
|
|
|
+ TIEDA_ACQ_VALUE(pAlarmInfo->val, TIEDA_VAL_STATE::TVS_AFTER_MOVE), TIEDA_ACQ_VALUE(pAlarmInfo->refer_val, TIEDA_VAL_STATE::TVS_AFTER_MOVE), 0);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- if (bNew)
|
|
|
- {
|
|
|
- CString sql;
|
|
|
- sql.Format("INSERT INTO [rm_alarm]([ID],[mo],[mp],[no],[type],[occur_time],[level],[desc],[suggest],[val],[event_id],[rel_id],posi,loworhigh,referval,[sunroof]) "\
|
|
|
- "VALUES(%d, '%s', '%s', %d, %d, '%s', %d, '%s', '%s', %d, '%s', '%s',%d,%d,%d,%d);",
|
|
|
- pAlarmInfo->id, pAlarmInfo->mo.c_str(), pAlarmInfo->mp.c_str(), pAlarmInfo->no, pAlarmInfo->type,
|
|
|
- ctAlarmTime.Format("%Y-%m-%d %H:%M:%S"), pAlarmInfo->level, pAlarmInfo->desc.c_str(), pAlarmInfo->suggest.c_str(), pAlarmInfo->val,
|
|
|
- pAlarmInfo->event_id.c_str(), pAlarmInfo->rel_id.c_str(), uint8_t(pAlarmInfo->posi), uint8_t(pAlarmInfo->loworhigh), pAlarmInfo->refer_val,
|
|
|
- pAlarmInfo->sunroof);
|
|
|
+ if (bNew)
|
|
|
+ {
|
|
|
+ CString sql;
|
|
|
+ sql.Format("INSERT INTO [rm_alarm]([ID],[mo],[mp],[no],[type],[occur_time],[level],[desc],[suggest],[val],[event_id],[rel_id],posi,loworhigh,referval,[sunroof]) "\
|
|
|
+ "VALUES(%d, '%s', '%s', %d, %d, '%s', %d, '%s', '%s', %d, '%s', '%s',%d,%d,%d,%d);",
|
|
|
+ pAlarmInfo->id, pAlarmInfo->mo.c_str(), pAlarmInfo->mp.c_str(), pAlarmInfo->no, pAlarmInfo->type,
|
|
|
+ ctAlarmTime.Format("%Y-%m-%d %H:%M:%S"), pAlarmInfo->level, pAlarmInfo->desc.c_str(), pAlarmInfo->suggest.c_str(), pAlarmInfo->val,
|
|
|
+ pAlarmInfo->event_id.c_str(), pAlarmInfo->rel_id.c_str(), uint8_t(pAlarmInfo->posi), uint8_t(pAlarmInfo->loworhigh), pAlarmInfo->refer_val,
|
|
|
+ pAlarmInfo->sunroof);
|
|
|
|
|
|
- if (false == CDBConnectPool::Instance()->DBExecuteSQL(sql))
|
|
|
- CSimpleLog::Error("执行语句失败" + sql);
|
|
|
- else
|
|
|
- {
|
|
|
- uint8_t* pack = nullptr; int len = 0;
|
|
|
- auto packno = CResistAlarmMng::GeneralNewAlarmData(pAlarmInfo, &pack, &len);
|
|
|
- if (packno) CSuperManager::Instance()->SendPack(pack, len, packno, E_ZL_PROTOCAL::ZL_ALARM_DATA, true);
|
|
|
- delete[] pack;
|
|
|
- pack = nullptr;
|
|
|
- }
|
|
|
+ if (false == CDBConnectPool::Instance()->DBExecuteSQL(sql))
|
|
|
+ CSimpleLog::Error("执行语句失败" + sql);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ uint8_t* pack = nullptr; int len = 0;
|
|
|
+ auto packno = CResistAlarmMng::GeneralNewAlarmData(pAlarmInfo, &pack, &len);
|
|
|
+ if (packno) CSuperManager::Instance()->SendPack(pack, len, packno, E_ZL_PROTOCAL::ZL_ALARM_DATA, true);
|
|
|
+ delete[] pack;
|
|
|
+ pack = nullptr;
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //恢复
|
|
|
{
|
|
|
- //恢复
|
|
|
+ std::lock_guard<mutex> lock(pService->m_mtxAlarm);
|
|
|
+ for (auto it = pService->m_lstUnConfirmAlarm.begin(); it != pService->m_lstUnConfirmAlarm.end();)
|
|
|
{
|
|
|
- std::lock_guard<mutex> lock(pService->m_mtxAlarm);
|
|
|
- for (auto it = pService->m_lstUnConfirmAlarm.begin(); it != pService->m_lstUnConfirmAlarm.end();)
|
|
|
+ auto pAlarm = *it;
|
|
|
+ if (pAlarm->no == (uint8_t)posi && pAlarm->type == eZL_ALARMTYPE::RETENSION_FORCE && pAlarm->recoveryTime.wYear < 2000 //预警和报警单独计算
|
|
|
+ && pAlarm->mo.compare(mo) == 0 && pAlarm->mp.compare(mp) == 0)
|
|
|
{
|
|
|
- auto pAlarm = *it;
|
|
|
- if (pAlarm->no == (uint8_t)posi && pAlarm->type == eZL_ALARMTYPE::RETENSION_FORCE && pAlarm->recoveryTime.wYear < 2000 //预警和报警单独计算
|
|
|
- && pAlarm->mo.compare(mo) == 0 && pAlarm->mp.compare(mp) == 0)
|
|
|
+ pAlarmInfo = pAlarm;
|
|
|
+ if (pAlarmInfo)
|
|
|
{
|
|
|
- pAlarmInfo = pAlarm;
|
|
|
- if (pAlarmInfo)
|
|
|
- {
|
|
|
- //恢复
|
|
|
- //1. 更新数据库
|
|
|
- //2. 更新内存数据
|
|
|
- //3. 上送恢复消息
|
|
|
- if (ctAlarmTime.GetTime() == 0) ctAlarmTime = CTime::GetCurrentTime();
|
|
|
- string recovery_time = ctAlarmTime.Format("%Y-%m-%d %H:%M:%S");
|
|
|
- CString sql;
|
|
|
- sql.Format("UPDATE [rm_alarm] SET [recovery_time]='%s' WHERE ID = %d;", recovery_time.c_str(), pAlarmInfo->id);
|
|
|
- CDBConnectPool::Instance()->DBExecuteSQL(sql);
|
|
|
-
|
|
|
- if (pAlarmInfo->ack_result == 1)
|
|
|
- {
|
|
|
- it = pService->m_lstUnConfirmAlarm.erase(it);
|
|
|
- continue;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ctAlarmTime.GetAsSystemTime(pAlarm->recoveryTime);
|
|
|
- }
|
|
|
+ //恢复
|
|
|
+ //1. 更新数据库
|
|
|
+ //2. 更新内存数据
|
|
|
+ //3. 上送恢复消息
|
|
|
+ if (ctAlarmTime.GetTime() == 0) ctAlarmTime = CTime::GetCurrentTime();
|
|
|
+ string recovery_time = ctAlarmTime.Format("%Y-%m-%d %H:%M:%S");
|
|
|
+ CString sql;
|
|
|
+ sql.Format("UPDATE [rm_alarm] SET [recovery_time]='%s' WHERE ID = %d;", recovery_time.c_str(), pAlarmInfo->id);
|
|
|
+ CDBConnectPool::Instance()->DBExecuteSQL(sql);
|
|
|
|
|
|
- g_p315ClientManager->GetTcpClient()->SendAlarmData(zzjno, 2, CTime(pAlarmInfo->time).GetTime(), ctAlarmTime.GetTime(),
|
|
|
- pAlarmInfo->type, posi == eSuoBiPosi::SB_FIX ? eDaoChaPosi::DCP_FIX : eDaoChaPosi::DCP_INVERT, pAlarmInfo->level, pAlarm->loworhigh,
|
|
|
- TIEDA_ACQ_VALUE(pAlarm->val, TIEDA_VAL_STATE::TVS_AFTER_MOVE), TIEDA_ACQ_VALUE(pAlarm->refer_val, TIEDA_VAL_STATE::TVS_AFTER_MOVE), 0);
|
|
|
+ if (pAlarmInfo->ack_result == 1)
|
|
|
+ {
|
|
|
+ it = pService->m_lstUnConfirmAlarm.erase(it);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ctAlarmTime.GetAsSystemTime(pAlarm->recoveryTime);
|
|
|
}
|
|
|
+
|
|
|
+ g_p315ClientManager->GetTcpClient()->SendAlarmData(pAlarmInfo->zzjno, 2, CTime(pAlarmInfo->time).GetTime(), ctAlarmTime.GetTime(),
|
|
|
+ pAlarmInfo->type, posi == eSuoBiPosi::SB_FIX ? eDaoChaPosi::DCP_FIX : eDaoChaPosi::DCP_INVERT, pAlarmInfo->level, pAlarm->loworhigh,
|
|
|
+ TIEDA_ACQ_VALUE(pAlarm->val, TIEDA_VAL_STATE::TVS_AFTER_MOVE), TIEDA_ACQ_VALUE(pAlarm->refer_val, TIEDA_VAL_STATE::TVS_AFTER_MOVE), 0);
|
|
|
}
|
|
|
- it++;
|
|
|
}
|
|
|
+ it++;
|
|
|
}
|
|
|
- return;
|
|
|
-
|
|
|
}
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void CResistAlarmMng::JudgeAlarm1(CResistAlarmMng* pService, RETENSION_FORCE_DROP* pRetensionForceDropInfo, time_t show_time, int show_val,
|
|
|
+void CResistAlarmMng::JudgeAlarm3(CResistAlarmMng* pService, RETENSION_FORCE_DROP* pRetensionForceDropInfo, time_t show_time, int show_val,
|
|
|
eSuoBiPosi posi, string mo, string mp, uint32_t zzjno)
|
|
|
{
|
|
|
if (pRetensionForceDropInfo == nullptr || pRetensionForceDropInfo->enable == false) return;
|
|
|
@@ -2337,47 +2346,40 @@ void CResistAlarmMng::ThreadProcAlarmSet(DWORD_PTR param)
|
|
|
if ((eSuoBiPosi)item.second->no != eSuoBiPosi::SB_FIX && (eSuoBiPosi)item.second->no != eSuoBiPosi::SB_INVERT)
|
|
|
continue;
|
|
|
|
|
|
- int nPos = item.first.find('.');
|
|
|
- if (nPos == -1) continue;
|
|
|
- int nPos2 = item.first.find('.', nPos + 1);
|
|
|
- if (nPos2 == -1) continue;
|
|
|
- string mo = item.first.substr(0, nPos);
|
|
|
- string mp = item.first.substr(nPos + 1, nPos2 - nPos - 1);
|
|
|
- string momp = item.first.substr(0, nPos2);
|
|
|
+ string momp = item.second->momp;
|
|
|
+ if (momp.empty())
|
|
|
+ {
|
|
|
+ int nPos = item.first.find('.');
|
|
|
+ if (nPos == -1) continue;
|
|
|
+ int nPos2 = item.first.find('.', nPos + 1);
|
|
|
+ if (nPos2 == -1) continue;
|
|
|
+ string mo = item.first.substr(0, nPos);
|
|
|
+ string mp = item.first.substr(nPos + 1, nPos2 - nPos - 1);
|
|
|
+ momp = item.first.substr(0, nPos2);
|
|
|
+ }
|
|
|
|
|
|
auto pInfo = CMonitorObjectMng::Instance()->GetMoMpInfo(momp);
|
|
|
- //SPDLOG_INFO("[保持力下降]{} {}", momp, (bool)pInfo);
|
|
|
- //ASSERT(pInfo && pInfo->pDeivce);
|
|
|
if (pInfo == nullptr) continue;
|
|
|
if (pInfo->pDeivce == nullptr) continue;
|
|
|
|
|
|
auto pAlarmSet = (RETENSION_FORCE_DROP*)item.second;
|
|
|
- if (pAlarmSet->tmLastCheckTime == pInfo->pDeivce->m_ctUpdateTime.GetTime()) continue;//不重复检测
|
|
|
- pAlarmSet->tmLastCheckTime = pInfo->pDeivce->m_ctUpdateTime.GetTime();
|
|
|
-
|
|
|
auto pMap0 = pInfo->pDeivce->GetStatInfo(pInfo->idx, 0);
|
|
|
auto pMap1 = pInfo->pDeivce->GetStatInfo(pInfo->idx, 1);
|
|
|
- //auto pMap2 = pInfo->pDeivce->GetStatInfo(pInfo->idx, 0);
|
|
|
+ if (pMap0->size() < 2) continue;
|
|
|
+
|
|
|
+ if (pAlarmSet->tmLastCheckTime >= pMap0->rbegin()->first) continue;//不重复检测
|
|
|
+ pAlarmSet->tmLastCheckTime = pMap0->rbegin()->first;
|
|
|
+
|
|
|
std::map<time_t, tagSecondStatInfo>* pMap = nullptr;
|
|
|
|
|
|
if (((eSuoBiPosi)pAlarmSet->no == eSuoBiPosi::SB_FIX && pInfo->name1.find("定位") != -1) ||
|
|
|
((eSuoBiPosi)pAlarmSet->no == eSuoBiPosi::SB_INVERT && pInfo->name1.find("反位") != -1))
|
|
|
{
|
|
|
- if (pMap0 == nullptr || pMap0->size() < 3) {
|
|
|
- //SPDLOG_INFO("[保持力下降]{}.{} {} 未满足检测条件. {} ", mo, mp,
|
|
|
- // (eSuoBiPosi)pAlarmSet->no == eSuoBiPosi::SB_FIX ? "定位" : "反位", pMap0->size());
|
|
|
- continue;
|
|
|
- }
|
|
|
pMap = pMap0;
|
|
|
}
|
|
|
else if(((eSuoBiPosi)pAlarmSet->no == eSuoBiPosi::SB_FIX && pInfo->name2.find("定位") != -1) ||
|
|
|
((eSuoBiPosi)pAlarmSet->no == eSuoBiPosi::SB_INVERT && pInfo->name2.find("反位") != -1))
|
|
|
{
|
|
|
- if (pMap1 == nullptr || pMap1->size() < 3) {
|
|
|
- //SPDLOG_INFO("[保持力下降]{}.{} {} 未满足检测条件. {} ", mo, mp,
|
|
|
- // (eSuoBiPosi)pAlarmSet->no == eSuoBiPosi::SB_FIX ? "定位" : "反位", pMap1->size());
|
|
|
- continue;
|
|
|
- }
|
|
|
pMap = pMap1;
|
|
|
}
|
|
|
else
|
|
|
@@ -2397,28 +2399,27 @@ void CResistAlarmMng::ThreadProcAlarmSet(DWORD_PTR param)
|
|
|
auto it = pMap->end();
|
|
|
auto it0 = --it;
|
|
|
auto it1 = --it;
|
|
|
- auto it2 = --it;
|
|
|
if (momp.compare(g_strMoMp) == 0)
|
|
|
- SPDLOG_INFO("[保持力下降]{}.{} 波动值. {} {} {}", mo, mp, it2->second.dif_val, it1->second.dif_val, it0->second.dif_val);
|
|
|
- if (it0->second.dif_val < 100 && it1->second.dif_val < 100 && it2->second.dif_val < 100)
|
|
|
+ SPDLOG_INFO("[保持力下降]{} 波动值. {} {}", momp, it1->second.dif_val, it0->second.dif_val);
|
|
|
+ if (it0->second.dif_val < 200 && it1->second.dif_val < 200 /*&& (it0->first - it1->first) > 2*/)
|
|
|
{
|
|
|
- nMinVal = it0->second.max_val;
|
|
|
- tMinTime = it0->second.max_time;
|
|
|
+ nMinVal = it0->second.min_val;
|
|
|
+ tMinTime = it0->second.min_time;
|
|
|
if (it1->second.max_val > nMinVal)
|
|
|
{
|
|
|
- nMinVal = it1->second.max_val;
|
|
|
- tMinTime = it1->second.max_time;
|
|
|
- }
|
|
|
- else if (it2->second.max_val < nMinVal)
|
|
|
- {
|
|
|
- nMinVal = it2->second.max_val;
|
|
|
- tMinTime = it2->second.max_time;
|
|
|
+ nMinVal = it1->second.min_val;
|
|
|
+ tMinTime = it1->second.min_time;
|
|
|
}
|
|
|
+ //else if (it2->second.max_val < nMinVal)
|
|
|
+ //{
|
|
|
+ // nMinVal = it2->second.min_val;
|
|
|
+ // tMinTime = it2->second.min_time;
|
|
|
+ //}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
if (nMinVal != INT_MAX)
|
|
|
- JudgeAlarm(pService, pAlarmSet, tMinTime, nMinVal, (eSuoBiPosi)pAlarmSet->no, pInfo->mo, pInfo->mp, pInfo->zzjno);
|
|
|
+ JudgeAlarm(pService, pAlarmSet, tMinTime, nMinVal, (eSuoBiPosi)pAlarmSet->no, pInfo->mo, pInfo->mp, pInfo);
|
|
|
}
|
|
|
|
|
|
//清理无效位置
|
|
|
@@ -2933,7 +2934,7 @@ void CResistAlarmMng::ThreadProcMove(DWORD_PTR param)
|
|
|
CResistAlarmMng::InsertToDBByMove(mo, mp, it.first, 0, 0,
|
|
|
(int)it.second, show_val, i, (uint8_t)eDaoChaPosi::DCP_FIX, (uint8_t)ePowerName::PN_RETENTION, fmt::format("保持力:{}", show_val));
|
|
|
|
|
|
- JudgeAlarm(pService, pFixConstRetensionForceWaveInfo, it.first, show_val, eSuoBiPosi::SB_FIX, mo, mp, pMompInfo->zzjno, pMompInfo);
|
|
|
+ JudgeAlarm(pService, pFixConstRetensionForceWaveInfo, it.first, show_val, eSuoBiPosi::SB_FIX, mo, mp, pMompInfo);
|
|
|
}
|
|
|
|
|
|
for (auto& it : maxlock1)
|
|
|
@@ -2951,7 +2952,7 @@ void CResistAlarmMng::ThreadProcMove(DWORD_PTR param)
|
|
|
CResistAlarmMng::InsertToDBByMove(mo, mp, it.first, 0, 0,
|
|
|
(int)it.second, show_val, i, (uint8_t)eDaoChaPosi::DCP_INVERT, (uint8_t)ePowerName::PN_RETENTION, fmt::format("保持力:{}", show_val));
|
|
|
|
|
|
- JudgeAlarm(pService, pInvertConstRetensionForceWaveInfo, it.first, show_val, eSuoBiPosi::SB_FIX, mo, mp, pMompInfo->zzjno, pMompInfo);
|
|
|
+ JudgeAlarm(pService, pInvertConstRetensionForceWaveInfo, it.first, show_val, eSuoBiPosi::SB_FIX, mo, mp, pMompInfo);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -2973,7 +2974,7 @@ void CResistAlarmMng::ThreadProcMove(DWORD_PTR param)
|
|
|
CResistAlarmMng::InsertToDBByMove(mo, mp, it.first, 0, 0, (int)it.second, show_val, i,
|
|
|
(uint8_t)eDaoChaPosi::DCP_INVERT, (uint8_t)ePowerName::PN_RETENTION, fmt::format("保持力:{}", show_val));
|
|
|
|
|
|
- JudgeAlarm(pService, pInvertConstRetensionForceWaveInfo, it.first, show_val, eSuoBiPosi::SB_INVERT, mo, mp, pMompInfo->zzjno);
|
|
|
+ JudgeAlarm(pService, pInvertConstRetensionForceWaveInfo, it.first, show_val, eSuoBiPosi::SB_INVERT, mo, mp, pMompInfo);
|
|
|
}
|
|
|
|
|
|
for (auto& it : maxlock1)
|
|
|
@@ -2991,7 +2992,7 @@ void CResistAlarmMng::ThreadProcMove(DWORD_PTR param)
|
|
|
CResistAlarmMng::InsertToDBByMove(mo, mp, it.first, 0, 0, (int)it.second, show_val, i,
|
|
|
(uint8_t)eDaoChaPosi::DCP_FIX, (uint8_t)ePowerName::PN_RETENTION, fmt::format("保持力:{}", show_val));
|
|
|
|
|
|
- JudgeAlarm(pService, pFixConstRetensionForceWaveInfo, it.first, show_val, eSuoBiPosi::SB_FIX, mo, mp, pMompInfo->zzjno, pMompInfo);
|
|
|
+ JudgeAlarm(pService, pFixConstRetensionForceWaveInfo, it.first, show_val, eSuoBiPosi::SB_FIX, mo, mp, pMompInfo);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -3212,6 +3213,7 @@ BOOL CResistAlarmMng::LoadAlarmSet()
|
|
|
pInfo->f_alarm_high_limit = f_alarm_high_limit;
|
|
|
pInfo->f_warn_high_limit = f_warn_high_limit;
|
|
|
pInfo->tmLastCheckTime = time;
|
|
|
+ sprintf_s(pInfo->momp, 20, "%s.%s", mo, mp);
|
|
|
|
|
|
stringstream ss;
|
|
|
ss << mo << '.' << mp << '.' << to_string(no) << '.' << to_string(type);
|
|
|
@@ -3278,6 +3280,7 @@ BOOL CResistAlarmMng::LoadAlarmSet()
|
|
|
pInfo->dw_alarm_high_limit = dw_alarm_high_limit;
|
|
|
pInfo->dw_warn_high_limit = dw_warn_high_limit;
|
|
|
pInfo->tmLastCheckTime = time;
|
|
|
+ sprintf_s(pInfo->momp, 20, "%s.%s", mo, mp);
|
|
|
|
|
|
stringstream ss;
|
|
|
ss << mo << '.' << mp << '.' << to_string(no) << '.' << to_string(type);
|
|
|
@@ -3297,6 +3300,7 @@ BOOL CResistAlarmMng::LoadAlarmSet()
|
|
|
pInfo->warn_low_limit = yyjson_get_int(yyjson_obj_get(root, "warn_low_limit"));
|
|
|
pInfo->alarm_high_limit = yyjson_get_int(yyjson_obj_get(root, "alarm_high_limit"));
|
|
|
pInfo->warn_high_limit = yyjson_get_int(yyjson_obj_get(root, "warn_high_limit"));
|
|
|
+ sprintf_s(pInfo->momp, 20, "%s.%s", mo, mp);
|
|
|
|
|
|
stringstream ss;
|
|
|
ss << mo << '.' << mp << '.' << to_string(no) << '.' << to_string(type);
|
|
|
@@ -3318,6 +3322,7 @@ BOOL CResistAlarmMng::LoadAlarmSet()
|
|
|
pInfo->dw_warn_low_limit = yyjson_get_int(yyjson_obj_get(root, "dw_warn_low_limit"));
|
|
|
pInfo->up_alarm_high_limit = yyjson_get_int(yyjson_obj_get(root, "up_alarm_high_limit"));
|
|
|
pInfo->up_warn_high_limit = yyjson_get_int(yyjson_obj_get(root, "up_warn_high_limit"));
|
|
|
+ sprintf_s(pInfo->momp, 20, "%s.%s", mo, mp);
|
|
|
|
|
|
stringstream ss;
|
|
|
ss << mo << '.' << mp << '.' << to_string(no) << '.' << to_string(type);
|
|
|
@@ -3336,6 +3341,9 @@ BOOL CResistAlarmMng::LoadAlarmSet()
|
|
|
|
|
|
pInfo->enable = yyjson_get_bool(yyjson_obj_get(root, "enable"));
|
|
|
pInfo->dw_alarm_low_drop = yyjson_get_int(yyjson_obj_get(root, "dw_alarm_low_drop"));
|
|
|
+ pInfo->alarm_high_percent = yyjson_get_int(yyjson_obj_get(root, "alarm_high_percent"));
|
|
|
+ pInfo->alarm_low_percent = yyjson_get_int(yyjson_obj_get(root, "alarm_low_percent"));
|
|
|
+ sprintf_s(pInfo->momp, 20, "%s.%s", mo, mp);
|
|
|
|
|
|
stringstream ss;
|
|
|
ss << mo << '.' << mp << '.' << to_string(no) << '.' << to_string(type);
|
|
|
@@ -3359,7 +3367,9 @@ BOOL CResistAlarmMng::LoadAlarmSet()
|
|
|
else
|
|
|
{
|
|
|
auto pInfo = new RETENSION_FORCE_DROP;
|
|
|
- Insert(it.second->mo, it.second->mp, (uint8_t)eSuoBiPosi::SB_FIX, (uint8_t)eZL_ALARMTYPE::RETENSION_FORCE, pInfo);
|
|
|
+ pInfo->no = (uint8_t)eSuoBiPosi::SB_FIX;
|
|
|
+ sprintf_s(pInfo->momp, 20, "%s.%s", it.second->mo.c_str(), it.second->mp.c_str());
|
|
|
+ Insert(it.second->mo, it.second->mp, pInfo->no, (uint8_t)eZL_ALARMTYPE::RETENSION_FORCE, pInfo);
|
|
|
}
|
|
|
|
|
|
if (Find(it.second->mo, it.second->mp, (uint8_t)eSuoBiPosi::SB_INVERT, eZL_ALARMTYPE::RETENSION_FORCE))
|
|
|
@@ -3369,7 +3379,9 @@ BOOL CResistAlarmMng::LoadAlarmSet()
|
|
|
else
|
|
|
{
|
|
|
auto pInfo = new RETENSION_FORCE_DROP;
|
|
|
- Insert(it.second->mo, it.second->mp, (uint8_t)eSuoBiPosi::SB_INVERT, (uint8_t)eZL_ALARMTYPE::RETENSION_FORCE, pInfo);
|
|
|
+ pInfo->no = (uint8_t)eSuoBiPosi::SB_INVERT;
|
|
|
+ sprintf_s(pInfo->momp, 20, "%s.%s", it.second->mo.c_str(), it.second->mp.c_str());
|
|
|
+ Insert(it.second->mo, it.second->mp, pInfo->no, (uint8_t)eZL_ALARMTYPE::RETENSION_FORCE, pInfo);
|
|
|
}
|
|
|
}
|
|
|
|