Applies To:
  • CitectSCADA 5.40

Summary:
Discussion on %N and %R operators as well as the new %N+ operator.  These operators are used for drivers which require the variable.dbf record index to allow them to retrieve the actual tag record.

%N ensures that the variable.dbf record number is placed in the address values passed to the driver. By default, Citect tries to block tags together . So the following tag definitions

TAG TYPE UNIT RECORD
PUMP1 INT 2000 10
PUMP2 INT 2000 11
PUMP3 INT 2000 12

are likely to result in a blocked read of 3 items, with

ADDR 10 UNIT 2000 COUNT 3

For these type of drivers, this is not desirable.  This is where the %R operator comes in, it adds the record number to the address field, effectively disabling compiler blocking and yielding %N%R will yield

 

ADDR 10 UNIT 2010 COUNT 1

ADDR 11 UNIT 2011 COUNT 1

ADDR 12 UNIT 2012 COUNT 1

However, the %N operator is prone to incorrect blocking when a general template is used, much as

(in driver.DBF)

%N%! INT 1000

%N%! REAL 2000

%N%! LONG 3000

In this case it is possible that tags of different data types will be blocked together . It is also possible to generate redundant requests for data based on the address value of the tag.

 

Solution:
The %N+ operator solves both these problems. It tells the compiler to group items together ONLY if the TAG data type matches the data type in the template file.  Thus using %N+ is recommended, even with the %R operator.  An issue to remember when trying to block tag references together is that it is possible to get blocking wrong for your requirements, e.g.
 
TAG TYPE UNIT RECORD
ABC100 INT 1000 51
ABC200 INT 1000 51
ABC300 INT 1000 52
DEF100 INT 1000 53
DEF200 INT 1000 54
ABC400 INT 1000 55
ABC500 INT 1000 56

 

%N or %N+ is likely to result in a count of 7 at ADDR 50, which is fine if these are the same, but if ABCxxx needs to be handled differently to DEFxxx, you need to ensure they have different UNIT values.  To ensure all tags to be blocked are correctly, arrange tags to be contiguous in the variable tag database.  In this case EXCEL can be used to insert tags into the project when new tags are required.

Citect only adds tags to the end of the database.

NB: Ensure you save any EXCEL DBF files in DBF III format.

 

Keywords:
 

Attachments