Setting and Reporting Tags from text files

From SysCAD Documentation
Jump to navigation Jump to search

Navigation: User Guide ➔ Menu Commands ➔ Tools ➔ Command Scripts ➔ Setting and Reporting Tags from text files

Related Links: Command Line Options, Excel Reports


Introduction

SysCAD tags can be set from and reported to text files. Available from Build 138.26203. This provides an alternative to Excel COM Automation for efficiently getting/setting tags. The advantage of this is significant speed up in setting tags and reporting tags. A disadvantage (as compared to Excel) is no formatting will be stored.

Currently this functionality is only available through use of Command Scripts using commands SetTags and ReportTags.

Setting Tags from text files

Set a list or table of tags in a text file to the specified values. The command script command for this is SetTags(Format, Filename).

For the text file (Filename), the first row of the file is reserved for headings. Any rows starting with ";" in the text file are ignored. The SysCAD tags must exist. Engineering units may be specified. Available formats are:

  1. Format set to TagList. The file should be a csv formatted file, first column contains full tag, second column contains required value.
  2. Format set to TagTable: The file should be a csv formatted file, first row contains primary tags separated by commas, subsequent rows contain secondary tag followed by required values separated by commas.

See Example 1 for more detail.

Reporting Tags to text files

Reports a list or table of tags in a text file, based on a template file which contains the tags and options. The command script command for this is ReportTags(Format, Templatefile, Filename).

The template file should be a csv formatted file, but could have any extension and can be edited in any text editor (do not need to use Excel). Any rows in the template file starting with ";" are ignored. The SysCAD tags must exist. Engineering units may be specified. An output file (Filename), separate to the template file is created and populated based on the format and settings in the template file. Available formats are:

  1. Format set to TagList: The first row of the template file is reserved for headings, the first column containing a list of full tags. The output file will contain the tags in the first column and the reported values in the second column.
  2. Format set to TagTable: This is similar to Excel Tag Table Reports. The template file may have 4 possible keywords on any line in any sequence.
    • Tags (required): a comma separated list of the primary tags for the table.
    • DataTags (required): a comma separated list of the secondary tags for the table. Conversion units can optionally be specified with the tag. When missing, SysCAD SI Units are used.
    • DataLabels (optional): a comma separated list of descriptive headings for the data tags. This needs to match DataTags.
    • Options (optional): a comma separated list of options:
      • H or V primary tags to be horizontal or vertical
      • C or CnvLabels adds additional column/row of engineering conversion units
      • N or NoDataTags to not ouput the column/row of DataTags.
  3. Format set to TagSelectTable: Available from Build 139.31151. This is similar to Excel Tag Select Reports. The template file may would have 4 possible keywords on any line in any sequence.
    • TagSelect (required): a Where boolean expression, optional OrderBy expression. Please refer to Excel Tag Select Syntax Table for documentation on WHERE and ORDERBY expressions. For legacy compatibility, the keyword "Select" can be used instead of "Where".
    • DataTags (required): a comma separated list of the secondary tags for the table. Conversion units can optionally be specified with the tag. When missing, SysCAD SI Units are used.
    • DataLabels (optional): a comma separated list of descriptive headings for the data tags. This needs to match DataTags.
    • Options (optional): a comma separated list of options:
      • H or V primary tags to be horizontal or vertical
      • C or CnvLabels adds additional column/row of engineering conversion units
      • N or NoDataTags to not output the column/row of DataTags.
  4. Format set to TagSelectList: Available from Build 139.31151. The resulting output file is a list of tags meeting the criteria. The template file will requires one keyword.
    • TagSelect (required): a Where boolean expression, optional OrderBy expression. Please refer to Excel Tag Select Syntax Table for documentation on WHERE and ORDERBY expressions. For legacy compatibility, the keyword "Select" can be used instead of "Where".

See Example 1 for more detail.

Examples

Example 1 - Use command script to create reports in text file (csv) format

The workflow for text file reporting is as follows:

  1. create the input file for any tag to be set into SysCAD.
    • This is similar to the normal Excel Set Tag Report, useful for setting a list of values (such as the project criteria) into the model.
  2. create the template file for reporting values from SysCAD.
    • This is similar to the normal Excel Get Tag Report, useful for reporting a list or table of values.
    • This template file will not be replaced or updated by report generation, a new file will be created.
    • The template file can be stored within the project folder or any other folder.
    • If the file is not stored within the project folder, then subfolder or full folder path should be given.
  3. create the command script file that will instruct SysCAD to do the data transfer.
    • This is similar to the Excel automation step, except we are using command script.
    • User must specify the filename and location of the output file.
    • The output file will be auto-created from the template file provided.

