Database functions#

Following functions are available in IEC programs for point database access.

AlarmAckF#

AlarmAckF(Mode := 0, intParameter := 0, strParameter := '')#

Acknowledging alarms from IEC program.

Parameters:
  • Mode (INT) –

    • 0 - All points

    • 2 - Named point, tag name in strParameter

    • 3 - Named alarm group, group name in strParameter

    • 4 - Priority in intParameter

    • 32 - All alarm points will be swiched to AUTO

    You can also add to mode:

    • 100 - Only counts unacknowledged alarms without acknowledging them.

    • 200 - Only counts active alarms without acknowledging them.

    Deprecated since version 14.0.0: See /substation/security

    • 1 - All but security points (Still return same as 0)

    • 20 - All security points

    • 21 - Security group, index in intParameter

    • 30 - All security alarm points will be swiched to AUTO

    • 31 - All security alarm points in security group intParameter will be swiched to AUTO

  • intParameter (INT) –

  • strParameter (STRING) –

Return type:

INT

Returns:

Number of unacknowledged alarms

Example:

Get all active alarms without acknowledging them

active_alarms := AlarmAckF(Mode := 200, intParameter := 0, strParameter := '');
Example:

Acknowledge all alarms if some point is active

ack_all := GetDigitalPointF('ACK_ALL_ALARMS');
IF (ack_all != 0) THEN
    ret := AlarmAckF(Mode := 0, intParameter := 0, strParameter := '');
END_IF

ConversionTableFB#

ConversionTableFB()#

IEC program can read or edit conversion table parameters.

Note

All values in lookup table are always sorted by ValueFrom (unused are at the end of list). This means that for example, if IEC edits ValueFrom on index 10 to be less than the value on index 9, on next read index the values have changed places.

Parameters:
  • Index (INT - input) – Value from 0-14 to read/change corresponding pair in lookup table. Value 100 refers to offset. Note! some values might not be used in range of 0-14. They will be referred to as “unused” value in this manual.

  • Write (INT - input) – Set to 0 for reading (default) and 1 for writing. If writing to unused index, the index will become used.

  • ValueFrom (REAL - input/output) – Contains the value that will be converted from (measured value). Does nothing if Index is 100 (offset) or if ValueTo is set to -9999.0 when writing.

  • ValueTo (REAL - input/output) – Contains the value that will be converted to (converted value). Contains/writes offset if Index is 100 (offset). Write with value -9999.0 to delete (set to unused) given Index

  • Name (string(30) - input) – Pointname of lookup table

  • Error (INT - output) –

    • 0 - Everything OK

    • -1 - Invalid index

    • -2 - Unused, but valid index (when reading)

    • -9999 - Lookup table doesn’t exist

Example:

This example read the first value pair/entry from Conversion table named ‘POINT_CONVTABLE’ and then writes a new values to the converted value, but not where it’s converted from.

VAR
    ConversionTable :ConversionTableFB;
END_VAR

ConversionTable(Index:=0, Name:='POINT_CONVTABLE');
IF ConversionTable.Error = 0 THEN
    ConversionTable.ValueTo:=10.0;
    ConversionTable(Index:=0,Write:=1, Name:='POINT_CONVTABLE');
END_IF;

GetConversionTableF#

GetConversionTableF(Value := 12.34, Name := 'POINT_NAME')#

Converts Value using conversion table Name. If table does not exist return Value.

Parameters:
  • Value (REAL) –

  • Name (STRs) –

Return type:

REAL

Returns:

Converted value.

Example:

Convert some analog_point with NTC10.

TE10 := GetAnalogValueF(Name := 'TE10_M');
TE10 := GetConversionTableF(Value := TE10, Name := 'NTC10');

GetDigitalPointF#

GetDigitalPointF(Name := 'POINT_NAME')#

If point is not found from database return value is -9999.

Note only difference between this and GetAnalogPointF is that they return different type. Control point is an exception, GetDigitalPointF returns state of point, GetAnalogPointF returns set value of point.

Parameters:

Name (STR) –

Return type:

INT

Returns:

Value of point

Example:

Get point value point

switch10 := GetDigitalPointF(Name := 'SWITCH10_DI');

SetDigitalPointF#

GetAnalogPointF#

GetAnalogPointF(Name := 'POINT_NAME')#

If point is not found from database return value is -9999.0.

Note only difference between this and GetDigitalPointF is that they return different type. Control point is an exception, GetDigitalPointF returns state of point, GetAnalogPointF returns set value of point.

Parameters:

Name (STR) – Name of point

Return type:

REAL

Returns:

Value of point

Example:

Get point value point

sun := GetAnalogPointF(Name := 'SUN_M');

SetAnalogPointF#

GetLimitF#

GetLimitF(LimitNumber:=1, Name:='POINT_NAME')#

Get value or lockstate of limit of named point. Get lockstate of limit by adding 10 to LimitNumber.

Parameters:
  • LimitNumber (INT) – Index of limit

  • Name (STRING(30)) – Name of point

Return type:

INT

Returns:

Value or lockstate of limit

If point not found return -9999. Different lockstates see GetLockstateF.

Example:

