TagSelect Class

From SysCAD Documentation
(Redirected from Tag Select Class)
Jump to navigation Jump to search

Navigation: PGMs ➔ Classes ➔ TagSelect Class

Global Pre-Defined Class Instances SysCAD Pre-Defined Classes
Sp Database
SDB Class
Particle Size Defn
PSD Class
Plant Model
PM Class
Array
Class
StrArray
Class
Matrix
Class
TagSelect
Class
Time
Class
Noise
Class

Latest SysCAD Version: 19 March 2024 - SysCAD 9.3 Build 139.35102

Related Links: Defining a Class, Example PGM Files


Description

The TagSelect class, provides a member function to retrieve a list of model tags meeting a SQL type select query, similar to the Excel Tag Select Reports. A list of all SubType tags, for example reaction blocks, can be returned.

The main Exec function is used to perform the query. The OrderBy cannot be specified, the tags returned will be in ascending order. The other functions can then be used to find the results of the query.

The query is a computationally expensive function and is not intended to be carried out every iteration. It is best carried out once per run, such as during initialisation or termination of the model solution using the Trigger Subroutines.

Data Members

None

Member Functions

Call Functionality Return Type Parameters
Exec(Criteria,WithGraphic,WithUnitType)

This is the main function call.

Bit

  • Criteria is a string variable which contains the query criteria (SQL "Where" clause)
  • WithGraphic is a bit variable to indicate if the graphic will be included in the results
  • WithUnitType is a bit variable to indicate if the unit type will be included in the results
GetLen()

The number of items found by the query.

Integer

None

Size()

The number of items found by the query.

Integer

None

Tag(Index)

The Tag of the query result corresponding to the specified Index.

String

Index is an integer variable, valid values are 0 to the result of (GetLen()-1)

Graphic(Index)

The Graphic (flowsheet) for the query result corresponding to the specified Index.

String

Index is an integer variable, valid values are 0 to the result of (GetLen()-1)

UnitType(Index)

The UnitType of the query result corresponding to the specified Index.

String

Index is an integer variable, valid values are 0 to the result of (GetLen()-1)

StatusString()

The status of the query:

  • "OK" if successfully completed
  • Blank if not performed
  • Error message if problem with Criteria

String

None

CriteriaString()

The query criteria returned as a string.

String

None

GetValues(VariableTag, ValueArray)
  • Sets the contents of ValueArray are based on VariableTag provided.
  • The length of ValueArray is always set to number of items found by the TagSelect.Exec function call (which is equal to TagSelect.GetLen() function).
  • The number returned is the count of found full tags and may be equal or less than the array length.
  • If less then this means that the specified full tag is not found for one or more of the entries.
  • For the entries corresponding to invalid tags the corresponding result value in the returned ValueArray is zero.

Long

VariableTag is a String.

  • This variable tag is combined with the Returned Unit Tag to form a valid SysCAD Tag.
  • The tag will start with a dot, e.g.: ".QProd.Qm (t/h)"

ValueArray is an Array

  • The array is used to store values for all tags meeting the Exec Function call criteria.

Examples

Simple examples for calling the tag select functions in the above table:

TagSelect TS
Array Flows
OK = TS.Exec("[UnitType] == 'Pipe-1'", true, false)
ResultState = TS.StatusString()
CriteriaUsed = TS.CriteriaString()
TagCount = TS.GetLen()
TheTag = TS.Tag(i)
TheGraphicPage = TS.Graphic(i)
TheUnitType = TS.UnitType(i)
FoundCount = TS.GetValues(".QProd.Qm (t/h)", Flows)

GetValue Function Examples

These examples uses the GetValue function call for the mass summation calculations.

Steady-State Project Mass Balance

The following examples show how the Tag Select Class could be used to perform a simple mass balance in a steady-state project.

Dynamic Project Mass Balance

The following example shows how the Tag Select Class could be used to perform a simple mass balance in a dynamic project. The main difference to the steady-state mass balance shown above is that is needs to take account of material in surges and tears (in dynamic, tears can have surge).

Species Mass Balance

See How to perform a Species Mass Balance

See also Example PGM - Species Check for how to check if the species is used in the project.

Elemental Mass Balance

See How to perform an Elemental Mass Balance

Mass Balance per Flowsheet

To perform a mass balance per flowsheet, the logic would be identical to the Project Mass Balance above except the Criteria statements would change to something similar to the following:

  • "(([UnitType]=='FeederSink' AND ([State]==1 OR [State]==3)) OR [UnitType]=='MakeupSource') AND [Graphic]=='Page1'"
  • "[UnitType]=='FeederSink' AND ([State]==2 OR [State]==4) AND [Graphic]=='Page1'"

Notes:

  1. These criteria will capture both connected and disconnected feeders and sinks.
  2. This assumes that Makeup Sources are only used on the flowsheets they themselves are on.
  3. The Page name of each flowsheet (Page1, Page2, etc.) can be found on the Plant Model-Flowsheets tab page. Alternatively, the full flowsheet name could be used e.g. [Graphic]=='05_Flowsheet'