findOneByAedId($aed_id); $thr_proc = $serv_infl->getValue() == ServInfl::SI_THRAFF; if ($tasar && ! $thr_proc) throw new Exception("threshold value expected."); // process threshold alarms if ($thr_proc) { $obs_val = $serv_infl->getObsVal(); if ($tasar == null) { // create dummy tasar $tasar = new ThresholdAlarmSeverityAssignmentRule(); $tasar->setName("AutoGenerated"); $tasar->setAedId($aed_id); $tasar->setCntValClear(0); $tasar->setCntValWarn(0); $tasar->setCntValMin(0); $tasar->setCntValMaj(0); $tasar->setCntValCrit($obs_val); $tasar->save(); } if ($tasar->getCntValCrit() > $tasar->getCntValClear()) { // positive count direction if ($obs_val >= $tasar->getCntValCrit()) { $alm_sev = new AlarmSevty(AlarmSevty::AS_CRIT); } elseif ($obs_val >= $tasar->getCntValMaj()) { $alm_sev = new AlarmSevty(AlarmSevty::AS_MAJ); } elseif ($obs_val >= $tasar->getCntValMin()) { $alm_sev = new AlarmSevty(AlarmSevty::AS_MIN); } elseif ($obs_val >= $tasar->getCntValWarn()) { $alm_sev = new AlarmSevty(AlarmSevty::AS_WARN); } else { $alm_sev = new AlarmSevty(AlarmSevty::AS_CLEAR); } } else { if ($obs_val <= $tasar->getCntValCrit()) { $alm_sev = new AlarmSevty(AlarmSevty::AS_CRIT); } elseif ($obs_val <= $tasar->getCntValMaj()) { $alm_sev = new AlarmSevty(AlarmSevty::AS_MAJ); } elseif ($obs_val <= $tasar->getCntValMin()) { $alm_sev = new AlarmSevty(AlarmSevty::AS_MIN); } elseif ($obs_val <= $tasar->getCntValWarn()) { $alm_sev = new AlarmSevty(AlarmSevty::AS_WARN); } else { $alm_sev = new AlarmSevty(AlarmSevty::AS_CLEAR); } } return($alm_sev); } // default values of alarm severity depending on service influence switch ($serv_infl->getValue()) { case ServInfl::SI_INDEP: $alm_sev = new AlarmSevty(AlarmSevty::AS_MAJ); break; case ServInfl::SI_NONAFF: $alm_sev = new AlarmSevty(AlarmSevty::AS_MIN); break; case ServInfl::SI_AFF: $alm_sev = new AlarmSevty(AlarmSevty::AS_CRIT); break; default: throw new Exception("invalid service influence: $serv_infl"); } // search for matching alarm severity assignment rules ordered by precedence $asar_lst = AlarmSeverityAssignmentRuleQuery::create()->find(); $aes_lst = AssignmentEventSelectorQuery::create()->findByAedId($aed_id); $max_prec = 0; foreach ($asar_lst as $asar) { $asar_id = $asar->getId(); if ($asar->getEvtSelMode()->getValue() == SelectMode::SM_EXCL) { $prc_asar = TRUE; foreach ($aes_lst as $aes) { if ($aes->getAsarId() == $asar_id) { $prc_asar = FALSE; break; } } } else { $prc_asar = FALSE; foreach ($aes_lst as $aes) { if ($aes->getAsarId() == $asar_id) { $prc_asar = TRUE; break; } } } if ($prc_asar && ($prec = $asar->getPrecedence()) > $max_prec) { $max_prec = $prec; switch ($serv_infl->getValue()) { case ServInfl::SI_INDEP: $alm_sev = $asar->getSevServIndep(); break; case ServInfl::SI_NONAFF: $alm_sev = $asar->getSevServUnaff(); break; case ServInfl::SI_AFF: $alm_sev = $asar->getSevServAff(); break; default: throw new Exception("invalid service influence: $serv_infl"); } } } return($alm_sev); } } ?>