4. The subsystem "Data acquisition" (TDAQS)
The subsystem "Data acquisition" is represented by the TDAQS object which contains modular objects of the data sources' types TTypeDAQ and the objects of the libraries of parameters' templates of subsystem "Data acquisition" TPrmTmplLib. Object of the data sources types contains objects of the controllers TController and objects of the parameters' types TTypeParam. Parameters' types objects are provided by the controller module and contain the DB structure of the separate parameters' types (analog, digital ...). Controllers' objects contain parameters' objects TParamContr. Each parameter is associated with only one type of the parameter. For the attribute storage parameter is inherited from the values object TValue, which contains the attributes' values TVal. The library of the parameters' templates of this subsystem contains templates' objects TPrmTmpl. An example of the described hierarchical structure is shown in Fig. 4.
Fig. 4. Hierarchical structure of the data acquisition subsystem.
Subsystem contains the types of data sources. The source may be virtually any substance providing any data. Type of source can be divided into individual sources (controllers) within the limits of the particular type. For example, if we take the data from the operating system (OS), then the single source can be the separate operating system of the separate PC.
Data source (controller) is further divided (contains) into the parameters. The parameter is the part of the data source. In the case of the OS it will be, for example,: used RAM, the processor's frequency and many other parts.
Parameter, in its turn, contains the attributes, which provide the data. In addition to the basic data attributes can provide the related or detailing data. In the case of the same operating system and the memory usage, the attributes may not only provide the used memory, and also how much it all, how much in the swap, etc.
Some of the implementation of the data sources may provide the possibility of setting the structure of the parameter based on previously developed parameters' templates. For this purpose subsystem contains templates' libraries, which, in their turn, provide the parameters' templates . The example shows a library of templates "base" with the templates "digAlrm" and "smplBrd".
At the level of the subsystem the redundancy mechanism for data sources is provided. Redundancy means the possibility of coordinated work of several OpenSCADA stations to perform common task of data acquisition from the same data sources.
4.1. Object of subsystem "Data acquisition" (TDAQS)
Public methods:
- int subVer( ); Version of the subsystem.
- void subStart( ); Start the subsystem.
- void subStop( ); Stop the subsystem.
- AutoHD<TTypeDAQ> at( const string &name ) const; Connection to the type of data source.
- AutoHD<TValue> prmAt( const string &path, char sep = 0, bool noex = false ) const; Connection to the parameter by path or separated by sep string. Do not throw an exceptions if set noex.
- AutoHD<TVal> attrAt( const string &path, char sep = 0, bool noex = false ) const; Connection to the parameter's attribute by path or separated by sep string. Do not throw an exceptions if set noex.
- void ctrListPrmAttr( XMLNode *nd, const string &addrBase, bool toPrm = false, char sep = 0, const string &pref = "" ); Browsing list for items of attributes of parameters or only the parameters DAQ by toPrm with prefix pref from path or separated by sep string from base address addrBase.
- string tmplLibTable( ); Name of table to store the parameters' templates of the subsystem "Data acquisition".
- void tmplLibList( vector<string> &list ) const; The list of available parameters' templates.
- bool tmplLibPresent( const string &id ) const; Check the availability of the parameter's template id.
- void tmplLibReg( TPrmTmplLib *lib ); Registration of the parameter's template lib.
- void tmplLibUnreg( const string &id, int flg = 0 ); Deleting/removing of the registration of the parameter's template id.
- AutoHD<TPrmTmplLib> tmplLibAt( const string &id ) const; Connection to the parameter's template id.
- float rdRestDtTm( ); Maximum depth of the archive data recovery when starting in hours.
- void setRdRestDtTm( float vl ); Set of the maximum depth of the archive data recovery when starting in hours.
- void rdActCntrList( vector<string> &ls, bool isRun = false ); The list of active controllers working in the redundancy scheme. When we indicate isRun there will be in the list only running controllers in this station.
- string rdStRequest( const string &cntr, XMLNode &req, const string &prevSt = "", bool toRun = true ); Request req to the redundant station on behalf of the controller cntr. The station for the request is selected after specified in prevSt for the running remote controller when indicating toRun.
- TElem &elLib( ); The structure of the table of the libraries if parameters' templates.
- TElem &elTmpl( ); The structure of the table of parameters' templates.
- TElem &elTmplIO( ); The structure of the attributes of parameters' templates.
- TElem &elErr( ); The structure of the attribute(s) of parameters' errors.
4.2. Modular object of the controller's type (TTypeDAQ)
Inherits: | TModule, TElem. |
Inherited: | Root object of the modules of subsystem "Data acquisition". |
Public methods:
- string DAQPath( ); Getting for DAQ-address of the element.
- void modStart( ); Start of the module.
- void modStop( ); Stop of the module.
- void list( vector<string> &list ) const; The list of the controllers.
- bool present( const string &name ) const; Check for the availability of the specified controller.
- void add( const string &name, const string &daq_db = "*.*" ); Add the controller.
- void del( const string &name ); Delete the controller.
- AutoHD<TController> at( const string &name, const string &who = "" ) const; Connect to the controller.
- bool tpPrmPresent( const string &name_t ); Check for the availability of the specified controller type.
- unsigned tpPrmToId( const string &name_t ); Getting of the index of the parameters' types by their names.
- int tpParmAdd( const char *id, const char *n_db, const char *name ); Addition/registration of the parameters' types.
- unsigned tpPrmSize( ); Quantity of the parameters' types.
- TTypeParam &tpPrmAt( unsigned id ); Get the object of the parameters' type.
- virtual bool compileFuncLangs( vector<string> *ls = NULL ); Request of the list of languages for which it is realized the possibility of formation of user procedures in this module, and check for it support fact.
- virtual void compileFuncSynthHighl( const string &lang, XMLNode &shgl ); The rules of syntax highlight request for specifying language.
- virtual string compileFunc( const string &lang, TFunction &fnc_cfg, const string &prog_text, const string &usings = "", int maxCalcTm = 0 ); Compiling/setup of the user function on the supported programming language lang and on the source code of procedure prog_text, based on the parameters of procedure fnc_cfg. The result is the address to the prepared function object.
- virtual bool redntAllow( ); The indication of support of redundancy mechanisms by the module. It must be simply overridden and return true.
Protected methods:
- virtual TController *ContrAttach( const string &name, const string &daq_db ); Connecting of the controller. It must be obligatory overridden in the descendant of the module.
4.3. Controller's object (TController)
Inherits: | TCntrNode, TConfig. |
Inherited: | Objects of the modules of subsystem "Data acquisition". |
Data:
Redundancy modes (enum TController::Redundant):
- Off (0) Turned off;
- Asymmetric (1) asymmetric;
- OnlyAlarms (2) only alarms, suppressing on the reserve.
Command specific
Public methods:
- TController( const string &name_c, const string &daq_db, TElem *cfgelem ); Initializing constructor of the controller.
- string DAQPath( ); Getting for DAQ-address of the element.
- string id( ); Controller ID.
- string workId( ); Work ID of the controller, including the ID of the module.
- string name( ); Controller's name.
- string descr( ); Controller's description.
- virtual string getStatus( ); Request function of the controller's status.
- string DB( ); DB name of the controller's instance.
- string tbl( ); The name of the table of DB of the controller's instance.
- string fullDB( ); The full name of the table of DB of the controller's instance.
- void setName( const string &nm ); Set the controller's name.
- void setDescr( const string &dscr ); Set the controller's description.
- void setDB( const string &idb ); Setting of the DB name of the controller's instance.
- bool toEnable( ); Sign "To enable the controller".
- bool toStart( ); Sign "To start the controller".
- bool enableStat( ) const; Status "Enable".
- bool startStat( ); Status "Run".
- int messLev( ); Messages level of diagnostic information.
- void start( ); Controller's start.
- void stop( ); Controller's stop.
- void enable( ); Controller's enabling.
- void disable( ); Controller's stopping.
- void list( vector<string> &list ) const; Parameter's list in the controller.
- bool present( const string &name ) const; Check for the availability of the parameter name.
- void add( const string &name, unsigned type ); Addition of the parameter name of the type type.
- void del( const string &name, bool full = false ); Deleting of the parameter name. If the field full is specified the controller will be completely removed.
- AutoHD<TParamContr> at( const string &name, const string &who = "th_contr" ) const; Connection to the controller's parameter name.
- bool redntUse( Redundant md = Asymmetric ); Redundancy state for mode md.
- void setRedntUse( bool vl ); Changing of the getting the data from the backup station mode.
- Redundant redntMode( ); Redundancy mode ("<high>", "<low>", "<optimal>", {ForceStation}), enabling.
- void setRedntMode( Redundant vl ); Setting of the redundancy mode, enabling.
- string redntRun( ); Configuration of the preferred execution.
- void setRedntRun( const string &vl ); Setting the configuration of the preferred execution.
- virtual void redntDataUpdate( ); An operation of the data receiving from the backup station execution. It is called automatically by the service procedure of the redundancy scheme of the subsystem.
- virtual string catsPat( ); regular expression rules separated '|' list for the object's generated messages math by category.
- void alarmSet( const string &mess, int lev = -TMess::Crit, const string &prm = "" ); Formation of the alarm (violation) for the object controller prm, or the controller as a whole if the object is not specified, the message mess and level lev. The negative value of the level lev is used to set and positive for removal of the violation. This function generates the violation and message with a category: al{ModId}:{CntrId}[.{PrmId}].
- TTypeDAQ &owner( ) const; The type of the data source (module) - the owner of the controller.
Protected attributes:
- bool en_st; Sign "Enable".
- bool run_st; Sign "Running".
Protected methods:
- virtual void enable_( ); Enabling of the controller. Intercepted by the child.
- virtual void disable_( ); Disabling of the controller. Intercepted by the child.
- virtual void start_( ); Starting of the controller. Intercepted by the child.
- virtual void stop_( ); Stopping of the controller. Intercepted by the child.
- virtual TParamContr *ParamAttach( const string &name, int type ); Modular method of the creation/opening of the new parameter.
4.4. Parameters' type object (TTypeParam)
Public methods:
- TTypeParam( const char *iid, const char *iname, const char *idb = "", bool i_isPrmCntr = false ); Initializing constructor.
- virtual void create( TParamContr *prm ); Create or set the parameter prm type.
- virtual void destroy( TParamContr *prm ); Remove or clean the parameter prm type.
- virtual string DB( TController *cntr ); Get table name of the parameters of the controller cntr.
- void setDB( TController *cntr, const string &vl ); Set the table name of the parameters of the controller cntr.
- virtual void enable( TParamContr *prm ); To enable the parameter prm.
- virtual void disable( TParamContr *prm ); To disable the parameter prm.
- virtual bool cfgChange( TParamContr *prm, TCfg &cfg ); The configuration filed cfg of the parameter prm change.
- virtual void vlGet( TParamContr *prm, TVal &vo ); Predicting function of the value getting, through the parameter prm. It is used for direct (synchronous) reading.
- virtual void vlSet( TParamContr *prm, TVal &vo, const TVariant &vl, const TVariant &pvl ); Predicting function of the value setting, through the parameter prm. It is used for direct (synchronous) writing vl with the previous value into pvl.
- virtual void vlArchMake( TParamContr *prm, TVal &val ); Notifying function of the creation of the archive for the val attribute, through parameter prm. It is used to configure the created archive in accordance with the peculiarities of the data source.
- virtual void getVals( TParamContr *prm ); Asynchronous mode internal realization, called into the controller object cycle for parameter prm.
- virtual bool cntrCmdProc( TParamContr *prm, XMLNode *opt ); Function of requests' processing of the control interface, from parameter prm.
Public attributes:
- string name; Parameter's type name.
- string descr; Parameter's type description.
- string db; DB of the parameter's type.
4.5. Object of the physical level parameter (TParamContr)
Inherits: | TConfig, TValue. |
Inherited: | Objects of the module's parameters of subsystem "Data acquisition". |
Public methods:
- TParamContr( const string &name, TTypeParam *tpprm ); Initializing constructor.
- string DAQPath( ); Getting for DAQ-address of the element.
- string ownerPath( bool inclSelf = false ); The parameter-owner path, include inclSelf the parameter.
- bool operator==( TParamContr & PrmCntr ); Parameter's comparison.
- string id( ); Parameter's ID (key).
- string name( ); Parameter's name.
- string descr( ); Parameter's description.
- bool toEnable( ); Sign "To enable parameter".
- bool enableStat( ) const; Status "Enable".
- void setName( const string &inm ); Setting of the parameter's name.
- void setDescr( const string &idsc ); Setting of the parameter's description.
- void setToEnable( bool vl ); Setting of the sign "To enable the parameter".
- void list( vector<string> &list ) const; Parameter's list in the parameter.
- bool present( const string &name ) const; Check for the availability of the parameter name.
- void add( const string &name, unsigned type = 0 ); Addition of the parameter name of the type type.
- void del( const string &name, bool full = false ); Deleting of the parameter name. If the field full is specified the controller will be completely removed.
- AutoHD<TParamContr> at( const string &name, const string &who = "th_prm" ) const; Connection to the controller's parameter name.
- TTypeParam &type( ) const; Parameter's type.
- virtual TElem *dynElCntr( ); Container of the dynamic elements of the DAQ attributes.
- virtual void enable( ); To enable parameter.
- virtual void disable( ); To disable parameter.
- TController &owner( ) const; Controller the parameter's owner.
Protected methods:
- virtual void setType( const string &tpId ); is called to change the parameter type tpId and can be processed in the object module for self data change.
4.6. Object of the value (TValue)
Inherits: | TCntrNode, TValElem. |
Inherited: | TParamContr. |
Public methods:
- bool dataActive( ); Activity (updatable) flag of data.
- virtual string DAQPath( ); Getting for DAQ-address of the element.
- void vlList( vector<string> &list ) const; Getting the attributes' list.
- bool vlPresent( const string &name ) const; Check for the availability of the specified attribute.
- AutoHD<TVal> vlAt( const string &name ) const; Connection to the attribute.
Protected methods:
- TConfig *vlCfg( ) Getting of the associated configuration object. If NULL is returned then there is no associated configuration object.
- void setVlCfg( TConfig *cfg ); Setting of the associated configuration object cfg.
- bool vlElemPresent( TElem *ValEl ); Check for the availability if the attributes' elements ValEl.
- void vlElemAtt( TElem *ValEl ); Attach of the data structure ValEl.
- void vlElemDet( TElem *ValEl ); Detach of the data structure ValEl.
- TElem &vlElem( const string &name ); Get the data structure by its name name.
- virtual TVal* vlNew( ); Creation of the TVal instance. It can be overridden in the module for the creation of derived objects of the parameters' attributes of the subsystem "Data acquisition".
- virtual void vlGet( TVal &vo ); Predicting function of the value getting. It is used for direct (synchronous) reading.
- virtual void vlSet( TVal &vo, const TVariant &vl, const TVariant &pvl ); Predicting function of the value setting. It is used for direct (synchronous) writing vl with the previous value into pvl.
- virtual void vlArchMake( TVal &val ); Notifying function of the creation of the archive for the val attribute. It is used to configure the created archive in accordance with the peculiarities of the data source.
4.7. Attribute's object (TVal).
Data:
Additional flags to the object TFld (enum TVal::AttrFlag):
- TVal::DirRead(0x100) Flag for the direct reading of the value;
- TVal::DirWrite(0x200) Flag for the direct writing of the value;
- TVal::Dynamic(0x400) Flag of the dynamic attribute, creates in typical from user procedures.
Public methods:
- TVal( ); Default constructor.
- TVal( TFld &fld ); Initialization as the repository of dynamic data.
- TVal( TCfg &cfg ); Initialization as the reflection of static data (DB).
- string DAQPath( ); Getting for DAQ-address of the element.
- void setFld( TFld &fld ); Initialization as the repository of dynamic data.
- void setCfg( TCfg &cfg ); Initialization as the reflection of static data (DB).
- string name( ); Attribute's name.
- int64_t time( ); Time marker of the the last/current value (10-6s).
- bool isCfg( ); Sign of the value object created in base of a configuration element.
- bool dataActive( ); Activity (updatable) flag of data.
- string getSEL( long long *tm = NULL, bool sys = false ); Request of the selected type value for the specified time tm. If NULL then it will be returned the last value.
- TVariant get( long long *tm = NULL, bool sys = false ); Request of the value for the specified time tm. If NULL then it will be returned the last value.
- string getS( long long *tm = NULL, bool sys = false ); Request of the string type value for the specified time tm. If NULL then it will be returned the last value.
- double getR( long long *tm = NULL, bool sys = false ); Request of the real type value for the specified time tm. If NULL then it will be returned the last value.
- int64_t getI( long long *tm = NULL, bool sys = false ); Request of the integer type value for the specified time tm. If NULL then it will be returned the last value.
- char getB( long long *tm = NULL, bool sys = false ); Request of the boolean type value for the specified time tm. If NULL then it will be returned the last value.
- AutoHD<TVarObj> getO( int64_t *tm = NULL, bool sys = false ); Request of the object type value.
- void setSEL( const string &value, long long tm = 0, bool sys = false ); Setting of the selected type value value.
- void set( const TVariant &value, long long tm = 0, bool sys = false ); Setting of the value value.
- void setS( const string &value, long long tm = 0, bool sys = false ); Setting of the string type value value.
- void setR( double value, long long tm = 0, bool sys = false ); Setting of the real type value value.
- void setI( int64_t value, long long tm = 0, bool sys = false ); Setting of the integer type value value.
- void setB( char value, long long tm = 0, bool sys = false ); Setting of the boolean type value value.
- void setO( AutoHD<TVarObj> value, int64_t tm = 0, bool sys = false ); Setting of the object type value value.
- AutoHD<TVArchive> arch( ); Getting the associated with the value archive.
- void setArch( const AutoHD<TVArchive> &vl ); Setting the associated with the value archive.
- string setArch( const string &nm = "" ); Setting/creation new archive with proposed name nm or automatic, if name empty.
- bool reqFlg( ); bool resB1( ); bool resB2( ) Get some realisation-specific flags.
- void setReqFlg( bool vl ); void setResB1( bool vl ); void setResB2( bool vl ) Set some realization-specific flags.
- TFld &fld( ); Descriptor of the attribute's structure.
4.8. Object of the templates library of parameters of the "DAQ" subsystem (TPrmTmplLib)
Inherits: | TCntrNode, TConfig. |
Public methods:
- TPrmTmplLib( const char *id, const char *name, const string &lib_db ); Initializing constructor.
- string id( ); Library ID.
- string name( ); Library name.
- string descr( ); Library description.
- string DB( ); DB of the library instance.
- string tbl( ); DB table of the library instance.
- string fullDB( ); Full address of the DB table of the library instance.
- bool startStat( ); Sign "Library started".
- void start( bool val ); Satart/stop of the library.
- void setName( const string &vl ); Setting of the library name.
- void setDescr( const string &vl ); Setting of the library description.
- void setFullDB( const string &vl ); Setting of the full address of the DB table of the library instance.
- void list( vector<string> &ls ) const; Templates list in the library.
- bool present( const string &id ) const; Check for the presence of the template id in the library.
- AutoHD<TPrmTempl> at( const string &id ) const; Connection to the template id.
- void add( const char *id, const char *name = "" ); Addition of the template id.name into the library.
- void del( const char *id, bool full_del = false ); Deleting of the template id from the library.
- TDAQS &owner( ) const; Object subsystem "DAQ", owner of the library.
4.9. The object of the parameter's template of the "DAQ" subsystem (TPrmTempl)
Inherits: | TFunction, TConfig. |
Data:
Additional flags to the attribute's object of the function IO (enum TPrmTempl::IOTmplFlgs):
- TPrmTempl::AttrRead(0x10) Read only attribute;
- TPrmTempl::AttrFull(0x20) Full access attribute;
- TPrmTempl::CfgPublConst(0x40) Public constant;
- TPrmTempl::CfgLink(0x80) External link;
- TPrmTempl::LockAttr(0x100) Blocked attribute.
Public methods:
- TPrmTempl( const char *id, const char *name = "" ); Initializing constructor of the template.
- string id( ); Parameter's template ID.
- string name( ); Parameter's template name.
- string descr( ); Parameter's template description.
- int maxCalcTm( ); The limit on the maximum time calculation of procedure template.
- string progLang( ); Parameter's template programming language.
- bool progTr( ); Parameter's template program transaltion.
- string prog( ); Parameter's template program.
- int64_t timeStamp( ); Timestamp for the object changes into DB.
- void setName( const string &inm ); Setting the name of the parameter's template.
- void setDescr( const string &idsc ); Setting the description of the parameter's template.
- void setMaxCalcTm( int vl ); Setting the limit on the maximum time calculation of procedure template.
- void setProgLang( const string &ilng ); Setting the programming language of the parameter's template.
- void setProgTr( bool vl ); Setting the program of the parameter's template translation.
- void setProg( const string &iprg ); Setting the program of the parameter's template.
- void setStart( bool val ); Start/stop of the parameter's template.
- AutoHD<TFunction> func( ); Connection to the function formed by the template.
- TPrmTmplLib &owner( ) const; Object of the templates' library - the owner of the template.