📜 ⬆️ ⬇️

How I made a project in OpenSCADA

image

The article will focus on the very OpenSCADA, which is under Linux and with oscada.org .

What for:
• because SCADA is really worthy of attention and popularization;
• in some low-budget or small projects it is simply not alternative;
• judging by the articles about the process control system on the Habré, many readers of the process control system seem to be black magic, under-IT or something similar (they break the unfortunate modbus, torture WinCC, which is already so hard ... People read and groan: "How can you .... holey Software in industry ", but no one is surprised at breaking Win95 and the 6th donkey. LON would have broken encrypted, OPC, OPC_UA ... ... And WinCC itself shares a folder with a project with the name of the type WinCC_Project_xxxxxx when you first open it + you have not yet seen how its plug-in to Excel it can tightly hang the Windows when inaccurately inserting cells a little more than it can az to overpower!) - add educational program;


How do you like that?
')

What is it?


Hindus do not like to handle mistakes at all ... Why, and that-a-ak will do ...

In general, the only ones who work in Siemens are MANAGERS. They need to erect a monument in their lifetime. With such managers, programmers can not strain.

• Habr benefits me (in terms of information) - I will bring Habra and me;
• get rid of read-only to participate in the comments.

For whom:
• for those who have not heard about openSCADA and indeed about OpenSource SCADA under Linux, but are interested in similar ones;
• for those who have heard, but did not have time to try, in order to understand whether it is necessary;
• for those who opened - looked - did not understand - closed;

Why openSCADA:
• this project required savings;
• TK did not force to use something specific;
• in this case, you can use communication with a PLC via Modbus (for example, if you wanted to send alarms with a time stamp to the PLC, then alas ...).

Given:
• a couple of generators and a half megawatts;
• operator's seat to manage all of this;
• B & R PLC, communication with SCADA via ModbusTCP.

What you need:
• monitoring the status of components and assemblies;
• control units and aggregates;
• recording of emergency and warning events (alarms);
• archiving of events;
• archiving of parameter values.

I must say that its author quite competently approached the task (he even got his second degree as a programmer, the first - an electronics engineer). Uses CPP, Qt, svn, etc. Those. You can download and compile the latest version without waiting for the release. Separately, it is necessary to say about feedback on bugs. Noticed the bug? Write on the forum in the section “Error tracking” and, voila, it is fixed. Specific examples: from 40 minutes to 4 hours, and there was a case after 12 at night. You can fix it yourself and Roma will add. Now tell me, which of the giants of production, at least industrial software, does at least an order of magnitude longer? For example, MS for MS Project ....... M?

Not enough documentation on the wiki? Come on wiki under your forum nickname and complement.

It seems that each entry about a bug is perceived as almost a personal insult, and if your arguments are iron and the bug is in his program, not in your DNA, then he corrects and each sentence ends with an exclamation mark.



At first glance, openSCADA has a high entry threshold and the developer himself says that your previous experience with SCADA is hardly useful, but only at first glance. Everything is incomprehensible, incomprehensibly called, incomprehensible how this works. The documentation is not very structured. An example - a search result on a site is replete with the phrases “parameter attribute argument”:



Therefore, there is a demo project - AGLKS. C it should start. Create your own, unzip the components, look at how this or that feature is implemented. I did just that: left the root page and the way to navigate through the pages.

image
An example of an explanation of the concept of interaction of the viscera

Components of openSCADA:
QTCfg - QT configurator (data collection, calculations, archives);



Vision - a graphical user interface ("pictures");



QTCfg - DB




The basis of this SCADA is the database, i.e. All projects are stored in the database. Maybe this is good, but for a simple "copy the project from the folder X to the USB flash drive" or "copy the valve from one project to another" is not trivial. In the case of a SQLite database, the entire database is a file and it is not difficult to copy from a folder to a USB flash drive. And for PostgeSQL? With copying a graphic element from one project to another task. Although no one bothers to keep the library of something in a separate database and simply connect the necessary instance to your project. All tables of all databases can be viewed and there is an SQL query input field, so that you can stick together queries in a spreadsheet editor and inject something into your project in large quantities instead of endless poking with the mouse.

QTCfg - Controller




