This story began in 2010. I myself automation engineer, engaged in the development and implementation of automatic process control systems (PCS). Basically, the work consists in the development of application software in dedicated software, the so-called SCADA-package. Enough for a long time worked in the company of the national developer of such a system, starting with the tester, went through technical support, has grown to the level of the head of the Department of system integration, the development of automation projects carried out under the key-based software company that develops. In the process of drafting, I found himself in the shoes of the end-user product, often had to refine the tools for specific tasks of a file, because as a functional or buggy, or did not reach the proper level. A debate with all the development and marketing of product development, or rested on the reluctance to do anything on the part of the development, or written off all that my hands curves and I do not understand anything in sausage scraps. Long so could not continue, and that one day our paths diverged with this company, I went to one of his major customers continue to do what they did in the same order, but in the state of the customer.

In their spare time, I helped people and friends from this area on their projects as an elective. Fortunately for many years in this field I have accumulated a lot of good contacts, and my reputation as a good engineer strengthened. Sometimes I even officially bought back the company for specific projects as a developer, consultant. My projects and work experience in the field of process control system can be found here.

Initially engaged in automation systems for dispatching of engineering systems of buildings in Moscow. Then, with the development of Internet technologies, the opportunity to develop projects for remote sites in other cities. Customer connected a dedicated secure communication channel with the object through the Internet, which made it possible to connect directly to an object and maintain the adjustment and fine-tuning of the project right from home. He continued to work on the same software as before, because the most suitable alternatives have not yet been observed, and have had very good experience of previous achievements and developments that did not want to just leave the transition to the new system.

While working on the project itself has modified SCADA their own patches, which allow a functional substitute for regular package because of its unsatisfactory performance or inability to implement certain requirements. During this revision system has become like a little kernel, which was hung with external tools and services like a Christmas tree toys. And now, looking at the result of abuse of the package began to creep seditious thought: as a matter of fact, why do we need a blacksmith? Besides a strong incentive it was also the fact that the company-developer of SCADA and continues its path of accumulation of bugs and glitches, releasing all the new releases, not doing normal testing and study of the product architecture. And as I was doing some development in my spare time, I was greatly sorry for the slain of their free time on the dismantling of bugs on a foreign system, which often lasted for half the night, and so for several nights in a row. Yes, and customers began to be indignant: what kind of money is paid, then a lot of mistakes comes out at start-up for the basic functionality, then this is the functionality really do not quite live up to the declared and something has to be a third-party plug or develop, although marketing tunes corrupt managers about the mega-power package for the customer are sung about were quite the opposite. As a result of the overflow of emotions over the edge sat me behind the wheel of a vacuum cleaner (ie a PC), and I decided to write my own SCADA!

Since it is primarily a tool for yourself, then do it, I decided not to as required by the advertising slogans, and as I see this tool as a developer of process control projects. As the basic system architecture was chosen architecture already known to me for many years of work SCADA package. Reinventing the wheel, I decided not to, and pay attention to its functionality.

It would have been great if not for one thing - I was not originally a programmer. What I wrote their own utility for the package - it was something like a third-party hobbies, hobby so to speak, for whom began studying .Net technology and the C # programming language. Before anything like a serious I did not do many of my knowledge in programming and some technologies have been at - somewhere heard or have seen how it works for someone. However - the eyes are afraid, but the hands are doing.

Most of my friends and colleagues learned about my idea, respond to it as one - turning the index finger to his temple. Of course, all the brands in this area makes the team of developers for years and years is to lick to get a little closer to perfection. But, in spite of such a reaction, I began to carry out his plan. And then there's the phrase where Genghis Khan heard something just became my motto: "If you're afraid - do not do, and if you do - do not be afraid!". Picking up the keyboard, I sat down to design his first major systems. Looking around the front to get a job, I began to be cushioned with books on programming in C #, as well as references to the thematic forums, which drew all the necessary information on the principles of implementation of various functions in the package. But more about this later and order.

 

Architecture


Before working I made some functional map pack for myself, from which the main elements of what is needed and knowledge (what technologies), to establish these elements. In general, the system loomed as follows:

In the center - the mathematical core, which performs conversion project structure consisting of a base variable, linked by logical connections. Also present in the project database and algorithms, which are also associated variables of the project. These algorithms creates a project developer, they perform control and monitoring of technological object through the variable base, which are connected with field (sensors and actuators) through the I/O subsystem by hardware (controllers, I / O boards, distributed data acquisition devices and management). To the operator (if the system is meant) everything is colorful and intuitive to demonstrate and give him the opportunity to manage the progress of the process provided subsystem of the graphic I/O, which is in the form of mimic diagrams shows the pre-designed screens technological system elements (graphics primitives , images, indicators, trends, collections of graphic objects that consist of full-time primitives) and various controls (buttons, sliders, field response to a mouse click, etc.). Since the system assumes the function of conducting the history of the course of the process - the parameters of the variables database must be able to be stored in some files, so that they can then be lifted on trends or reports on the technology situations and operational staff. Also in the same files must be stored on the logs events in the system - this is some text messages with certain categories (communication, prevention, accident, mistake, the action of the operator), marks the emergence of time, acknowledging their operational staff and the text that describes the essence of the event. All of these should be engaged in the subsystem data archiving and logging events. Since the control system design is often a multi-node system consisting of multiple operator sites, server nodes, on the lower level controller nodes, gateway machines, all this combined network by Ethernet technology and requires operational interaction in quasi-real time. To carry out such an interaction should subsystem network exchange. Here is a brief general architecture of the complex. We now turn specifically to the technology that will be required for the implementation of these subsystems:

 

Mathematical engine - here the emphasis should be placed on the development of object-oriented model of the design of the internal structure, consisting of some components (variables of the project), which are descendants of the base class with a specific set of features, interfaces and methods that implement data processing algorithms for variable in a quasi-real time (signal filtering, scaling, arbitrary user based on the processing algorithm developed program or a fixed functionality depending on the type of the variable). This comprehensive calculator core processing in the process of implementation of the project on the host workstation operator (Operator Workstation) or the controller is performed cyclically with a certain predetermined conversion cycle, which allows you to organize the logic of continuous progress in the executive module.

 

Algorithms - Historically, that the ptocess control automation engineer was not originally a programmer and knowledge of high-level languages ​​do not have a requirement for it. In addition the requirements for support and readability algorithms other developers have led to the fact that in this area there was an international standard (IEC61131.3) 5 languages ​​- three of them visual, two text. Many manufacturers of SCADA systems in addition to the standard also supports scripts - programming in high level languages ​​(eg VB), or the like (for example Ci-code, something C-like). My system was not an exception in this sense, but I'll explain in a separate article, which plans to devote his editor algorithms. Technologies that were drawn in the direction I was not pleased, because for the implementation of this task, you must: write your own editor (especially interesting was the task of creating an editor for visual programming language) compiler, as well as a calculator for the execution units, which would be carried out and counted algorithms in the project when the project starts in the continuous implementation of the facility operation. The prospect was drawn that still, even started stocking tons of literature on the subject and prepare for principles of compiler to overpower this work. But the details later.

 

Graphics engine - this subsystem meant a sufficiently large section of the work: to develop a vector editor for drawing screens. Moreover, the subsystem must be able to operate as a static image, and with the dynamization of individual elements of graphics, such as: dynamic change fill colors for the graphics primitive in execution mode, depending on the design parameter values ​​(indicators), the output variable values ​​on the screen operating personnel in the form of text and graphic forms. At the same time it should be:

  • Beautiful (very often on the beautiful interface biting final customer and makes his decision about its purchase).
  • Functional
  • Conveniently

 

At first, I thought to solve the issue by licensing ready-made library of graphics engines. I learned a new word for themselves in this regard: Canvas. However, having examined the question and comparing the cost and effort to license third-party funds has come to the conclusion that I want to or not, but I'll have to write my own vector graphics engine from scratch. At the same time the prospect pleased me very much that before just about the time I imagined how to draw a regular line of language functions on the screen and paint it the desired color. Yes, we had a little sweat, read thematic forums programmers, where, as it turned out, the question of the implementation of a vector editor to pop up the people all the time, and had a lot of developments and decisions, among which it was necessary to choose a convenient time for your destination. Oh, and incidentally it was also peruse a decent amount of literature on computer graphics programmers, now I even know what a GDI + and what it eats. Detailed implementation of graphic editor, I also plan to devote a separate article, which try to examine in detail what has been done and what came of it.

 

Data logging and events subsystem - this section was a serious stumbling block to the SCADA system, in which I had worked. There developer followed the path of reinventing the wheel and closed files for external funds, which automatically makes the system indigestible in many projects as needed to have access to archived data and also third-party tools. A bugs in the implementation made it a non-functional with a serious application in large projects. By the way, all this has led many users to opt out of the regular system backup. The main requirements for this subsystem in the first place were: its openness and easy access to information for analysis and generation of reporting forms of technological units of the system operating personnel. The most convenient solution to this problem - the use of a relational database. Many brands, incidentally, also go exactly this way, store historical data and logs it in a relational database. This is probably the only option subsystem with which I am to some extent indirectly have worked, because one of the patches for the SCADA before that I was doing just exactly subsystem collection and archiving of data and event logs from the SCADA to external relational databases. Following their current solutions, I have chosen as the basis of MySQL, as well as a provider of modern communications technology ADO.Net.

 

I/O subsystem to communicate with the devices - in this subsystem, the main issue is to maintain enough common open international standards of hardware protocols for automation manufacturers (example is ModBus protocol in all its implementations), and programming interfaces for communication with external software (here the primary role played by the OPC interface - OLE for Process Contol). On this subject also I paneer separate article, which will describe his vision of the implementation of support equipment in its software package, especially the implementation and what came of it.

 

Network subsystem for communication between a nodes of the project - due to the fact that not all automation projects are limited one single operator station and can consists of a plurality of nodes that require the data exchange mechanism between of them. And as the real-time data (operational) and archival (vector data with time stamps, sample arrays). This section of the system is still under development, so more information prepare and publish a little later, as soon as the main work on the development is completed.

 

What does this all happened at the moment... 

I began my work in this project from scratch in the literal and figurative sense, somewhere in April of 2010. I am worked in his spare time, mostly in the evenings. Almost turned garage-startup, because for one-room apartment occupied in the kitchen, where would sit sometimes until dawn, filling code and reading a literature. All the main components of the development took a little less than a year: in the fall I made the core of the visual editor algorithms, the Project Editor, the project has developed a model and project-storage file structure (all XML-based format). At the same time prescribed archiving subsystem, its main engine at the core of the runtime execution system. Under the new year began to a graphics editor. Praise the New Year holidays, there was a time to study the matter thoroughly and choose the right way. By early spring of 2011, I have almost finished graphics and spring refined mathematical engine support algorithms in pure C#. In early summer, I modified a bit subsystem on the support of the OPC interface I/O. Now I do network communications subsystem.

 

Here is some functional project statistics (in 2011):

  1. There are two tool system and runtime (execution units, under which runs the original project of automation in the facility), one for MS Windows (for workstations), the other under WinCE (controllers).
  2. Runtime under Windows and supports graphics and mathematics. Under WinCE - only mathematics, because the controller is the graphics are not particularly necessary.
  3. The system supports two programming languages: FBD and pure C#
  4. In the system itself in the kernel it has developed its own model of working with data - the system does not work with data types, it is woking with the concept of "object". It turned out a lot of interesting things in a cast at the level of functionality of the system: for example, a single arithmetic FBD-block addition, this technology can be put not only the number but also the strings, or even different types of data with each other
  5. Implemented the ability to work and processing system, dynamic arrays, and using its data model, they can be mixed and different types of functionality: local files and buffers for ESD systems and PAC! Possibility algorithmic processing of dynamic arrays of any data type. This in many SCADA packages is simply impossible in principle.
  6. All archiving and event logs fully relational databases - MySQL is
  7. Supports file save the system state between restarts runtime (dump). Dump format - XML
  8. Due to the fact that the project itself is stored in an open XML format, the system allows using common repositories lead the drafting group
  9. All import-export (screens, software project itself), even graphics libraries built on the XML format is completely open and can be used by the developer in its sole discretion to work with it or its third-party tools
  10. According to the schedule I have tried to get as close to the quality of modern systems, but do not be guided by a very clever graphics acceleration technology, which for the most part it is often not accelerated, but only aggravate and hinder it in practice, but that did not stop to make her beautiful. For example - a few examples of graphical displays:

Screenshot#1

 

Screenshot#2

 

Screenshot#3

 

Screenshot#4

 

Screenshot#5

 

Screenshot#6

 

Screenshot#7

 

Screenshot#8

 

 

But here the comparison examples of screens for the same projects in my system (left) and one of the brands (on the right):

 

Screen#1

 

Screen#2

 

 

Very large emphasis in the toolbox on the debug function of the project, therefore, supports the instrumentals:

  1. Online editing algorithms directly in the process of implementation of the project in the debugger.
  2. Online editing of graphical screens - also directly in the process of implementation of the project in the debugger.
  3. Online editing of the project structure - also in the process of its execution in the debugger (in general, a SCADA itself turned out as a single online environment for development).
  4. Integrated project corrector - is able to keep track of logical errors that might prevent a developer and point to them with autoposition on project components, where the error is found.
  5. Integrated circuit tester design - allows you to create self-testing scripts, also screen graphics self-testing, in order to verify its correctness.
  6. Built-in mechanism for the development of mathematical models on the basis of standard algorithms in the FBD or C #, which are connected to the descriptors of equipment and the project can be transferred to the debugging on the model instead of the real hardware. back and forth almost in one click.
  7. Built-in debugger in the development environment allows you to debug projects with distributed architecture as a whole in a single PC with simulated inter-node communications and the ability to access, monitor and change the hands of any system parameter in the debugging process.

 

Scrolling can be long and hard, so then brought the most basic and big "chips" ... With the rest of the system will be possible to meet in the process of interaction with me.
It is also possible to see a demo video showing the principles of operation of the system.

 

Online editing in the FBD algorithms in the process of debugging the project:

 

 

Online graphic editing in the process of debugging the project:

 

 

Demonstration of engine types for processing in real time (on the FBD programs):

 

 

Sample project to the algorithm on C # - demonstrated by the formation of a report in HTML-format:

 

 

An example of the automatic adjustment of the project:

 

 

An example of the development of a simple project. The plot is this: developed a simple design, wherein the controller module is connected with the I7017 by ICP-DAS, the first module is connected to the sensor input. The value of this sensor from the controller rises in the operator station. Demonstrates how to debug the project:

  1. First, the debugger just manually checked the work of the project, the sensor input value is set manually, then through the I/O debugger panel
  2. Then, within the project means staff created a mathematical model of the simulator in the FBD and is connected to the I/O
  3. Checking the work of the project with the simulator debugger. In the real-time simulator can be switched off or to connect with one mouse click
  4. Not stopping the debug process is edited by the mathematical model of the simulator, which we connected to the I/O
  5. Without stopping the process of debugging the project edit project parameters - initial processing of the signal in the form of a factor in the channel

 

 

 

And so on until the entire project schedules ... any distributed architecture, even without the presence of iron, creating a model simulators directly in the project and their linkuya on I/O create, edit, and debug the entire project on a single PC.
Fast duplication of developments in the schedule with a comfortable rebinding dynamized properties in the copied group graphic elements. That is - the developer does not have to manually go through all the new properties in the copied group, to bind it to the new arguments for the dynamic modification of the new instance - the system will automatically scan the group and makes a list of bindings, which already DnD operation developer quickly reassigns binding.

 

 

 

When working with the graphics system provides developers with a convenient grouping mechanism and access to the components of the screen without disturbing the integrity of the group.
Features Drag-n-Drop while moving graphic elements between the two groups, moving pieces in the library. Import and export libraries in external files in an open XML format for sharing with other developers or save for future use developments.
Select items across the screen with the list of elements, or the list itself - allows access to individual properties of any graphics component without disrupting the overall hierarchy.

 

 

 

An example of the symbiosis of the two languages within a single algorithm program: FBD + C#.
Particular attention should be paid that the C# code can also be modified without stopping the calculation program as FBD in real time. Very useful for debugging logic.

 

 

 

Vector graphics animation: moving on key points. The numerical parameter.

 

 

 

String Value.

 

 

 

Developing your own visual tools for graphs: the pointer device.

 

 

 

Histograms.

 

 

 

An example of using the library of graphic resources for rapid development of graphics.
Feature editor is that it "remembers" which features graphic primitives are dynamized in the development of this item before putting it in the graphics library. When a developer inserts it into the screen from the library system scans the item, and is a single list of dynamization. On this list, you can bind any dynamization drag-n-drop an existing or to the argument of the screen, or as a drag-n-drop dynamization simply create a new argument and the system will tie it at all dynamizing object machine, where he participated. With this operation the developer can choose the assignment mode is the name of a new argument - a good name, as it has been in the development of this item at the beginning, or with the modifier name of the object on the screen, how to ask the developer (actually, if such elements planned several for different screen implementations).

 

 

 

Below is an example of how easily and quickly in the draft standard means you can create a mathematical model of the object to debug the project. The model can be developed as the project algorithm, this algorithm is bound to the input-output device in the project, replacing the logic real input-output, if set simulation flag on the device. Besides I/O points in the algorithm can also be simulated to link any of the design parameters as read and write. Thus, you can create quite complex and intelligent simulation models, which can be controlled even with the operator interface. Changing the mode of operation in the project through the I/O model or through a real piece of metal (interface) is done in one click. Project imitators, being loaded into the executive runtime, can run on these simulators without any real hardware, fully imitating the operation of the system on the developer's algorithms. Moreover - even within the development environment in the Debugger project has the support of simulators design, which can be controlled even in the online project execution in the Debugger: set imitation flag on the I/O and see how to debug a project working on the model, remove the simulation flag and work with any of the input-output points of the project in the manual setting mode in the Debugger.

 

 

 

The system provides the opportunity to work with dynamic arrays of any data type. And they allowed transmission and reception program for algorithmic processing. With dynamic arrays of channels you can create local archives in the workstations and controllers, arrays themselves can be saved at any time into separate CSV file, XML, or DAT. In addition they can be transmitted over the grid and stored in the archives. Enough opportunities for use. One of array modes of operation may be packing or unpacking arguments: for example, the data from this channel arguments are packaged into an array and passed to the program, it is processed, and the result is again delivered by an array through a single program argument back to the dynamic array channel, which unpacks it again in arguments. If the argument is binding - the data is collected or distributed attribute node channels, where the channel is created. All this is done in 1 beat. That is now working with the project team data can be easily and without much fuss.

 

 

The developer tools include built-in automatic tester project. This service allows developers to create audit logs that contain lists of actions to be carried out. Every action - it is in fact sending a certain value in the component of the system, then the developer checks the result of this action as a certain value in a certain component of the system. As usual in other SCADA systems, this process is always performed manually, the developer repeatedly runs the manual values ​​for system components and verify the results of the work of logic processing channel flow values ​​and other things. This service allows it to automate this process to run such an operation was carried out in the debugger automatic latching the result in the form of a report. Each audit log is created in the project are stored within the project, and if I as a developer of a portion of the project, release the project to another developer in the group (or development process is carried out in parallel with the team work on the project), I am interested in getting my logical developments within the project have not been damaged as a result of project modifications. With the help of the project log, I can at any time run AutoCheck and in seconds make sure that the created logical chain is efficient and does not contain logical errors. If any of the operations during its execution verification log does not match the result of me - it is immediately highlighted in the report list and HTML red. And on it I have specifically to do analysis of the situation, and why there is a discrepancy in the project.

 

 

In addition to direct interaction with any attribute argument or logical structure of the project allows the automatic tester for graphical part of the project in real time. It also creates audit logs, which the developer sets the coordinates of the mouse click on a particular screen operator interface in the project. A screen arguments immediately possible to control the result of such an operation. Well then perform operational checks graphics without routine all graphical controls in the interface of the operator after the global modifications.

 

 

Connecting to the OPC server. When connected, you can select the OPC server from the list, consider the structure of the group tree, and then bind to the OPC tags that tree. It works with any type of data, even the string types.

 

 

Furthermore - many OPC server allows the scalar value types do not pass, and the vector, not to be confused with the HDA-mode (similar, but not that). With this OPC server exchange issues or accepts an array of a particular data type (float, int, etc.). Since my SCADA support dynamic array as native type, it can work directly with such data - receive a data vector OPC server can be further processed or decompress algorithms to individual array elements. Below is an example of such a connection - creates a connection to the OPC server, select the tag, which is an array Float'ov, linkuem it on a dynamic array channel, we ask him to unpack mode, and in runtime in real time to the arguments of the channel get the result in the form of decompressed values the resulting vector from the OPC.

 

 

Demonstration of scaling screen image without losing quality vector coordinates and sizes. Very long before I had redrawn from one object to another project under the equipment that was purchased every time new monitors and different from the regular approval, which are dictated by the customer. Implemented in their system to zoom in the screen as a whole, and individual groups of graphic elements. The developer can adjust the image by setting the coefficient for any resolution. When this stretching and compression algorithm also takes into account the sizes of fonts for inscriptions, and moreover the compressive and tensile is no loss of image quality due to loss of arithmetic transformations of vector coordinates.

 

 

Reading data samples from the archives. As an archive can be any archival database table data, in which the material preservation of archive information - it can be both numeric data and event logs to text information.The example demonstrates the creation and launch of the project, in which one of the sinusoidal signal channel is stored in the archive. The project created a channel of a dynamic array in a mode of taking the sample from the archive of that table, which is stored sine wave. For the analysis of the sample - sampling performed unpacking adopted on individual values ​​in the arguments, which are then displayed on the screen in the form of histograms. At the end of the development project is launched in the executive module for debugging, which demonstrates the ability to separate work screen, the list of the loaded assembly, and attributes of any of the channels of the channel.Also I draw your attention to the functional development of the graphical display: a fast replicating cells and their rapid binding to dinamiziruemym parameters.

Working with the sample can be on a separate channel or even all of the data in the archive table. When you run the sample, you can set the start and (or) end timestamp sampling range. Or ask your full text query condition in the syntax of SQL-language.When the sample from the archive workflow runtime is not interrupted, because sampling is performed in a separate thread, allowing for the processing of very, very large data sets are not hindering the process of implementing the basic objectives of the project. On completion of sampling attributes channel statistics are displayed on it: the sampling time in microseconds, and the number of entries in it.Each sample - this is not just an array of values, and this is 4 array: values, time stamp, attribute flags mask. This information is maintained for each record in the archive, and also returned when the sample in a single channel dynamic array.Also graphics data array, it can be transmitted in algorithms and produce them with calculation operations.Easy and simple work with archived information without unnecessary puzzles and obstacles for setting up and processing directly inside the project by regular means!

 

In summary

With this article I would like to open a small series of articles in its development, to share with the people of his personal experience of studying the fundamentals and principles of programming, .Net technology and related technologies, of which there were many during the operation of the system. In general - in fact, show that it is often not so devil as he is painted. Perhaps to find like-minded people who want to take part in the development, testing of the package on the case or to make proposals to its own considerations about the functional or operating principles.In general - I hope that the information will be useful and interesting, and this series of articles will find their readers.Waiting for your comments and questions!