Alarms - displaying string (text description) in a table

Recommended Posts

I want to display a text string corresponding to an alarm value in a table of alarms.

It all works fine with numeric data but how do I convert the value to a "descriptive text" value in a table?

It seems that VChannels do not accept string values?

It seems that there is no function to convert the value to a "descriptive value" in a table.

If this is logged to a separate file, how do I read this data back in to a table?

How do I open a file and read the fields and display them?


Link to comment
Share on other sites

Not sure exactly what you are doing, but you can use either a string variable:

global string alarmlist

or a Test channel with I/O type String

Reading data back is done using the File. functions, especially, file.readdelim() and file.close(). These are all documented in the logging chapter of the help.

Link to comment
Share on other sites

OK, thanks.

When using - Test channel with I/O type String to write the descriptive text associated with the alarm value.... (That's OK)

I want to display that new "Test" channel's data in to a table. Displaying the string / data is OK, .... how do I display the Time from that "Test" channel also so that the table now has a time and a string value as the two columns?

Currently I am writing the time of the original alarm event (as per one of the examples - "AlarmStatusTable.ctl") to a vChannel in a format but that seems like a complication to get something that is automatically written in to this new "Test" channel. The precise time is not critical so if there is a millisecond or so between the real time of the event and the time that the Test channel inserts it is good enough.

Link to comment
Share on other sites

Follow on from the reply post a short while ago....

If I use this...

FormatTime("%Y / %b / %d %a - %H:%M:%S" , Alarm_Description.Time)

to try to get the "Time" field to display it gives a blank, if I take out all the time formatting part and just have


it lists the time only in a standard format.

What have I got wrong here?

I want - year, month, date, day hr, min,sec as the time.


Link to comment
Share on other sites

OK, I seem to have grasped how to put my alarms descriptions in to Channels and display them in a table.

Since it is possible for the Channels to get flushed inadvertantly - e.g. a PC crash etc. I want to go to logging and reading to an external file. I can log to it OK and it contains the correct data. (I am still putting data into VChannel and Channel for now so I can see what things should be like).

I'm afraid I have no idea what the logic is with the Read part of this Sequence - the Channel that is supposed to "read" and "store" the data from the file(?????!!! - is that what happens??) ends up duplicating and some - hence it has too much data.

There are two or so loops in the sequence so it is very likely that this is causing it.

Can you please help me to get the logic correct w.r.t. the "READ" part of the sequence - if that is the only issue.



// change this to the descriptions & values for the alarm - this is a test channel so it goes -ve +ve
  case (Var.ChannelValue[0] > 0.98)
	Alarm_Description = "High water"
  case (Var.ChannelValue[0] > 0.94)
	Alarm_Description = "Low water"
  case (Var.ChannelValue[0] > 0.93)
	Alarm_Description <= "2nd Low"
	Alarm_Description = "High High water"

V.strTimeFired = FormatDateTime("%Y/%b/%d; %a - %H:%M:%S",Alarm.WaterLevelAlarm.TimeFired)
// Open File and get handle

//we write to an external file
Private FileHandle = File.Open("C:\Modscan\Files\WaterLevelAlarms.csv",0,1,1,1)

// Format string

Private string strText = FormatTime(Alarm_Description.Time[0]) + "," + (Alarm_Description[0])

// Write data to text file


// Close the file


// here we read the file contents into Channel Alarm_Description_File - this seems to be where the plot falls apart?

// Opens the file sets the variable FileHandle
Private FileHandle = File.Open("C:\Modscan\Files\WaterLevelAlarms.csv",1,0,0,1)
Private string strIn
while (1)
  // read a line
  strIn = File.Read(FileHandle)
  // This checks for an empty string
  if(strIn == "")
	 // Breaks out if empty string
  // This code Parses the String and sets the output channel
  Alarm_Description_File = (Parse(strIn,1,","))

  // Reads 1 second at a time
  delay (1)
// Closes the file

// Call the function to acknowledge all alarms. I don't need to acknowledge & reset alarms - just log the trigger
// Sets the variable back to 0 after the alarms has been reset
Var.AlarmReset_1 = 0

Link to comment
Share on other sites

I don't get why you are reading in the same loop?

First, use a logging set to log the channel. That is much easier and it will do everything for you.

Next, the only time you need to read back is when your application boots, so use a start up sequence to read the data in once and prefill the channel. Make sure you don't start the logging set until after you've read from the current log so the read doesn't get rewritten to the log.

Link to comment
Share on other sites


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