From OpenSCADAWiki
Jump to: navigation, search
Other languages:
Constr.png The translation checking and actualizing

Author: Roman Savochenko

Maxim Lysenko (2012) — the page translation

Before starting of programming into OpenSCADA you must learn a structure of objects of the program from the program manual of OpenSCADA. From the document you also will see that you can program next parts of OpenSCADA as the user:

User programming API is the tree of OpenSCADA objects, every object of which can provide own list of properties and functions. Properties and functions of the objects can be used by the user in procedures on the languages of user programming of OpenSCADA.

Currently OpenSCADA provides only one language of text programming that is JavaLikeCalc then you must learn it also before the starting! The entry point for access to the objects of OpenSCADA from user programming language JavaLikeCalc is the reserved word "SYS" of the root OpenSCADA object. For example, to access the function of outgoing transport you should write: SYS.Transport.Serial.out_ModBus.messIO(mess);.

API of the objects provided by the modules is described in the own documentation of the modules.

1 System-wide user objects

JavaLikeCalc provides the data type "Object" support. The data type "Object" is associated container of properties and functions. The properties can support data of fourth basic types and other objects. The access to properties is doing through the dot to object obj.prop and also by property placement into the rectangle brackets obj["prop"]. It is obvious that the first mechanism is static, while the second lets you to specify the name of the property through a variable. Object's properties removing you can perform by the operator "delete". Creating an object is carried by the keyword new: varO = new Object(). The basic definition of the object does not contain functions. Copying of an object is actually makes the reference to the original object. When you delete an object is carried out the reducing of the reference count, and when a reference count is set to zero then object is removed physically.

Different components can define basic object with special properties and functions. The standard extension of the object is an array "Array", which is created by the command varO = new Array(prm1,prm2,prm3,...,prmN). Comma-separated parameters are placed in the array in the original order. If the parameter is the only one the array is initiated by the specified number of empty elements. Peculiarity of the array is that it works with the properties as the indexes and the main mechanism of addressing is placing the index into square brackets arr[1] is accessible. Array stores the properties in its own container of the one-dimensional array. Digital properties of the array are used to access directly to the array, and the characters work as object properties. For more details about the properties and functions of the array can be read here.

The object of regular expression "RegExp" is created by command varO = new RegExp(pat,flg), where pat — pattern of regular expression, and flg — match flags. The object for work with regular expressions, based on the library "PCRE". In the global search set object attribute "lastIndex", which allows you to continue searching for the next function call. In the case of an unsuccessful search for the attribute "lastIndex" reset to zero. For more details about the properties and functions of the regular expression object can be read here.

For random access to the arguments of the functions provided the arguments object, which you can refer to by the symbol "arguments". This object contains the property "length" with a number of arguments in functions and allows you to access to a value of the argument by its number or ID. Consider the enumeration of the arguments on the cycle:

args = new Array();
for(var i=0; i < arguments.length; i++)
  args[i] = arguments[i];

The basic types have the partial properties of the object. Properties and functions of the basic types are listed below:

  • NULL type, functions:
    • bool isEVal(); — Return "true".
  • Logical type, functions:
    • bool isEVal(); — Check value to "EVAL".
    • string toString(); — Performs the value as the string "true" or "false".
  • Integer and real number:
Properties:
  • MAX_VALUE — maximum value;
  • MIN_VALUE — minimum value;
  • NaN — error value.
Functions:
  • bool isEVal(); — Check value to "EVAL".
  • string toExponential( int numbs = -1 ); — Return the string of the number, formatted in exponential notation, and with the number of significant digits numbs. If numbs is missing the number of digits will have as much as needed.
  • string toFixed( int numbs = 0, int len = 0, bool sign = false ); — Return the string of the number, formatted in the notation of fixed-point, and with the number of significant digits after the decimal point numbs for minimum length len and strong sign present sign. If numbs is missing the number of digits after the decimal point is equal to zero.
  • string toPrecision( int prec = -1 ); — Return the string of the formatted number with the number of significant digits prec.
  • string toString( int base = 10, int len = -1, bool sign = false ); — Return the string of the formatted number of integer type with the following representation base (2-36) for minimum length len and strong sign present sign.
  • String:
Properties:
  • int length — string length.
Functions:
  • bool isEVal(); — Check value to "EVAL".
  • string charAt( int symb ); — Extracts from the string the symbol symb, numbering from zero.
  • int charCodeAt( int symb ); — Extracts from the string the symbol code symb.
  • string concat( string val1, string val2, ... ); — Returns a new string formed by joining the values val1 etc. to the original one.
  • int indexOf( string substr, int start ); — Returns the position of the required string substr in the original row from the position start. If the initial position is not specified then the search starts from the beginning. If the search string is not found then "-1" is returned.
  • int lastIndexOf( string substr, int start ); — Returns the position of the search string substr in the original one beginning from the position of start when searching from the end. If the initial position is not specified then the search begins from the end. If the search string is not found then "-1" is returned.
  • int search( string pat, string flg = "" ); — Search into the string by pattern pat and pattern's flags flg. Return found substring position or "-1" for else.