In data collection, setting up communication with our B & R PLC is simple: how often to poll, the modbus protocol (TCP / IP, RTU, ASCII), the address transports, the modbus address of our B & R PLC, and so on. It is worth noting especially the setting “Maximum parameter of the request block” - this is how many registers to request from our PLC at a time. Some devices simply do not respond if you request more than a certain amount. For example, the EK-270 gas corrector, the PCC3300 control panel in Cummins engines, is “suffering”.

The status is quite informative, especially in case of communication problems - there is text and an error code that can be easily processed in scripts.

QTCfg - output MBTCP transport




Setting up communication with the PLC - how? There are transports and there are transport protocols. Where? In the transports there are Sockets, in the Sockets Output and Input Transport. ModbusTCP seems to be through sockets, but in Transport protocols there is Modbus.
Setting up communication with the PLC is located in Transports - Sockets - Output Transport - MyMyOneTransport a. For modbusTCP, the configuration looks straightforward. Tooltip helps.

In the Status we see the current status, especially important when debugging, diagnostics.

QTCfg - Modbus - Diagnostics




To collect data from our PLC, B & R created a controller in the ModBUS section. In Runtime on the tab "Diagnostics" we observe the exchange of packages. If the PLC does not respond, we immediately see the reason.

QTCfg - User Protocol




The user protocol is generally an openSCADA mega-feature, which opens doors to it a lot where. In this module you can describe your protocol, which is absent in openSCADA. For example, the very same modbus-like 32-bit registers, etc. The picture shows an example of the protocol for the heat meter VKT-7 from Teplokom. So you can do your own modbus-like protocol with 64-bit registers, time stamps and encryption in PLC and implement its reception in openSCADA.

Moreover, you can implement your C ++ protocol as * .so and connect it as a module to Data Collection when building openSCADA. For an example, you can take the SNMP module.

We want to form our own alarm mechanism just as a module in Data Collection , and inside use not an array (which is not convenient for sorting), but SQLite with work in RAM instead of files.

QTCfg - JavaLikeCalc




All user-defined functions are implemented in the Data Collection section — JavaLikeCalc — Library — Your Library . The call of its functions is very clumsy: SYS.DAQ.JavaLikeCalc ["lib_MyLib"] ["MyFunc"] , the prefix "lib_" in the name of the library "MyLib" is required. There are two variants of calling functions: statically setting the name of the function in the code or dynamically composing the name in the code.

Debugging your own functions through the analogue of printf () - just write to the Archive what you need. No “step by step or breakpoint”. Syntax highlighting is. Auto-declaration of variables when first used - be careful with ochepyatkami - will create a new variable and go. In each function there is a this object - a link to the function itself, for example, in the script you can refer to the attributes of the function in a loop, etc. There is also the f_start flag - the flag of the first execution of the function, it is convenient to thrust initialization or something like that one-time.

QTCfg - An example of a custom function prioritets in JavaLikeCalc




An example of creating a custom function. Language - JavaLikeCalc (he is the only one). Input / output function variables are described in table IO. The order matters: 1 line = 1 variable when calling a function. You can swap lines in IO.

There are several ways to access tags. In openSCADA, the same can be done in at least two ways. The access to the tag (attribute in terms of openSCADA) in the code can be done as follows SYS.DAQ ["JavaLikeCalc"] [LocalPLC] [Local_Param] ["myTag"] get () , where " JavaLikeCalc " is a statically defined data collection module, " LocalPLC "- the name of the controller in the Data Collector , specified via a variable," myTag "- the statically specified tag name, get () - the function of requesting the tag value.

In JavaLikeCalc, the syntax for using inline functions is: strMyTag.StrToInt ()? where StrToInt () is the function of converting text into an integer, strMyTag is our text variable. This feature of using embedded functions syntax led to the fact that in Vision access to object properties is not done through a dot (MyObject.property1), but through underscore (MyObject_property1), which significantly reduces readability, since “_” in tag names is used instead of a space .
Another example syntax: this ["pgCont"]. AttrSet ("geomY", soOff) .attrSet ("geomH", this ["pgCont"]. Attr ("geomH") + soSize)

QTCfg - execute function




The “Execute” tab allows you to check your function without departing from the cash register. Plus will show the time spent on the function.

QTCfg - calling a third-party JavaLikeCalc application (using the example of my play_warn function)




To sound the alarms, we had to write a function with a call to the console player of sound files. They created a controller, which was assigned the function of monitoring active alarms and playing the corresponding sound.

QTCfg - SETS




