You are on page 1of 5

2017 2nd International Conference for Convergence in Technology (I2CT)

Scripting Engine for SCADA HMI


1
MRUNALI TANDEL, 2UDAY JOSHI, 3AMIT GOLHANI

Mrunali Tandel Uday Joshi


Department of Computer Engineering Department of Computer Engineering
K J Somaiya College of Engineering K J Somaiya College of Engineering
Mumbai, India Mumbai, India
mrunali.t@somaiya.edu udayjoshi@somaiya.edu

Amit Golhani
Power Electronics and Technology Center (PEATC)
Larsen & Toubro Electrical and Automation
Navi Mumbai, India
Amit.Golhani@lntebg.com

Abstract— Conventionally, the modules of SCADA system


such as Message broker, Human Machine Interface (HMI)
Building Environment, Database Manager and drivers including
the SCADA HMI are developed in compiler-based languages
such as C/C++. Thus, the person who develops the SCADA HMI
has to be well versed with that language whose learning curve is
steep. Every time the user has to rely on the SCADA engineer to
Figure 1 Block Diagram of SCADA
develop the SCADA HMI for them. Customization of SCADA
HMI is a difficult task, as all the classes and the pointers in the
language has to be managed by the SCADA Engineer, thus, From the development of SCADA system to its usage
increasing the time to market. Scripting Engine module with in industry, there are three roles assigned to a person
combination of Qt technology is introduced in this study, which associated with the SCADA. The first role is SCADA
enables the SCADA Engineer to develop SCADA HMI using easy Developer, who develops the core logic of data processing and
to use scripting language, balancing the time required for mechanism of control and communication. The second role is
development as well as meeting the performance standards. As of SCADA Engineer, who develops the SCADA HMI for the
scripting languages are believed to be easily adoptable by the user, according to the needs and requirement of SCADA
non-programmer, the person with the non-programming
system at the user-side and the purpose for which it is used.
background can easily setup the SCADA screens. The
comparative analysis of the Scripting Engine approach and The third role is of SCADA Operator, who monitors and
conventional approach is also presented in this study. controls the processes; acknowledge alerts and events on the
remote devices using the HMI developed by SCADA
Keywords— SCADA, Human Machine Interface (HMI), Engineer. The SCADA HMI is easy to use because of the
Database Manager, compiler-based language, scripting language. efforts put in by the SCADA Engineers, who write the display
logic behind the SCADA HMI using the core libraries
I. INTRODUCTION developed by the SCADA Developer.
Supervisory Control and Data Acquisition (SCADA)
system is an industrial software used for monitoring and In the conventional approach of SCADA development,
controlling processes remotely, mostly used in utility and the entire thing ie. Core libraries and display logic is
developed entirely using compiler-based programming
manufacturing industry for monitoring processes, alarms and
events [6]. The typical SCADA system consists of languages like C/C++. Generally, the compiler-based
languages are difficult to master in. But they provide the best
components such as Human-Machine Interface (HMI),
performance for the developed application and thus are
SCADA Server, Driver, PLC and actual on-field device to be
monitored as shown in Figure 1 below: considered as first choice for real-time application
development like SCADA. Another alternative is to develop
the application using an interpreter-based scripting language.
Scripting languages are easy to adopt and use. But the
applications developed using scripting language are not

978-1-5090-4307-1/17/$31.00 ©2017 IEEE 492


performance efficient compared to those developed using integrated with the each SCADA UI objects. The Scripting
compiler-based languages. In order to make the SCADA Engine is responsible for interacting with the core libraries
development approach easy and performance efficient, the which manages the interaction with field devices using
concept of Scripting Engine is introduced in SCADA drivers. Thus, the events are managed to-and-fro the HMI
development. module using Scripting Engine. It is also responsible for
fetching the records from Historical Database, which can be
The Scripting Engine is a tool/component or library provided to the other modules of HMI such as Report &
introduced in SCADA suite, which is able to load script, Trends generating modules. In addition to this, the scripting
interpret at runtime, execute it and fetch the result to the engine also provides communication facility where, the status
SCADA HMI. The Scripting Engine is integrated with the of the SCADA can be reported to the remote user. Thus, it
SCADA HMI Builder, which can be used by the SCADA automates the remote communication process easily.
Engineer to develop the SCADA HMI. The main aim of its
introduction in SCADA development is to make the task of The mechanism behind Scripting Engine is as shown in
SCADA Engineer much easier with easy to use small script as Figure 3 below:
well as developing application with almost same performance
efficiency compared to the application developed entirely in
C++. Thus, its introduction in SCADA reduces the
dependency on C/C++ proficient SCADA Engineer. Along
with this, it will enable the easy customization of application
according to the industrial requirements and automation of the
repetitive tasks.