var rez = "Java123Script".search("script","i");  // rez = 7
  • int search( RegExp pat ); — Search into the string by "RegExp" pattern pat. Return found substring position or "-1" for else.
var rez = "Java123Script".search(new RegExp("script","i"));  // rez = 7
  • Array match( string pat, string flg = "" ); — Call match for the string by pattern pat and flags flg. Return matched substring (0) and subexpressions (>0) array. Set "index" attribute of the array to substring position. Set "input" attribute to source string.
var rez = "1 plus 2 plus 3".match("\\d+","g");  // rez = [1], [2], [3]
  • Array match( TRegExp pat ); — Call match for the string and "RegExp" pattern pat. Return matched substring (0) and subexpressions (>0) array. Set "index" attribute of the array to substring position. Set "input" attribute to source string.
var rez = "1 plus 2 plus 3".match(new RegExp("\\d+","g"));  // rez = [1], [2], [3]
  • string slice( int beg, int end ); string substring( int beg, int end ); — Return the string extracted from the original one starting from the beg position and ending before the end (not included), numbering from zero. If the beginning or end is negative, then the count is conducted from the end of the line. If the end is not specified, then the end is the end of the line. For example, the construction substring(-2) return two last symbols of the string.
  • Array split( string sep, int limit ); — Return the array of strings separated by sep with the limit of the number of elements limit.
  • Array split( RegExp pat, int limit ); — Return the array of strings separated by RegExp pattern pat with the limit of the number of elements limit.
rez = "1,2, 3 , 4 ,5".split(new RegExp("\\s*,\\s*"));  // rez = [1], [2], [3], [4], [5]
  • string insert( int pos, string substr ); — Insert substring substr into this string's position pos.
  • string replace( int pos, int n, string str ); — Replace substring into position pos and length n to string str.
rez = "Javascript".replace(4,3,"67");  // rez = "Java67ipt"
  • string replace( string substr, string str ); — Replace all substrings "substr" to string "str".
rez = "123 321".replace("3","55");  // rez = "1255 5521"
  • string replace( RegExp pat, string str ); — Replace substrings by pattern pat to string str.
rez = "value = \"123\"".replace(new RegExp("\"([^\"]*)\"","g"),"``$1''"));  // rez = "value = ``123''"
  • real toReal(); — Convert this string to real number.
  • int toInt( int base = 0 ); — Convert this string to integer number in accordance with the base base (from 2 to 36). If base is 0, then the prefix will be considered a record for determining the base (123-decimal; 0123-octal; 0x123-hex).
  • string parse( int pos, string sep = ".", int off = 0 ); — Get token with number pos from the string when separated by sep and from offset off. Result offset is returned back to off.
  • string parseLine( int pos, int off = 0 ); — Get line number pos from the string and from offset off. Result offset is returned back to off.
  • string parsePath( int pos, int off = 0 ); — Get path token with number pos from the string and from offset off. Result offset is returned back to off.
  • string path2sep( string sep = "." ); — Convert path into this string to separated by sep string.
  • string trim( string cfg = " \n\t\r" ); — String trimming at begin and end for symbols cfg.


1.1 Array object

Peculiarity of the array is that it works with the properties like with the indexes, and complete their naming if senseless, and hence the mechanism of addressing is available only by the conclusion of the index in square brackets "arr[1]". Array stores the properties in its own container of one-dimensional array. Digital properties of the array are used to access directly to the array, and the characters work as object properties.

Array provides the special property "length" to get the array size "var = arr.length;". Also array provides the following functions:

  • string join( string sep = "," ), string toString( string sep = "," ), string valueOf( string sep = "," ) — Returns the string with the array elements separated by sep or the character ','.
  • Array concat( Array arr ); — Adds to the initial array the elements of the arr array. Returns the initial array with changes.
  • int push( ElTp var, ... ); — Places the element(s) var to the end of the array, as to the stack. Returns the new array size.
  • ElTp pop( ); — Deleting of the last element of the array and return of its value, as from the stack.
  • Array reverse( ); — Changing the order of the elements of the array. Returns the initial array with changes.
  • ElTp shift( ); — The shift of the array to the top. The first element is removed and its value is returned.
  • int unshift( ElTp var, ... ); — Shift element(s) var to the array. The first element to the 0, second to the 1 and so on.
  • Array slice( int beg, int end ); — Returns an array fragment from beg to end (exclude). If the value of beginning or end is negative, then the count is made from the end of the array. If the end is not specified, then the end is the end of the array.
  • Array splice( int beg, int remN, ElTp val1, ElTp val2, ... ); — Inserts, deletes or replaces the elements of the array. Returns the removed elements array. Firstly it is made the removing of elements from the position beg and in the quantity of remN, and then the values val1 are inserted and so on, beginning from the position beg.
  • Array sort( ); — Sort array elements in lexicographical order.

1.2 RegExp object