For “local” tags, we use the controller in the JavaLikeCalc section. The controller was called “LocVars”, in it they created a group of actions, calibrs, sets (“parameters” in terms of openSCADA). These parameters are useful and used by chance. Associated with them is a convenient mechanism for linking graphics to tags in the Vision graphic editor. We will come back to this. In the field "Data Fields" we write the names of our "local" tags. These tags retain their values ​​after restarting the computer.

QTCfg - SETS values




The values ​​of our "local" tags can be viewed and set on the "Attributes" tab. In this case, “sets” is just a logical group of tags, and the tags themselves in terms of openSCADA are attributes. What kind of SCADA allows this in as simple a form?

QTCfg - actions




We need local tags for our own needs in SCADA. I had to create a controller and assign it a function. The trick is that the attribute values ​​(which are analogs of classic tags) are saved when the computer is restarted.

QTCfg - parameter G1




The parameter is a logical unit with a set of tags. We have division by nodes and aggregates. “Enabled” - whether it is currently being processed, “Enable” - whether to enable SCADA at startup.

The configuration of tags and addresses in the case of Modbus is just a song - it is just text that is easily glued together in a tabular editor, easily corrected in openSCADA. For example, according to the project you have tags read-only, you have them in registers 30xxx. In openSCADA, it looks like RI_b15: 101: rw: TagName: TagComment . In this case, on the Attributes tab, you will not be able to set tag values, although you have specified rw. A flick of the wrist in any notebook replacing RI_ with R_ and you already have registers 40xxx. In this case, you can set values ​​for tags on the Attributes tab, which is much more convenient than calculating a bit in a word and climbing in a modbus simulator and setting it in decimal form. If the register is 40xxx, but rw , then you cannot set values ​​on the Attributes tab. RI_b15: 101 is 15 bits in the 30101 modbus register.

QTCfg - parameter G1 - values




In Runtime, it's very easy to see the current tag values. Open the "Attributes" tab of the required parameter of the controller and observe, if the register is 40xxx and "rw", then we control - for debugging it is irreplaceable. Try to repeat this in WinCC or Citect .... Although in WinCC you can see the value of the tag by hovering the mouse over it.

QTCfg - parameter G1 - archiving values




Configuration archiving tag - put a check on the tab "Archiving". Any tag can be archived simultaneously in different archives.
What is important: the information in the archive is compressed (and not just a million lines of the timestamp | tagName | tagValue type).

File structure:

image

The mechanism of sequential packaging of values:
image

There are still a lot of subtleties like “hard grid” and “high resolution time” ...

QTCfg - archive of messages




Configuring the archive of messages: we will store in the database, with the category “LOG” (the category in this case is just a prefix for filtering our messages from the system ones), the size of the archive in hours.

QTCfg - archive of messages - messages




View your messages in your archive - the "Messages" tab of our respective archive.

Archive of messages - a folder and a file




Archive of messages - text files (quite readable). Old files are rolled up by the gzip archiver according to the message archiving settings.

QTCfg - Trend Archive




