Applies To:
  • CitectSCADA
  • CitectHMI

Summary:
What is the difference between doing 'A=PT101' and 'A=TagRead("PT101")'
 

Solution:
When CICODE is compiled, all the tags directly used in the function are listed internally and on calling the function are requested from the IOServer.

'A=PT101' would therefore be automatically requested the value when the function starts.

'A=TagRead("PT101")' would not recognise PT101 as a tag and therefore the request would not occur until it gets to that line of code, and the function would wait (block) for the value to return.

The thing to be aware of in the 'A=PT101' case is the use of loops (eg : WHILE and FOR). As the tags are read at the start of the function call, if a loop is used, theoretically the tag would never be requested again and any changes would not be seen. To rectify this, simply perform a 'ReRead(0)' within the loop.

The main reason TagRead was created was so that it was possible to make generic functions that can discover a tag name at runtime and still get tag access.

E.g.

INT FUNCTION GetPTValue( sPTNumber = "101" )

    RETURN( TagRead( "PT" + sPTNumber ) );

END


Another factor to be aware of is that compiled tag requests allow CitectSCADA to 'Block' the request, thus making better utilisation of the communications bandwidth. TagRead("PT101") however, sends a request for a single tag directly to the IOServer, bypassing the compiled blocking CitectSCADA can provide and relying solely on the dynamic blocking from the IOServer.

Similarly, if you pass the value into a function [eg : MyFunction(PT101)] as opposed to passing in the tag name and using TagRead within the function [eg : MyFunction("PT101")] will allow the request to be blocked with others.

In summary, if the tag names are known, use direct tagnames where possible.

 

Keywords:
Cicode, TagRead, Loop, While, For 

Attachments