Object for work with regular expressions, based on the library PCRE. In the global search set object attribute "lastIndex", which allows you to continue searching for the next function call. In the case of an unsuccessful search for the attribute "lastIndex" reset to zero.

As arguments passed to create the object put string with the text of regular expression and flags as a string of characters:

  • 'g' — global match mode;
  • 'i' — case insensitive match mode;
  • 'm' — multi-line match mode;
  • 'u' — UTF-8 symbols force for other locales;
  • 'p' — expressions test by typical template with key symbols: '?', '*' and '\'.

Object's properties:

  • source — Original regular expression pattern, read-only.
  • global — Global match flag, read-only.
  • ignoreCase — Ignore case flag, read-only.
  • multiline — Multiline search, read-only.
  • UTF8 — UTF-8 symbols allowed.
  • lastIndex — Index of a character of the substring from the last search. Used in global mode for match continue, at next call.

Object's functions:

  • Array exec( string val ); — Call match for string val. Return found substring (0) and subexpressions (>0) in array. Set attribute "index" of the array to matched substring position. Set attribute "input" of array to source string.
    var re = new RegExp("(\\d\\d)[-/](\\d\\d)[-/](\\d\\d(?:\\d\\d)?)","");
    var rez = re.exec("12/30/1969");
    var month = rez[1];
    var day = rez[2];
    var year = rez[3]; 
  • bool test( string val ); — Return "true" for match substring in val.
    var re = new RegExp("(\\d\\d)[-/](\\d\\d)[-/](\\d\\d(?:\\d\\d)?)","");
    var OK = re.test("12/30/1969"); 

1.3 XMLNodeObj object

Functions:

  • string name( ) — The name of the node, XML-tag.
  • string text( bool full = false ) — The text of the node, contents of the XML-tag. Set full for get combined text all included nodes.
  • string attr( string id ) — The value of the node's attribute id.
  • XMLNodeObj setName( string vl ) — Setting of the node's name to vl. Returns the current node.
  • XMLNodeObj setText( string vl ) — Setting of the node's text to vl. Returns the current node.
  • XMLNodeObj setAttr( string id, string vl ) — Setting the attribute id to the value vl. Returns the current node.
  • XMLNodeObj clear( bool full = false ) — Clear the node for the childs remove, text and attributes for full.
  • int childSize( ) — Quantity of the embedded nodes.
  • XMLNodeObj childAdd( ElTp no = XMLNodeObj ); XMLNodeObj childAdd( string no ) — Addition of the object no as the embedded one. no may be the direct object-result of the function "SYS.XMLNode()", and the string with the name of the new tag. Returns the embedded node.
  • XMLNodeObj childIns( int id, ElTp no = XMLNodeObj ); XMLNodeObj childIns( int id, string no ) — Insert of the object no as the embedded one to the position id. no may be the direct object-result of the function "SYS.XMLNode()", and the string with the name of the new tag. Returns the embedded node.
  • XMLNodeObj childDel( int id ) — Deleting the included node from the position id. Returns the current node.
  • XMLNodeObj childGet( int id ) — Getting the included node in the position id.
  • XMLNodeObj childGet( string name, int num = 0 ) — Getting the included node with tag name and position number num.
  • XMLNodeObj parent( ) — Get parent node.
  • string load( string str, bool file = false, int flg = 0, string cp = "UTF-8" ) — Loading the XML from the string str or from the file with the path in str if the file "true", with source encoding cp. flg — loading flags:
0x01 — full loading, with texts and comments blocks into special nodes;
0x02 — no remove spaces for begin and end tag's text.
  • string save( int flg = 0, string path = "", string cp = "UTF-8" ) — Saving the XML tree to the string or to the file path with the formatting flags flg and target encoding cp. Returns the XML text or the error code. The following formatting options flg are provided:
0x01 — interrupt the string before the opening tag;
0x02 — interrupt the string after the opening tag;
0x04 — interrupt the string after a closing tag;
0x08 — interrupt the string after the text;
0x10 — interrupt the string after the instruction;
0x1E — interrupt the string after all;
0x20 — insert standard XML-header;
0x40 — insert standard XHTML-header.
  • XMLNodeObj getElementBy( string val, string attr = "id" ) — get element from the tree by attribute attr value val.

2 System (SYS)

