First Up Alarm


Recommended Posts

I have 9 possible alarms that are each valued 0 if the alarm is not set and 1 if it is.

I would like them to display in a list such that the first one to alarm will be at the top of the list and the second below this and so on. As and when a particular alarm condition clears then the lower entries in the list will move up to fill the empty space of the cleared alarm. There is a text caption (currently an array of strings) with each element of the array holding the particular alarm caption and I would also like to display the time that the alarm became set to 1.

I have experimented with the alarms of DaqFactory but cannot get these to do what I want. I have no need to acknowledge an alarm nor can it be reset by the operator as it is purely a value sent from the remote equipment (via a serial input every second)

Any help would be appreciated!

Thanks

Link to comment
Share on other sites

well, you probably don't want the built in alarm feature. You just need an array of strings containing the alarms. The time will be associated when you set it. To add a newly fired alarm, just do:

alarmlist.append("my alarm")

to remove one and have everything shift do:

for (private i = 0, i < numrows(alarmlist), i++)
   if (alarmlist[i] == alarmtodelete)
	  alarmlist.removeat(i)
	  break
   endif
endfor

Link to comment
Share on other sites

Thanks for that.

I found as my data is coming in every second that alarmlist kept on growing whilst the alarm was active so I changed the alarmlist.append to be a sequence similar to the delete alarm code loop:

Private Found = 0
For(Private Index = 0, Index < NumRows(AlarmList), Index++)
	If(AlarmList[Index] == ThisAlarm)
	   // Alarm already in list so just update the time
	   AlarmList.Time[Index] = SysTime()
	   Found = 1
	EndIf
EndFor
If(Found == 0)
   // Alarm not yet in list so append it
   AlarmList.Append(ThisAlarm)
EndIf

This seems to work ok.

I tried the sequence as a Function passing the string ThisAlarm {AddAlarm(ThisAlarm)}but it appended NaN to the list so presumably one can only pass numbers to a Function Sequence? I'm now using a Global string ThisAlarm and that works ok with BeginSeq(AddAlarm)

My list as displayed on the screen is a vertical column of 9 variable value components having AlarmList[0] in the top one through to AlarmList[8] in the bottom one. That works ok as when AlarmList is empty nothing is displayed and as the list fills, the individual elements display. I have added an extra vertical column of Variable value components (beside the first column) with:

FormatDateTime("%a %d %b %H:%M:%S", AlarmList.Time[n]) in each of them and this shows the time that the alarm was set or updated but when the list is empty the variable shows as a zero crossed out. Is there a way to blank this empty list condition? I assume I could replace the failing formatted empty timestamp with a single space using some boolean arithmatic but I'm not sure how.

Looking forward to the release of Version 6!

Link to comment
Share on other sites

Yes, I was only explaining how to add to the end. You could replace your loop with the search() function. It would run much faster and be a bit cleaner to read.

Why not use a table control instead of a bunch of variable value components?

As for making it disappear, us the iif() statement:

iif(alarmlist.time[n] == 0, "", formatdatetime(...))

Finally, yes you can pass strings into functions, you just have to declare it as a string in the function prototype:

function foo(string myparam)

instead of a number:

function foo(myparam)

DAQFactory only has two data types, but you have to tell it which one you want! Otherwise you end up with problems like in javascript where 1+1 sometimes equals 11 not 2.

Link to comment
Share on other sites

Archived

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