The mechanism of Scripting Engine is to handle the


performance critical tasks at core library level, which is
developed using compiler-based language like C/C++ and
providing the provision for SCADA Engineer to access the
core libraries using scripting language [7]. Thus, the SCADA
Engineer can develop the SCADA HMI using script without
hampering the overall performance. The provision is given to Figure 3 Mechanism of Scripting Engine
write the display logic using scripting language.
In Figure 3, Scripting Engine is placed between
II. DETAILS EXPERIMENTAL middleware module and HMI screen. On arrival of an event
(e.g. Alarming condition), the event is passed by Middleware
A. Module Structure Broker to the Scripting Engine. The event is handled by the
The placement of the implemented Scripting Engine in GUI module and it is further passed to the library. An
the SCADA system is as shown below in Figure 2. appropriate function is selected by library and interpreted by
command interpreter. Once, the command is interpreted i.e. it
is decided what should be displayed on the screen (eg. Red
color display for alarming condition), the control is send back
to the GUI Module and once the properties are set, the GUI
component is rendered on the HMI screen.
B. Languages and Technology
The following are the languages and technology used
for the experimental setup of Scripting Engine for SCADA:
• Qt Framework, which is a cross-platform application
and user-interface development framework, is used to
develop development environment for SCADA
Engineer, HMI Builder, which is integrated with
Scripting Engine [8].
• Based on the previous work done of literature survey,
Figure 2 Scripting Engine in SCADA System
Python scripting language is used for Scripting
Engine for SCADA and appropriate Python binding
The Scripting Engine for SCADA is integrated with for Qt is used. Thus, the SCADA Engineer is given
SCADA HMI Builder which is the development environment the provision to develop SCADA HMI using Python
provided for SCADA Engineers. The SCADA Engineer can scripts [4].
use the Engine using the script and the Script Editor is

