Applies To:
  • CitectSCADA 5.01, 5.10, 5.20

Summary:
I'm calling a Cicode function in the Alarm Desc field of an Advanced Alarm which returns a string. The function gets called but only 2 characters are displayed. What is the problem and how can I fix it? 

Solution:
The problem here is Citect does not know what the format of the return value from the function is, so we have to trick Citect into thinking that it is 255 characters. To do this you can configure a variable tag of the STRING datatype and use this variable in the Alarm Desc field. This String tag is going to be null and will be concatenated to the function return value. For example:

Configure the following Variable Tag:

Variable Tag Name: DummyStringTag
Data Type: STRING
I/O Device: Memory_Dev
Address: s100

Associate it to a memory device and leave it null, unless you wish to concatenate a string to the beginning of the Alarm Description. Then configure the Advanced Alarm and Alarm Category forms as follows:

Advanced Alarm:

Alarm Tag: AdvAlm1
Alarm Name: My Advanced Alarm
Alarm Desc: {DummyStringTag + GetStringFunction()}
Expression: Code > 0
Category 2

Alarm Category:

Category Number: 2
Alarm Off Font (Unacknowledged):
AlmUnAccOffFont
Alarm Off Font (Acknowledged):
AlmAccOffFont
Alarm On Font (Unacknowledged):
AlmUnAccOnFont
Alarm On Font (Acknowledged):
AlmAccOnFont
Summary Format: {OnDate,15}^t {OnTime,15}^t{SumDesc,40}

Note - You must use the "SumDesc" Alarm Display Field and not "Desc".

Cicode Function:

String
Function
GetStringFunction()
    String sMessage;

    SELECT CASE Code

    CASE 1   sMessage = "Message 1";
    CASE 2   sMessage = "Message 2";
    CASE Else   sMessage = "Message 3";

END SELECT

Return sMessage;

End

This will log the appropriate description on the alarm summary page based on the value of the tag named Code.

Note: String formatters can also be used - ie. {MyFunc():12} - if 12 characters are needed. This removes the need for declaring dummay variables.

See also KB Article Q2383

 

Keywords:
 

Attachments