Alarm table filter


Daggos

Recommended Posts

Hi 

I have found this script for displaying alarms in a table which is working perfectly but i would like to also filter the rows out by group as well.

This is the sequence

========================================================

Global ALARM_DISPLAY_MANAGER_RUN_TIME
private ALARM_DISPLAY_MANAGER_RUN_TIME_START

Global Alm_Activos
Global Alm_ActivosNum
Global string AlmDateFormat = "%Y-%m-%d %H:%M:%S"
Global NumRowsTodos_Alm = 0

private Alm_Activos_NSort
private Alm_NActivos_NSort

private string Todos_Alm
private string strAlmIter
private AlmIter
private iter = 0


private i = 0
private k = 0
private n = 0
private string m

private sort = 0

class Alm
   local string AlmName
   local AlmFired
   local AlmAck
   local AlmPriority  
   local AlmTimeFired
   local string strAlmDesc
   
   local string strAlmTimeFired
   local string AlmEstado
   
   local string strAlmDescArray
   
   function CopyFrom(string obfrom)
      AlmName = obfrom
      Execute("AlmFired = Alarm."+AlmName+".Fired")
      Execute("AlmAck = Alarm."+AlmName+".Acked")
      Execute("AlmPriority = Alarm."+AlmName+".Priority")
   endfunction
   
   function ParseEstado()     
      Execute("AlmTimeFired = Alarm."+AlmName+".TimeFired")
      Execute("strAlmDesc = Alarm."+AlmName+".strDescription")
      strAlmTimeFired = FormatDateTime(AlmDateFormat,AlmTimeFired)
      strAlmDescArray = Parse(strAlmDesc,-1,";")
      if(AlmFired)
         AlmEstado = "Alarming"
      else
         AlmEstado = "Reset"
      endif
   endfunction
endclass


Todos_Alm = Alarm.ListAll()

while(1)
   try()
      
   ALARM_DISPLAY_MANAGER_RUN_TIME_START = systime() 
   
   Alm_Activos_NSort.ClearHistory()
   Alm_NActivos_NSort.ClearHistory()
   
   if(NumRows(Todos_Alm)!=NumRowsTodos_Alm)
      Todos_Alm = Alarm.ListAll()
   endif
   NumRowsTodos_Alm = NumRows(Todos_Alm)
   iter = 0
   while (iter<NumRowsTodos_Alm)
      strAlmIter = Todos_Alm[iter]
      AlmIter = new(Alm)
      AlmIter.CopyFrom(strAlmIter)
      
   
      if(AlmIter.AlmPriority==4 && (AlmIter.AlmFired || (!AlmIter.AlmFired && !AlmIter.AlmAck)))
        
         AlmIter.ParseEstado()
         if(AlmIter.AlmFired)
            Alm_Activos_NSort.Append(AlmIter)
         else
            Alm_NActivos_NSort.Append(AlmIter)
         endif
      endif
      iter=iter+1
   endwhile
   
   sort = 0
   
   if(sort == 1)
      n = NumRows(Alm_Activos_NSort)
      for( i = 1,i<n,i++)
       for (k = i, k > 0 && (Alm_Activos_NSort[k].AlmTimeFired > Alm_Activos_NSort[k-1].AlmTimeFired), k--)
            m = Alm_Activos_NSort[k-1]
            Alm_Activos_NSort[k-1]=Alm_Activos_NSort[k]
            Alm_Activos_NSort[k] = m
         endfor
      endfor

      n = NumRows(Alm_NActivos_NSort)
      for( i = 1,i<n,i++)
         for (k = i, k > 0 && (Alm_NActivos_NSort[k].AlmTimeFired > Alm_NActivos_NSort[k-1].AlmTimeFired), k--)
            m = Alm_NActivos_NSort[k-1]
            Alm_NActivos_NSort[k-1]=Alm_NActivos_NSort[k]
            Alm_NActivos_NSort[k] = m
         endfor
      endfor
   endif
  
   n = NumRows(Alm_NActivos_NSort)
   for( i = 0,i<n-1,i++)
      Alm_Activos_NSort.Append(Alm_NActivos_NSort)
   endfor
   
   
   Alm_Activos = Alm_Activos_NSort
   Alm_ActivosNum = NumRows(Alm_Activos)
   ALARM_DISPLAY_MANAGER_RUN_TIME = systime() - ALARM_DISPLAY_MANAGER_RUN_TIME_START
   catch()
   endcatch()
   delay(1)
endwhile

 

 

==================

Below are the table components

Alm_Activos.strAlmTimeFired

Alm_Activos.strAlmDescArray[0]

Alm_Activos.strAlmDescArray[1]

Alm_Activos.AlmEstado

 

========================

to display the group in separate column alarm description is as follows

Pump Station 2; L1 ELR Alarm;

or 

Pump Station 1; L1 ELR Alarm;

======================

So in the tables i want to only display group Pump Station 1 and a different table for Pump Station 2

Thanks for any help im hoping its a simple extra if statement

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.