Alarm Custom1 property string data fails to display on graphics page.

Hello.

In my project I want some static alarm property information to be displayed on graphics pages.
Our static information is written as strings in the alarms table fields "Alarm Desc" and "Comment" properties.
Displaying the information in the "Alarm Desc" property performs well using a string expression like "AlarmTag.Desc" on the graphics page.

For some reason, displaying the string value in the property "Comment" by putting the string expression "AlarmTag.Comment" on the graphics page fails. The error message "Some variable tags were not found" shows up. Seems that the "Comment" property is not supported for access on the graphics page.

So in order to display the information in the "Comment" field on a graphics page I tried to copy the string in this field into the "Custom1" field and put the string expression "AlarmTag.Custom1" on my graphics page but nothing appears on the graphics page at runtime. Neither information or error code, simply nothing.

Can somebody enlighten this issue?

  • Hi ,

    I don't think the comment property is supported as an alarm property you would be able to view on a graphic page, see the help on the supported properties "System Model > Alarms > Using Alarm Properties as Tags > Supported Alarm Properties" As for the Custom1 set the [Alarm]UseConfigLimits=1 in your ini file.

    If you don't mind me asking what's the use case for displaying a static alarm property on a graphic page, I have made the broad assumption that this is not a normal alarm page you talking about?

  • Hi Jan,

    In runtime the Comment field has to be referenced as "AlmComment" because the "Comment" property is used for user defined comment that can be added to an alarm in runtime.

    Your custom1 field information may not appear until you delete the alarm database. This is the case if the custom information was added after the alarm has already been triggered once or more. Upon triggering an alarm the static fields are imported in the runtime alarm database and are not updated automatically. There is also a parameter (which I don't recall right now) that changes this behaviour.

    Cheers,
    Patrick
  • Hei
    Thank you Richard for testing, I also found the information on which properties can be referenced in the help file, leading to try the Custom1 field approach.
    The reason to display this static information is to have some information on the alarm actions on a popup we have made for setting the corresponding alarm limits. It would have been nice to display the same information on these popups as shown in the different included alarm table views without having to copy the information between the different fields/properties.

    I have another question related to the same issue.
    When displaying the string "AlarmTag.Desc" on the graphics page it is a lot of options for formatting the text but I can't find a way to break a long text into several lines. I am looking for the possibility to define a field with fixed width and then "word wrap" the string inside this field.
    The only tool I find that can help is to manually insert a lineshift ^n in the string, but this will not look very nice when output on the standard included alarm views.
  • Another option is to use the AlmBrowse functions to read the alarm comment. It is designed to be callable directly from graphics objects. You would have to call AlmBrowseOpen from the On Page Entry event (in the page properties). You specify to filter for the exact tag you want, then store the handle returned in a local variable or page variable. Then, call AlmBrowseFirst() to select the first (and only) result. On your graphic object, you'd call AlmBrowseGetField to read the COMMENT or ALMCOMMENT field.

    There are built in functions to calculate text width, like StrCalcWidth and StrTruncFontHnd, but they're more suited to truncating text to fit the screen than to  wrapping lines. So, here's a function I wrote for adding ^N to a text string to wrap it every so many characters.

    //Adds carriage returns to the specified text string at the specified intervals, to the nearest word. Text is truncated
    //at the max number of rows, if specified, and "..." is appended.
    //
    //Modified
    //5/11/04		E.Black		Original
    //
    //sText			Text string to wrap
    //iMaxColumns	Max number of characters per line
    //iMaxRows		Max number of rows of text (default is -1 for unlimited rows)
    //
    //Returns the text string with carriage returns is returned.
    //
    STRING
    FUNCTION
    Wrap(STRING sText, INT iMaxColumns, INT iMaxRows = -1)
    
    	STRING sOutput;
    	STRING sWord;
    	STRING sLine;
    	INT iRow = 1;
    	
    	WHILE sText <> "" DO
    		sWord = StrWord(sText);
    		
    		IF (StrLength(sLine) + StrLength(sWord) + 1) <= iMaxColumns THEN
    
    			IF sLine <> "" THEN
    				sLine = sLine + " " + sWord;
    			ELSE
    				sLine = sWord;
    			END
    
    		ELSE
    			IF iRow <> iMaxRows THEN
    
    				IF sOutput <> "" THEN
    					sOutput = sOutput + "^n" + sLine;
    				ELSE
    					sOutput = sLine;
    				END
    				
    				sLine = sWord;
    				iRow = iRow + 1;
    
    			ELSE
    
    				sOutput = sOutput + "^n" + sLine;
    				sOutput = StrLeft(sOutput, StrLength(sOutput) - 3) + "...";
    				RETURN sOutput;
    			END
    		END
    	END
    	
    	IF sLine <> "" THEN
    		IF sOutput <> "" THEN
    			sOutput = sOutput + "^n" + sLine;
    		ELSE
    			sOutput = sLine;
    		END
    	END
    	
    	RETURN sOutput;
    END
    
  • Hi


    As highlighted by once i added the [Alarm]UseConfigLimits=1 ini file parameter it now works for the Custom1 Field (besides the "AlmComment" one ).Will edit my response as well.

    The hacky way you could get around the Alarm Comment if you really really really want to and can't find a native alternative to work then you can copy the Alarm Comment  to Custom2. Not the best as this is essentially duplication and then having the onus on a person to make sure whenever they update/add an alarm to also copy the comment to Custom2 https://softwareforums.aveva.com/cfs-file/__key/system/emoji/1f914.svg

  • StrToLines() is similar and seems simple. However, it has 2 limitations: (1) It writes the line count to a Cicode variable which you must pass to the function. So, you can't call it directly from a graphics object's display expression. You'd have to write a wrapper Cicode function to call it. (2) It has no limit for the number of lines of text it creates. If you have a small box on the screen to display a string in, StrToLines will keep you from overflowing the width of the box, but will not prevent you from overflowing the height. My function allows you to set the max number of lines of text and it adds "..." to the end if it has to truncate text to fit.
    It might have been simpler for my function to just call StrToLines() to do the splitting, and if too many lines were returned, then search for the nth newline character and truncate the string. If I was rewriting it, I'd probably use StrCalcWidth() to get the right width according to the text displayed and the font used. For example: capital letters and symbols are usually wider than lower case or punctuation, so wrapping at a hard-coded number of characters may not display correctly unless you use a monospace font like Courier New.