Object functions:

  • {string|int} system( string cmd, bool noPipe = false ); — calls the console commands cmd of OS returning the result by the channel. If noPipe is set the return code is returned the the execution of the programs in the background ("sleep 5 &") is possible. The function offers great opportunities to the OpenSCADA user by calling any system software, utilities and scripts, as well as by way of access to the huge volume of system data. For example the command "ls-l" returns the detailed contents of the working directory.
  • string fileRead( string file ); — Return file content by string.
  • int fileWrite( string file, string str, bool append = false ); — Write str to file, remove presented or append. Return wrote bytes count.
  • int fileRemove( string file ); — Remove file. Return the removing result.
  • int message( string cat, int level, string mess ); — formation of the system message mess with the category cat, level level (-7...7). The negative value of the level forms the alarms (Alarm).
  • int messDebug( string cat, string mess ); int messInfo( string cat, string mess ); int messNote( string cat, string mess ); int messWarning( string cat, string mess ); int messErr( string cat, string mess ); int messCrit( string cat, string mess ); int messAlert( string cat, string mess ); int messEmerg( string cat, string mess ); — formation of the system message mess with the category cat and the appropriate level.
  • XMLNodeObj XMLNode( string name = "" ); — creation of the XML node object with the name name.
  • string cntrReq( XMLNodeObj req, string stat = "" ); — request of the control interface to the system via XML. The usual request is written as "<get path="/OPath/%2felem"/>". If the station stat is indicated to the request then to the external station will send one. The address into attribute "path" you can obtain into OpenSCADA configurator, namely into status line where the address appear at the mouse cursor point to configuring or information field. Examples for wide requests:
    • Reading value from the element (user "test" name):
      req = SYS.XMLNode("get").setAttr("path","/sub_Security/usr_test/%2fprm%2fDESCR");
      SYS.cntrReq(req);
      idSt = req.text(); 
    • Writing value to the element (user "test" name):
      req = SYS.XMLNode("set").setAttr("path","/sub_Security/usr_test/%2fprm%2fDESCR").setText("New test user name");
      SYS.cntrReq(req); 
    • Adding new node (user "test"):
      req = SYS.XMLNode("add").setAttr("path","/sub_Security/%2fbr%2fusr_").setText("test");
      SYS.cntrReq(req); 
    • Deleting node (user "test"):
      req = SYS.XMLNode("del").setAttr("path","/sub_Security/%2fbr%2fusr_").setText("test");
      SYS.cntrReq(req); 
    • Saving the node changes to DB (user "test"):
      req = SYS.XMLNode("save").setAttr("path","/sub_Security/usr_test/%2fobj");
      SYS.cntrReq(req); 
    • Loading the node from DB (user "test"):
      req = SYS.XMLNode("load").setAttr("path","/sub_Security/usr_test/%2fobj");
      SYS.cntrReq(req); 
  • int sleep( real tm, int ntm = 0 ); — put to sleep the execution thread on the tm seconds (precised up to nanoseconds) and ntm ns. The sleeping time you can set up to STD_INTERF_TM (5 seconds).
  • int time( int usec ); — returns the absolute time in seconds from the epoch of 1/1/1970 and the microseconds part into usec if specified.
  • int utime( ); int mtime( ); — return absolute time in microseconds and milliseconds from the epoch of 1/1/1970.
  • int {localtime|gmtime}( int fullsec, int sec, int min, int hour, int mday, int month, int year, int wday, int yday, int isdst ); — returns the full date in seconds (sec), minutes (min), hours (hour), days of the month (mday), month (month), year (year), days in the week (wday), days in the year (yday) and sign of summer time (isdst), based on the absolute time in seconds fullsec from the epoch 1.1.1970. gmtime return time into GMT(UTC).
  • int {mktime|timegm}( int sec, int min, int hour, int mday, int month, int year, int wday, int yday, int isdst ); — the time forming since Epoch 1.1.1970 from separated seconds, minutes, hours, days, month etc. The values for separated time items can be set out from this typical range, that allow the function using for seek will correct and return the items values into typical range. timegm work into GMT(UTC) time.
  • string {strftime|strftimegm}( int sec, string form = "%Y-%m-%d %H:%M:%S" ); — Converts an absolute time sec to the string of the desired format form. Record of the format corresponds to the POSIX-function strftime. strftimegm return time into GMT(UTC).
  • int {strptime|strptimegm}( string str, string form = "%Y-%m-%d %H:%M:%S" ); — Returns the time in seconds from the epoch of 1/1/1970, based on the string record of time str, in accordance with the specified template form. For example the template "%Y-%m-%d %H:%M:%S" corresponds with the time "2006-08-08 11:21:55". Description of the template's format can be obtained from the documentation on POSIX-function "strptime". strptimegm work into GMT(UTC) time.
  • int cron( string cronreq, int base = 0 ); — returns the time, planned in the format of the standard Cron cronreq, beginning from basic time base or from the current, if the basic is not specified.
  • string strFromCharCode( int char1, int char2, int char3, ... ); — String creation from symbol's codes char1, char2 ... charN.
  • string strCodeConv( string src, string fromCP, string toCP ); — Encoding the text src from the encoding fromCP to toCP. If encoding is omitted (empty string), it is used inside.
  • string strEncode( string src, string tp = "Bin", string opt1 = "" ); — String src encoding by the rule tp and the option opt1. Allowed rules:
    "PathEl" — symbols '/' and '%' to "%2f" and "%25", respectively;
    "HttpURL" — symbols ' ', '\t', '%' and "> 0x80" to "%20", "%09", "%25" and etc.;
    "HTML" — symbols of the HTML-entities '>', '<', '"', '&', '\ to ">", "<", """ and etc.;
    "JavaScript" — symbol '\n' shielding "\\n";
    "SQL" — symbols shielding '\, '\"', '`', '\\' or doubling of the listed symbols into opt1;
    "Custom" — set symbols into opt1 to "%NN";
    "Base64" — same Base 64 binary encoding, into opt1 sets line termination symbol(s) after 57 symbols;
    "FormatPrint" — symbol '%' to "%%";
    "OscdID" — almost all symbols like ' ', '/', '\\', '&', '(' to '_';
    "Bin" — ASCII bytes list ("XX XX XX XX ...") to binary represent;
    "Reverse" — reversion the sequence;
    "ShieldSimb" — shielding symbols like '\a', '\b', ..., '\0NNN', '\xNN' to binary represent.
  • string strDecode( string src, string tp = "Bin", string opt1 = "" ); — String src decoding by the rule tp and the option opt1. Allowed rules:
    "PathEl", "HttpURL", "Custom" — decoding symbols like "%NN" to binary represent;
    "Base64" — same from Base 64;
    "Bin" — the binary string to ASCII bytes ("XX XX XX XX .. A.b.c.."), opt1 points to separator or "<text>" for enable the offset to the left and the text part to the right.