Example of the above has been created for the Gold Example Project (added January 2021), a brief description of the files are given below:

Example Command Script File TestTagTransfer.ssc

;Example Command Script file for settag and gettag report in text file format
;
;== Example for setting a list or Table of Tags to SysCAD == Syntax is:   SetTags(format, filename)
 SetTags(TagList,     Reports\ModelCriteriaInput.csv)

;== Example for getting a list or Table of Tags from SysCAD == Syntax is:   ReportTags(format, templatefile, filename)
 ReportTags(TagList,  CommandScript\csvTemplate\ReportListCriteria.csv,      Reports\ModelCriteriaOutput.csv)
 ReportTags(TagTable, CommandScript\csvTemplate\ReportTableStreamReport.csv, Reports\StreamReport.csv)

Text file Set Tag List Report Example: ModelCriteriaInput.csv (partial)

Tag,Value
SLURRY_IN.QmReqd (t/h),40
Feed_ppm_Set.TC[1].User.Value,40
Feed_ppm_Set.TC[2].User.Value,500
SLURRY_IN.Content.DLockup.[Au(s)].LockupReqd (%),10
CARBON_IN.QmReqd (kg/h),292
CSTR.TankVolume,300

Text file Get Tag List Report Template Example: ReportListCriteria.csv (partial)

Tag
;Plant Feed Characteristics
;Ore Slurry Feed
P_001.Qm (t/h)
P_001.Qo.Calc.GoldinOre_ppm
P_001.Qo.Calc.CuinOre_ppm
P_001.Qo.Lockup.[Au(s)].LockedUp.Frac (%)

;Carbon Feed
P_010.Qm (kg/h)
  • first line is ignored, reserved for Tag
  • lines starting with semicolon ; are ignored, can use this to add in group headings
  • blank lines are allowed

Text file Get Tag Table Report Template Example ReportTableStreamReport.csv (partial)

Tags,P_001,P_002,P_003,P_004,P_005,P_006,P_007,P_008,P_009,P_010
DataTags,GenDesc,Qo.Qm (t/h),Qo.LQm (t/h),Qo.SQm (t/h),Qo.Qv (m^3/h),Qo.LQv (m^3/h),Qo.SQv (m^3/h),Qo.T (dC),Qo.P (bar),Qo.SF (%)
DataLabels,Description,Total,Liquid,Solids,Total @T,Liquid @T,Solids @ T,Temperature,Pressure,%Solids
Options,H,C,,,,,,,,
;Options,V,N,C,,,,,,,
  • Tags, DataTags, etc. are comma separated. Or simply create the file in MS Excel, then save as CSV (comma delimited) (*.csv) format.
  • Lines starting with semicolon ; are ignored.
  • Blank lines are allowed.
  • Options for Horizontal or Vertical table as per normal SysCAD TagTable reports.

Please see the full template files and report files in the Gold Project

  • Command Script file can be found in the \CommandScript subfolder
  • Template files can be found in the \CommandScript\csvTemplate subfolder
  • Report files can be found in the \report subfolder, with .csv file extension
    1. The "ModelCriteriaInput.csv" and "ModelCriteriaOutput.csv" files are based on the "Model Criteria" worksheet of the "Gold Model Criteria.xlsx" workbook.
    2. The "StreamReport.csv" file is based on the "Streams" worksheet of the "Gold Model Criteria.xlsx" report.

Example 2 - TagSelect format example

Command script example:

ReportTags(TagSelectTable, CommandScript\csvTemplate\ReportTagSelect.csv, Reports\TagSelectReport.csv)

Templatefile for TagSelectTable format

;TagSelect,Where [UnitGroup] == "Stream"
TagSelect,Where [UnitGroup] == "Stream",OrderBy [Tag]
DataTags,GenDesc,Qo.Qm (t/h),Qo.LQm (t/h),Qo.SQm (t/h),Qo.Qv (m^3/h),Qo.LQv (m^3/h),Qo.SQv (m^3/h),Qo.T (dC),Qo.P (bar),Qo.SF (%)
DataLabels,Description,Total,Liquid,Solids,Total @T,Liquid @T,Solids @ T,Temperature,Pressure,%Solids
Options,H,C
;Options,V,N,C