Get limit value 2 from point ‘POINT_M’

temp_limit := GetAnalogPointF(LimitNumber:=2, Name:='POINT_M');

SetLimitF#

GetLimitF(LimitNumber:=1, Value:=0.0, LockState:=1, Name:='POINT_NAME')#
Parameters:
  • LimitNumber (INT) – Index of limit

  • Value (REAL) –

  • LockState (INT) –

    • 0 = Tries to set limit to Auto state.

    • 1 = Tries to set limit to Program state, this is most commmon value.

    • 2 = Forces limit to Manual state.

    • 3 = Forces limit from Manual state to Auto state.

    Note

    Note that only when LockSate is 1 or 2 the value of limit is changed, otherwise Value parameter is meaningless (it have to be defined anyway).

  • Name (STRING(30)) – Name of point

Return type:

INT

Returns:

  • 0 = Point found

  • 1 = Point not found

Example:

Get limit value 2 from point ‘POINT_M’

temp_limit := GetAnalogPointF(LimitNumber:=2, Name:='POINT_M');

GetLockstateF#

GetLockstateF(Name:='POINT_NAME')#

Get lockstate of named point.

If you want lockstate of limit use GetLimitF.

Parameters:
  • LimitNumber (INT) – Index of limit

  • Name (STRING(30)) – Name of point

Return type:

INT

Returns:

Value or lockstate of limit

  • 0 = Auto

  • 1 = Program

  • 2 = Manual

  • -9999 = Point not found

If point is an unacknowledged alarm then 10 is added to above value

Example:

Use with alarm point

VAR
    Result : INT;
    LockState : INT;
    UnAcknowledged : INT;
END_VAR

Result := GetLockStateF(Name:='SOME_ALARM');
(* After using MOD operator value of 'LockState' is 0/1/2 *)
LockState := Result MOD 10;
(* After divide operation value of 'UnAcknowledged ' is 0/1 *)
UnAcknowledged := Result / 10;

GetPointErrorF#

GetPointErrorF(Name:='POINT_NAME')#

Read error state of point.

Note

Communication fail of global point may be used for monitoring condition of network and another substation.

Parameters:

Name (STRING(30)) – Name of point

Return type:

INT

Returns:

Point error state

  • 0 = No error

  • -9992 = Configuration or communication error at BACnet point

  • -9993 = Communication fail at SNMP point

  • -9994 = Invalid point number (e.g. point number 15 at AI8 module)

  • -9995 = Configuratoin error at point

  • -9996 = Sensor fail at AI point

  • -9997 = Communcation fail at global point

  • -9998 = Module error at physical point

  • -9999 = Point not found

GetTimeEventFB#

GetTimeEventFB(DayOfWeek:=0, EventNumber:=0, Name:='POINT_NAME')#

With this function block it is possible to write a program where some operations are executed at desired time before time schedule event. For example you can start cooling an hour before opening of office.

Parameters:
  • DayOfWeek (INT) –

    At call DayOfWeek= 100 if event of ‘today’ is searched, with other values (1..12) event of that day is fetched. After call DayOfWeek is day number of possibly found event.

    Note

    Calendar may force ‘today’ to be other than today in real time.

  • EventNumber (INT) – At call EventNumber= 100 if event following current time is searched, with other values (1..6) that event is fetched. After call EventNumber is number of possibly found event.

  • Name (STRING(30)) – Name of point

  • DataValid (INT - output) –

    • -1 = Schedule or event not found

    • 0 = Valid

  • CurrentState (INT - output) – If schefule is found holds state of time schedule.

  • State (INT - output) – State of event

  • Hours (INT - output) –

  • Minutes (INT - output) –

  • HoursLeft (REAL - output) –

    Difference of event time and current time in hours

  • MinutesLeft (INT - output) – Difference of event time and current time in minutes

Example:
VAR
    TimeEvent : GetTimeEventFB;
END_VAR

TimeEvent(DayOfWeek:=100, EventNumber:=100, Name:='AnyTimeSchedule');

IF TimeEvent.DataValid = 1 AND TimeEvent.HoursLeft < 2.5 AND TimeEvent.State=1 THEN
    (* Do something 2 hours 30 minutes before time schedule is changing to state 1 *)
    ;
END_IF;

GetControlPointFB#

GetControlPointFB(Name:='POINT_NAME')#
Parameters:
  • Name (STRING(30)) – Name of point

  • Stage1 (REAL - output) –

  • Stage2 (REAL - output) –

  • Stage3 (REAL - output) –

  • Stage4 (REAL - output) –

  • Stage5 (REAL - output) –

  • Stage6 (REAL - output) –

Example:
VAR
    ControlTE1 : GetControlPointFB;
    stage1, stage2 : REAL;
END_VAR

ControlTE1(Name:='PointName');

IF ControlTE1.Stage1 > 0.0 THEN
    ;
END_IF;

GetControlParameterF#

GetControlParameterF(Mode:=0, Name:='POINT_NAME')#

Return selected value from point. See Mode parameters in SetControlParameterF

SetControlParameterF#

SetControlParameterF(Mode:=0, Value:=0.0, LockState:=0 Name:='POINT_NAME')#

TODO