3 Any object (TCntrNode) of OpenSCADA objects tree (SYS.*)

Object functions:

  • TArrayObj nodeList( string grp = "", string path = "" ); — Get child nodes identifiers list for group grp and node from path path. If grp empty then return nodes for all groups.
  • TCntrNodeObj nodeAt( string path, string sep="" ); — Attach to node path into OpenSCADA objects tree. If a separator set into sep then path process as separated string.
  • TCntrNodeObj nodePrev( ); — Get previous, parent, node.
  • string nodePath( string sep = "", bool from_root = true ); — Getting the path of the current node in the object tree OpenSCADA. One separator character is specified in sep to get the path through the separator, for example, "DAQ.ModBus.PLC1.P1.var", otherwise "/DAQ/ModBus/PLC1/P1/var". from_root indicates a need to form a path from the root, and without the Station ID.
  • int messSys( int level, string mess ) — Formation of the system message mess with the level with the node path as a category and with the human readable path before the message.

4 Subsystem "Security" (SYS.Security)

The subsystem object's functions (SYS.Security):

  • int access( string user, int mode, string owner, string group, int access ) — Check for user access to resource what owned by owner and group and access for mode:
user — user for access check;
mode — access mode (4-R, 2-W, 1-X);
owner — resource owner;
group — resource group;
access — resource access mode (RWXRWXRWX — 0777).

The user (SYS.Security["usr_User"]) object's functions:

  • ElTp cfg( string nm ) — get value of configuration field nm of the object.
  • bool cfgSet( string nm, ElTp val ) — set configuration field nm of the object to value val.
  • Array groups( ) — groups list of the user

The group (SYS.Security["grp_Group"]) object's functions:

  • ElTp cfg( string nm ) — get value of configuration field nm of the object.
  • bool cfgSet( string nm, ElTp val ) — set configuration field nm of the object to value val.
  • bool user( string nm ) — checking for user nm presence into the group.

5 Subsystem "DB" (SYS.BD)

DB object functions (SYS.BD["TypeDB"]["DB"]):

  • ElTp cfg( string nm ) — get value of configuration field nm of the object.
  • bool cfgSet( string nm, ElTp val ) — set configuration field nm of the object to value val.
  • Array SQLReq( string req, bool tr = EVAL ); — formation of the SQL-request to the DB, inside (tr=true), outside (tr=false) or no matter (tr=EVAL) to transaction. At an error the result's property "err" sets to the error value.
    DBTbl = SYS.BD.MySQL.GenDB.SQLReq("SELECT * from DB;");
    if(DBTbl.err.length) SYS.messInfo("TEST DB","Error: "+DBTbl.err);
    else for(var iRw = 0; iRw < DBTbl.length; iRw++) {
      var rec = "";
      for(var iFld = 0; iFld < DBTbl[iRw].length; iFld++) rec += DBTbl[iRw][iFld] + "\t";
      SYS.messInfo("TEST DB", "Row "+iRw+": "+rec);
      //Get column value by the name
      if(iRw) SYS.messInfo("TEST DB", "Row "+iRw+": 'NAME'"+DBTbl[iRw]["NAME"]);
    } 

Table object functions (SYS.BD["TypeDB"]["DB"]["Table"]):

  • XMLNodeObj fieldStruct( ); — The table structure get in XML-node "field" with child node-columns "<RowId type="real" len="10.2" key="1" def="Default value">{Value}</RowId>", where:
    • {RowId} — column identifier;
    • {Value} — column value;
    • type — value's type for column: str — string, int — integer, real — real and bool — boolean;
    • len — value's length for column, in chars;
    • key — the flag for key-column, and used for search by it value;
    • def — default value for column.
  • string fieldSeek( int row, XMLNodeObj fld ); — Seek field row of table. For success returned "1" else "0". On error case returned "0:Error".
  • string fieldGet( XMLNodeObj fld ); — Field value request. On error case returned "0:Error".
    req = SYS.XMLNode("field");
    req.childAdd("user").setAttr("type","str").setAttr("key","1").setText("root");
    req.childAdd("id").setAttr("type","str").setAttr("key","1").setText("/Lang2CodeBase");
    req.childAdd("val").setAttr("type","str");
    SYS.BD.MySQL.GenDB.SYS.fieldGet(req);
    SYS.messDebug("TEST DB","Value: "+req.childGet(2).text());
  • string fieldSet( XMLNodeObj fld ); — Field set. On error case returned "0:Error".
  • string fieldDel( XMLNodeObj fld ); — Field remove. On error case returned "0:Error".