493
• The core-libraries, where performance critical task, III. RESULT AND DISCUSSION
communication and control mechanism is As the approach of Scripting Engine for SCADA
implemented, are developed using compiler-based development resolves around using scripts for UI
C/C++ language. development, unlike conventional approach, the ease of the
• SQL Server is used for historical database storage. development of UI is enhanced and dependency on the
• SMTP protocol is used for remote notification of proficient C/C++ programmer is reduced. In order to compare
SCADA status. the conventional approach with Scripting Engine approach for
SCADA development, SCADA HMI screens are developed
C. Functionality Provided using both approaches with no functional difference.
The following essential functions are implemented for Following are the observations noted when Scripting Engine
Scripting Engine of SCADA that can be used by SCADA approach for SCADA development is compared with the
Engineer for SCADA HMI development based on which conventional approach:
evaluation is done.
• Database Functions: A. Standard Python Library extension
The Database Function for SCADA includes function The standard python library includes String, Math, Time
for retrieving historical data from historical database, and File handling functions that can be used by SCADA user
which can be used for reporting, getting object (device) for SCADA development. Apart from that, this standard
and tag details (both system and user-created) from online library functions are extended in the Scripting Engine
database. The SCADA Engineer can use it to display the considering the requirements of the SCADA and its users.
data on SCADA HMI using easy to use python script.
B. Auomated Database Connection management
• Tag Functions: For retrieving the historical data or alarm data using
This includes the set of functions mostly used for the conventional approach, the users have to explicitly open
control and monitoring of remote field devices. It includes the connection, generate the query for retrieving the data from
the function for getting and setting on field device’s tag the server and should close the connection, upon receiving the
values as well as monitoring the live status of devices. data. The user will also have to deal with complex datatypes
These functions are mainly used for displaying the field of the library for programmatically accessing SQL Server to
values on SCADA UI component by SCADA Engineer. retrieve the values from the SQL server.
The SCADA Engineer can also provide the SCADA Eg. Functionality in C++:
Operator to control the Tag values by writing the display
logic using this set of functions. PGconn* connection=NULL;
connection=PQconnectdb("user=********** password=**********
dbname=HistoricalDB hostaddr=127.0.0.1 port=5432");
• Communication Functions: PGresult* res;
These functions include the functions to notify the res=PQexec(conn, "BEGIN");
remote user about SCADA status. The functions include res=PQexec(conn, Sql_statement.c_str()); // Sql_statement is the query
res=PQexec(conn, "FETCH ALL FROM record");
the function to send SMS and email and to read SMS and Close_connection(conn);
Email. The SCADA Engineer can configure the functions
for SCADA UI components representing devices, to Additionally, to convert the data from the complex
automatically notify the remote user about the device datatype to the simple format, which can be used in UI
status. development, complex logic has to be written and memory has
to be managed carefully, to avoid memory leakage.
• File Handling Functions: Unlike the conventional approach, the user has to be
These functions include functions for file handling concerned about passing the proper Tag ID and Timestamp
which the SCADA Engineer can use to design the range for query generation and the Scripting Engine will
SCADA HMI and providing the user to handle the files handle the connection, query generation and handling complex
using SCADA HMI. datatypes.
Eg. Functionality in Python:
• Standard library extension:
data_req=DATA_REQUEST(1, b"14/10/15 09:35", b"10/12/15 17:00",
In addition to above functionality provided, the
b"value_number")
standard python library (Time and String Functions) is retrieve_historical_data(byref(data_req))
also extended, which can be used by SCADA Engineer to
write display logic. In the above example DATA_REQUEST is the structure
defined in Scripting Engine. The value can be retrieved by
accessing the data member of the structure.

494
C. Automated Memory management person who is proficient with buffer management
For retrieving the historical data or alarm data using programmatically and well versed with socket programming.
conventional approach, the user has to delete the memory In addition, the user has to free the allocated memory space as
allocated to the data handling variable once it is given to UI the amount of data received in this type of communication is
screen component, as it will lead to memory leakage. huge. And the application is more prone to memory leakage.
Using the scripting engine approach, the memory is Eg. For sending SMS using conventional approach, the user
automatically deallocated at python-level, once the variable is will have to createFile, readFile and writeFile for comport
out of scope. The memory management at library level is using fileAPI and will have to extract the response received.
handled by the destructor of DATA_REQUEST. For doing the same task using Scripting Engine
## The destructor approach, the user can open COM port, send SMS and close
def __del__(self): COM port using a simple function.
lib.delete_obj.restype=None
lib.delete_obj.argtypes=[ctypes.POINTER(DATA_REQUEST)]
lib.delete_obj(self) Eg. Sending SMS using Scripting Engine:
The similar approach is implemented for all other
functions of Scripting Engine for automating memory i=openComport(3, 9600, "8N1")
sendSMS(i, "+91**********", "Message")
management, reducing the burden at user-side. closeComport(i)

D. No exposure of Core library classes F. Less Coding


For the development of SCADA HMI using The amount code required to design the complex UI screen
conventional approach, it is observed that the classes of core using conventional approach is more compared to the
libraries have to be exposed to the user, in order to get/set the approach of Scripting Engine. To prove this, four complex
data from server. In Scripting Engine approach, only the applications were developed using the compiler based
information needed to develop the SCADA HMI is provided approach and scripting engine approach with functional
to the Engineer, and it can be accessed using script. difference. Following are the difference observed in Lines of
Code (LoC):
Eg. For getting the list of the names of the objects registered at
Table 1 Comparative analysis of Scripting Engine approach and
the Database Manager using C++ with Qt:
Compiler based approach in terms of Lines of Code (LoC)
ElementList objElementList;
ElementDetails objElementDetails;
ObjectList pObjectList=(ObjectList)GetProcAddress(m_pHandle,
"ObjectList");
pObjectList("_Mod_Device", objElementList);
for(Luint i=0; i<objElementList.getElementCount(); i++)
{
objElementList.getElementDetailsat(i, objElementDetails);
QString objName=
QString::fromStdString(objElementDetails.getElementName());
}
In the above example ElementList and
ElementDetails are the classes of Core library in SCADA.
Thus, it would be very difficult for user to keep the track of
classes to be used as well as extracting the names using its
instance. The number of lines of code required for developing
Using the Scripting Engine library, there is no need using conventional approach is almost 2.49 times larger than
to expose the core library classes and to retrieve the list using those required by using Scripting Engine approach.
instance of those classes. Instead, the user has to write a line The reason is the complicated task handled by Scripting
code to get the list of the object. Engine, no memory management at user-level coding and no
Eg. Python Script: datatype handling.

lDeviceList=getObjectName("_Mod_Device") G. Datatype Handling


In conventional approach, if the user has to store some
E. Buffer Management and Socket Communication value returned by some function, it has to be declared prior to
For sending notification to remote location via its use.
SMS/Email using conventional approach, the user has to Eg. C++ with Qt:
bool bIsChecked;
manage the socket communication and will have to send and bIsChecked= ui->isPolling->isChecked()
receive buffers, interpret the command received and will have
to extract the data to and from the buffer. This requires the

495
Using the scripting engine approach, the user is not proficient in complex compiler-based language. The
concerned with the declaration of the datatype and can directly customization of application at user side is possible with the
use it. scripting language. Thus, the Scripting Engine helps in rapid
Eg. Python with Qt: development of SCADA and is far better than the
bIsChecked=self.ui. isPolling.isChecked() conventional approach of C/C++. As, all of the performance
critical tasks are managed at the library level, the performance
H. Performance of the resulting application is acceptable, balancing the best of
In [[4]], the performances of the different scripting both the languages (Compiler-based and Interpreter-based).
languages are compared with respect to Kilobytes lines of
code. In SCADA screen development using Scripting Engine
approach, the typical screen size can range from 4kB to 100
Acknowledgment
kB as only the business logic is scripted and rest of the The authors are thankful to Dr. Shubha Pandit, the
performance critical task are managed at the library level. Principal of K J Somaiya College of Engineering, Prof.
Thus, the drawback of Python being slow for real-time Bharthi Narayan, Head of Computer Department, Mr. Rahul
application development than compiler-based languages is Rane and Mr. Shishir Gupta from Larsen & Toubro
compensated. Automation, Navi Mumbai, for providing the opportunity and
The performance test has been done to check the necessary facilities for the preparation of the paper.
performance difference between the conventional approach
and Scripting Engine approach. To do this, 500 objects were References
created in Database of objectType Meter and all the objects of
that object type were retrieved on SCADA screen initialization [1] Hans Christian Woithe and Ulrich Kremer, "A Light Weight Scripting
and displayed on the screen. for the Slocum Glider", IEEE Oceans 2010 Conference, Sydney,
Australia, May 2010.
Table 2 Comparative analysis of Scripting Engine approach and [2] M. McLaughlin and M. Katchabaw, "A Reusable Scripting Engine for
Compiler based approach in terms of Performance Automating Cinematics and Cut-Scenes in Video Games", Proceedings
of CGSA 2006 Symposium.
[3] Milivoj Bozic, Dusan Zivkov, Istvan Pap and Goran Miljkovic,
"Scriptable Graphical user Interface Engine for embedded platform",
21st Telecommunication Forum TELFOR 2013.
[4] Mrunali Tandel, Prof. Uday Joshi and Amit Golhani, "Literature
Review: Scripting in Qt for Scripting Engine development",
International Journal of Computer Science and Information
Technologies, Vol. 7(3), 2016, 1242-1245.
[5] QiangXie, Jinfeng Liu and Pai H. Chou, "Tapper: A lightweight
Scripting engine for highly constrained wireless sensor nodes", IPSN
IV. CONCLUSION 2006.
The Scripting Engine for SCADA aims to provide a [6] SCADA (Supervisory Control and Data Acquisition),
http://whatis.techtarget.com/definition/SCADA-supervisory-control-
flexible solution to the SCADA development. As interpreter- and-data-acquisition
based language is used, there is no need for the compilation at [7] Scripting|Mono, http://www.mono-
user side, unlike the traditional approach where the object project.com/docs/advanced/embedding/scripting/
rendering and command interpretation was done using C/C++ [8] Qt Documentation, 2016, http://doc.qt.io/qt-5/index.html
language. The ease with which the scripting language is [9] PyQt Whitepaper, Riverbank Computing Limited,
adopted and learned is nowhere closer to the compiled www.riverbankcomputing.com, 2013.
language. Thus, the SCADA engineer need not be a person

496

You might also like