Modules/BlockCalc - OpenSCADAWiki

# Modules/BlockCalc

English • ‎mRussian • ‎Українська

| The translation checking and actualizing

Module | Name | Version | License | Source | Languages | Platforms | Type | Author | Description
--- | --- | --- | --- | --- | --- | --- | --- | --- | ---
BlockCalc | Block calculator | 1.12 | GPL2 | daq_BlockCalc.so | en,uk,ru,de | x86,x86_64,ARM | DAQ | Roman Savochenko Maxim Lysenko (2009,2012) — the page initial translation | Provides a block calculator.

The module of subsystems "DAQ" BlockCalc provides the system OpenSCADA with the mechanism for creating custom calculations. The mechanism of calculations based on the formal language of block circuits(functional blocks).

Also, the module implements the functions of the horizontal reservation, namely, working in conjunction with the remote station of the same level. In addition to the synchronization of the archives of values and archives of attributes of parameters the module implements synchronization of computational templates, in order to shockless catch of the algorithms.

Languages of block programming based on the notion of circuits(functional blocks). Moreover, depending on the substance of the block, block circuits may include: logic, relay logic circuits, a model of technological process, and more. The essence of the block circuit is that it contains a list of blocks and relations between them.

From a formal point of view a block is an element(function), which has inputs, outputs, and an algorithm for computing. Basing on the concept of programming area, block is a frame of values associated with the object of function.

Of course, the inputs and outputs of blocks may be needed to be connected for a solid block scheme. The following types of links are provided:

- Interblock, connecting the input of one block to the output of another one, the input of one block to another one's input and output of one block to the input of another one;
- Interblock remote, connection of blocks of controllers of different block circuits of the module;
- Coefficients, the transformation of input into the constant, all inputs / outputs by default are initiated as a constant;
- External attribute of the parameter.

Conditionally, connections of blocks can be represented as links between the blocks as a whole(Fig. 1) or detailing of the links(Fig. 2). In the process of binding parameters of blocks the connection of parameters of any type is acceptable. Thus, in the process of computation automatically casting of types will be done.

Fig. 1. General connections between blocks of a block scheme.
Fig. 2. Detailed links between blocks.

## 1 The controller of the module

Each controller of this module contains the block circuit, which he computes with the specified period. In order to provide calculated data in the system OpenSCADA the parameters can be created in the controller. Example of the configuration tab of the controller of the given type depicted in Fig. 3.

Fig. 3. Configuration tab of a controller.

From this tab you can set:

- State of the controller object, as follows: status, "Enabled", "Running" and the storage name containing the configuration.
- Identifier, name and description of the controller.
- The state "Enabled" and "Running", in which the controller object must be translated at start up.
- Policy of scheduling, priority of the data acquisition task and number of iterations in one cycle of calculating task of the block scheme of the controller.

## 2 The block scheme of the controller

The block scheme is formed by means of the tab controller's blocks, configuration of the block (Figure 4) and its connections (Fig. 5). The blocks are stored in a table with the name "BlckCalcBlcks_{CntrId}".

Blocks of block scheme can connect both among themselves and to the attributes of the parameters. Blocks themselves do not contain the structure of input/output(IO), but contain values, based on the IO-structure of related function. Function for linking with a block is used from the object model of the system OpenSCADA.

Any block may at any time be removed from the process and be reconfigured and then may be again included in the process. Communications between the blocks can be configured without exception blocks from the processing and stopping of the controller. All IO values without connections can be changed during processing.

Using tab of the blocks you can:

- Add/remove a block in the block scheme.
- To monitor the total number, number of enabled and the number of processing blocks.

Fig. 4. Configuration tab of a block scheme.

Using the form of block configuration it can be set:

- The state of the block, as follows: "Enable" and "Process".
- Id, name and description of the block.
- The state in which the block is to be translated at boot time: "To enable" and "To process".
- Set block which must calculate before this block.
- Appoint a working function from the object model. Back to the function for familiarization.

Fig. 5. Configuration tab of links of a block of a block scheme.

Using the configuration tab of links of the block of the block scheme the links can be set for the parameter of each block separately.

The following types of links are supported:

