LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

alarm handling

Solved!
Go to solution

 I have a problem that I have a alarm log and I want to sort and count them. I dont understand that how can I count each alarm and sort the whole list. Please give med suggestions. Below is the attached file of alarm log. 

0 Kudos
Message 1 of 5
(2,718 Views)

Your file is a simple tab-delimited text file. It is already sorted by the S.Nr column, so I presume that is not what you meant.  Do you want to sort by the Sluttidspunkt column?

 

You can read it with the Read from Spreadsheet File.vi and get a 2D array of strings. LabVIEW has a built-in function for sorting a 1D array, but that cannot be used directly.  If you re-arrange the 2D array so that the column on which you want to sort becomes column zero, then there are some ways that may work. One is to create a 1D array of clusters where each cluster contains a 1D array of strings from a row of the re-arranged 2D array. Then use Sort 1D Array on that array of clusters. If necessary, reverse the previous column re-arrangement to restore the original column order but retaining the sorted row order.

 

The other approach is similar except convert the row arrays to a Spreadsheet String and make a 1D array of these strings.  Sort that array, then convert back to 2D array if needed.

 

Note that the sorts may not be identical in the two cases because of the way the sort will process data after the first column.

 

Lynn

0 Kudos
Message 2 of 5
(2,702 Views)

Thank you Lynn but how may I count each alarm? I want to know that how many times each alarm is pesent in the list? Sllutttidspunkt column is actually alarms tags. 

In the programm attached, I tried to count each alarm but I have to search in the list manually. Programm should be smart that it should automatically give me the number of occurance in the list.

My answer should look like:

 

Tag                                   No. of occurance

 

1H2_PUMP04_KMD          1  times

1H2     -P5_14_ST             3 times

1H3     -TK5_7_B4_PRV    33 times

0 Kudos
Message 3 of 5
(2,687 Views)
Solution
Accepted by topic author Alarmhandling

Counting the number of occurences of each unique tag is slightly more complicated.

 

First, sort the array of tags. This will group all of the values to be counted together.

 

Next place each element into a shift register and compare the current element to the previous one. When they are equal, increment the count. When not equal, reset the count and update the Counts and Tags arrays.

 

Note that I disabled the Read from file and made a control of the Alarms Log indicator to simplify testing.  Since I have only one alarm log, I had no need to repeatedly read it from the file.  You can restore the file read to process other logs.

 

Lynn

0 Kudos
Message 4 of 5
(2,669 Views)

Thank you Lynn

0 Kudos
Message 5 of 5
(2,643 Views)