We configure trends: we store on the file system (Roma's recommendation), how often to read values, how often to write to the archive, the path for the archive files, the archive size in hours, etc.

QTCfg - Trend Archive - Values




You can view the values ​​of the archive of values ​​right there on the “Archives” tab. It is possible to export to a * .CSV or * .WAV file.

QTCfg - Trend Archive - Graph




The trend archive on the chart without departing from the cash register is not a question. The size of the image graph can be changed.

QTCfg - alarm configuration




Since in openSCADA there are no alarms in the classic understanding of SCADA systems (instead of them Roma came up with violations - some kind of abstraction doesn’t understand what, the level of violations is set by the programmer of the project at the time the violation is formed and doesn’t mean anything). We created a separate controller on JavaLikeCalc and asked it to monitor the values ​​of the necessary tags for alarms and generate a list of active alarms.

QTCfg - violations




The built-in mechanism of “speaking” violations (violations in openSCADA is a kind of abstraction in the direction of alarms). From here, they took the command to play the files for their own alarms sounding mechanism.

QTCfg - speech synthesis




It should be noted: the built-in mechanism of "alarms" openSCADA allows you to pronounce the text of the message with the tts engine. Install tts with the Russian language - the built-in "alarms" (ie, violations) will speak in Russian.




Vision-development




Go to the chart. To do this, use the "second half" openSCADA - Vision.

QTCfg - Vision




Configuring Vision from QTCfg: we ask with which user Vision will open in development and in Runtime a graphical user interface, which project to run in Runtime.

Vision-development - widgets




A widget is a graphic unit (valve, valve, generator, input box, and even a whole page).

Tab Widgets - here are all the widgets collected in the library. This is a kind of common base for storing graphic units.
It is possible to insert other widgets dynamically in Runtime into one widget page. Analog WinCC shnyh PictureWindow. To do this, you need to put a widget on the page and set the “container” property to it and give the group property some name. The inserted widget must have the same group.

In this way, the operator interface is formed, where there is a constant menu and alarm area and dynamically changing mnemonic diagrams.

Vision-development - projects




But on the Project tab, we already collect the skeleton of the graphic part of our project from instances of library widgets (we type the pages and determine the navigation through them). In the Project, we can set personal properties of library widgets — for example, the widget “window with data from a digital multimeter” —we create 5 windows for five high-voltage cells and link them to the tags of the corresponding cells.

Vision-development - group change of properties




A very convenient option: group change of properties of several objects - selected objects and immediately assigned to all.

Vision-development - text - arguments




The standard “Text” graphic element has a very useful feature - arguments.

Thus, one Text element allows you to implement a complete formatted element of the mnemonic diagram of the form “P = 32, kW”, where “P” is the parameter designation, “32” is its value (tag value), and “kW” are units of measurement. Those. dynamically binds only the value of the tag, the rest is already there. The format is simple: “P =% 1, kW” (instead of% 1 there will be a tag value).

Vision-development - drawing shapes




That's drawing is not very. Drawing geometric shapes is possible only in a certain container of type Box. As you can see in the picture in the List of line items field, the text is presented as line (15.359 | 0.505) :( 15.359 | 22.915) ::::::::::: . Try to guess who is where ... But not so sad. As you can see in the picture below the file menu there are buttons for drawing straight lines, Bezier curves, circles. And what is sad? For example, a circle is defined by five points, and not by a familiar rectangle / square.



By changing the coordinates of any of the five points, the other thing is to get the hell out of what's needed. Fill color is possible only for a closed loop, i.e. the usual bar filled with color from 0% to 100% is realized by a “rectangle” contour plus a “stick-cross”, which divides our rectangle into two halves. Fill set for one half of our rectangle. In parallel, we move the “stick-crossbar”, changing the ratio of the areas of the halves - the fill area also changes. Those. make a circle fill - that is another task. In short, you have to adapt to draw, and sometimes izgolsya. But in Citect with this kind of fill no problems.


Sample fill in Citect

To draw a similar task in openSCADA.

Library widget - sets - processing




Here we come to the most interesting - linking graphics on the page (and indeed on any widget) with tags (attributes in terms of openSCADA). To open the above window, you need to give focus to our widget and press the button with a wrench . JavaLikeCalc , , , , . ( = ), «».

: vcaAttrGet(strParsePath(path,0)+"/pg_control/pg_ElCadr/a_pgOpen") .
: this — this.nodeList(«pg_» ) .
«» .

« » – , . «|», – . (, G1), . 100 , . .
, , .

— general –




, (SYS.DAQ.xxx ), . :

— , , ;
— ;
— ;
— ( ).

- .

— sets —




(, PU_set_G1) . , wdg:… .

this




this .

— vcaAttrGet




vcaAttrGet .

— /




Runtime . (, ) .

Vision — —




«» - HTML. « : » , // . .

Trends




99 ( Wonderware 8 ).
. -, . , ( ) . Citect, , openSCADA . . ++/Qt openSCADA .


, , .


« »

.







, .



:



.



(*.png, *.xpm,*.jpg).
.

. web- (*.html, web- ) (*.csv, MS Excel ). openSCADA — . HTML CSS.



: openSCADA — .

UPD1


, ( ) , ( ). , «» . , , . - /? WinCC — , Citect : - ?1? ?5?, Citect — WinAss(-2,5,«DU_PID_kP_valve1»,0), 5 — ?5? DU_PID_kP_valve1. Citect 255 , - « » () CiCode Editor . - RSView32 - — , , .

openSCADA : , , (.. )
<page>|DU_PID_kP
— « , » — !

Source: https://habr.com/ru/post/238537/


All Articles