6 Subsystem "DAQ" (SYS.DAQ)

Functions of subsystem's object (SYS.DAQ):

  • bool funcCall(string progLang, TVarObj args, string prog, string fixId = ""); — call function text prog with arguments args for program language progLang and with the function fixing identifier fixId (automatic if it is empty). Return "true" on well call. The fixed function differ from the automatic by it does not remove after execution and uses repeatedly by an address into fixId, which replaces that original identifier in first call. For the fixed function recreate you need change the program or clean up fixId by the function original id.
    var args = new Object();
    args.y = 0;
    args.x = 123;
    SYS.DAQ.funcCall("JavaLikeCalc.JavaScript",args,"y=2*x;");
    SYS.messDebug("TEST Calc","TEST Calc rezult: "+args.y); 

Functions of object of controller (SYS.DAQ["Modul"]["Controller"]):

  • ElTp cfg( string nm ) — get value of configuration field nm of the object.
  • bool cfgSet( string nm, ElTp val ) — set configuration field nm of the object to value val.
  • string name( ) — controller name.
  • string descr( ) — controller description.
  • string status( ) — controller status.
  • bool alarmSet( string mess, int lev = -5, string prm = "" ) — set/remove of violations mess with the level lev (negative for remove otherwise for set), for the parameter prm. The function forming alarm with category: al{ModId}:{CntrId}[.{PrmId}], where:
    • ModId — the module identifier;
    • CntrId — the controller identifier;
    • PrmId — parameter identifier, from argument prm.
  • bool enable( bool newSt = EVAL ) — get enable status or change it by argument newSt assign.
  • bool start( bool newSt = EVAL ) — get start status or change it by argument newSt assign.

Functions of object of controller's parameter (SYS.DAQ["Modul"]["Controller"]["Parameter"]):

  • ElTp cfg( string nm ) — get value of configuration field nm of the object.
  • bool cfgSet( string nm, ElTp val ) — set configuration field nm of the object to value val.
  • TCntrNodeObj cntr() — return the object of controller for the parameter nesting independent.

Functions of object of atribute of controller's parameter (SYS.DAQ["Modul"]["Controller"]["Parameter"]["Attribute"]):

  • ElTp get( int tm = 0, int utm = 0, bool sys = false ); — get attribute value at time tm.utm and system access flag sys. The time attributes tm.utm is outputs also then real time of the gotten value also places here if their are variables.
  • bool set( ElTp val, int tm = 0, int utm = 0, bool sys = false ); — write value val to attribute with time label tm.utm and system access flag sys.
  • TCntrNodeObj arch( ); — gets the archive associated with this attribute. In case of absence the associated archive returns "false".
  • string descr( ); — get attribute description.
  • int time( int utm ); — time of the last value of the attribute in seconds and microseconds into utm, if it pointed and a variable.
  • int len( ); — field length.
  • int dec( ); — float resolution.
  • int flg( ); — field's flags.
  • string def( ); — default value.
  • string values( ); — allowed values list or range.
  • string selNames( ); — names of allowed values list.
  • string reserve( ); — reserve string property value.

Functions of object of templates library (SYS.DAQ[tmplb_Lib"]) and template (SYS.DAQ[tmplb_Lib"]["Tmpl"]) of controller's parameter:

  • ElTp cfg( string nm ) — get value of configuration field nm of the object.
  • bool cfgSet( string nm, ElTp val ) — set configuration field nm of the object to value val.

6.1 Module DAQ.JavaLikeCalc

The object "Functions library" (SYS.DAQ.JavaLikeCalc["lib_Lfunc"])

  • ElTp {funcID}(ElTp prm1, ...) — call the library function "funcID" of library "Lfunc". Return result of the called function. The prefix "lib_" before the library identifier is required!

The object "User function" ( SYS.DAQ.JavaLikeCalc["lib_Lfunc"]["func"] )

  • ElTp call(ElTp prm1, ...) — call the function "func" of library "Lfunc" with parameters "prm{N}". Return result of the called function. The prefix "lib_" before the library identifier is required!

6.2 Module DAQ.LogicLev

The object "Parameter" [this]

  • bool attrAdd( string id, string name, string tp = "real", string selValsNms = "" ) [for enabled parameter of the standard type] — attribute id and name for type tp add. If the attribute already present then will apply properties allowed to hot changing: name, selection mode and the selection mode parameters.
    • id, name — new attribute id and name;
    • tp — attribute type [boolean | integer | real | string | text | object] + selection mode [sel | seled] + read-only [ro];
    • selValsNms — two lines with values in first and it's names in first (separated by ";").
  • bool attrDel( string id ) [for enabled parameter of the standard type] — attribute id remove.