- Inter-block. Connecting the block input to the output of another block, the input of one block to another's input and output of one block to the input of another.
- Distant inter-block. The connection of blocks from various controllers of the module.
- Ratio. The transformation of the input to a constant. All inputs/outputs by default are initiated as constants.
- External attribute of the parameter.

To set values for the parameter of the block there is the corresponding tab (Fig.6).

In accordance with the custom functions in the system OpenSCADA the four main types of IO are supported: integer, float, boolean and string.

Fig. 6. Configuration tab of values of parameters of a block of a block scheme.

The module provides a special treatment of a number of IO of the block:

- f_frq — Frequency computation or the time after the last calculation of the block, the negative in seconds for scheduling of CRON, read-only.
- f_start — First calculate of the block, start, read-only.
- f_stop — Last calculate of the block, stop, read-only.
- this — The block object.

## 3 Parameters of the controller

The module provides only one the "Standard (std)" type of the parameters with the parameters table name "BlckCalcPrm_{CntrId}". The parameter used to reflect the data, calculated in the blocks, on the attributes of the controller's parameters. Example of the configuration tab of the parameter is shown in Fig.7.

Fig. 7. Configuration tab of values of parameters of a controller.

From this tab you can set:

- The state of the parameter, as follows: "Enable" and type of the parameter.
- Id, name and description of the parameter.
- The state in which the parameter must be translated at boot time: "To enable".
- The list of attributes that are reflected on the parameters of the blocks. It is created as the list of elements in the format: {BLK}.{BLK_IO}[:{AID}:{ANM}]. Where:

  {BLK} — block ID, block schemes ID; for constant value set to:
    '*s' — string type;
    '*i' — integer type;
    '*r' — real type;
    '*b' — boolean type.
  {BLK_IO} — parameter of the block or of the the block scheme; for constant value set to attribute value;
  {AID} — attribute of the parameter ID;
  {ANM} — name of the attribute of parameter.

## 4 Copying of the block schemes

To simplify and expedite the development of complex and repetitive block schemes the mechanism of copying of the elements of block scheme both individually and block schemes entirely is provided. The mechanism of copying is integrated into the kernel of OpenSCADA and operates transparently.

## 5 User programming API

Some objects of the module provides functions for user's programming.

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

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

## 6 Service commands-functions of the Control Interface

Service functions are an interface for accessing OpenSCADA from external systems through the Control Interface. This mechanism is the basis of all exchange within OpenSCADA, implemented through weak links and OpenSCADA's own exchange protocol.

Getting for values of all block attributes of the controller object
REQ: <get path="/DAQ/BlockCalc/{CNTR}/blk_{BLK}/%2fserv%2fattr" />

- CNTR, BLK — controller object and block in the block scheme.

RESP: <get path="/DAQ/BlockCalc/{CNTR}/blk_{BLK}/%2fserv%2fattr" rez="0">{attributes}</get>

- attributes — the block attributes in the tags "a": <a id="{ID}">{value}</a>
  - ID — identifier of the attribute;
  - value — value of the attribute.

    <get path="/DAQ/BlockCalc/CM101/blk_AT101_1/%2fserv%2fattr" rez="0" user="roman">
      <a id="Fi">50.3839725707191</a>
      <a id="Pi">10.2588208891757</a>
      <a id="Ti">331.149550201738</a>
      <a id="Si">0.071</a>
      <a id="li">10</a>
    </get>

Setting for values of list the block attributes of the controller object
REQ[root-DAQ]: <set path="/DAQ/BlockCalc/{CNTR}/blk_{BLK}/%2fserv%2fattr">{attributes}</set>

- CNTR, BLK — controller object and block in the block scheme;
- attributes — the block attributes in the tags "a": <a id="{ID}">{value}</a>
  - ID — identifier of the attribute;
  - value — value of the attribute.

    <set path="/DAQ/BlockCalc/CM101/blk_AT101_1/%2fserv%2fattr">
      <a id="Fi">50.3839725707191</a>
      <a id="Pi">10.2588208891757</a>
    </set>

## 7 Links

- Diagram: User object model of the module BlockCalc.

Modules/BlockCalc/en - GFDL | May 2026 | OpenSCADA 0.9.9