12. Components of the object model of the OpenSCADA system
Object model of the OpenSCADA system is based on the function object TFunction, on the parameters of the function IO and on the values' frame of the function TValFunc. Later the function's objects are included in the object tree, forming an object model of the system. Using the functions of the object model is made by linking the frame of values TValFunc with function.
The idea in general is shown in Fig. 7.
Fig. 7. The basis of the programming area of the OpenSCADA system.
Object of the function (TFunction) provides an interface for the formation of function parameters and algorithm of the computing in the object which inherits it.
Object of the function's parameter (IO) contains the configuration of the single parameter.
Object of the values' frame (TValFunc) contains values in accordance with the structure of the linked function. While the execution of the algorithm by the associated function the values of this object are used.
12.1. The function object (TFunction)
Inherits: | TCntrNode |
Inherited: | By the modules and nodes of the systems, which contains the functions for publication in the object model of the system. |
Public methods:
- TFunction( const string &id, const char *grp = "root", const string &istor = "" ); — Initializing constructor of the function with the identifier id, users group grp and storage stor.
- TFunction &operator=( const TFunction &func ); — Copying of functions.
- string id( ); — Function ID.
- virtual string name( ); — Localized name of the function.
- virtual string descr( ); — Description of the function.
- virtual string prog( ); — Program's text of the function, for no static ones.
- virtual string stor( ); — Storage DB, for table "Trs" mostly.
- bool startStat( ); — Status - "Running".
- int use( ); — Counter of the function's using.
- ResRW &fRes( ); — Link to the resource of the function.
- void setId( const string &vl ); — Set the function identifier.
- virtual void setProg( const string &prg ); — Set program's text of the function, for no static ones.
- void setStor( const string &istor ); — Set storage DB to stor.
- virtual void setStart( bool val ); — Start/stop val of the function.
- void ioList( vector<string> &list ); — The list of the function's parameters list.
- int ioId( const string &id ); — Getting the index of the function's parameter id.
- int ioSize( ); — The quantity of the function's parameters.
- IO *io( int id ); — Getting the function's parameter by the index id.
- void ioAdd( IO *io ); — Addition of the function's parameter io.
- int ioIns( IO *io, int pos ); — Insert of the function's parameter io into the position pos. Returns the actual position of the new parameter.
- void ioDel( int pos ); — Deleting the function's parameter in the position pos.
- void ioMove( int pos, int to ); — Moving the function's parameter from the position pos to the position to.
- virtual void calc( TValFunc *val ); — The calculation of the function's algorithm of the specified values val.
- virtual void valAtt( TValFunc *vfnc ); — Is called by the object of the values' frame vfnc in the case of attaching with the function.
- virtual void valDet( TValFunc *vfnc ); — Is called by the object of the values' frame vfnc in the case of detaching from the function.
- virtual void preIOCfgChange( ); — Is called before the changing of the configuration of the function.
- virtual void postIOCfgChange( ); — Is called after the changing of the configuration of the function.
Protected attributes:
- string mId; — Function ID.
- bool runSt; — Sign - "Running".
- bool beStart; — Sign - "Start".
- TValFunc *mTVal; — Reference to the values' object, used for testing the function. May be absent.
12.2. The object of the function's parameter (IO)
Data:
Parameter's type (enum — IO::Type):
- IO::String — string/text;
- IO::Integer — integer;
- IO::Real — real;
- IO::Boolean — boolean;
- IO::Object — object.
Parameter's flags (enum — IO::IOFlgs):
- IO::Default — default mode (input);
- IO::Output — output;
- IO::Return — return.
Public methods:
- IO( const char *id, const char *name, IO::Type type, unsigned flgs, const char *def = "", bool hide = false, const char *rez = "" ); — Initializing constructor.
- IO &operator=( const IO &iio ); — Copying of the function parameters.
- const string &id( ); — ID of the function's parameter.
- const string &name( ); — The localized name of the function's parameter.
- const Type &type( ); — The type of the function's parameter.
- unsigned flg( ); — The flags of the function's parameter.
- const string &def( ); — Default value.
- bool hide( ); — Sign - "Hide".
- const string &rez( ); — The reserve property of the function's parameter.
- void setId( const string &val ); — Set the identifier to val.
- void setName( const string &val ); — Set the name to val.
- void setType( Type val ); — Set the type to val.
- void setFlg( unsigned val ); — Set the flags to val.
- void setDef( const string &val ); — Set the default value to val.
- void setHide( bool val ); — Set/unset the sign - "Hide".
- void setRez( const string &val ); — Set the reserve property to val.
12.3. The object of the function's value (TValFunc).
Public methods:
- TValFunc( const string &iname = "", TFunction *ifunc = NULL, bool iblk = true ); — Initializing constructor.
- string user( ); — User on whose behalf the function is executed.
- const string &vfName( ); — Name of the values' object.
- bool blk( ); — The sign - "Blocking of the parameters' changes of the function".
- bool dimens( ); — The sign - "To measure the computation time".
- bool mdfChk( ); — The sign - "To check attributes to modify".
- void setUser( const string &iuser ); — Set the user on whose behalf the function will be executed.
- void setVfName( const string &nm ); — Set the name of the values' object to nm.
- void setDimens( bool set ) — Set/unset set of the sign - "To measure the computation time".
- void setMdfChk( bool set ); — Set/unset set of the sign - "To check attributes to modify".
- void ioList( vector<string> &list ); — The list of the function's parameters list.
- int ioId( const string &id ); — Getting the parameter's index id.
- int ioSize( ); — The whole quantity of the parameters.
- IO::Type ioType( unsigned id ); — Parameter's type id.
- unsigned ioFlg( unsigned id ); — Parameter's flags id.
- bool ioHide( unsigned id ); — Parameter's sign id - "Hide".
- bool ioMdf( unsigned id ); — Parameter's sign id - "Modified".
- TVariant get( unsigned id ); — Get the value of the parameter id.
- string getS( unsigned id ); — Get the value (string) of the parameter id.
- int64_t getI( unsigned id ); — Get the value (integer) of the parameter id.
- double getR( unsigned id ); — Get the value (real) of the parameter id.
- bool getB( unsigned id ); — Get the value (boolean) of the parameter id.
- AutoHD<TVarObj> getO( unsigned id ); — Get the value of the parameter's object id.
- void set( unsigned id, const TVariant &val ); — Set the value val of the parameter id.
- void setS( unsigned id, const string &val ); — Set the value val (string) of the parameter id.
- void setI( unsigned id, int64_t val ); — Set the value val (integer) of the parameter id.
- void setR( unsigned id, double val ); — Set the value val (real) of the parameter id.
- void setB( unsigned id, bool val ); — Set the value val (boolean) of the parameter id.
- void setO( unsigned id, AutoHD<TVarObj> val ); — Set the value val of the parameter's object id.
- virtual void calc( const string &user = "" ); — To calculate on behalf of the user user or user, specified earlier.
- double calcTm( ); — Computation time.
- void setCalcTm( double vl ); — Initializing of the time of value's calculation vl.
- TFunction *func( ); — Attached function.
- void setFunc( TFunction *func, bool att_det = true ); — To attach with the specified function func.
- virtual void preIOCfgChange( ); — Is called before the configuration changes.
- virtual void postIOCfgChange( ); — Is called after the configuration changes.
- TValFunc *ctxGet( int key ); — Get context for key key.
- void ctxSet( int key, TValFunc *val ); — Set context for key key.
- void ctxClear( ); — External functions call context clear.
Public attributes:
- void *exCtx; — The function execution context.