6.3 Module DAQ.BlockCalc

The object "Block" (SYS.DAQ.BlockCalc["cntr"]["blk_block"])

  • ElTp cfg( string nm ) — get value of configuration field nm of the object.
  • bool cfgSet( string nm, ElTp val ) — set configuration field nm of the object to value val.
  • TCntrNodeObj cntr( ) — return the object of controller for the parameter nesting independent.

6.4 Module DAQ.ModBus

The object "Controller" [this.cntr()]

  • string messIO(string pdu) — sending pdu through the transport of controller object by means of ModBus protocol. PDU query result is placed instead of the query pdu, and the error returned by the function.

The object "Parameter" [this]

  • bool attrAdd( string id, string name, string tp = "real", string selValsNms = "" ) [for enabled parameter of the logical type] — attribute id and name for type tp add. If the attribute already present then will apply properties allowed to hot changing: name, selection mode and the selection mode parameters.
    • id, name — new attribute id and name;
    • tp — attribute type [boolean | integer | real | string | text | object] + selection mode [sel | seled] + read-only [ro];
    • selValsNms — two lines with values in first and it's names in first (separated by ";").
  • bool attrDel( string id ) [for enabled parameter of the logical type] — attribute id remove.


7 Subsystem "Archives" (SYS.Archive)

Functions of the subsystem's object:

  • Array messGet( int btm, int etm, string cat = "", int lev = 0, string arch = "", int upTm = 0 ); — request of the system messages or alarms for the time from btm to etm for the category cat, level lev (-7...7) and archivators arch (separated by symbol ';'; "" — buffer and archivators; "<buffer>" — buffer; "{ArhMod}.{Arh}" — concrete archivator of the module). upTm sets the operation continuance limit to time; a negative value used as relative time; less to STD_INTERF_TM (5). Return time of stopping of the reading (attribute "tm" of the array) and array of the message's objects with preset attributes:
    • tm — time of the message, seconds;
    • utm — time of the message, microseconds;
    • categ — category of the message;
    • level — level of the message;
    • mess — text of the message.
  • bool messPut( int tm, int utm, string cat, int lev, string mess, string arch = "" ); — write message mess with category cat, level lev (-7...7) and time tm.utm to archivators arch (separated by symbol ';') or/and alarms list.

Functions of object's archiver of messages (SYS.Archive["mod_Modul"]["mess_Archivator"]):

  • ElTp cfg( string nm ) — get value of configuration field nm of the object.
  • bool cfgSet( string nm, ElTp val ) — set configuration field nm of the object to value val.
  • bool status( ) — get the archiver start status.
  • int end( ) — get the archiver data end time.
  • int begin( ) — get the archiver data begin time.

Functions of object's archiver of values (SYS.Archive["val_Modul"]["val_Archivator"]):

  • ElTp cfg( string nm ) — get value of configuration field nm of the object.
  • bool cfgSet( string nm, ElTp val ) — set configuration field nm of the object to value val.
  • bool status( ) — get the archiver start status.

Functions of object's archive (SYS.Archive["va_Archive"]):

  • ElTp cfg( string nm ) — get value of configuration field nm of the object.
  • bool cfgSet( string nm, ElTp val ) — set configuration field nm of the object to value val.
  • bool status( ) — get the archive start status.
  • int end( string arch = "" ) — get the archive data end time for the archiver arch, in microseconds.
  • int begin( string arch = "" ) — get the archive data begin time for the archiver arch, in microseconds.
  • int period( string arch = "" ) — get the archive data period for the archiver arch, in microseconds.
  • TArrayObj archivatorList( ) — get the archivers list which using the archive as source.
  • VarType getVal( int tm, bool up_ord = false, string arch = "" ) — get one value from the archive for the time tm, up order up_ord and the archiver arch:
    • tm — the time for requested value, in microseconds, set to 0 for end(), the attribute is an output also then real time of the gotten value also places here if it is a variable;
    • up_ord — fit the requested value time to up for the grid;
    • arch — the archiver for the request, set to empty for buffer and all archivers try, set to "<buffer>" for the buffer only process.
  • bool setVal( int tm, VarType vl, string arch = "" ) — set one value vl to the archive for the time tm and the archiver arch:
    • tm — the time for set value, in microseconds;
    • vl — the value;
    • arch — the archiver for the query. Set to empty for buffer and all archivers. Set to "<buffer>" for the buffer only process.

8 Subsystem "Transports" (SYS.Transport)

Functions of the ingoing transport object (SYS.Transport["Modul"]["in_Transp"]):

  • ElTp cfg( string nm ) — get value of configuration field nm of the object.
  • bool cfgSet( string nm, ElTp val ) — set configuration field nm of the object to value val.
  • string status() — the transport status.
  • string addr( string vl = "" ) — the transport address return, set the to no empty vl.
  • string writeTo(string sender, string mess) — Send the message mess to sender sender.
  • TArrayObj assTrsList() — assigned output transports list to the input.

