This paper describes an application programming interface (API) of the OpenSCADA system.
OpenSCADA is the project of an open SCADA-system based on the modular principle. The document contains an exhaustive description of the internal system architecture of OpenSCADA. In addition to information on the architecture the background information on methods and attributes of the system is provided.
The document is intended for programmers wishing to understand the architecture of OpenSCADA and develop extensions for it. The document is not intended for users and integrators of OpenSCADA!
For understanding of this document it is necessary for you to know the concept of Object Oriented Programming (OOP) and Universal Modeling Language (UML), and for the possibility of studying the source code of the project it is required the knowledge of programming language C++. In addition, the document contains the mentioning of the following technologies: relational databases, XML.
For the purpose of visual and affordable perception of the OpenSCADA system architecture in general the Figure 1 shows the static class diagram of OpenSCADA on the universal modeling language (UML). Based on the chart it is clear that the OpenSCADA system contains modular subsystems: "Archives", "Databases", "Transports", "Transport protocols", "User interfaces", "Data acquisition" and "Special", as well as subsystems: "Safety" and "Module's management". The chart graphically presents the relationship between modular subsystems and modules.
2. The overall structure of the system. Modularity (TSubSYS, TModule)
The root, from which we construct the whole system is the object of TSYS. The root contains a subsystem (TSubSYS). Subsystems can be: the ordinary and modular. The difference between the modular subsystems is clearly shown in Fig. 1. Thus, the modular subsystems necessarily contain a list of modular structures (TModule), such as subsystem TArchiveS contain modular objects TTypeArchivator. At the same time, the normal subsystem does not contain such objects. For example TSecurity subsystem (Figure 2).
Fig. 2. Hierarchical structure of OpenSCADA.
In the process of initializing the root (TSYS) the global variable SYS is defined. The variable SYS can be used for direct access to the root of the system from any of its node. Initialization of the root is performed only one time from the main calling function. After starting the management is captured by the system object till stop. The root object concentrate all system functions of the OpenSCADA system.
Extension of the root object (TSYS) is the object TMess, which performs the functions of service of the flow of system messages. The object is accessible through the global variable Mess, which is initialized by the root of the system. The object contains the functions of encoding, decoding, and localization of messages.
In the subsystems (TSubSYS) the functions typical for each subsystem individually with the general access for all subsystems are carried out through the object TSubSYS. Modular subsystem is able to extend its functionality by means of modules. For this purpose, modular subsystem provides access to the modules of its type in the form of modular objects.
Module is the component of the modular subsystem. In general, for all modules and subsystems, the module provides information about itself, its origin and export functions. Individual module implements the functionality according to its own needs.
2.1. The root object system (TSYS)
Inherits:
TCntrNode.
Data:
Information variables of the program:
PACKAGE_LICENSE — Distribution license of the program
PACKAGE_DESCR — Brief description of the program
PACKAGE_AUTHOR — Author of the program
PACKAGE_SITE — Web site of the program support
Methods for coding of symbol sequences (enum — TSYS::Code):
PathEl — element of the path (the characters: '/' and '%' to the form '%2f');
HttpURL — address of the browser (http url);
Html — special characters for use in html;
JavaSc — end of line character for JavaScript;
SQL — SQL-query value;
Custom — selective coding of the specified characters;
base64 — Mime encoding in the standard Base64;
FormatPrint — Coding/masking of the formating elements for functions like "printf";
oscdID — coding of the nodes' identifiers.
Bin — Encoding of the binary data in text and vice versa.
Reverse — Invert the order of characters in the line.
ShieldSimb — Shielded symbols like "\n" encoding to real code.
ToLower — Convert to lower case.
Types of representations of the integer in the function TSYS::int2str(), and TSYS::ll2str() (enum — TSYS::IntView):
Dec — decimal;
Oct — octal;
Hex — hexadecimal.
Structure of redundant station (class — TSYS::SStat):
int8_t lev; — station level;
bool isLive; — flag "Station Alive";
float cnt; — counter of requests to the remote station or timer of a re-connection try;
SStat( int8_t ilev, bool iisLive = false, float icnt = 0 ) — station object constructor with level ilev, initiated as "Alive" iisLive and counter icnt;
SStat( ) — constructor by default, initiated as as a missed and an inactive station;
bool isActive( ) — station is active.
Structure of OpenSCADA task (class — TSYS::STask):
STask( pthread_t ithr, char ipolicy, char iprior ); — constructor of the task's descriptor for thread ithr, it's scheduling policy ipolicy and priority iprior.
float consumpt( ) const; — the task's last CPU time consumption, in seconds.
float period( ); — the task's call instant periodicity, in seconds.
string path; — path.
pthread_t thr; — thread handler.
uint8_t policy, prior; — scheduling policy and priority.
pid_t tid; — thread's identifier as a Linux process's ID.
int64_t tm_beg, tm_end, tm_per, tm_pnt, cycleLost, lagMax, consMax; — statistic variables of the task execution.
Templates/definitions:
USER_FILE_LIMIT — The limit to files size for user's loading (1 MB).
STR_BUF_LEN — Standard length of string buffers (10000).
NSTR_BUF_LEN — Standard length of string buffers, for numbers (100).
STD_WAIT_DELAY — Standard quantum of the waiting time cycles (100 ms).
STD_CACHE_LIM — Standard cache limit (100).
STD_WAIT_TM — Standard interval of the event waiting (10 ms).
STD_INTERF_TM — Timeout, maximum time, waiting for the interface reaction (5 s).
BUF_ARCH_NM — The archive buffer name ("<buffer>").
ALRM_ARCH_NM — The alarms table name ("<alarms>").
__func__ — The full name of the calling function.
vmin (a,b) — Determination of the minimum value.
vmax (a,b) — Definition of the maximum value.
Public methods:
TSYS( int argi, char **argb, char **env ); — The initializing constructor.
void unload( ); — Unload subsystems.
int start( ); — Start of the system. The function is finished only with the finishing of the system. The return code is returned.
void stop( int sig = SIGUSR1 ); — Stop program by the signal sig, by default it is SIGUSR1 and SIGUSR2 reserved for projects manager.
int stopSignal( ); — The return code in the case of system shutdown. Can be used as a sign of "System shutdown" of the various subsystems.
string id( ); — station ID.
string name( ); — Localized name of the station.
string user( ); — The system user on behalf of which the system is running .
string host( ); — Host name for the station run.
void list( vector<string> &list ) const; — A list of registered subsystems in the system.
bool present( const string &name ) const; — Check the availability of the subsystem.
void add( TSubSYS *sub ); — Add/registration of the subsystem.
void del( const string &name ); — Removing the subsystem.
AutoHD<TSubSYS> at( const string &name ) const; — Connection to the specified subsystem.
AutoHD<TUIS> ui( ); — Direct access to the subsystem "User interfaces".
AutoHD<TArchiveS> archive( ); — Direct access to the subsystem "Archives".
AutoHD<TBDS> db( ); — Direct access to the subsystem "Databases".
AutoHD<TControllerS> daq( ); — Direct access to the subsystem "Data acquisition".
AutoHD<TProtocolS> protocol( ); — Direct access to the subsystem "Protocols".
AutoHD<TTransportS> transport( ); — Direct access to the subsystem "Transports".
AutoHD<TSpecialS> special( ); — Direct access to the subsystem "Special".
AutoHD<TModSchedul> modSchedul( ); — Direct access to the subsystem "Module".
AutoHD<TSesurity> sesurity( ); — Direct access to the subsystem "Security".
string workDir( ); — Working directory of the station.
string modDir( ); — Directories with the modules of OpenSCADA, separated by ';', they can include a files' template into the end (/my/modules/path/lib*.so).
string icoDir( ); — Directory of the icons of OpenSCADA.
string docDir( ); — Directory of the documents of OpenSCADA.
void setWorkDir( const string &wdir, bool init = false ); — Setting the working directory of the station.
void setModDir( const string &mdir, bool init = false ); — Specifying the directories of the modules of OpenSCADA.
void setIcoDir( const string &idir, bool init = false ); — Specifying of the directory of icons of OpenSCADA.
void setDocDir( const string &idir, bool init = false ); — Specifying of the directory of documents of OpenSCADA.
string cfgFile( ); — Name of configuration file of the system.
XMLNode &cfgRoot( ); — Parsed structure of the configuration file.
XMLNode *cfgNode( const string &path, bool create = false ); — Node of configuration getting by it path path. Elements of the path creation by it miss create.
void modifCfg( bool chkPossibleWR = false ); — Configuration mark to modification or write possibility chkPossibleWR, for next saving to file.
string workDB( ); — The full name of the working database.
string selDB( ); — Chosen DB. Used for selective loading from the specified database in the subsystem "DB".
string mainCPUs( ); — Used processors list.
bool clockRT( ); — The Real-time clock selection for the tasks planning, else used the monotonic one (by defaults).
bool saveAtExit( ); — Sign - "Save configuration on exit".
int savePeriod( ); — Frequency of the automatically saving the station in the database (seconds).
void setWorkDB( const string &wdb ); — Setting of the full name of the working database.
void setSelDB( const string &vl ); — Installation of the selected database for the specified boot.
void setMainCPUs( const string &vl ); — Setting of used processors list.
void setClockRT( bool vl ); — Setting of the Real-time clock selection for the tasks planning.
void setSaveAtExit( bool vl ); — Setting of the sign - "Save configuration on exit".
void setSavePeriod( int vl ); — Set the frequency of the automatically saving of the station to the database (seconds).
bool chkSelDB( const string &wDB ); — The function of checking for compliance of the specified database wDB with the selected "selDB()".
string optDescr( ); — Localized help on the options of the command line and parameters of the configuration file.
static void sighandler( int signal ); — Function of the default handler of the signals of the system as a whole.
unsigned long long sysClk( ); — The estimated frequency of the processor on which the system works (Hz).
void clkCalc( ); — Calculation of frequency of the processor on which the system works. It is called periodically for the systems with variable CPU frequency.
unsigned long long shrtCnt( ); — The function of the measurement of small intervals of time by the counter of the CPU cycles. Returns the value of the counter of CPU cycles.
static long HZ( ); — Time of the system teak of the CPU.
void taskCreate( const string &path, int priority, void *(*start_routine)(void *), void *arg, int wtm = 5, pthread_attr_t *pAttr = NULL, bool *startSt = NULL ); — Create task (thread) with id path, priority (-1...99), task's function start_routine and it argument arg, and also wait for user's code start by flag startSt.
void taskDestroy( const string &path, bool *endrunCntr = NULL, int wtm = 5, bool noSignal = false ); — Destroy task with id path, start control flag startCntr. Use noSignal for exclude signal SIGALRM send to the task.
double taskUtilizTm( const string &path, bool max = false ); — Utilization of CPU time, in seconds, for task path or it's maximum max.
static bool taskEndRun( ); — Check for the task endrun by signal SIGUSR1.
static const STask& taskDescr( ); — Get reference to the task's descriptor.
static int sysSleep( float tm ); — System sleep in seconds up to nanoseconds (1e-9).
time_t sysTm( ); — System time fast access, from updated cell
static int64_t curTime( ); — The actual time in microsecond from the beginning of the era (01.01.1970).
string prjUserDir( ); — Directory of the user projects.
bool prjCustMode( ); — Custom mode of projects.
void setPrjCustMode( bool vl ); — Set for custom mode of projects.
string prjNm( ); — Project name of the configuration.
void setPrjNm( const string &vl ); — Set project name of the configuration.
int prjLockUpdPer( ); — Get project lock updating period, zero for the lock disable.
bool prjLock( const char *cmd ); — Project lock process for the command cmd ("hold", "free", "update").
static void taskSleep( int64_t per, const string &cron = "", int64_t *lag = NULL ); — The function of the flow sleep by the grid of absolute time with the period per in the nanosecond or for the scheduled time cron. If set lag then to it will return different value from real and planed wake up time (lost cycles).
static time_t cron( const string &vl, time_t base=0 ); — Planning the execution time on the format of the standard Cron vl beginning at the basic time base or at the current time if the base is not specified.
static bool eventWait( bool &m_mess_r_stat, bool exempl, const string &loc, time_t time=0 ); — Function of the event waiting exempl for the variable m_mess_r_stat within a specified time interval time for the source loc.
bool cntrEmpty( ); — Debug counters checking to empty.
void cntrSet( const string &id, double vl ); — Debug counter id setting to value vl.
void cntrIter( const string &id, double vl ); — Debug counter id iteration to value vl.
bool rdEnable( ); — Redundancy enabled, at least one redundancy station presented.
bool rdActive( ); — Redundancy active, at least one active station presented.
void rdStList( vector<string> &ls ); — List of ls stations into the redundancy.
SStat rdSt( const string &id ); — Get copy of state structure of the redundancy station id.
map<string, SStat> rdSts( ); — Get copy of list of state structures of redundancy stations.
int rdStLevel( ); — Current station level into the redundancy system.
void setRdStLevel( int vl ); — Set current station level into the redundancy system.
float rdTaskPer( ); — Period of execution of the redundancy processing task.
void setRdTaskPer( float vl ); — Set period of execution of the redundancy processing task.
int rdRestConnTm( ); — Time of the retry attempts to reconnect to the backup station after its loss in seconds.
void setRdRestConnTm( int vl ); — Set time of the retry attempts to reconnect to the backup station after its loss in seconds.
string rdStRequest( XMLNode &req, const string &st = "" ); — Common request req to pointed redundancy station st.
static string int2str( int val, IntView view=Dec ); — Transformation of a signed integer to the string of the type of view view.
static string uint2str( unsigned val, IntView view=Dec ); — Transformation of unsigned integer to the string type of view view.
static string ll2str( long long val, IntView view=Dec ); — Transformation of a long integer (64bit) to the string type of view view.
static string real2str( double val, int prec=15, char tp='g'); — Real transformation with an accuracy prec signs and type tp to the string.
static double realRound( double val, int dig=0, bool toint=false ); — Rounding the real number to the specified digit dig after the decimal point with the possibility of transformation to integer after rounding toint.
static string atime2str( time_t tm, const string &format = "" ); — Astronomic UNIX time tm conversion to string, by format format of POSIX-function "strftime()".
static string time2str( double tm ); — Convert time interval, in seconds, to string like "1hour 23min 10sec".
static string cpct2str( double cnt ); — Traffic counter cnt (bytes) convert to string like "12.5KiB".
static double str2real( const string &val ); — String transformation to the real.
static void *str2addr( const string &str ); — Convert string into the address.
static string strTrim( const string &val, const string &cfg = " \n\t\r" ); — Deletes from the original string val pointed into cfg (mostly empty) characters at the beginning and end of it.
static string strSepParse( const string &path, int level, char sep, int *off=NULL ); — Parsing of the string path into the components separated by the dividing symbol sep, beginning with the offset off and controlling the offset of the element end in itself.
static string strParse( const string &str, int level, const string &sep, int *off = NULL, bool mergeSepSymb = false ); — Parse function's "strSepParse()" expanded version which allow using multi-symbols separators and one symbols merging.
static string strLine( const string &str, int level, int *off = NULL ); — Parsing text lines for different ways to the end of a line (CR, LF and CR/LF).
static string pathLev( const string &path, int level, bool decode = true, int *off = NULL ); — The allocation of the elements of the path path with the ability of their decode, starting with the offset off and controlling the offset of the element end in itself.
static string path2sepstr( const string &path, char sep = '.' ); — Transformation the path into string with the separator sep of the elements.
static string sepstr2path( const string &str, char sep = '.' ); — Transformation of the string with the separator sep of the elements into the path.
static string strEncode( const string &in, Code tp, const string &opt1 = "" ); — Encoding of the string by the specified rule tp and option opt1 (symbols by "Custom").
static string strDecode( const string &in, Code tp = Custom, const string &opt1 = "" ); — Decoding of the string in by the specified rule tp and option opt1 (separator or "<text>" for "Bin").
static string strMess( const char *fmt, ... ); static string strMess( unsigned len, const char *fmt, ... ); — Formation of the string by the template fmt and arguments. It is implemented on the basis of "printf". For the length limit variant exceeding mark by append "...".
static string strLabEnum( const string &base ); — Individual string labels from base forming by increment at end. Supported numbering into decimal, hexadecimal (prefix "0x") or octal (prefix "0") notation.
string strCompr( const string &in, int lev=-1); — Compression of the string in with the compression level lev.
string strUncompr( const string &in ); — Decompression of the string in.
static inline int getUnalignInt( const void *p ); — Unaligned read for integer from buffer by offset.
static inline float getUnalignFloat( const void *p ); — Unaligned read by real "float" from buffer by offset.
static inline double getUnalignDbl( const void *p ); — Unaligned read by real "double" from buffer by offset.
static uint16_t i16_LE( uint16_t in ); static uint32_t i32_LE( uint32_t in ); static uint64_t i64_LE( uint64_t in ); — Byte order conversion for integer in from Little-Endian (LE) to internal represent.
static uint16_t i16_BE( uint16_t in ); static uint32_t i32_BE( uint32_t in ); static uint64_t i64_BE( uint64_t in ); —Byte order conversion for integer in from Big-Endian (BE) to internal represent.
static float floatLE( float in ); static double doubleLE( double in ); — Real number in conversion from internal to format IEEE754 Little-Endian (LE).
static float floatLErev( float in ); static double doubleLErev( double in ); — Real number in conversion from format IEEE754 Little-Endian (LE) to internal.
static float floatBE( float in ); static double doubleBE( double in ); — Real number in conversion from internal to format IEEE754 Big-Endian (BE).
static float floatBErev( float in ); static double doubleBErev( double in ); — Real number in conversion from format IEEE754 Big-Endian (BE) to internal.
string getCmdOpt( int &curPos, string *argVal = NULL ); static string getCmdOpt_( int &curPos, string *argVal, int argc, char **argv ); — Command line parameters parsing by cursor scanning curPos. Return argument name and it's possible value into argVal. Implement formats for short keys: "-v", "-v val", "-abcv", "-abcv val"; and long keys: "--var", "--var=val", "--var val".
bool cmdOptPresent( const string &opt ); — Check the command-line option opt for presenting.
string cmdOpt( const string &opt, const string &setVl = "" ); — Get command-line option opt. Set it at setVl if pointing.
static void ctrListFS( XMLNode *nd, const string &fsBase, const string &fileExt = "" ); — Browsing list for file system's items from base fsBase, for the files with extensions fileExt in list "png;jpeg;gif;".
ResRW &cfgRes( ); — Access to config file tree resource locking.
Public attributes:
static bool finalKill — Sign "The final killing of". It is used for forced disconnection of blocked objects on the the final stage of shutdown.
Short calls for global functions into "OSCADA" namespace:
template <class fVal> fVal fmin( fVal a, fVal b ); template <class fVal> fVal fmax( fVal a, fVal b ); — functional templates for obtain of two values minimum and maximum.
Data:
Types (levels) of messages (enum — TMess::Type):
Debug (0) — debug;
Info (1) — information;
Notice (2) — the notification;
Warning (3) — warning;
Error (4) — error;
Crit (5) — critical situation;
Alert (6) — alert;
Emerg (7) — emergency.
Direction for the messages (enum — TMess::Direct):
DIR_SYSLOG (0x1) — to SYSLOG;
DIR_STDOUT (0x2) — to standard output;
DIR_STDERR (0x4) — to standard errors output;
DIR_ARCHIVE (0x8) — to messages archive.
The structure of the message (class — TMess:: SRec):
time_t time; — time of the message;
int utime; — microsecond of the message time;
string categ; — category of messages (usually the way inside the system);
int8_t level; — the level of the message;
string mess; — message.
Templates:
_( mess ) — Wrapper over the translation of the messages function for the provision of the accepted by the most of the programs translation of the messages.
trL(base,lng); trU(base,usr); trLU(base,lng,usr) — Wrappers over the text variables dynamic translation functions by language and user.
trSetL(base,lng,mess); trSetU(base,usr,mess); trSetLU(base,lng,usr,mess) — Wrapper over the text variables dynamic translation set functions by language and user.
FTM(rec); FTM2(tm, utm) — Get a full time of the message, in microseconds, using the two fields of time of the message structure.
mess_lev() — The system's messages level. Often used for debug mode check (=Debug).
message( cat, lev, fmt, args ... ) — Formation of the the full message.
mess_debug( cat, fmt, args ... ) — Formation of the debug message.
mess_info( cat, fmt, args ... ) — Formation of the information message.
mess_note( cat, fmt, args ... ) — Formations of the message - notification.
mess_warning( cat, fmt, args ... ) — Formation of the warning message.
mess_err( cat, fmt, args ... ) — Formation of the error message.
mess_crit( cat, fmt, args ... ) — Formation of the critical condition message.
mess_alert( cat, fmt, args ... ) — Formation of the alarm message.
mess_emerg( cat, fmt, args ... ) — Formation of the emergency message.
message_( cat, lev, fmt, args ... ) — Formation of the the full message (selected level and debug categories are ignored).
mess_debug_( cat, fmt, args ... ) — Formation of the debug message (selected level and debug categories are ignored).
mess_info_( cat, fmt, args ... ) — Formation of the information message (selected level is ignored).
mess_note_( cat, fmt, args ... ) — Formations of the message - notification (selected level is ignored).
mess_warning_( cat, fmt, args ... ) — Formation of the warning message (selected level is ignored).
mess_err_( cat, fmt, args ... ) — Formation of the error message (selected level is ignored).
mess_crit_( cat, fmt, args ... ) — Formation of the critical condition message (selected level is ignored).
mess_alert_( cat, fmt, args ... ) — Formation of the alarm message (selected level is ignored).
mess_emerg_( cat, fmt, args ... ) — Formation of the emergency message (selected level is ignored).
Public methods:
void load( ); — Download.
void save( ); — Saving.
string codeConv( const string &fromCH, const string &toCH, const string &mess); — Conversion of the codepage of the messages.
string codeConvIn( const string &fromCH, const string &mess); — Conversion the codepage of the messages into the internal system codepage.
string codeConvOut ( const string &toCH, const string &mess); — Conversion of the message from the internal system codepage.
const char *I18N( const char *mess, const char *d_name = NULL, const char *mLang = NULL ); — Getting the message mess/ in the language mLang// or system one at its NULL or empty or not dynamic messages translation mode.
string I18Ns( const string &mess, const char *d_name = NULL, const char *mLang = NULL ); — Getting the message mess/ in the language mLang// or system one at its NULL or empty or not dynamic messages translation mode.
string lang( ); — Language of the system, as en_US.UTF-8.
string lang2Code( ); — Language of the system in bi-symbolic codepage (en).
string &charset( ); — The system codepage.
int logDirect( ); — Receivers to whom the system messages (stdout, stderr, syslog, archive) are sent;
int messLevel( ); — The level below which the messages are ignored.
void put( const char *categ, int8_t level, const char *fmt, ... ); — The message forming for the current time with the category categ, the level, the formatted message fmt and the followed arguments.
void put_( const char *categ, int8_t level, const char *fmt, ... ); void putArg( const char *categ, int8_t level, const char *fmt, va_list ap ); — The message forming for the current time (selected level and debug categories are ignored) with the category categ, the level, the formatted message fmt and the followed arguments.
void get( time_t b_tm, time_t e_tm, vector<TMess::SRec> &recs, const string &category = "", int8_t level = Debug ); — Get the message from the archive for the period of time b_tm — e_tm under the category template category and minimum level level.
string lang2CodeBase( ); — The language of basic variables of the text messages in bi-symbolic codepage(en).
bool translDyn( bool plan = false ); — Mode "Dynamic translation" or the plan to next start.
bool translEnMan( ); — The sign "Enabled translations manager", for activation of the built translation messages index and the translation manager.
string translLangs( ); — List of translation languages, into the manager.
string translFld( const string &lng, const string &fld, bool isCfg = false ); — Representing the translated field name by the field name fld and language lng for configuration isCfg or DB.
void setLang2CodeBase( const string &vl ); — Setting the language of the basic message of text variables in the bi-symbolic codepage (en).
void setTranslDyn( bool val, bool plan = true ); — Setting the mode "Dynamic translation" or the plan to value val for next start.
void setTranslEnMan( bool vl, bool passive = false ); — Setting "Enabled translation manager" to value vl and passive mode passive.
void setTranslLangs( const string &vl ); — Setting a list of translation languages.
string translGet( const string &base, const string &lang, const string &src = "" ); string translGetU( const string &base, const string &user, const string &src = "" ); string translGetLU( const string &base, const string &lang, const string &user, const string &src = "" ); — Getting translation for base text variable for language lang or user and optional source src.
string translSet( const string &base, const string &lang, const string &mess, bool *needReload = NULL ); string translSetU( const string &base, const string &user, const string &mess, bool *needReload = NULL ); string translSetLU( const string &base, const string &lang, const string &user, const string &mess, bool *needReload = NULL ); — Setting translation for base text variable for language lang or user and optional source src to value mess.
void translReg( const string &mess, const string &src, const string &prms = "" ); — Registering the translated message mess with source src and appended parameters prms into the translations index.
TSubSYS( const char *id, const char *name, bool mod = false ); — Initialize the constructor. Sign mod indicates that subsystem is module one.
string subId( ); — ID of the subsystem.
string subName( ); — Localized name of the subsystem.
bool subStartStat( ); — Sign of the subsystem execution.
bool subModule( ) const; — Sign of the modularity of the subsystem.
virtual int subVer( ); — Version of the subsystems.
virtual void subStart( ); — Start of the the subsystem.
virtual void subStop( ); — Stop of the subsystem.
void modList( vector <string> &list ); — List list of the modules of the modular subsystem.
bool modPresent( const string &name ); — Check for the availability of the module name.
void modAdd( TModule *modul ); — Add/registration of the module modul.
void modDel( const string &name ); — Deleting of the module name.
AutoHD <TModule> modAt( const string &name ) const; — Connection to the module name.
virtual void perSYSCall( unsigned int cnt ); — Periodic call from system thread, with period 10 seconds and seconds counter cnt.
virtual bool rdProcess( XMLNode *reqSt = NULL ); — Processing of redundancy of the subsystem, calls from the system's task of redundancy. reqSt pass a result of a state request to the redundancy station for this subsystem.
TSYS &owner( ) const; — The system - the owner of the subsystem.
int tVer; — version of the type of module (subsystem) to which the module is designed.
The structure of exported functions (class — TModule::ExpFunc):
string prot; — a prototype of the function;
string dscr; — localized description of the function;
void (TModule::*ptr) (); — relative address of the function (with respect to the object module).
Public methods:
TModule( const string &id ); — Initialize the constructor of module id.
string modId( ); — ID of the module.
string modName( ); — Localized name of the module.
virtual void modStart( ); — Start of the module.
virtual void modStop( ); — Stop of the module.
virtual void modInfo( vector<string> &list ); — A list of information items list of the module.
virtual string modInfo (const string &name ); — Getting the contents of the specified information item name. For get the item on different language, at dynamic messages translation, you can set the name in way "{Name}:{lang}".
virtual void perSYSCall( unsigned int cnt ); — Periodic call from system thread, with period 10 seconds and seconds counter cnt.
void modFuncList( vector<string> &list ); — The list of exported functions list of the module.
bool modFuncPresent( const string &prot ); — Check the availability of the specified function by its prototype prot.
ExpFunc &modFunc (const string & prot); — Get the information about exported function of the module prot.
bool modFunc( const string &prot, void (TModule::**offptr)(), bool noex = false ); — Getting the relative address offptr of the exported function prot. Returns "true" for successful and the non-exceptional mode noex.
const char *I18N( const char *mess ); — Localization of modular message mess in accordance with the current locale.
TSubSYS &owner( ) const; — Subsystem - the owner of the module.
Subsystem "Databases" is represented by the object TBDS, which contains a modular objects of the following types of DB TTypeBD. Each type of database contains objects of individual databases of that type TBD. Each database in its turn, contains the objects of their tables TTable (Fig. 3).
Fig. 3. Hierarchical structure of the database subsystem.
The subsystem provides the basic functions to access the type of database, as well as generalized functions for the manipulation of the databases and tables. For example, to hide the source of data, which may be a configuration file, the functions of an abstract access to the data source are provided. For the storage system-wide data the system table and the function of the abstract to access it are provided. Consequently, system-wide data can be stored in the configuration file and in the database table. Priority source, in this case, is the database table.
Being a modular object, the type of database (TTypeBD) provides access to the implementation of the mechanism of one or another database. Access is made through a public databases of the module of a given type of database. Open/registered database is described in the table of databases to be opened or in the configuration file. There is, the so-called, the working database, which is always opens and is shown in the configuration file. DB which support the SQL-queries can grant access based on direct SQL-queries.
While working, the components of the OpenSCADA system open tables (TTable) available in the database and work with them.
3.1. Object of subsystem "Database" (TBDS)
Inherits:
TSubSYS, TElem.
Data:
Flags of the queries to the system table (enum – TDBS::ReqGen):
OnlyCfg — request only to the configuration file.
UseTranslate — use the translation of text variable.
Public methods:
int subVer( ); — Subsystem version.
static string realDBName( const string &bdn ); — Conversion of the full template name of the database or table (of view *.*.myTbl) in the real name. Actually the replacement of the special elements '*' by the elements of the working DB.
void dbList( vector<string> &ls, bool checkSel = false ); — A list of available databases.. checkSel points to the necessity to verify the fact of boot from the selected database and to insert to the db list the only selected one.
AutoHD<TTable> open( const string &bdn, bool create = false ); — Opening the table bdn of the DB by its full path with the creation create in the case of its absence.
void close( const string &bdn, bool del = false ); — Closing the table bdn of the DB by its full path with the possibility of deleting of it after closing del.
bool dataSeek( const string &bdn, const string &path, int lev, TConfig &cfg, bool forceCfg = false, vector< vector<string> > *full = NULL ); — Total scanning of the records of the data source. The configuration file of the DB is the source if data. In the case of DB absence the configuration file is used. If the DB name bdn or path path to the configuration file are not indicated, their processing is skipped. full defines before a record for it's result preloading in whole and significant acceleration.
bool dataGet( const string &bdn, const string &path, TConfig &cfg, bool forceCfg = false, bool noEx = false ); — Getting the record from the data source (database or configuration file). If the DB name bdn or path path to the configuration file are not indicated, their processing is skipped.
void dataSet( const string &bdn, const string &path, TConfig &cfg, bool forceCfg = false, bool noEx = false ); — Set/Save the record in the data source (database or configuration file). If the DB name bdn or path path to the configuration file are not indicated, their processing is skipped.
bool dataDel( const string &bdn, const string &path, TConfig &cfg, bool useKeyAll = false, bool forceCfg = false, bool noEx = false ); — Deleting the record in the data source (database or configuration file). If the DB name bdn or path path to the configuration file are not indicated, their processing is skipped. useKeyAll is used to indicate the necessity of the all keys set fro their using while deleting with the restoration of the original state of the keys selection when the function is finished. If this flag is not set, the early selected keys are used to perform the operation.
static string genDBGet( const string &path, const string &oval = "", const string &user = "root", char rFlg = 0 ); — Get system-wide data from the configuration file or system tables on behalf of user name user. If data are not available the value oval is returned.
static void genDBSet( const string &path, const string &val, const string &user = "root", char rFlg = 0 ); — Set/Save the system-wide data in the configuration file or system tables on behalf of user name user.
string fullDBSYS( ); — The full name of the system table.
string fullDB( ); — The full name of the table with a description of the registered databases.
TElem &openDB_E( ) — The structure of the table of registered databases.
AutoHD<TTypeBD> at( const string &iid ) — Referencing to the DB module(DB type).
string optDescr( ); — Localized help on the command line options and parameters in the configuration file.
3.2. Modular object of types of databases (TTypeBD)
Inherits:
TModule.
Inherited:
By root objects of the modules of subsystem "DB".
Public methods:
bool fullDeleteDB( ); — Sign of the complete removal of the database.
void list( vector<string> &list ) const; — The list of registered (opened) databases.
bool openStat( const string &idb ) const; — Check the availability of the specified opened database.
void open( const string &iid ); — Opening of the database.
void close( const string &iid, bool erase = false ); — Closing the database. If the sign erase is set, the database will be completely removed.
AutoHD<TBD> at( const string &name ) const; — Connection to the opened database.
TBDS &owner( ) const; — Subsystem - the owner of the module.
3.3. The object of the database (TBD)
Inherits:
TCntrNode, TConfig.
Inherited:
By the database objects of the modules of subsystem "DB".
string addr( ) const; — Address of the database. The form of recording is different for each type of database.
string codePage( ); — Codepage in which the data of the database are stored.
bool enableStat( ) const; — The state of the database: "Enabled".
bool toEnable( ); — Sign of the DB: "To Enable".
void setName( const string &inm ); — Setting the DB name.
void setDscr( const string &idscr ); — Setting the DB description.
void setAddr( const string &iaddr ); — Setting the DB address.
void setCodePage( const string &icp ); — Setting of the codepage for the storage of the DB data.
void setToEnable( bool ivl ); — Setting of the sign: "To Enable".
virtual void enable( ); — Enabling of the DB.
virtual void disable( ); — Disabling of the DB.
virtual void allowList( vector<string> &list ) const; — The list of the tables in this DB.
void list( vector<string> &list ) const; — The list of opened tables.
bool openStat( const string &table ) const; — The sign that indicates of the fact that the requested table is opened.
void open( const string &table, bool create ); — Opening of the table. If the sign create is set, in the case of absence the table will be created.
void close( const string &table, bool del = false, long tm = -1 ); — Closing of the table. If the sign del is set, the table will be completely removed.
AutoHD<TTable> at( const string &name ) const; — Connection to the table.
virtual void sqlReq( const string &req, vector< vector<string> > *tbl = NULL, char intoTrans = EVAL_BOOL ); — Sending the SQL-request req to the DB and receiving the result in tabular form tbl. If set intoTrans to true then will open transaction for the request, else if set to false then transaction will close.
virtual void transCloseCheck( ) — The function call periodic for opened transaction check to close for old transaction or overloaded.
TTypeBD &owner( ) const; — DB type – the owner of the DB.
Protected methods:
virtual TTable *openTable( const string &table, bool create ); — The modular method for opening the table.
3.4. The object of the table (TTable)
Inherits:
TCntrNode.
Inherited:
By tables objects of the modules of subsystem "DB".
string fullDBName( ); — Full name a storage-table into DB.
virtual void fieldStruct( TConfig &cfg ); — Getting the structure of the table.
virtual bool fieldSeek( int row, TConfig &cfg, vector< vector<string> > *full = NULL ); — Scanning the records cfg of the table by row, where full defines before a record for it's result preloading in whole and significant acceleration.
virtual void fieldGet( TConfig &cfg ); — Request the specified record. The requested record is determined by the values of key cells of the original record cfg.
virtual void fieldSet( TConfig &cfg ); — Setting the values of the specified record. In the case of absence the record will be removed.
virtual void fieldDel( TConfig &cfg ); — Deleting of the specified record.
TBD &owner( ) const; — DB – the owner of the table.
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)
Inherits:
TSubSYS.
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 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".
OnlyAlarms (2) — only alarms, suppressing on the reserve.
Command specific
Any (0) — any mode.
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.
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.
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".
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.
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).
Inherits:
TCntrNode.
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)
Subsystem "Archives" is represented by an object TArchiveS, which contains at the subsystem level the modular objects of the archivers types TTypeArchivator. Each object of the archiver type contains objects of the messages' archivers TMArchivator and values' archivers TVArchivator. In addition, the subsystem object contains the methods of the messages archive and objects of the values' archives TVArchive. The object of the values' archive TVArchive contains the buffer of values through the inheritance of the buffer object TValBuf. To connect the archive of values with the archivers the object of the value element TVArchEl is provided. This object is contained in the archiver and it is referenced by the archive. Structure of the subsystem "Archives" is presented in Fig. 5.
Fig. 5. The hierarchical structure of subsystem "Archives".
Subsystem "Archives" contains the mechanisms for archiving of messages and values. It directly contains the messages' archive together with its buffer. Contains methods for accessing the archives of the values and for the archivers of values and messages. Besides it performs the actively data acquisition from sources of values for the archives of values, as well as archiving the archive of messages by the archivers.
Archive of values (TVArchive) contains the buffer (TValBuf) for intermediate values' accumulation before archiving. It is connected with the source of values in the person of OpenSCADA system parameters in active or passive mode, as well as with other sources in the passive mode. To archive to the physical storage it is connected with the values' archivers of various types.
Object of the buffer TValBuf contains an array of values of the main types of OpenSCADA system: string, integer, real and boolean. It is supported the storage of values in the modes of hard, soft grid and in the free access mode. It is also provided the mode of high-resolution time (microseconds). It is used for direct storage of large arrays of values, and for the exchange of large arrays by the frame-accurate method of access.
Root object of the module of subsystem "Archives" (TTypeArchivator) contains information about the specific type of module. Within the individual modules it can implement their own module-wide functions. In general, for modules of this type it contains methods to access the repositories of values and messages.
Object of the messages' archiver (TMArchivator) contains the specific implementation of the message storage. In general, for messages' archivers the interface of access to the implementation of an archiving mechanism in modules is provided.
Object of the values' archiver (TVArchivator) contains the specific implementation of the repository of values. In general, for the values' archivers the access interface to implementation of the archiving mechanism and the appointment of archives of values for service by archiver are provided.
Object of the archive element TVArchEl links the archive objects with the archivers. It is used to access the archiver from the archive, as well as to archives from the archiver, ie for cross-calls.
5.1. The object of the subsystem "Archives" (TArchiveS)
Inherits:
SubSYS.
Public methods:
int subVer( ); — Subsystem's version.
int messPeriod( ); — Period of archiving of messages from the buffer (seconds).
int valPeriod( ); — Acquisition of values period for the active archivers (milliseconds).
int valPrior( ); — Priority of the tasks of the values acquisition for the active archivers.
bool valForceCurTm( ); — Points to force of current time as the time-stamp of the getting values.
void setMessPeriod( int ivl ); — Setting the period of the archiving of messages from the buffer (seconds).
void setValPeriod( int ivl ); — Setting the values' acquisition period for active archivers (milliseconds).
void setValPrior( int ivl ); — Setting the priority of the values' acquisition task for the active archivers.
void setValForceCurTm( bool vl ); — Force of current time as the time-stamp of the getting values.
void setToUpdate( ); — Planing update flag set.
void subStart( ); — Start of the subsystem.
void subStop( ); — Stop of the system.
void valList( vector<string> &list ) const; — The list of the values'archives in the subsystem.
bool valPresent( const string &iid ) const; — Check for the availability of the values' archive iid.
void valAdd( const string &iid, const string &idb = "*.*" ); — Addition of the new values' archive iid.
void valDel( const string &iid, bool db = false ); — Deleting of the values' archive iid.
AutoHD<TVArchive> valAt( const string &iid ) const; — Connection/addressing to the values' archive iid.
void setActMess( TMArchivator *a, bool val ); — Setting of the messages archivator a into the active status val. Active archivator will be provided by the subsystem with the flow of messages.
void setActVal( TVArchive *a, bool val ); — Setting of the value archive a into the active status val. Active archive will be provided by the subsystem with the periodic flow of values (is determined by the periodicity of the archive).
AutoHD<TTypeArchivator> at( const string &name ); — Connection/addressing to the archiver's type (module) name.
void messPut( time_t tm, int utm, const string &categ, int8_t level, const string &mess, const string &arch = "", bool force = false ); — Location of the value mess with the level level of the category categ and time tm+utm into the buffer, and then into the messages' archive or direct to the pointed archivators arch (separated by symbol ';'). force for direct writing to the archivator omit the redundancy.
void messPut( const vector<TMess::SRec> &recs, const string &arch = "", bool force = false ); — Location of the group of values recs into the buffer, and then into the messages' archive or direct to the pointed archivators arch (separated by symbol ';'). force for direct writing to the archivator omit the redundancy.
time_t messGet( time_t bTm, time_t eTm, vector<TMess::SRec> &recs, const string &category = "", int8_t level = TMess::Debug, const string &arch = "", time_t upTo = 0 ); — Values' request reqs for the specified period of time bTm, eTm for the specified category (by the template) category and level level from the archivators arch (separated by symbol ';'). Return time of the request stop, useful for continue from the point.
time_t messBeg( const string &arch = "" ); — Beginning of the messages' archive as a whole or for the specified archiver arch.
time_t messEnd( const string &arch = "" ); — End of the messages' archive as a whole or for the specified archiver arch.
float rdRestDtOverTm( ); — Overtime of the reserve history reload at start in days.
void setRdRestDtOverTm( float vl ); — Setting of overtime of the reserve history reload at start in days.
void rdActArchMList( vector<string> &ls, bool isRun = false ); — The list of active message archivators working in the redundancy scheme. When we indicate isRun there will be in the list only running message archvators in this station.
string rdStRequest( const string &arch, XMLNode &req, const string &prevSt = "", bool toRun = true ); — Request req to the redundant station on behalf of the message archivator arch. The station for the request is selected after specified in prevSt for the running remotely message archivators when indicating toRun.
TElem &messE( ); — DB structure of the messages' archivers.
TElem &valE( ); — DB structure of the values' archivers.
TElem &aValE( ); — DB structure of the values' archives.
Public methods:
bool SubStarting; — The subsystem starting flag.
5.2. The object of the values' archive (TVArchive)
Inherits:
TCntrNode, TValBuf, TConfig
Data:
The data acquisition mode/source (struct — TVArchive::SrcMode):
Passive — passive mode of the data acquisition, the source puts the data into the archive itself;
PassiveAttr — passive mode of the data acquisition from the parameter's attribute, the parameter's attribute puts the data into the archive itself;
ActiveAttr — active mode of the data acquisition from the parameter's attribute, the parameter's attribute is periodically polled by the subsystem "Archives";
Public methods:
TVArchive( const string &id, const string &db, TElem *cf_el ); — Initializing constructor of the archive, where id — archive ID, db — DB for storage and cf_el — DB structure of the values' archives.
string id( ); — Archive's ID.
string name( ); — Archive's name.
string dscr( ); — Archive's description.
SrcMode srcMode( ); — Linkage mode with the data source.
AutoHD<TVal> srcPAttr( bool force = false, const string &ipath = "" ); — Connect to associated attribute of parameter of data source.
string srcData( ); — Parameters of the data source, in the case of access mode to the parameter this is the address of the parameter.
bool toStart( ); — Sign: "Start the archive when starting the system".
bool startStat( ); — Status: "Archive started".
string DB( ); — DB address of the values' archive.
string tbl( ); — DB table of the values' archive.
string fullDB( ); — Full name of the DB table of the values' archive.
int64_t end( const string &arch = BUF_ARCH_NM ); — End of the archive time at whole (arch="") or the specified archiver, buffer (arch="<bufer>").
int64_t begin( const string &arch = BUF_ARCH_NM ); — Start of the archive time at whole (arch="") or the specified archiver, buffer (arch="<bufer>").
int64_t period( const string &arch = BUF_ARCH_NM ); — Periodicity of the archive buffer or the specified archiver (microseconds).
TFld::Type valType( bool full = false ); — Type of the archived value. full — request full type, else only generic.
bool hardGrid( ); — Using of the hard grid in the archive buffer.
bool highResTm( ); — Using of the high-resolution time in the archive buffer (microseconds).
bool fillLast( ); — Fill pass points to a last value. Mostly the pass values fill by EVAL but sometime the source's data periodicity greater to the archive's one and it is normal.
int size( ); — Archive buffer size (units).
void setName( const string &inm ); — Setting the name of the archive.
void setDscr( const string &idscr ); — Setting the description of the archive.
void setSrcMode( SrcMode vl = SaveCur, const string &isrc = "<*>", bool noex = false ); — Setting the linkage mode with the data source.
void setToStart( bool vl ); — Setting the sign: "Start the archive when starting the system".
void setDB( const string &idb ); — Setting the DB address of the values' archive.
void setValType( TFld::Type vl ); — Setting the type of the archived value.
void setHardGrid( bool vl ); — Setting the using of the hard grid in the archive buffer.
void setHighResTm( bool vl ); — Setting of using of the high-resolution time in the archive buffer (microseconds).
void setFillLast( bool vl ); — Set to fill pass points to a last value.
void setSize( int vl ); — Setting of the archive buffer size (units).
void setPeriod( int64_t vl ); — Setting the periodicity of the archive buffer.
void start( ); — Start of the archive.
void stop( bool full_del = false ); — Stop of the archive with it's completely deleting full_del.
TVariant getVal( int64_t *tm = NULL, bool up_ord = false, const string &arch = "", bool onlyLocal = false ); — Request of the single value for the time tm and with the sign of the moving to the top up_ord from the specified archiver arch, buffer (arch = "<bufer>") or from all archivers in the course of falling quality (arch =""). To process the request only by the local station onlyLocal is set.
void getVals( TValBuf &buf, int64_t beg = 0, int64_t end = 0, const string &arch = "", int limit = 100000, bool onlyLocal = false ); — Request of the values' frame buf for the time from beg to end from the specified archiver arch, buffer (arch = "<bufer>") or from the all archivers in the course of falling quality (arch =""), limiting the size of the request limit of the record. To request only the local archives, without compensation gaps in the archives from the backup stations, set onlyLocal.
void setVals( TValBuf &buf, int64_t beg, int64_t end, const string &arch ); — Set of the values' frame buf for the time from beg to end to the specified archiver arch, buffer (arch = "<bufer">) or to all archivers (arch ="").
void getActiveData( const int64_t &tm = 0 ); — To interrogate the data source with forcing time-stamp to tm (not zero). Is used for periodic data acquisition by the active archives in the subsystem.
void archivatorList( vector<string> &ls ); — List of archivers which serves the archive.
bool archivatorPresent( const string &arch ); — Check the archiver for it's servicing of the given archive.
void archivatorAttach( const string &arch ); — Connecting the archive to be served by the specified archiver.
void archivatorDetach( const string &arch, bool full = false ); — Disabling this archive from the servicing of the specified archiver.
void archivatorSort( ); — Sort of the serving archivers in the order of decreasing quality.
string makeTrendImg( int64_t beg, int64_t end, const string &arch, int hsz = 650, int vsz = 230 ); — Building of the (pdf) image of the trend for the specified amount of time beg, end and for this archiver arch.
TArchiveS &owner( ) const; — Subsystem "Archives" - the owner of the archive of values.
5.3. Object of the values' buffer (TValBuf)
Inherited:
TVArchive
Public methods:
TValBuf( ); — Buffer initializer with default settings.
TValBuf( TFld::Type vtp, int isz, int64_t ipr, bool ihgrd = false, bool ihres = false ); — Buffer initializer with the specified parameters.
TFld::Type valType( bool full = false ); — Type of the value stored in the buffer. full — request full type, else only generic.
bool hardGrid( ); — Hard grid working mode.
bool highResTm( ); — High resolution (microseconds) working mode of the buffer.
bool fillLast( ); — Fill pass points to a last value. Mostly the pass values fill by EVAL but sometime the source's data periodicity greater to the archive's one and it is normal.
int size( ); — Maximum buffer size (units).
int realSize( ); — Real buffer size (units).
int64_t period( ); — Frequency of values in the buffer (microseconds). If the frequency is zero the buffer operates in the mode of free access.
int64_t begin( ); — Start time of the buffer (microseconds).
int64_t end( ); — End time of the buffer (microseconds).
bool vOK( int64_t ibeg, int64_t iend ); — Checking for values in the buffer for the specified period of time from ibeg to iend.
void setValType( TFld::Type vl ); — Setting of the value type stored by the buffer.
void setHardGrid( bool vl ); — Setting the hard grid mode.
void setHighResTm( bool vl ); — High resolution (microseconds) working mode setting.
void setFillLast( bool vl ); — Set to fill pass points to a last value.
void setSize( int vl ); — Buffer size (units) setting.
void setPeriod( int64_t vl ); — Frequency of values in the buffer (microseconds) setting.
virtual void getVals( TValBuf &buf, int64_t beg = 0, int64_t end = 0 ); — Request of the values' frame buf for the time from beg to end.
TVariant get( int64_t *tm = NULL, bool up_ord = false ); — Request value for the time tm and with the sign of moving to the top up_ord.
virtual string getS( int64_t *tm = NULL, bool up_ord = false ); — Request of the string type value for the time tm and with the sign of moving to the top up_ord.
virtual double getR( int64_t *tm = NULL, bool up_ord = false ); — Request of the real type value for the time tm and with the sign of moving to the top up_ord.
virtual int64_t getI( int64_t *tm = NULL, bool up_ord = false ); — Request of the integer type value for the time tm and with the sign of moving to the top up_ord.
virtual char getB( int64_t *tm = NULL, bool up_ord = false ); — Request of the boolean type value for the time tm and with the sign of moving to the top up_ord.
virtual void setVals( TValBuf &buf, int64_t beg = 0, int64_t end = 0 ); — Setting the values' frame from buf fro the time from beg to end.
void set( const TVariant &value, int64_t tm = 0 ); — Setting value with the time tm.
virtual void setS( const string &value, int64_t tm = 0 ); — Setting the string type value with the time tm.
virtual void setR( double value, int64_t tm = 0 ); — Setting the real type value with the time tm.
virtual void setI( int64_t value, int64_t tm = 0 ); — Setting the integer type value with the time tm.
virtual void setB( char value, int64_t tm = 0 ); — Setting the boolean type value with the time tm.
Protected methods:
void makeBuf( TFld::Type v_tp, int isz, int64_t ipr, bool hd_grd, bool hg_res ); — Rebuilding the buffer for the specified parameters.
5.4. The modular object of the archiver's type (TTypeArchivator)
Inherits:
TModule.
Inherited:
By the root objects of the modules of subsystem "Archives".
Public methods:
void messList( vector<string> &list ) const; — The list of the messages' archivers.
bool messPresent( const string &iid ) const; — Check for the presence of the specified messages' archiver.
void messAdd( const string &iid, const string &idb = "*.*" ); — Adding of the messages' archiver.
void messDel( const string &iid, bool full = false ); — Deleting of the messages' archiver.
AutoHD<TMArchivator> messAt( const string &iid ) const; — Connection to the messages' archiver.
void valList( vector<string> &list ) const; — The list of the values' archivers.
bool valPresent( const string &iid ) const; — Check for the presence of the specified values' archiver.
void valAdd( const string &iid, const string &idb = "*.*" ); — Adding of the values' archiver.
void valDel( const string &iid, bool full = false ); — Deleting of the values' archiver.
AutoHD<TVArchivator> valAt( const string &iid ) const; — Connection to the values' archiver.
TArchiveS &owner( ) const; — Subsystem "Archives" - the owner of the archiver's type.
Protected methods:
virtual TMArchivator *AMess( const string &iid, const string &idb ); — The modular method of creating of the messages' archiver.
virtual TVArchivator *AVal( const string &iid, const string &idb ); — The modular method of creating of the values' archiver.
5.5. The object of the messages' archiver (TMArchivator)
Inherits:
TCntrNode, TConfig
Inherited:
By the objects of the archivers of messages of modules of the subsystem "Archives".
Public methods:
TMArchivator( const string &id, const string &db, TElem *cf_el ); — Initializing constructor of the messages' archiver with the ID id, for the storage in the database db with the structure <cf_el>.
string id( ); — Archiver's ID.
string workId( ); — Working identifier, it includes the name of the module.
string name( ); — Archiver's name.
string dscr( ); — Archiver's description.
bool toStart( ); — The sign "To start the archiver".
bool startStat( ); — Archivers' status "Run".
string &addr( ) const; — Address of the archiver's storage.
int &level( ); — The level of messages, serviced by the archiver.
void categ( vector<string> &list ); — Categories (templates) of messages, serviced by the archiver.
string DB( ); — DB address of the archiver.
string tbl( ); — Table address of the archiver's DB.
string fullDB( ); — The full table address of the archiver's DB.
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 void start( ); — Start of the archiver.
virtual void stop( ); — Stop of the archiver.
virtual time_t begin( ); — The beginning of the archive of the specified archiver.
virtual time_t end( ); — The end of the archive of the specified archiver.
virtual bool put( vector<TMess::SRec> &mess, bool force = false ); — Place the group of messages in the messages' archive of the specified archivator. Return "true" on successful operation. force for direct writing to the archivator omit the redundancy.
virtual time_t get( time_t bTm, time_t eTm, vector<TMess::SRec> &mess, const string &category = "", char level = 0, time_t upTo = 0 ); — Get the messages from the archive of the specified archiver for the specified filter parameters. Return time of the request stop, useful for continue from the point.
TTypeArchivator&owner( ) const; — Archiver's type – the owner of the messages' archiver.
Protected attributes:
bool run_st; — Sign "Run".
int messHead; — The pointer to last read message of the messages buffer.
Protected methods:
bool chkMessOK( const string &icateg, int8_t ilvl ); — Check the message to the filter conditions.
5.6. The object of the values' archiver (TVArchivator)
Inherits:
TCntrNode, TConfig
Inherited:
By the objects of the archivers of values of modules of the subsystem "Archives".
Public methods:
TVArchivator( const string &id, const string &db, TElem *cf_el ); — Initializing constructor of the values' archiver with the ID id, for the storage in the database db with the structure cf_el.
string id( ); — Archiver's ID.
string workId( ); — Working identifier, it includes the name of the module.
string name( ); — Archiver's name.
string dscr( ); — Archiver's description.
string addr( ) const; — Address of the archiver's storage.
double valPeriod( ); — Frequency of values of the archiver (microseconds).
int archPeriod( ); — Frequency of the values' archiving by the archiver. Time after which the archiver makes archiving of the frame of values from the archive's buffer.
int selPrior( ); — Selection priority for mode "All" archivers.
bool toStart( ); — The sign "To start the archiver".
bool startStat( ); — Archivers' status "Run".
string DB( ); — DB address of the archiver.
string tbl( ); — Table address of the archiver's DB.
string fullDB( ); — The full table address of the archiver's DB.
void setAddr( const string &vl ); — Setting the address of the archiver's storage.
void setValPeriod( double iper ); — Setting the frequency of values of the archiver (microseconds).
void setArchPeriod( int iper ); — Setting the frequency of the values' archiving by the archiver. Time after which the archiver makes archiving of the frame of values from the archive's buffer.
void setSelPrior( int vl ); — Set selection priority for mode "All" archivers.
void setToStart( bool vl ); — Setting the sign "To start the archiver".
void setDB( const string &idb ); — Setting the DB adress of the archiver.
virtual void start( ); — Start of the archiver.
virtual void stop( bool full_del = false ); — Stop of the archiver with the possibility of it's full deleting full_del.
void archiveList( vector<string> &ls ); — The archive's list, serviced by the archiver.
bool archivePresent( const string &iid ); — Check for the servicing of the specified archive by the specified archiver.
TTypeArchivator &owner( ) const; — Archiver's type – the owner of the values' archiver.
Protected methods:
TVArchEl *archivePlace( TVArchive &item ); — Add the archive item to the processing by the archiver.
void archiveRemove( const string &id, bool full = false ); — Remove the archive id from the processing by the archiver, with the possibility of its full deleting full.
virtual TVArchEl *getArchEl( TVArchive &arch ); — Getting the object of the archive's element for the specified archive.
virtual void pushAccumVals( ); — Push the accumulated by the archivation task values, for the accumulated archivators.
Protected attributes:
Res a_res — Resource of the archiving process.
bool run_st — Sign "Archive is run".
vector<TVArchEl *> arch_el; — Array of elements of archives.
5.7. The object of the archive's element in the archiver (TVArchEl)
Inherited:
By the objects of the archivers of values of modules of the subsystem "Archives".
Public methods:
TVArchEl( TVArchive &iarchive, TVArchivator &iarchivator ); — Initializing constructor fro the connection the archive iarchive with the archiver iarchivator.
virtual void fullErase( ); — Full deleting of the element.
virtual int64_t end( ); — End time of data (microseconds).
virtual int64_t begin( ); — Start time of data (microseconds).
int64_t lastGet( ); — Time of last transfer of the data from the buffer to the storage.
TVariant getVal( int64_t *tm, bool up_ord, bool onlyLocal = false ); — Request of the value for the time tm and with the sign of moving to the top up_ord, with the specifying of the request of only local archive in onlyLocal.
void getVals( TValBuf &buf, int64_t beg = 0, int64_t end = 0, bool onlyLocal = false ); — Request of the values' frame buf for the time from beg to end, with the specifying of the request of only local archive in onlyLocal.
void setVals( TValBuf &buf, int64_t beg = 0, int64_t end = 0, bool toAccum = false ); — Setting the values' frame from the buf for the time from beg to end, through the accumulation toAccum.
int64_t prev_tm; — The previous value time. It is used for averaging.
string prev_val; — The previous value time. It is used for averaging.
Protected methods:
virtual TVariant getValProc( int64_t *tm, bool up_ord ); — The processing function of the single value from the archive request.
virtual void getValsProc( TValBuf &buf, int64_t beg, int64_t end ); — Function of the processing the request of the module to get the data.
virtual void setValsProc( TValBuf &buf, int64_t beg, int64_t end, bool toAccum ); — Function of the processing the request of the module to set the data, through the accumulation toAccum.
"Transports" subsystem is represented by the TTransportS object, which contains modular objects of the transports' types TTypeTransport on the subsystem-level. Each type of transport contains objects TTransportIn of the incoming and TTransportOut of the outgoing transports. The overall structure of the subsystem is shown in Fig. 6.
Fig. 6. The layered structure of the transports subsystem.
The root object of the "Transports" subsystem's module provides information about the specific type of module and about the external OpenSCADA hosts/stations. As part of the single module it can be implemented the own general-module functionality. In general, for all modules, the access methods for both: inbound and outbound transports of the specific module are contained.
The object of the incoming transport TTransportIn provides an interface to the implementation of the modular method of incoming transport.
The object of the outgoing transport TTransportOut provides an interface to the implementation of the modular method of outgoing transport.
6.1. The object of the "Transports" subsystem (TTransportS)
Inherits:
TSubSYS.
Data:
External hosts mode (enum — ExtHost::Mode):
User (0) — User.
System (1) — System.
UserSystem (2) — User and System.
The structure of the external OpenSCADA hosts/stations (class TTransportS::ExtHost):
string userOpen; — User who created the record about the external host/station.
string id; — Id of the external host/station.
string name; — Name of an external host/station.
string transp; — Transport which is used to access an external host/station.
string addr; — Address for the transport, which is used to access an external host/station.
string user; — Users of the external host/station.
string pass; — Password of the external host/station user.
uint8_t upRiseLev; — External hosts uprising level/depth of this host/station.
int8_t mode; — Host mode.
time_t mdf; — Modification time.
Public methods:
int subVer( ); — Subsystem's version.
void inTrList( vector<string> &ls ); — Full list of incoming transports.
void outTrList( vector<string> &ls ); — Full list of outgoing transports.
string extHostsDB( ); — Database for the storing the list of external hosts.
void extHostList( const string &user, vector<ExtHost> &list, bool andSYS = false, int upRiseLev = -1 ); — The list of external hosts for user, include system andSYS and the uprising level upRiseLev (-1 - starting from the host's entry level).
ExtHost extHostGet( const string &user, const string &id, bool andSYS = false ); — Getting the information object from the external host id on behalf of the user user, include system andSYS ( "*" — for the system hosts).
AutoHD<TTransportOut> extHost( TTransportS::ExtHost host, const string &pref = "" ); — Creation - request of the outgoing transport to service the external host host with the prefix of the identification of the system node pref.
void extHostSet( const ExtHost &host, bool andSYS = false ); — Setting of the external host/station host, include system andSYS.
void extHostDel( const string &user, const string &id, bool andSYS = false ); — Deleting of the external host/station id on behalf of the user user, include system andSYS ( "*" — for the system hosts).
int cntrIfCmd( XMLNode &node, const string &senderPref, const string &user = "" ); — Transfer of the control area request of the OpenSCADA node to the remote station.
void subStart( ); — Start of the subsystem.
void subStop( ); — Stop of the subsystem.
TElem &inEl( ); — DB structure of the incoming transports
TElem &outEl( ); — DB structure of the outgoing transports
AutoHD<TTypeTransport> at( const string &id ) const; — Addressing/connection to the type of transport id.
6.2. The modular object of the transports' type (TTypeTransport)
Inherits:
TModule.
Inherited:
By the root object of the subsystem's "Transports" modules..
Public methods:
void inList( vector<string> &list ) const; — The list of the incoming transports.
bool inPresent( const string &name ) const; — Check for an incoming transport presence.
void inAdd( const string &name, const string &db = "*.*" ); — Addition of the incoming transport.
void inDel( const string &name, bool complete = false ); — Deleting of the incoming transport. It is possible to completely delete with the database included, by setting the complete sign.
AutoHD<TTransportIn> inAt( const string &name ) const; — Connection to the incoming transport.
void outList( vector<string> &list ) const; — The list of the outgoing transports.
bool outPresent( const string &name ) const; — Check for an outgoing transport presence.
void outAdd( const string &name, const string &db = "*.*" ); — Addition of the outgoing transport.
void outDel( const string &name, bool complete = false ); — Deleting of the outgoing transport. It is possible to completely delete with the database included, by setting the complete sign.
AutoHD<TTransportOut> outAt( const string &name ) const; — Connection to the outgoing transport.
TTransportS &owner( ) const; — "Transports" subsystem - the owner of the transport's type.
Protected methods:
virtual TTransportIn *In( const string &name, const string &db ); — The modular method of the creating/opening of the new "incoming" transport.
virtual TTransportOut *Out( const string &name, const string &db ); — The modular method of the creating/opening of the new "outgoing" transport.
6.3. The object of the incoming transports (TTransportIn)
Inherits:
TCntrNode, TConfig.
Inherited:
By the objects of incoming transports of the subsystem's "Transports" modules.
string workId( ); — Full ID including the ID of the module.
string name( ); — Transport's name.
string dscr( ); — Transport's description.
string addr( ) const; — Address.
string protocol( ); — Linked transport protocol.
virtual string getStatus( ); — Getting the status of the incoming transport.
bool toStart( ); — The sign "To start".
bool startStat( ); — The status "Running".
string DB( ); — Transport's DB address.
string tbl( ); — Transport's DB table.
string fullDB( ); — The full name of the transport's DB table.
void setName( const string &inm ); — Setting the name of transport in inm.
void setDscr( const string &idscr ); — Setting the description of transport in idscr.
void setAddr( const string &addr ); — Setting the address of transport in addr.
void setProtocol( const string &prt ); — Setting of the linked transport protocol.
void setToStart( bool val ); — Setting of the sign "To start".
void setDB( const string &vl ); — Setting of the transport's DB address.
virtual void start( ); — Start of the transport.
virtual void stop( ); — Stop of the transport.
virtual int writeTo( const string &sender, const string &data ); — Sending data backward to the sender.
vector<AutoHD<TTransportOut> > assTrs( bool checkForCleanDisabled = false ); — The assigned output transports massive, created by the input transport for typical requests to the connection initiator. Set checkForCleanDisabled for prior checking and clean up disabled ones.
int logLen( ); — length of the IO log.
void setLogLen( int vl ); — set length of the IO log.
void pushLogMess( const string &vl ); — push the message vl to the log in format "{Message}\n{BinData}".
TTypeTransport &owner( ) const; — Transport's type – the owner of the incoming transport.
Protected methods:
string assTrO( const string &addr ); — The assigned output transport creation with address addr.
Protected attributes:
bool run_st; — The sign "Run".
6.4. The object of the outgoing transports (TTransportOut)
Inherits:
TCntrNode, TConfig.
Inherited:
By the objects of outgoing transports of the subsystem's "Transports" modules.
string workId( ); — Full ID including the ID of the module.
string name( ); — Transport name.
string dscr( ); — Transport description.
string addr( ) const; — Transport address.
virtual string timings( ); — Transport timeouts.
int prm1( ); — First backup parameter.
int prm2( ); — Second backup parameter.
bool toStart( ); — Sign "To start".
bool startStat( ); — Status "Running".
time_t startTm( ); — Status "Time of starting/connection".
virtual string getStatus( ); — Getting the status of the transport.
string DB( ); — Transport's DB address.
string tbl( ); — Transport's DB table.
string fullDB( ); — The full name of the transport's DB table.
void setName( const string &inm ); — Setting the name of transport.
void setDscr( const string &idscr ); — Setting the description of transport.
void setAddr( const string &addr ); — Setting the address of transport.
virtual void setTimings( const string &vl ); — Setting the transport timeouts.
void setPrm1( int vl ); — Setting of the first backup parameter.
void setPrm2( int vl ); — Setting of the second backup parameter.
void setToStart( bool val ); — Setting of the sign "To start".
void setDB( const string &vl ); — Setting of the transport's DB address.
virtual void start( int time = 0 ); — Start of the transport with connection time time.
virtual void stop( ); — Stop of the transport.
virtual int messIO( const char *obuf, int len_ob, char *ibuf = NULL, int len_ib = 0, int time = 0 ); — Sending of the data over the transport. The waiting time time of the connection (in milliseconds). The time in negative disables the transport's request/respond mode and allow independent reading/writing to a buffer IO, with the reading timeout time in absolute.
void messProtIO( XMLNode &io, const string &prot ); — Sending of the data in the XML tree in over the transport using the transport protocol prot.
int logLen( ); — length of the IO log.
void setLogLen( int vl ); — set length of the IO log.
void pushLogMess( const string &vl ); — push the message vl to the log in format "{Message}\n{BinData}".
TTypeTransport &owner( ) const; — Type of transport - the owner of outgoing transport.
ResMtx &reqRes( ); — The requesting resource, needs to global lock into protocols with fragments receiving.
Subsystem "Communication interfaces' protocols" is presented by the TProtocolS object, which contains modular objects of the separate protocols TProtocol on the a subsystem's level. Each protocol contains objects of the opened sessions of the incoming protocols TProtocolIn.
TProtocolS object provides an access to the both: the incoming and the outgoing protocols of the individual types of transport protocols. The inner side of outgoing protocol based on the steaming principle with the individual structure of the stream for each implementation of the protocol.
7.1. The object of the “Communication interfaces' protocols” subsystem (TProtocolS)
Inherits:
TSubSYS.
Public methods:
int subVer( ); — Subsystem's version.
AutoHD<TProtocol> at( const string &id ) const; — Connection to the protocol's id module.
string optDescr( ); — Localized help for command-line options and parameters of the configuration file.
7.2. The modular object of the protocol (TProtocol)
Inherits:
TModule.
Inherited:
By the root object of the subsystem's "Protocols" modules.
Public methods:
virtual void itemListIn( vector<string> &ls, const string &curIt = "" ); — Items list of protocol for individual addressing into transport.
void list( vector<string> &list ) const; — The list of open incoming sessions.
bool openStat( const string &name ) const; — Check for the openness of the incoming session with the specified name.
void open( const string &name, TTransportIn *tr = NULL, const string &sender = "" ); — Opening of the session on behalf of the incoming transport tr.
void close( const string &name ); — Closing of the incoming session.
AutoHD<TProtocolIn> at( const string &name ) const; — Connecting to the open incoming sessions.
virtual void outMess( XMLNode &io, TTransportOut &tro ); — Sending the data in the XML tree in over the protocol and transport tro.
7.3. The object of the incoming protocol's session (TProtocolIn)
Inherits:
TCntrNode.
Inherited:
By the session objects of the incoming modules' protocol of the subsystem "Protocols".
string name( ); — The name of the incoming session.
AutoHD<TTransportIn> &srcTr( ) — The transport-source of the opening of the session of the incoming protocol.
const string &srcAddr( ) — The sender address; second line contains service part of the address for backward messages.
virtual unsigned waitReqTm( ); — A request waiting time on input transport (in milliseconds), after what call to the protocol with the empty message — the polling mode. Setting it to zero will disable the polling mode.
virtual void setSrcTr( TTransportIn *vl ) — Setting of the transport-source of the opening of the session of the incoming protocol.
virtual void setSrcAddr( const string &vl ); — Setting of the sender address.
int writeTo( const string &data ); — Sending the messages data backward to the sender, into srcAddr().
virtual bool mess( const string &request, string &answer ); — Transfer of unstructured data to their processing by the protocol.
TProtocol &owner( ) const; — The protocol, the owner of incoming sessions.
The subsystem "User Interfaces" is presented by the TUIS object, which contains modular objects of the TUI user interfaces' on the subsystem's level.
8.1. The object of the "User interfaces" subsystem (TUIS)
Inherits:
TSubSYS.
Data:
Requests parameters (enum — GetOpts):
GetPathURL (1) — Path get.
GetContent (2) — Open document command get.
Public methods:
int subVer( ); — Subsystem's version.
void subStart( ); — Start of the subsystem.
void subStop( ); — Stop of the subsystem.
AutoHD<TUI> at( const string &name ) const; — Connecting to the user's interface module.
static string icoGet( const string &inm, string *tp = NULL, bool retPath = false ); — Download image of the icon inm from standard directories or return path, on retPath, to allowed icon. Detecting icons for file extensions "png", "gif", "jpg", "jpeg", which return into tp.
static string docGet( const string &inm, string *tp = NULL, unsigned opt = 0 ); — Download document inm from standard directories or return path, on retPath, to allowed document. Detecting documents for file extensions "pdf", "html", "odt", which return into tp.
static string mimeGet( const string &inm, const string &fDt, const string &orig = "" ); — Get file's mime type in view {group}/{type} for the file name inm, its content fDt and the original hint orig.
8.2. The modular object of the user interface (TUI)
Inherits:
TModule.
Inherited:
By the root objects of the "User interfaces" subsystem.
Security subsystem is presented by an object TSesurity, which contains group objects of TGroup and users TUser.
User object TUser contains user information and checks the authenticity of the user in accordance with the specified password.
TGroup user object contains information about the group of users and checks the user's belonging to the group.
10.1. The object of the "Security" subsystem. (TSeñurity)
Inherits:
TSubSYS.
Public data:
static const string pHashMagic; — String-pointer (prefix) of the password into hash.
Public methods:
bool access( const string &user, char mode, int owner, int groups, int access ); — Check the access of the user in the mode to the resource with the owner, groups (separated ',') and permition access.
void usrList( vector<string> &list ) const; — The list of the users list.
void usrGrpList( const string &name, vector<string> &list ); — The list of the users' groups list, in which the user name is included.
bool usrPresent( const string &name ) const; — Check fro the presence of the specified user name.
int usrAdd( const string &name, const string &db = "*.*" ); — Addition of the user name with the saving to the DB db.
void usrDel( const string &name, bool complete = false ); — Deleting of the user name with the possibility of the completely deleting complete.
AutoHD<TUser> usrAt( const string &name ) const; — Attaching of the user name.
void grpList( vector<string> &list ) const; — The list of the users' groups list.
bool grpPresent( const string &name ) const; — Check fro the presence of the specified users' group name.
int grpAdd( const string &name, const string &db = "*.*" ); — Addition of the users' group name with the saving to the DB db.
void grpDel( const string &name, bool complete = false ); — Deleting of the users' group name with the possibility of the completely deleting complete.
AutoHD<TGroup> grpAt( const string &name ) const; — Connection to the users' group name.
string lang( ); — User language, only into the dynamic translation text variables mode.
bool sysItem( ); — Sign of the system user.
bool auth( const string &pass, string *hash = NULL ); — Check the authenticity of the user by the password pass. The password hash, if it is supports, placing into the hash.
string DB( ); — User DB address.
string tbl( ); — Address of the table of user's DB.
string fullDB( ); — The full name of the table of user's DB.
Subsystem “Modules' sheduling” is presented by the object TModSchedul.
The subsystem contains the control mechanism for modules contained in shared libraries.
11.1. The object of the subsystem “Modules' sheduling” (TModSchedul)
Inherits:
TSubSYS.
Data:
The structure of information about the shared library (struct – TModSchedul::SHD):
void *hd; — the title of the shared library (if NULL, the library is present, but not connected);
vector<string> use; — list of connected modules;
time_t tm; — modification time of the library;
string name; — full name/path of the shared library.
Public methods:
string allowList( ) const; — The list of permitted shared libraries (modules).
string denyList( ); — The list of prohibited shared libraries (modules).
int chkPer( ); — The verification period of the directory with the modules (s).
void setAllowList( const string &vl ); — Setting of the list of permitted shared libraries (modules).
void setDenyList( const string &vl ); — Setting of the list of prohibited shared libraries (modules).
void setChkPer( int per ); — Setting the verification period of the directory with the modules (s). If the frequency is equal to zero, the check will be disabled.
void subStart( ); — Subsystem's start.
void subStop( ); — Subsystem's stop.
int loadLibS( ); — Loading the shared libraries and initialization of the modules. Return numbers loaded modules.
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.
13. Data in the OpenSCADA system and their storage in the DB (TConfig)
Storing data in the system based on the objects TConfig and TElem. These objects store the structure and fields' values of the database, allowing for direct loading and saving the configuration via the "DB" subsystem. For the specialized different types data storage the TVariant object is provided.
TElem object contains the structure of database record. Structure of the record contains extensive information about the elements, their types, sizes and other parameters. Information in this structure is enough to create, control and manage the real structure of the database. Elementary unit of the record is the cell Tfld.
TConfig object is the heir of TElem and contains the actual values of elements. TConfig is used as the parameter in the functions of the manipulating with the table's records in the "DB" subsystem. Elementary unit of the record is the cell TCfg.
To provide an opportunity to inform the data storehouse about the changes in the structure it is provides an object TValElem, from which it is inherited the storehouse TConfig and the list of which is contained in the TElem structure.
TConfig &operator=( const TConfig &cfg ); TConfig &exclCopy( const TConfig &cfg, const string &passCpLs = "", bool cpElsToSingle = false ); — Copying from cfg, passing fields into passCpLs and creating same this fields cpElsToSingle for combined configurations.
void cfgList( vector<string> &list ) const; — Elements' list list.
bool cfgPresent( const string &n_val ) const; — Check for the element's presence n_val.
TCfg &cfg( const string &n_val ) const; — Getting of th element n_val.
TCfg *at( const string &n_val, bool noExpt = false ) const; — Getting of the element's pointer n_val. If the element is absent an exception is generated or the null pointer is returned when setting noExpt.
void cfgViewAll( bool val = true ); — Set/unset the sign of the visibility for all the elements.
void cfgKeyUseAll( bool val ); — Set/unset the sign of the using the key for all the elements.
TElem &elem( ); — The using structure.
void setElem( TElem *Elements, bool first = false ); — Setting the structure in Elements.
void cntrCmdMake( XMLNode *fld, const string &path, int pos, const string &user = "root", const string &grp = "root", int perm = 0664 ); — Formation of the information description of elements of the configuration for the management interface of OpenSCADA.
void cntrCmdProc( XMLNode *fld, const string &elem, const string &user = "root", const string &grp = "root", int perm = 0664 ); — Requests' of the OpenSCADA management interface to the elements of the configuration processing.
bool incomplTblStruct( ); — The DB struct incomplete flag.
void setIncmplTblStrct( bool vl ); — Setting the DB struct incomplete flag to vl.
bool reqKeys( ); — The sign "Requests key", mark for using the request keys by the group items.
TVariant objFunc( const string &id, vector<TVariant> &prms, const string &user ); — The object's functions for access to configuration.
Protected methods:
virtual bool cfgChange( TCfg &co, const TVariant &pc ); — Is called in the case of changing the contents of the configuration element.
13.2. Data cell (TCfg)
Inherits:
TVariant
Data:
Additional flags to TFld (enum — TCfg::AttrFlg):
TCfg::NoVal(0x100) — Do not reflect an element on the value of the TValue object.
TCfg::Key(0x200) — key field.
TCfg::Hide(0x400) — attribute is hidden.
Requests flags (enum — ReqFlg):
TFld::ForceUse(0x01) — Forcing the setting of the flag of the element's using during the setting of its value.
TFld::ExtValOne (0x02) — One/first (and default) value: set value for key.
TFld::ExtValTwo (0x04) — Two/second value: base value for the key request or set.
TFld::ExtValThree (0x08) — Three value: source address for translations.
bool operator==( TCfg &cfg ); — Comparison of the cells.
TCfg &operator=( const TCfg &cfg ); — Copying of the cells.
bool view( ) const; — The sign - "Cell is visible".
bool keyUse( ) const; — The sign - "Use the key" for the dataSeek() and dataDel() requests.
bool noTransl( ) const; — The sign "No translation" is provided to disable the translation of text variables for the record.
bool reqKey( ) const; — The sign "Requests key", for group operations produce by the field as key.
bool isKey( ) const; — Common sign of the field as key, depends from mode "Requests key" for the group.
bool extVal( ) const; — The sign "Extended value", for mark the field to misc role for search and update the key value and translation.
void setView( bool vw ); — Setting of the sign "The cell is visible" â vw.
void setKeyUse( bool vl ); — Setting of the sign "Use the key" in vl.
void setNoTransl( bool vl ); — Setting of the sign "No translation".
void setReqKey( bool vl ); — Setting of the sign "Requests key".
void setExtVal( bool vw ); — Setting of the sign "Extended value".
TFld &fld( ) const; — Configuration of the cell.
string getSEL( ); — Get the value of the selective type.
string getS( ) const; string getS( uint8_t RqFlg ); — Get the value of the string type with the request flags RqFlg.
const char *getSd( ); — Get the direct access to the string type value.
double &getRd( ); — Get the direct access to the real type value.
int64_t &getId( ); — Get the direct access to the integer type value.
char &getBd( ); — Get the direct access to the boolean type value.
void setSEL( const string &val, uint8_t RqFlg = 0 ); — Set the value of the selective type to the val with the request flags RqFlg.
void setS( const string &val ); TCfg &operator=( const string &vl ); TCfg &operator=( const char *vl ); void setS( const string &val, uint8_t RqFlg ); — Set the value of the string type to the val with the request flags RqFlg.
void setR( double val ); TCfg &operator=( double vl ); void setR( double val, uint8_t RqFlg ); — Set the value of the real type to the val with the request flags RqFlg.
void setI( int64_t val ); TCfg &operator=( int64_t vl ); void setI( int64_t val, uint8_t RqFlg ); — Set the value of the integer type to the val with the request flags RqFlg.
void setB( char val ); TCfg &operator=( bool vl ); void setB( char val, uint8_t RqFlg ); — Set the value of the boolean type to the val with the request flags RqFlg.
TConfig &owner( ) const; — The object of container-owner.
13.3. Data structure object (TElem)
Inherited:
By the TTypeParam, TControllerS, TTypeDAQ, as well as by the modular objects, combining the functions of the structure storage .
Public methods:
TElem( const string &name = "" ); — Initialization of the structure with the specified name name.
TElem( const TElem &src ); — Copying constructor.
TElem &operator=( const TElem &src ); — Copying from src.
string &elName( ); — The name if the structure.
void fldList( vector<string> &list ); — The cell's list in the structure list.
unsigned fldSize( ); — The number of cells in the structure.
unsigned fldId( const string &name, bool noex = false ); — Getting the index of the cell from its identifier name. Set noex on no the cell present caused return overall cells number, without exception generation.
bool fldPresent( const string &name ); — Check for the presence of the specified cell name.
int fldAdd( TFld *fld, int id = -1 ); — Addition/insert of the cell fld to the position id (-1 — insert to the end).
void fldDel( unsigned int id ); — Deleting of the cell id.
TFld &fldAt( unsigned int id ); — Getting of the cell id.
void fldClear( ); — Removing all cells.
void valAtt( TValElem *cnt ); — Is called automatically when the structure is attached to the data storage cnt.
void valDet( TValElem *cnt ); — Is called automatically when the structure is detached from the data storage cnt.
ResMtx &resEl( ); — Mutex for access to containers of the fields.
13.4. Data structure cell (TFld)
Data:
Cell's type (enum – TFld::Type):
TFld::Boolean(0) — boolean type;
TFld::Integer(1) — integer type;
TFld::Real(4) — real type;
TFld::String(5) — string type;
TFld::Object(6) — object type.
TFld::GenMask(0x0F) — generic types mask;
TFld::Int16(0x11) — signed integer 16 bits;
TFld::Int32(0x01) — signed integer 32 bits;
TFld::Int64(0x21) — signed integer 64 bits;
TFld::Float(0x14) — float (4 bytes);
TFld::Double(0x04) — double (8 bytes).
Cell's flags (enum — TFld::AttrFlg):
TFld::NoFlag(0x00) — No flags;
TFld::Selected(0x01) — selection mode from the available values, the selective type;
TFld::SelfFld(0x02) — To create the own copy of this cell;
void setDescr( const string &dscr ); — Set the descrition to the dscr.
void setLen( int vl ); — Set the cell's size to the vl.
void setDec( int vl ); — Set the fraction part of the real to the vl.
void setDef( const string &def ); — Set the default value to the def.
void setFlg( unsigned flg ); — Set the flags to flg.
void setValues( const string &vls ); — Set the working range of value or the list of possible values for the selective type (as — "vl1;vl2;vl3") to the vls.
void setSelNames( const string &slnms ); — Set the list of values' names for the selective type (as — "Value 1;Value 2;Value 3") to the slnms.
void setReserve( const string &ires ); — Set of the reserve parameter to res.
const vector<string> &selValS() const; — List of values' variants for the string type.
const vector<int> &selValI() const; — List of values' variants for the integer type.
const vector<double> &selValR() const; — List of values' variants for the real type
const vector<bool> &selValB() const; — List of values' variants for the boolean type
const vector<string> &selNm() const; — List of the names of values' variants.
string selVl2Nm( const string &val ); — Get the selected name from the value val of the string type.
string selVl2Nm( int64_t val ); — Get the selected name from the value val of the integer type.
string selVl2Nm( double val ); — Get the selected name from the value val of the real type.
string selVl2Nm( bool val ); string selVl2Nm( char val ); — Get the selected name from the value valof the boolean type.
string selNm2VlS( const string &name ); — Get the value of string type from the selected name name.
int64_t selNm2VlI( const string &name ); — Get the value of integer type from the selected name name.
double selNm2VlR( const string &name ); — Get the value of real type from the selected name name.
bool selNm2VlB( const string &name ); — Get the value of boolean type from the selected name name.
XMLNode *cntrCmdMake( XMLNode *opt, const string &path, int pos, const string &user = "root", const string &grp = "root", int perm = 0664 ); — Create a form element in accordance with the parameters of the cell.
13.5. The object which preacts about changing of the structure (TValElem)
Inherited:
TValue, TConfig.
Protected methods:
virtual void detElem( TElem *el ); — Notification by the element el of the container about it's wish to detach.
virtual void addFld( TElem *el, unsigned id ) = 0; — Notification about the addition of the cell id of the element el.
virtual void delFld( TElem *el, unsigned id ) = 0; — Notification about the deleting of the cell id of the element el.
13.6. Data cell (TVariant)
Data:
Error values for the different data types (define):
EVAL_BOOL — Error value of the boolean type (2);
EVAL_INT — Error value of the integer type (-2147483647);
EVAL_REAL — Error value of the real type (-3.3E308);
EVAL_STR — Error value of the string type ("<EVAL>").
EVAL_INT16 — Error value of the integer 16 type (-32767);
EVAL_INT32 — Error value of the integer 32 type (-2147483647);
EVAL_INT64 — Error value of the integer 64 type (-9223372036854775807ll);
EVAL_RFlt — Error value of the real type Float (-3.29E38);
EVAL_RDbl — Error value of the real type Double (-1.79E308).
Òèïû äàííûõ (enum — TVariant::Type):
TVariant::Null — data type and data is not set.
TVariant::Boolean — boolean type (boolean, 8áèò).
TVariant::Integer — integer type (integer, 32áèò).
14. The control interface of the system and the dynamic tree of the system objects (TCntrNode)
For complete coverage of the key components of the system by the network of the same structure objects the object of the dynamic tree node TCntrNode is provided. This objects provides the following functions:
providing of the uniform access to system components, including the blocks of the dynamic access;
building the distributed control interface.
Any object that has the need to provide dynamic access to itself or its components must be inherited from the object of the dynamic tree node TCntrNode. This relationship is automatically includes the node into the dynamic tree of objects covered by both: the direct and the reverse links, and also provides an opportunity to create containers for its own child nodes. In addition to this node is able to preact the inclusion and exclusion/remove of the node from the tree with the possibility of reject from the exclusion/removal.
The control interface of the system is included into the TCntrNode object and, accordingly, covers all the nodes of the dynamic tree of the system, allowing you to consistently manage the system regardless of the client tool used. The control interface of the system is based on the markup language XML. You can think of many ways to use control interface of system, as an example, we'll note the following most meaningful solutions:
Web interface of the configuration ;
GUI configuration interface (QT, GTK+, ...);
reflection of the configuration in the network for distributed management of multiple OpenSCADA-stations from the single management area;
using as the protocol for objects' data access from the network;
provision of service functions to access of the exterior application and the single OpenSCADA components to the internal data.
The control interface of the system is implemented by the following components:
information structure of the user configuration page;
dynamic part in the form of requests for getting, modification of data and service requests;
container or group of the above elements.
Information hierarchical structure contains information about public control elements and can be used to build custom dialogs for the node's control of the system.
The dynamic part contains the scripts of requests' to the control elements service which are described in the information structure; as well as hidden control elements in the form of service functions used for unified access to the node.
The container can also gather into the single request several information structures and dynamic parts, thereby optimizing the time of the request especially on the high latency network interfaces.
Overall control interface is built from individual components of the dynamic tree. Hierarchical inheritance from the TCntrNode object allows to realize multi-level addition of the configuration of the control interface. General view of the dynamic node tree is shown in Fig. 8.
Fig. 8. Example of dynamic tree of the node in the OpenSCADA system.
System's nodes, containing data for the control interface of the system must also be connected to the dynamic tree of objects.
Connection of the node to the dynamic tree is done as follows:
inheritance of the TCntrNode object or its child;
information structure formation;
service of the requests to dynamic data.
14.1. The syntax of the request and response of the control interface
Whole exchange with the control interface is done through the XML language. The internal exchange is done through the parsed structure of XML language (DOM), and external — through the transformation in the stream the characters of continuous XML-file and vice versa.
Request is executed by sending a container with some parameters in the attributes. The result is placed in the resulting container with the changes in certain attributes of the root container. In general, the request container can be written as follows: <cmd path="/TreePath" user="user" force="1"/>
Where:
cmd — request command; path — path to the node or to the branch of the tree; user — user of the system on behalf of which the request is sent; force — the sign: to execute the request without warning.
As the confirmation of the request's result it is set the result's attribute rez in values: 0-request succeeds, 1-warning (with the possibility of execution), 2-error. In the case of error and warning the messages are written in the text of the container and in the attribute mcat (message category): <cmd path = "/TreePath" user="user" force="1" rez="2" mcat="sub_DAQ/mod_BlockCalc>; Unable to delete the node </cmd>
Grouping request "CntrReqs" is processed at the API level of the node and does not require separate processing in the user code. In fact, into the tag "CntrReqs" may be placed any other requests with the possibility of hierarchical grouping by including of the internal tags "CntrReqs". The only attribute of this tag is an attribute path, which indicates the path to the node and is the basis for internal requests.
14.2. Tag of the information structure for describing the groups of child branches of the page
Each page can contain groups of child branches. For descriptions of groups of branches there is the tag "branches". Tag contains the description of groups of branches through embedded tags grp. The group tag can be accessed as for the "read" (visibility) and for modification ( the execution of commands for adding and removing the elements of the group), hence the element of the triad of access may be:
00 — there is no any access; 04 — there is an access only for reading; 02 — there is only access fro the writing, usually this value has no meaning because the write access means access for reading; 06 — there is an access to read, and to write.
Actions over the group of elements coincide with the actions over the list of visual elements "list", which is described below.
14.3. Tags of the description of the information structure of the control interface
Information tags for the XML form the alphabet of the formation of the description the configuration dialogs. Request command of the information part is: <info path="/TreePath" user="user"/>
As the result of the request it will be received the information structure of the page in accordance with the privileges of the specified user.
14.3.1. Area tag "area"
Areas are described with "area" tag and are intended to group the elements on different features. Area may include other elements and areas. The root ones form the bookmarks in the presentation of the user interface. To tag, you can access only to "read" or "visibility", hence the element of the triad of access can be set to 00, if access is absent, or 04, if it is present.
The tag can be accessed as to "read" and also to "write", therefore an element of the triad of access may be:
00 — there is no any access; 04 — there is an access only for reading; 02 — there is only access fro the writing, usually this value has no meaning because the write access means access for reading; 06 — there is an access to read, and to write.
Type of the element, discribed by the "fld" tag, is specified by the tp attribute (table 2).
<list id="mod_auto" dscr="List of shared libs(modules)" tp="str" dest="file"/>
The tag can be accessed as to "read" and also to "write"(modification), therefore an element of the triad of access may be:
00 — there is no any access; 04 — there is an access only for reading; 02 — there is only access fro the writing, usually this value has no meaning because the write access means access for reading; 06 — there is an access to read, and to write.
Type of the elements in the list is specified by the attribute tp. tp attribute's values are given in Table 1.
Table 4. Actions over the list.
Operation
Action
Interrogation
Request: command "get": <get path="/fld_teg" user="user"/> Result: confirmation with the result in the tag's text or an error message. The result is formed in the form:
To insert the string with the ID "tst" and value "Test" in position 3 with the string "tst1". In the case of the index list p_id attribute contains the identifier, else — the text of the string. If the list is not indexed, then the ID attribute is absent.
To replace the string at position 3 with the identifier "tst1" with the another string with the identifier "tst" and value "Test". In the case of the index list p_id attribute contains the identifier, else — the text of the string. If the list is not indexed, then the ID attribute is absent.
The tag of the table or single column can be accessed as to "read" and also to "write"(modification), therefore an element of the triad of access may be:
00 — there is no any access; 04 — there is an access only for reading; 02 — there is only access fro the writing, usually this value has no meaning because the write access means access for reading; 06 — there is an access to read, and to write.
If the attribute key is specified and it lists the key columns, the work with the table moves to the addressing mode by the identifiers for columns and keys.
To move the string from position 3 to position 5. Command does not work when attribute key is set!
Result: confirmation or an error message.
Change the cell
Request: command "set": <set path="/fld_teg" user="user" row="3" col="id">Test</set> or <set path="/fld_teg" user="user" key_id="Test" col="id">Test1</set> for the key mode
To set the cell's value in row 3 and column "id" to "Test" or set of the column named "id" of the row to the position where the id column value is "Test" to value "Test1". Practically, this command renames a key element of the specified row.
Result: confirmation or an error message.
d) Tag "img"
<img id="ico" descr="Page icon"/>
The tag can be accessed as to "read" and also to "write"(modification), therefore an element of the triad of access may be:
00 — there is no any access; 04 — there is an access only for reading; 02 — there is only access fro the writing, usually this value has no meaning because the write access means access for reading; 06 — there is an access to read, and to write.
Tag is provided to transfer images to the clients of control interface. Under the image may be: pages' icons, graphics of the values' arrays and other data that can be presented in graphical form.
The tag can be accessed as to "read" or visibility + service of the requests, and for modification or execution of the command, hence an element of the triad of access can be set to 00, if access is absent at all; 04, if the command can be seen, and 06, if the command can be initiated.
It is provided for transmission of commands and actions to the node, and also can be used to create links to other pages. Commands may include options. Parameters are described with "fld".
The branches are described by the usual list "list" with special attributes tp = "br". Methodology of the request and modification of branches coincides with the one of work with the list "list".
14.4 Hierarchical dependences of the information elements of the control language
Table 6. Hierarchical dependencies of the information elements of the language.
Tag
Description
Attributes
Contents
oscada_cntr
The root element of the page. It is the only and serves to identify the origin of language of control interface.
id — ID; dscr — description.
area, img, branches
branches
Container of the groups of child branches of the node.
id — Container's ID. It is equal: br.
grp
grp
The group of the child nodes.
id — prefix of the group of child nodes in the system; dscr — description of the branches' group; acs — access options.
area
Grouping of the standard tags.
id — ID; dscr — description; acs — access options.
area, fld, list, table, comm, img
comm
Commands to the node.
id — ID; dscr — description; help — command's help; tp — command's type (lnk — ññûëêà); acs — access options.
fld
fld
Description of the standard data types.
id — ID; dscr — description; help — help; acs — access options. tp — element's type:
str(len, dest, cols, rows(SnthHgl)) — string element; dec(len, max, min, dest) — integer in decimal representation; oct(len, max, min, dest) — integer in octal; hex(len, max, min, dest) — integer in hexadecimal; real(len, max, min, dest) — real number; bool — boolean sign; time — time/date in seconds (from 01/01/1970).
Connected: len — value length (char.); min — minimum of value; max — maximum of value; cols — number of columns; rows — number of rows; dest — input method:
data — source of binary data (base64). select(select) — selective type; sel_ed(select) — selective type with the possibility of editing.
select — path to the hidden list; sel_list — static list (separator ';'); sel_id — static list of the identifiers (separator ';').
list
List of standard data types.
id — ID; dscr — description; help — help list; acs — access options; tp — as in fld except:
br(br_pref) — child nodes.
idm — indexed list (0|1); s_com — ways of the list's modification [add][,ins][,edit][,del]:
add — add rows; ins — insert rows; edit — modify rows; del — delete rows.
Connected: br_pref — child node's prefix; dest — as in fld.
table
Table of standard data types.
id — ID; dscr — description; help — table help; acs — access options; key — key columns (key="id,name,per"); cols — list of columns in the request attribute; rows — range of rows in the attribute of the request; s_com — types of the table's modification [add][,del][,ins][,move]:
add — add rows; ins — insert rows; del — delete rows; move — move rows.
By all the dynamic and controlled objects directly or through the childs.
Data:
Named rights of access to control elements (define):
R_R_R_ (0444) — access to all read-only;
R_R___ (0440) — read access only to the owner and group;
R_____ (0400) — read access only to the owner;
RWRWRW (0666) — full access to all;
RWRWR_ (0664) — full access to the owner and group, and for the rest — the read-only;
RWR_R_ (0644) — full access to the owner and for the group and the rest — the read-only;
RWR___ (0640) — full access to the owner, read-only — to the group and closed for the rest;
RW____ (0600) — full access to the owner, but for the group and everyone else is closed.
Dynamic node's flags (enum TCntrNode::Flag):
TCntrNode::DoDisable — switching-off (0);
TCntrNode::Disabled — disabled (1);
TCntrNode::DoEnable — switching-on (2);
TCntrNode::Enabled — enabled (3);
TCntrNode::SelfModify — sign of the node's modification (0x04);
TCntrNode::SelfModifyS — sign for node's modification save into load_() (0x08).
TCntrNode::SelfSaveForceOnChild — force save, call "save_()", if changed-saving child nodes (0x10).
Flags of the enabling/disabling modes of the node (enum TCntrNode::Flag):
TCntrNode::NodeConnect — connection of the node;
TCntrNode::NodeRestore — restoration of the connection of the node.
Modification of the node flags (enum TCntrNode::ModifFlag):
TCntrNode::Self — the given node is modified;
TCntrNode::Child — the child nodes are modified;
TCntrNode::All — the given node and the child ones are modified.
Public methods:
TCntrNode( TCntrNode *prev = NULL ); — Initialization with an indication of the parent node prev.
virtual string objName( ); — Object name. Object-heir should extend the definition of aggregate object name.
virtual TCntrNode &operator=( const TCntrNode &node ); — Virtual copy function of the dynamic tree nodes.
void cntrCmd( XMLNode *opt, int lev = 0, const string &path = "", int off = 0 ); — Command of work with the control interface of the system. The transport transitions to the full path of the following form are supported: ãäå %2fgen — encoded sub-path to a particular field of the page (/gen).
static XMLNode *ctrId( XMLNode *inf, const string &n_id, bool noex = false ); — Getting the XML node by the attribute's value "id" n_id. XML requests of the node by the full path to it are supported (node1/node2/node3).
static XMLNode *ctrMkNode( const char *n_nd, XMLNode *nd, int pos, const char *req, const string &dscr int perm = 0777, const char *user = "root", const char *grp = "root", int n_attr = 0, ... ); static XMLNode *ctrMkNode2( const char *n_nd, XMLNode *nd, int pos, const char *req, const string &dscr, int perm = 0777, const char *user = "root", const char *grp = "root", ... ); — Adding the control element to the page. It is possible to specify the set of additional attributes in the number of n_attr as follows: "{attribute1},{values1},{attribute2},{values2},..." or by zero pointer at the end of the pair sequence.
bool ctrRemoveNode( XMLNode *nd, const char *path ); — Removing the control element path from the page nd.
static bool ctrChkNode( XMLNode *nd, const char *cmd="get", int perm=0444, const char *user="root", const char *grp="root", char mode=04, const char *warn = NULL ); — Checking for the dynamic command getting cmd and for the existence of rights to its execution.
ResMtx &dataRes( ); — Mutex for using resources of the node in common purpose.
virtual const char *nodeNameSYSM( ) const; — System message's location entry name, to place it to the system's message text by function "mess_sys" and "err_sys". Empty value, by default, to pass the node.
string nodePath( char sep = 0, bool from_root = true ) const; — Getting the full path to the node, beginning from the root from_root, and using the separator sep or standard path recording.
void nodeList( vector<string> &list, const string& gid = "" ); — Child nodes list list in the specified group gid.
AutoHD<TCntrNode> nodeAt( const string &path, int lev = 0, char sep = 0, int off = 0, bool noex = false ); — Attachment to the child node.
void nodeDel( const string &path, char sep = 0, int flag = 0 ); — Deleting the node using its path.
static void nodeCopy( const string &src, const string &dst, const string &user = "root" ); — Copying the nodes of the dynamic tree.
TCntrNode *nodePrev( bool noex = false ) const; — Address of the parent node.
char nodeFlg( ); — Node's flag.
void setNodeFlg( char flg ); — Set flags TCntrNode::SelfModify, TCntrNode::SelfModifyS and TCntrNode::SelfSaveForceOnChild.
char nodeMode( ) const; — Node's status.
unsigned nodeUse( bool selfOnly ); — Number of the connections to the node. selfOnly — only self connections, without childs.
unsigned nodePos( ); — The position of the node in the parent-node's container. It is valid only for ordered containers.
int isModify( int mflg = TCntrNode::All ); — Checking for the modification of the node or nodes' branch.
void modif( bool save = false ); — Setting the sign of the node's modification, with save sign save.
void modifG( ); — Setting the sign of the nodes' branch modification.
void modifClr( bool save = false ); — Clear the sign of the node's modification or save sign save.
void modifGClr( ); — Clear the sign of the nodes' branch modification.
void load( TConfig *cfg = NULL, string *errs = NULL ); — Load the dynamic tree node for ready configuration cfg. The loading errors place to errs by lines.
void save( unsigned lev = 0, string *errs = NULL ); — Saving the dynamic tree node, on nesting level lev (service). The saving errors place to errs by lines.
virtual void AHDConnect( ); — Connection to the node (capture of the resource).
virtual bool AHDDisConnect( ); — Disñonnection from the node (release of the resource). Resource will remove on zero result.
void mess_sys( int8_t level, const char *fmt, ... ); — The system message forms for the node path as the category, the level, the formatted message fmt appended by the node location and followed arguments.
TError err_sys( const char *fmt, ... ) const; TError err_sys( int cod, const char *fmt, ... ) const; — The error object forms for the node path as the category, the code cod, the formatted message fmt appended by the node location and followed arguments.
virtual TVariant objPropGet( const string &id ); — Request of the node's property as the user's object.
virtual void objPropSet( const string &id, TVariant val ); — Setting the node's property as the user's object.
virtual TVariant objFuncCall( const string &id, vector<TVariant> &prms ); — Node's function calling as the user's object.
int8_t grpSize( ); — Number of the containers with the child nodes.
int8_t grpId( const string &sid ); — Getting the index of the group by its ID.
virtual AutoHD<TCntrNode> chldAt( int8_t igr, const string &name, const string &user = "" ) const; — Attachment to the child node name of the container gr of the user user.
void chldList( int8_t igr, vector<string> &list, bool noex = false ) const; — The list of the child nodes list in the specified container gr.
bool chldPresent( int8_t igr, const string &name ) const; — Check for the presence of the specified child node name in the container gr.
Protected methods:
virtual void cntrCmdProc( XMLNode *req ); — Function of requests' processing of the control interface. It must be redefined by the child.
void nodeEn( int flag = 0 ); — Node's enabling.
void nodeDis( long tm = 0, int flag = 0 ); — Disabling of the node with the flag transfer.
void nodeDelAll( ); — Clear all containers with child nodes.
void setNodePrev( TCntrNode *node ); — Setting the parent node to node.
void setNodeMode( char mode ); — Setting the node's status.
GrpEl &grpAt( int8_t id ); — Access to the structure of the group.
unsigned grpAdd( const string &id, bool ordered = false ); — Adding the container of the child nodes with the prefix id and the possibility of an orderly storage ordered. Returns the ID of the new container.
void grpDel( int8_t id ); — Deleting the container of the child nodes id.
virtual void chldAdd( int8_t igr, TCntrNode *node, int pos = -1 ); — Adding the child node node to the container gr and position pos.
void chldDel( int8_t igr, const string &name, long tm = -1, int flag = 0 ); — Deleting the child node name from the container gr with the flag flag.
virtual void preEnable( int flag ); — The connection preact. It is called before the actual connection.
virtual void postEnable( int flag ); — The connection preact. It is called after the actual connection.
virtual void preDisable( int flag ); — The disconnection preact. It is called before the actual disconnection.
virtual void postDisable( int flag ); — The disconnection preact. It is called before the actual disconnection (before deleting).
virtual void load_( ); virtual void load_( TConfig *cfg ); — The function of the loading child node calling for ready configuration cfg.
virtual void save_( ); — The function of the saving child node calling.
XMLNode* setAttr( const string &name, const string &val ); — Setting/creation of the attribute name with the value val.
void load( const string &vl, unsigned flg = 0, const string &cp = "UTF-8" ); — Load/parsing of the XML-file, with source encoding cp and flags flg.
string save( unsigned flg = 0, const string &cp = "UTF-8" ) const; — Saving/creation of the XML-file with the formatting parameter flg and encoding to cp.
XMLNode* clear( ); — Clear the tag (recursively, including all childs).
bool childEmpty( ) const; — Check for empty included tags.
unsigned childSize( ) const; — Number of included tags.
void childAdd( XMLNode *nd ); XMLNode* childAdd( const string &name = "" ); — Adding the included tag.
int childIns( int id, XMLNode *nd ); — Insert of the included tag nd to the position id. Negative id counts from end.
XMLNode* childIns( int id, const string &name = "" ); — Insert of the included tag with the name name to the position id. Negative id counts from end.
void childDel( const int id ); — Deleting of the included tag id. Negative id counts from end.
void childDel( XMLNode *nd ); — Deleting of the included tag using its address nd.
void childClear( const string &name = "" ); — Clean up of the included tag name.
XMLNode* childGet( const int, bool noex = false ) const; — Getting the included tag by its index number.
XMLNode* childGet( const string &name, const int numb = 0, bool noex = false ) const; — Getting of the included numb indexed tag by the tag's name name. noex indicates the prohibition of the generation of exception in the case of absence of the tag.
XMLNode* childGet( const string &attr, const string &vl, bool noex = false ) const; — Getting the included numb indexed tag by its value vl of the attribute attr. noex indicates the prohibition of the generation of exception in the case of absence of the tag.
XMLNode* getElementBy( const string &attr, const string &val ); — Included node search by the value val of the attribute attr.
void getElementsBy( const string &tag, const string &attr, const string &val, TArrayObj *rez ); — get elements array rez from the tree by tag (empty for all) and attribute attr value val (empty for pass).
16. Resources in the OpenSCADA system (Res, ResAlloc, ResMtx, MtxAlloc, AutoHD)
Most of the units and subsystems of the OpenSCADA are dynamic, ie they allow the creation/deletion/configuration while the system is working. Taking into account the multi-threading of the system, this functionality imposes stringent requirements for synchronization of threads. For synchronization in the system the resources are used, functions of which are localized in the objects "Res" and "ResAlloc". Object "Res" provides storage of the resource, providing the functions of capture/release for the read and write. In object "ResAlloc" the automatic release of the resource functions are implemented. Automatic resource involves the creation of a local resource object with its automatic release at fracture (in the destructor). Using of automatic resource makes the work with resources when using the exceptions much easier.
Any dynamic system object is inherited from "TCntrNode" object, which contains a mechanism to connect via the "AutoHD" template. The main function of the template is to store the link to the object and the capture of the resource, excluding the deleting of the object at the time of use. Template supports copying the resource and its release in case of destruction of the template object. For clarity of the access to the objects generated by "TCntrNode" the "AutoHD" template supports casting, based on the dynamic cast.
16.1. Resource R/W lock object (ResRW)
Public methods:
ResRW( ); — Initialization of the resource.
static void resRequestW( long tm = 0 ); — Request the resource for writing/modification with wait timeout tm (in milliseconds).
bool resTryW( ); — Request try the resource for writing/modification. On success return "true" else "false".
static void resRequestR( long tm = 0 ); — Request the resource for reading with wait timeout tm (in milliseconds).
bool resTryR( ); — Request try the resource for reading. On success return "true" else "false".
static void resRelease( ); — Release of the resource.
ResAlloc( ResRW &rid ); — Initialization of the automatically released resource for the previously selected identifier rid.
ResAlloc( ResRW &rid, bool write, long tm = 0 ); — Initialization of the automatically released resource for the previously selected identifier rid. With the specification of the resource type write (read/write).
void request( bool write = false, long tm = 0 ); void lock( bool write = false, unsigned short tm = 0 ); — Request of the resource in the specified mode write (read/write).
void release( ); void unlock( ); — Release of the resource.
16.3. Template (AutoHD)
Public methods:
AutoHD( ); — Initializing without linkage to the object.
AutoHD( ORes *node, const string &who = "" ); — Initialization with the linkage to the object node. The object must contain the function AHDConnect() and AHDDisConnect().
AutoHD( const AutoHD &hd ); — Copyng constructor.
template <class ORes1> AutoHD( const AutoHD<ORes1> &hd_s, bool nosafe = false ); — Ñast constructor in safe mode casting (by help dynamic_cast). Return free resource on impossible cast.
ORes &at( ) const; — Getting the object by the resource.
AutoHD &operator=(const AutoHD &hd); — Copying of the resources.
bool operator==(const AutoHD &hd); — Compare objects into resource by pointer.
void free( ); — Release of the resource.
bool freeStat( ) const; — The sign "The resource is free".
16.4. Resources allocation object, by mutex (ResMtx)
Public methods:
ResMtx( bool isRecurs = false ); — Initialization of a mutex object with recursion isRecurs.
void lock( ); — Mutex lock. Return zero at the success.
void unlock( ); — Mutex unlock. Return zero at the success.
int tryLock( ); — Mutex try lock, without wait for free. Return zero at success.
pthread_mutex_t &mtx( ); — Direct link to the mutex structure.
16.5. Object of the string with the access shared by the resource (ResString)
Public methods:
explicit ResString( const string &vl = "" ); — Initialization of the string with the specified value vl.
ResString &operator=( const string &val ); — Function for implicit conversion from std::string.
operator string( ); — Function for implicit conversion to std::string.
size_t size( ); — The string size.
bool empty( ); — The string empty.
void setVal( const string &vl ); — Setting the string's value to vl.
const string &getVal( ); — Getting the string's value.
const string &getValRef( ); — Getting a direct reference to the string std::string. The resource is ignored when you use this function!
16.6. Conditional variable object, by mutex (CondVar)
Public methods:
CondVar( ); — Initialization of the conditional variable.
int wait( ResMtx &mtx, unsigned short tm = 0 ); — wait for the conditional variable wake up for the timeout tm with the mutex mtx.
int wakeOne( ); — wake up one thread.
int wakeAll( ); — wake up all threads.
16.7. Object of automatic unlock POSIX mutex (MtxAlloc)
Public methods:
MtxAlloc( ResMtx &iM, bool lock = false ); — Initialization of automatic unlock mutex for early allocated identifier iM. With the lock set at a creation.
int lock( ); — The resource lock. Return zero at the success.
int unlock( ); — The resource unlock. Return zero at the success.
int tryLock( ); — The resource try lock, without wait for free. Return zero at the success.
16.8. Object of the string with the access shared by the global the data resource (mutex) (MtxString)
Public methods:
MtxString( ResMtx &iM ); — The string initialization with the access sharing by resource iM.
MtxString &operator=( const string &val ); — Function for implicit conversion from std::string.
operator string( ); — Function for implicit conversion to std::string.
size_t size( ); — The string size.
bool empty( ); — The string empty.
void setVal( const string &vl ); — Setting the string's value to vl.
const string &getVal( ); — Getting the string's value.
const string &getValRef( ); — Getting a direct reference to the string std::string. The resource is ignored when you use this function!
17. Organization and structure of the database of the system components
Nodes and subsystems of OpenSCADA may have their own tables in the database to store their own data. The structure of tables is individual and determined by the <TConfig> object. Nodes and subsystems must create and configure the <TConfig> object under their demands.
17.1. System tables
OpenSCADA system has two system tables: BD and SYS. Table BD contains records of registered databases and the table SYS contains data of system-wide parameters.
Table 7. Structure if the table of system-wide parameters (SYS).
User <user>
Parameter's ID <id>
Parameter's value <val>
root
/DemoStation/MessLev
0
user
/DemoStation/Workdir
/mnt/home/roman/work/OScadaD/share/OpenScada
user
/DemoStation/UI/QTStarter/StartMod
QTCfg
Table 8. Structure if the table of registered DB.
ID <ID>
DB Type <TYPE>
Name <NAME>
Description <DESCR>
Address <ADDR>
Codepage of the database contents <CODEPAGE>
To enable <EN>
LibBD
MySQL
Function's library
server.diya.org;roman;123456;oscadaUserLibs
KOI8-U
1
AnastModel
SQLite
AGLKS model
./DATA/AGLKSModel.db
UTF8
1
GenDB
MySQL
Main DB
server.diya.org;roman;123456;oscadaDemoSt
KOI8-U
1
17.2. Tables of the "Data acquisition" subsystem
Controllers (data sources) of the subsystem "Data acquisition" are stored in the tables of their subsystems named DAQ_<ModName>. The structures of these tables can differ significantly, but all of them have the obligatory fields. The overall structure of the controllers' tables is presented in table 9.
Table 9. The overall structure of the controllers' tables of the subsystem "Data acquisition" (DAQ_<ModName>).
ID <ID>
Controller's name <NAME>
Description <DESCR>
To enable<ENABLE>
To start <START>
Individual parameters
AutoDA
Automatic source
Data acquisition from active sources with automatic identification of them.
1
1
...
Like the controller's table, the parameter's table for different types of data sources can differ significantly, but also have the obligatory fields. In addition to the differences which is typical to the type of data source, parameter's tables can still be different for different types of parameters. The overall structure of the parameters' tables is given in Table 10.
Table 10. The overall structure of the parameters' tables of the subsystem "Data acquisition".
Parameter's shifr <SHIFR>
Parameter's name <NAME>
Parameter's description <DESCR>
To enable <EN>
Individual parameters
P3
P3
Pressure on the diaphragm
1
...
In addition to controllers and parameters the subsystem "Data acquisition" contains parameter's templates. Parameter's templates are grouped by templates' libraries and are stored in tables of three types: templates' library table (ParamTemplLibs) — table 11, parameter's templates table — table 12 and template's parameters table — table 13.
Table 11. Structure of the templates' library table.
ID <ID>
Name <NAME>
Description <DESCR>
DB table of the library <DB>
base
Basic templates
Basic templates' library
tmplib_base
S7
Templates' Library for Siemens S7 series controllers.
tmplib_S7
Table 12. Structure of the templates' table.
ID <ID>
Name <NAME>
Description <DESCR>
Text of the template procedure <PROGRAM>
digAlarm
Digital signal
Alarm over the discrete parameter
JavaLikeCalc.JavaScript
simpleBoard
Simple boards
Formation of the simple boards of the analog signal.
JavaLikeCalc.JavaScript
Table 13. Structure of the table of the template's parameters.
Template's ID <TMPL_ID>
Parameter's ID <ID>
Name <NAME>
Type <TYPE>
Flags <FLAGS>
Value <VALUE>
Position <POS>
digAlarm
in
Âõîä
3
144
2
digitBlock
cmdOpen
Open command
3
161
0
17.3. Tables of the "Transports" subsystem
Subsystem "Transports" is divided into incoming and outgoing transports. For each type of transport there is its own table with its own structure. Table names, respectively: Transport_In and Transport_Out. Tables can be supplemented by fields, typical to the type of transport.
Table 14. Structure of the incoming transport's table (Transport_in).
ID <ID>
Type <MODULE>
Name <NAME>
Description <DESCRIPT>
Address <ADDR>
Protocol <PROT>
To start <START>
Individual fields of the transports' types
web1
Sockets
Web 1
Work web transport for proced http requests.
TCP::10002:0
HTTP
1
...
Self
SelfSystem
TCP 1
Test TCP input socket!
Sockets
TCP::10001:1
1
...
Table 15. Structure of the outgoing transport's table (Transport_out).
ID <ID>
Type <MODULE>
Name <NAME>
Description <DESCRIPT>
Address <ADDR>
To start <START>
Individual fields of the transports' types
tcp_o1
Sockets
TCP Out 1
Output TCP transport 1
TCP::10001
1
...
For the centralized description of the list of external OpenSCADA stations it is used the table of external hosts (CfgExtHosts). The structure of this table is shown in Table 16.
Table 16. The structure of the table of external OpenSCADA hosts (CfgExtHosts).
User of the system <OP_USER>
ID <ID>
Name <NAME>
Transport <TRANSP>
Address of the remote host <ADDR>
User of the external host <USER>
Password of the user of the external host <PASS>
tcp_o1
Sockets
TCP Out 1
Output TCP transport 1
TCP::10001
1
...
17.4. Tables of the "Archives" subsystem
Subsystem "Archives" contains three tables with fixed names:
Archives of values: Archive_val;
Archivers of values: Archive_val_proc;
Archivers of messages: Archive_mess_proc.
Tables of the archivers can be complemented by fields, typical for each type of archiver.
Table 17. Structure of the table of the values' archive (Archive_val).
ID <ID>
Name <NAME>
Description <DESCR>
To start <START>
The mode of the values' source <SrcMode>
Source of the values <Source>
Type of the values <VTYPE>
Buffer's periodicity <BPER>
Buffer's size <BSIZE>
Buffer's hard grid <BHGRD>
High resolution of the buffer's time <BHRES>
List of the serviced archivers <ArchS>
CPULoad_load
1
1
DAQ.System.AutoDA.CPULoad.load
4
1
100
0
0
FSArch.1s;DBArch.1m;FSArch.1m;
ai1_dP
0
0
4
0.0001
100
1
1
FSArch.POMP_20070301;FSArch.1s;
Table 18. Structure of the table of the values' archivers (Archive_val_proc).
ID <ID>
Archiver's type <MODUL>
Name <NAME>
Description <DESCR>
To start <START>
Address <ADDR>
Values' period <V_PER>
Archiving period <A_PER>
Individual fields of the archivers' types
1s
FSArch
One second
1
ARCHIVES/VAL/1s
1
60
...
POMP_20070301
FSArch
0
ARCHIVES/VAL/POMP_20070301
0.0001
60
...
Table 19. Structure of the table of the messages' archivers (Archive_mess_proc).
ID <ID>
Archiver's type <MODUL>
Name <NAME>
Description <DESCR>
To start <START>
Template of the messages' category <CATEG>
Messages' level <LEVEL>
Address <ADDR>
Individual fields of the archivers' types
StatErrors
FSArh
Station error
1
/DemoStation*
4
ARCHIVES/MESS/stError/
...
NetRequsts
FSArh
Network requests
1
/DemoStation/Transport/Sockets*
1
ARCHIVES/MESS/Net/
...
17.5. Tables of the "Security" subsystem
Subsystem "Security" contains two tables: table of the system's users (Security_user) and groups of the system (Security_grp).
Table 20. Structure of the table of the system's users (Security_user).
Name <NAME>
Description <DESCR>
Password <PASS>
Picture <PICTURE>
root
SuperUser
openscada
user
User
user
Table 21. Structure of the table of the system's users groups (Security_grp).
Name <NAME>
Description <DESCR>
Users in the group <USERS>
root
SuperUser's group
root;user
users
User's group
toot;user
17.6. The structure of the databases of the modules
Each module can have its own database tables to store individual data. Structure of database tables of the modules can be formed freely, based on internal needs.
18. Service functions of the OpenSCADA control interface
Service functions — is an interface to access the OpenSCADA system through the OpenSCADA control interface from external systems. This mechanism is the basis for all exchange mechanisms within OpenSCADA, implemented through weak links and standard exchange protocol of OpenSCADA. Its main advantage is the priority processing and the possibility of using non-standard packaging data. For access to normal data you can use the standard commands of the control interface.
18.1. Group access to the values of the parameter's attributes of the subsystem "Data acquisition", as well as to the detailed information
These requests let you to obtain detailed information about the parameters of the subsystem "Data acquisition", to acquire the values of all attributes of the parameters, and also to make the group setting. Detailed information about requests is given in Table 23.
Table 23. Attributes of the request commands of the attributes' parameters of the subsystem "Data acquisition"
Id
Name
Value
Request command of information about the attributes of the parameter:<list path="/sub_DAQ/mod_{SRC}/cntr_{CNTR}/prm_{PRM}/%2fserv%2fattr"/>
<el id="iatr"/>
Information of the attributes
In separate tags the information about attribute is returned.
id
Attribute's ID
The character identifier of the single attribute.
nm
Attribute's name
The name of the single attribute.
flg
Attribute's flags
Flags of the single attribute.
tp
Attribute's type
The type of the single attribute.
vals
Values area of the attribute.
Values area of the single attribute.
names
The names of the attribute's values for the selective type.
The names of the single attribute's values for the selective type.
Team request command of the all values of attributes of the parameter:<get path="/sub_DAQ/mod_{SRC}/cntr_{CNTR}/prm_{PRM}/%2fserv%2fattr"/>
<el id="iatr">val</el>
Attributes' values
In separate tags the values of the attributes are returned.
The set command of the the values of the specified attributes of the parameter:<set path="/sub_DAQ/mod_{SRC}/cntr_{CNTR}/prm_{PRM}/%2fserv%2fattr"/>
<el id="iatr">val</el>
The values of attributes are specified
In separate tags the values of attributes are specified.
18.2. Access to archived data of the archives of messages
To request and set the archive data in the archiving subsystem of the messages archive's object the following command is provided <info path="/sub_Archive/%2fserv%2fmess"/>, <get path="/sub_Archive/%2fserv%2fmess"/> and <set path="/sub_Archive/%2fserv%2fmess"/> to request the information about the archive, archive's values and set values to archive, respectively. Into the object of controller of subsystem "Data acquisition" provides service request for messages generated by the data source <get path="/sub_DAQ/{DAQ_TP}/{DAQ_CNTR}/%2fserv%2fmess"/>. The detailed description of these commands is presented in Table 24.
Table 24. Attributes of request commands of information about the archive of values and archive data
Id
Name
Value
Request command of the information about the archive:<info path="/sub_Archive/%2fserv%2fmess"/>
arch
Setting the name of the archive's archiver
Archive's archiver, for which to specify the parameters.
end
Control of the archive's top in the given archiver
As a result of the request points to the real top of the messages' archive in the given archiver <arch>.
beg
Control of the archive's depth in the given archiver
As a result of the request points to the real depth of the messages' archive in the given archiver <arch>.
Request command of the archival and/or current data:<get path="/sub_Archive/%2fserv%2fmess"/>
tm
Time set
Time of the block's top of the messages' archive.
tm_grnd
Time set of the foundation/beginning of the archive
Points to the foundation/beginning of the archive.
arch
Setting of the archive's archiver
Specifies at what archiver to request the values. If the archiver is not specified, the request will be made consistently in all archivers with the exception of duplicates.
cat
Setting the message's category
Specify the category/template of the requested messages.
lev
Setting the level of importance
Specifies the importance level of messages for which and above to get the messages.
<el>{mess}</el>
Messages
In separate tags the messages are returned.
time, utime
Message's time (seconds, microseconds)
Time of the separate message.
cat
Message's category
Category of the separate message.
lev
Message's level
Level of the separate message.
Set command of the archival data:<set path="/sub_Archive/%2fserv%2fmess"/>
<el>{mess}</el>
Messages
In separate tags the messages for set.
time, utime
Message's time (seconds, microseconds)
Time of the separate message.
cat
Message's category
Category of the separate message.
lev
Message's level
Level of the separate message.
Request command of the archival and/or current data of the data source:<get path="/sub_DAQ/{DAQ_TP}/{DAQ_CNTR}/%2fserv%2fmess"/>
tm
Time set
Time of the block's top of the messages' archive. If the value is zero then set and return here current time value.
tm_grnd
Time set of the foundation/beginning of the archive
Points to the foundation/beginning of the archive.
<el>{mess}</el>
Messages
In separate tags the messages are returned.
time, utime
Message's time (seconds, microseconds)
Time of the separate message.
cat
Message's category
Category of the separate message.
lev
Message's level
Level of the separate message.
18.3. Access to archived data of the values' archive
To request the archive data in the archiving subsystem of the values archive's object and parameter's attribute object of "Data acquisition" subsystem the following command is provided <info path="{a_p_addr}/%2fserv%2fval"/> è <get path="{a_p_addr}/%2fserv%2fval"/> to request the information about the archive's and archive values respectively. Attributes of these commands, involving various mechanisms of the request are presented in Table 25.
Table 25. Attributes of the request commands of information about the archive of archive data
Id
Name
Value
Request command of the information about the archive:<info path="{a_p_addr}/%2fserv%2fval"/>
arch
Setting the name of the archive's archiver
Archive's archiver, for which to specify the parameters.
end
Control of the archive's top in the given archiver
As a result of the request points to the real top of the values' archive in the given archiver <arch>. In the case of the archive's absence the attribute is set to "0".
beg
Control of the archive's depth in the given archiver
As a result of the request points to the real depth of the values' archive in the given archiver <arch>. In the case of the archive's absence the attribute is set to "0".
per
Control of the archive's periodicity in the given archiver
As a result of the request points to the real periodicity of the values' archive in the given archiver <arch>. In the case of the archive's absence the attribute is set to "0".
vtp
Control of the archive's/parameter's type of value
Returns the code of the type of the archive data values: 0 — Boolean, 1 — Integer, 4 — Real, 5 — String. But this property is only available in the case of request at the parameter without archive!
Request command of archive or/and current data<get path="{a_p_addr}/%2fserv%2fval"/>
tm
Setting and control of time
Time of the requested value or top of the archive values' block. If the attribute is not specified or equal to "0", the last value is returned. The value of this attribute is set to the value of time of obtained value or of the top of the archival data block.
tm_grnd
Setting and control of the foundation/beginning time of the archive
Points to the foundation/beginning of the archive. If the attribute is not specified or equal to "0", then the request of one value is made. The value of this attribute is set to the foundation of the block of archival data time.
per
Setting and control of the periodicity of the obtained values
Periodicity of requested values. If the attribute is not specified or equal to "0" or less than the real periodicity of the archive, then the values will be returned with the real periodicity of the archive and the value of this attribute will be set to the real periodicity value. If the attribute's value is more than the actual periodicity, the values of the archive will be averaged to the specified periodicity.
arch
Setting and control of the archive's archiver
Specifies at what archiver to request the values. If the archiver is not specified, the request will be made consistent with the priority from best to worst. The name of the archiver, from whom the values are obtained, will be indicated in this attribute when returning the result. If the archiver for this parameter is not set, or such archiver is not present, then the value of this attribute will be reset. In the case of the request, crossing several archivers, the processing occurs only for the first archiver with the specification of its name and dimension in the relevant attributes. To request the data of follow-up archivers the request is repeated starting from the dimension of the previous request.
mode
Setting and control of the mode of transfer of the archive data
The form in which it is desirable to obtain the archive data is specified. The following modes/forms of transfer of archives' data are provided:
0 — Simple record: single value — one string without packaging of the related values. In the case of string archive the values are encoded to exclude the newlines characters. Example of the writing form:
34.5678 23.6543 65.8754 34.6523
1 — Packed record on the principle of folding the related values: one value — one record. Before each value it is indicated its position number, separated by the space:
0 34.5678 1 23.6543 4 65.8754 6 34.6523
2 — The array of unpackaged binary values encoded by Mime Base64. Can not be used for string archives.
real_prec
Setting the precision of the real values
Specifies the precision with which to transmit the data of real values in the "0" and "1" mode. By default, this precision is 6 digits.
round_perc
Setting the rounding percent
Indicates the rounding percentage of related numeric values for the mode of "1".
Request name for archived parameter or same archive:<name path="{a_p_addr}/%2fserv%2fval"/>
Modules in the OpenSCADA system are implemented as shared libraries. As it was previously mentioned, one such library can contain many modules of OpenSCADA subsystems, actually acting as a container.
The first step in connecting the shared (SO — shared object) libraries is the connection of the initialization functions. These functions should be defined as usual "C" functions to avoid distortion of function names. Usually this is done as follows:
//================== CUT ========================= extern "C" { #ifdef MOD_INCL //Need for define only at case builtin to OpenSCADA core support by the module TModule::SAt bd_DBF_module( int n_mod ) #else TModule::SAt module( int n_mod ) #endif { //Allowed into the shared object the modules descriptors forming }
#ifdef MOD_INCL //Need for define only at case builtin to OpenSCADA core support by the module TModule *bd_Tmpl_attach( const TModule::SAt &AtMod, const string &source ) #else TModule *attach( const TModule::SAt &AtMod, const string &source ) #endif { //Selected module connect } } //================== CUT =========================
Functions for the working with shared library: TModule::SAt module( int n_mod );
The function is provided to sequentially poll the information about modules which are contained in the SO library. n_mod parameter indicates the serial number of the requested module and must be looked over, starting from zero. In the case of absence of the module with the given identifier the function must return the structure with the module name of zero length, that is the end of the scanning process.
Actually all functions and data of the system are summarized in the API-systems described in this document. However, to simplify and accelerate the process of writing the modules the main function, redefined in modules, are listed in Table 22.
Table 22. The main functions used when creating the modules
Common API
Objects API (TCntrNode):
virtual void load_( ); — Object loading from storage.
virtual void save_( ); — Object saving into storage.
Common modules API (TModule):
Attributes:
string mId; — Module's ID.
string mName; — Module's name.
string mDescr; — Module's description.
string mType; — Module's type.
string mVers; — Module's version.
string mAutor; — Module's author.
string mLicense; — Module's license.
string mSource; — Module's source/origin.
Methods:
virtual void modStart( ); — Module's start.
virtual void modStop( ); — Module's stop.
virtual void modInfo( vector<string> &list ); — The list of available elements of information about the module. There are the following information elements:
virtual void allowList( vector<string> &list ) const; — Tables' list in the DB.
virtual void sqlReq( const string &req, vector< vector<string> > *tbl = NULL, char intoTrans = EVAL_BOOL ); — Sending the SQL-request req to the DB and receiving the result in tabular form tbl. If set intoTrans to true then will open transaction for the request, else if set to false then transaction will close.
virtual void transCloseCheck( ); — The function call periodic for opened transaction check to close for old transaction or overloaded.
virtual void setAddr( const string &addr ); — The transport address set. It would be redefined for processing and checking for specific to the module transport's address format.
virtual void start(); — Transport's start.
virtual void stop(); — Transport's stop.
Outgoing transport (child from TTransportOut):
virtual string getStatus( ); — Interface status.
virtual void setAddr( const string &addr ); — The transport address set. It would be redefined for processing and checking for specific to the module transport's address format.
virtual void start( ); — Transport's start.
virtual void stop( ); — Transport's stop.
virtual int messIO( const char *obuf, int len_ob, char *ibuf = NULL, int len_ib = 0, int time = 0 ); — Sending data via the transport. Timeout time of the connection is indicated in milliseconds.
API of the modules of subsystem "Protocols".
Protocol (child from TProtocol):
virtual void itemListIn( vector<string> &ls, const string &curIt = "" ); — The input protocol subelements list, at case the protocol allow. Used for select in object of input transport configuration.
virtual void outMess( XMLNode &io, TTransportOut &tro ); — Data transfer in the XML tree in to the remote system by means of transport tro and the current outgoing protocol.
virtual bool mess( const string &request, string &answer, const string &sender ); — Transfer of unstructured message to the protocol.
API of the modules of "Data acquisition" subsystem.
Controller's type (child from TTypeDAQ):
virtual void compileFuncLangs( vector<string> &ls ); — The list of user programming languages that are supported by the module.
virtual void compileFuncSynthHighl( const string &lang, XMLNode &shgl ); — Syntax highlight rules shgl request for user programming language lang.
virtual string compileFunc( const string &lang, TFunction &fnc_cfg, const string &prog_text ); — Compilation of the user procedure and creation of the object of function's execution for the specified language of user programming.
virtual bool redntAllow( ); — The sign of support of the redundancy mechanisms by the module. Should by simply redefined and return true.
virtual TController *ContrAttach( const string &name, const string &daq_db ); — Opening/connection of the controller.
Controller (child from TController):
virtual string getStatus( ); — Call for specific controller status get.
virtual void enable_( ); — Controller enable.
virtual void disable_( ); — Controller disable.
virtual void start_( ); — Controller's start.
virtual void stop_( ); — Controller's stop.
virtual void redntDataUpdate( bool firstArchiveSync = false ); — An operation of the data receiving from the redundant station execution. It is called automatically by the service task of the redundancy scheme and before starting to synchronize the archives with the parameter firstArchiveSync set.
virtual TParamContr *ParamAttach( const string &name, int type ); — Creation/opening of the new parameter.
Controller's parameter (child from TParamContr->TValue):
virtual void enable( ); — Enable parameter.
virtual void disable( ); — Disable parameter.
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.
virtual TVal* vlNew( ); — Call at new attribute creation. Would be redefined for specific behavior into self, inherited from TVal, class at accessing to attribute.
virtual void vlSet( TVal &val, const TVariant &pvl ); — Call for attribute into direct write mode TVal::DirWrite (synchronous mode or writing to internal object's buffer) at a value set, for direct writing to physical controller or object's buffer.
virtual void vlGet( TVal &val ); — Call for attribute into direct read mode TVal::DirRead (synchronous mode or reading from internal object's buffer) at a value get, for direct reading from physical controller or object's buffer.
virtual void vlArchMake( TVal &val ); — Call at a value archive creation with attribute val as the source for quality properties initialization to archive's buffer according with specific of data source and its acquisition.
API of the modules of the "Archives" subsystem.
Archiver's type (child from TTypeArchivator):
virtual TMArchivator *AMess(const string &id, const string &db ); — Creation of the messages' archive.
virtual TVArchivator *AVal(const string &id, const string &db ); — Creation of the messages' archiver.
Messages' archiver (child from TMArchivator):
virtual void start( ); — Archiver's start.
virtual void stop( ); — Archiver's stop.
virtual time_t begin( ); — The beginning of the data in the archive.
virtual time_t end( ); — The end of the data in the archive.
virtual void put( vector<TMess::SRec> &mess ); — Put the message to the archiver.
virtual void get( time_t b_tm, time_t e_tm, vector<TMess::SRec> &mess, const string &category = "", char level = 0, time_t upTo = 0 ); — Get the message from the archiver.
Values' archiver (child from TVArchivator):
virtual void setValPeriod( double per ); — Set the periodicity of the archiver's values.
virtual void setArchPeriod( int per ); — Set the archiving periodicity.
virtual void start( ); — Start the archiver.
virtual void stop( bool full_del = false ); — Stop the archiver with the possibility of complete deleting if the full_del flag is set.
virtual TVArchEl *getArchEl( TVArchive &arch ); — Getting the arch archive, which is served by the archiver.
An archive element of values (child from TVArchEl):
virtual void fullErase( ); — Complete deleting of the part of archive in the archiver.
virtual int64_t end( ); — End time of the archive in the archiver.
virtual int64_t begin( ); — Start time of the archive in the archiver.
virtual TVariant getValProc( int64_t *tm, bool up_ord ); — Request processing function of the single value from the archive.
virtual void getValsProc( TValBuf &buf, int64_t beg, int64_t end ); — Function of the request processing by the module to get data group values buf for set time interval.
virtual void setValsProc( TValBuf &buf, int64_t beg, int64_t end ); — Function of the request processing by the module to set data values buf for set time interval.
API of the modules of subsystem "User interfaces".
User interface (child from TUI):
It does not contain specific functions!
API ìîäóëåé ïîäñèñòåìû "Ñïåöèàëüíûå”.
Specials (child from TSpecial):
It does not contain specific functions!
To monitor the quality of code and test the performance of various parts of the system the special modules are written that perform testing with the issue of testing protocol. These modules must be executed after the completion of any part of the project.
21. Rules for design and commenting of the sources of OpenSCADA and its modules
When writing and design of the sources of the OpenSCADA system and its modules you must to follow the rules:
indent between the levels of enclosure: 4 characters;
tabulation space: 8 symbols;
braces of opening placed in previous command place, if the shorter for 80 symbols;
braces of closing must be placed in separate lines at the level of the previous text;
it is possible to write an enclosure in the single line with the previous level of enclosure, in case of increasing the readability of the code;
distance between the descriptions of the functions of at least one character;
the distance between the definition of variables and the text of the program at least one symbol;
it is possible to define variables in the text while saving the readability;
to avoid long lines more than 100 characters;
preprocessor commands must be located on the first level, regardless of the current level of the text;
for the formatting the source code, inherited from the other free applications and examples, it is recommended to use the utility: