Graphical Versus Traditional Programming
Our teams develop full-stack control systems using the usual programming languages in the domain, such as VHDL, C++, C# and Java, but we also leverage the unique capabilities of LabVIEW.
The latter is a system-design tool and development environment for visual programming from NI. The environment has a graphical language and runs on Microsoft Windows, Unix, Linux, and macOS. Engineers typically use LabVIEW for instrument control, data acquisition, and industrial automation. Specific customers that rely heavily on NI hardware, for example, in the accelerator community, stipulate the use of LabVIEW for their device and systems integrating, so we comply — and in other cases may even advise it ourselves. In some instances, whole accelerator control systems are built with LabVIEW.
Relatively simple basic visual programming concepts of LabVIEW allows non-programmers to build programs by dragging and dropping virtual representations of simple laboratory devices. Advanced LabVIEW shops, however, employ more demanding LabVIEW programming for creating larger, distributed and self-sufficient applications using LabVIEW object-oriented programming (LVOOP) and other more complex programming concepts.
A Typical Cosylab Accelerator Control System
We usually design accelerator control systems with a three-tier architecture:
- Presentation tier – presents and handles user interaction;
- Service tier – is composed of services, such as alarm handling, archiving;
- Equipment tier – integrates devices and subsystems (in our example, based on LabVIEW);
The Equipment tier is comprised of a set of distributed services responsible for the integration of devices and subsystems. It takes care of both business logic as well as the communication of disparate subsystems and devices.
The Old Way of Creating God Classes
We typically observe in our integration projects, also where we use LabVIEW, that we can continually improve, refactor and optimise our development approach, replacing past practice.
In the past, we would usually create one big (god) class per device/subsystem type, whose methods represent values in the system (data points), such as set_voltage, set_acceleration, get_voltage, get_alarm, clear_alarm.
For example, as seen by the operator, the voltage must be limited to a range, multiplied by a factor, and added an offset before it is written to a register on the device.
In this case, we need additional parameters or class properties — or the original methods need extra parameters, for example, set_max_voltage, set_min_voltage, set_acceleration_scale …
The list can get long, and a lot of parameters require more or less similar processing.
Since some subsystems/devices possess many control parameters, even more than a hundred, such required functionality results in plenty of almost duplicated coding, which is prone to errors and lowers the maintainability.
The New Solution: Device Parameters as Objects
Even in LabVIEW we can use object oriented concepts as in other traditional programming languages to avoid this mostly duplicated coding. Let’s think of device parameters as objects, identify types of variables on the control system and preparing a class for each of them! One of the simplest and most commonly used is the real value:
class Double() {
write(double)
double get()
set_max(double)
set_min(double)
set_scale(double)
set_offset(double)
}
Leave a Reply
Want to join the discussion?Feel free to contribute!