Functions of the outgoing transport object (SYS.Transport["Modul"]["out_Transp"]):

  • ElTp cfg( string nm ) — get value of configuration field nm of the object.
  • bool cfgSet( string nm, ElTp val ) — set configuration field nm of the object to value val.
  • string status() — the transport status.
  • bool start( bool vl = <EVAL>, int tm = 0 ) — the transport start status return, start/stop it by vl (if it is not <EVAL>). For starting you can set the specific timeout tm.
  • string addr( string vl = "" ) — the transport address return, set the to no empty vl.
  • string timings( string vl = "" ) — the transport timings return, set the to no empty vl.
  • string messIO( string mess, real timeOut = 0, int inBufLen = -1 ); — sending the message mess through the transport with the timeout timeOut (in seconds) of waiting reply and the reply reading (buffer) size inBufLen bytes. In the case of a zero timeout is the time taken from the settings of outgoing transport. The timeOut in negative (< -1e-3) disables the transport's request/respond mode and allows for independent reading/writing to a buffer IO, with the reading timeout timeOut in absolute. For negative inBufLen the buffer size sets to STR_BUF_LEN(10000) and "0" disables the reading at all.
    At.png If your transport means getting data in parts for a request then for several devices on single bus-transport use the function into single thread but there is not a way to lock the transport into the user API. Single thread that is any object of controller of DAQ and the module "User protocol" locks the transport internally before self user procedures execution.
    rez = SYS.Transport.Serial.out_ttyUSB0.messIO(SYS.strFromCharCode(0x4B,0x00,0x37,0x40),0.2);
    //Wait for all the message tail by timeout and empty result
    while((trez=SYS.Transport.Serial.out_ttyUSB0.messIO("")).length) rez += trez; 
  • string messIO( XMLNodeObj req, string prt ); — sending the request req to the protocol prt for the implementation of a connection session through the transport by means of protocol.
    req = SYS.XMLNode("TCP");
    req.setAttr("id","test").setAttr("reqTm",500).setAttr("node",1).setAttr("reqTry",2).setText(SYS.strFromCharCode(0x03,0x00,0x00,0x00,0x05));
    SYS.Transport.Sockets.out_testModBus.messIO(req,"ModBus");
    test = Special.FLibSYS.strDec4Bin(req.text()); 

9 Subsystem "Protocols" (SYS.Protocols)

9.1 Module Protocol.HTTP

The same module's object "Protocol.HTTP" [SYS.Protocol.HTTP.pgCreator()]

  • bool pgAccess(string URL) — checking for page access pointed by the URL.
    • URL — URL of the checking page.
  • string pgCreator(string cnt, string rcode = "200 OK", string httpattrs = "Content-Type: text/html;charset={SYS}", string htmlHeadEls = "", string forceTmplFile = "", string lang = "" ) — forming page or resource from content cnt, wrapped to HTTP result rcode, with HTTP additional attributes httpattrs, HTML additional head's element htmlHeadEls, forced to template file forceTmplFile and language lang.
    • cnt — a page or a resource (images, XML, CSS, JavaScript, ...) content;
    • rcode — HTTP result code, like to "200 OK"; empty value there disables addition of the HTTP header;
    • httpattrs — additional HTTP-attributes, mostly this is "Content-Type" which by default sets to "text/html;charset={SYS}"; only for "Content-Type: text/html" will do wrapping to internal/service or force forceTmplFile HTML-template;
    • htmlHeadEls — an additional HTML-header's tag, it's mostly META with "Refresh" to pointed URL;
    • forceTmplFile — force template file for override the internal/service template by the main-page template or other.
    • lang — forming interface's language.


10 Subsystem "User interfaces" (SYS.UI)

10.1 Module UI.VCAEngine

Template:Include file="/HomePageEn/Doc/VCAconcept/part4/part14" notoc="1" first anchor="API" last anchor="endAPI"

11 "Special" subsystem (SYS.Special)

11.1 Module Library of the system API of the user programming area (Special.FLibSYS)

The object "Functions library" (SYS.Special.FLibMath)

  • ElTp {funcID}(ElTp prm1, ...) — call the library function {funcID}. Return result of the called function.

The object "User function" (SYS.Special.FLibMath["funcID"])

  • ElTp call(ElTp prm1, ...) — call the function with parameters prm{N}. Return result of the called function.

11.2 Module Library of standard mathematical functions (Special.FLibMath)

Template:Include file="/HomePageEn/Doc/FLibMath" notoc="1" first anchor="API" last anchor="endAPI"

11.3 Module Library of functions of compatibility with SCADA Complex1 of the firm DIYA Ltd (Special.FLibComplex1)

Template:Include file="/HomePageEn/Doc/FLibComplex1" notoc="1" first anchor="API" last anchor="endAPI"


At.png Link to DB API libraries ...