final-year-project-latest

164
SCADA SYSTEM INTEGRATION OF SATELLITE SUBSTATIONS IN COLOMBO CITY B.Sc. Engineering Department of Electronic & Telecommunication Engineering University of Moratuwa Supervisor Project Group Eng. A.T.L.K. Samarasinghe K.M.G.L.H. Konara - 100263H K.M.C.R.B. Abeysinghe -100009L B.M. Adhikarinayake -100019R A.A.H.S. Amarathunga - 100033E April 2015

Upload: lasitha-konara

Post on 10-Aug-2015

68 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: final-year-project-latest

SCADA SYSTEM INTEGRATION OFSATELLITE SUBSTATIONS IN

COLOMBO CITY

B.Sc. Engineering

Department of Electronic & Telecommunication

Engineering

University of Moratuwa

Supervisor Project Group

Eng. A.T.L.K. Samarasinghe K.M.G.L.H. Konara - 100263H

K.M.C.R.B. Abeysinghe -100009L

B.M. Adhikarinayake -100019R

A.A.H.S. Amarathunga - 100033E

April 2015

Page 2: final-year-project-latest

SCADA SYSTEM INTEGRATION OFSATELLITE SUBSTATIONS IN

COLOMBO CITY

B.Sc. Engineering

Department of Electronic & Telecommunication

Engineering

University of Moratuwa

Supervisor Project Group

Eng. A.T.L.K. Samarasinghe K.M.G.L.H. Konara - 100263H

K.M.C.R.B. Abeysinghe -100009L

B.M. Adhikarinayake -100019R

A.A.H.S. Amarathunga - 100033E

April 2015

Page 3: final-year-project-latest

Approval of the Department of

Electronic & Telecommunication

Engineering

...........................................................

Prof. S. Rohan Munasinghe,

Head of the department,

Department Of Electronic &

Telecommunication Engineering

This is to certify that we have read this project and that in our opinion it is fully

adequate, in cope and quality, as an Undergraduate Graduation Project.

Supervisor,

.......................................................

Eng. A.T.L.K. Samarasinghe

Senior Lecturer,

Department Of Electronic & Telecommunication Engineering

...............................

Date

i

Page 4: final-year-project-latest

Declaration

This declaration is made on the 8th day of May 2015.

Student’s Declaration:

We hereby declare that the work presented in this dissertation is our original work

and has been done in partial fulfillment of the B.Sc. Engineering degree at the

University of Moratuwa.

We have not copied from any other’s work or from any other sources except where

due reference or acknowledgement is made explicitly in the text, nor has any part

been written for us by another person.

We have aknowledged all main sources of assistance received for this work.

Parts of this dissertation have been published (see List of Publications) or may be

published in future.

..............................

Date of Submission

...................................................

K.M.G.L.H. Konara (100263H)

...................................................

K.M.C.R.B. Abeysinghe (100009L)

...................................................

B.M. Adhikarinayake (100019R)

...................................................

A.A.H.S. Amarathunga (100033E)

ii

Page 5: final-year-project-latest

EN4202 - Project

Supervisor’s Declaration:

I, Eng. A.T.L.K. Samarasinghe hereby certify that the work entitled SCADA

System Integration of Satellite Substations in Colombo City was prepared by the

above named students, and was submitted to the department of Electronic and

Telecommunication Engineering, Faculty of Engineering, University of Moratuwa

as a full fulfillment for the conferment of Honours Degree of Bachelor of Science

of Engineering, and the aforementioned work, to the best of my knowledge, is the

said students’ work.

Received for examination by :

...............................................

Eng. A.T.L.K. Samarasinghe

......................

Date

SCADA System Integration of Satellite Substations in Colombo City iii

Page 6: final-year-project-latest

EN4202 - Project

Abstract

SCADA System Integration of Satellite Substations in Colombo City

Supervisor : Eng. A.T.L.K. Samarasinghe

External Supervisor : Eng.Chandana Warnakulasuriya

Students : K.M.G.L.H. Konara,K.M.C.R.B. Abeysinghe,B.M.

Adhikarinayake,A.A.H.S. Amarathunga

Keywords : SCADA , PLC , VPN , CEB

Ceylon Electricity Board (CEB) has established a Supervisory Control And

Data Acquisition (SCADA) system in Colombo City in order to monitor and

control their distribution system. There are several substations are connected

to the SCADA ,primary substations,ring and radial substations and few satellite

substations.But only very small number of satellite substations are connected to

the existing SCADA. The main objective of carrying out this project is to find a

cost effective robust solution in order to connect those satellite substations to the

SCADA system and automate them.

The CEB engineers could only view the alarms raised for different substations

from its main control centre . Therefore another objective of this project is to

find a solution in order to provide the access to view alarms by any mobile device

through a virtual private network (VPN).Apart from that a lot of value added

services have been added to the mobile application and optimized in such a way

that CEB engineers could carry out their day to day activities in a very efficient

manner.

In power line communication (PLC) , there is an issue when a signal needs to

be sent through a power transformer. There is no physical connection between the

primary and the secondary winding of the transformer. Therefore an experiment

on how to bypass a power transformer using a wireless communication system

has been carried out on theoretical basis and have suggested a suitable design to

implement the system.The issues faced in powering up the system and the effects

of interference are also being discussed.

SCADA System Integration of Satellite Substations in Colombo City iv

Page 7: final-year-project-latest

Dedicated to

Our parents and teachers

v

Page 8: final-year-project-latest

Acknowledgments

Our heartfelt gratitude is given first and foremost to the supervisor of our project

Eng. A.T.L.K. Samarasinghe for the immense help, support and advice given

throughout the course of our project. His encouragement and contribution in

the form of alternative methods, ideas and concepts provided motivation for us to

move forward with our project. Our project coordinator, Prof. Rohan Munasinghe

gave us valuable guidance and advice since the very beginning of our project and

we are extremely thankful for his support.

Our gratitude is also extended to all the staff members of the Electronic and

Telecommunication Department who provided us with numerous advice and feed-

back, specially at the mid review, feasibility study and demonstration. We appre-

ciate your guidance.

Our special thanks goes out to our external project supervisor, Chief Engi-

neer Mr.Chandana Warnakulasuriya for giving us the opportunity to work on this

project, providing us with the access to SCADA system of Colombo City and also

for the guidance provided.Also we would like to thank all the staff members in

main SCADA control centre of Colombo CIty of Ceylon Electricity Board .

We would like to extend our gratitude to the staff members of the department

of Electrical Engineering,University of Moratuwa, for the support given for the

research.

We would also like to thank all the batch mates, academic and non academic

staff members of University of Moratuwa and everyone else who contributed .Your

support is greatly appreciated.

Last but not least, we would like to thank our family members and friends for

all the motivation and assistance provided.

vi

Page 9: final-year-project-latest

Contents

Approval i

Declaration i

Abstract iv

Dedication v

Acknowledgments vi

1 Introduction 1

1.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 Problem Identification . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.3 Current CEB Development . . . . . . . . . . . . . . . . . . . . . . . 3

1.4 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.5 Project Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.5.1 Phase I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.5.2 Phase II . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.5.3 Phase III . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.5.4 Phase IV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Phase I - SCADA System Integration 5

2.1 Proposed Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2.2 Detail Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.2.1 Viola M2M Gateway . . . . . . . . . . . . . . . . . . . . . . 9

2.2.2 Viola Arctic RTU . . . . . . . . . . . . . . . . . . . . . . . . 10

2.2.3 Communication Between M2M Gateway and RTU . . . . . . 11

vii

Page 10: final-year-project-latest

Contents EN4202 - Project

2.2.4 System Connectivity . . . . . . . . . . . . . . . . . . . . . . 12

2.2.5 System Configuration . . . . . . . . . . . . . . . . . . . . . . 13

2.3 Challenges Faced . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.3.1 Analyzing existing SCADA network and handling Inter-

operability issues . . . . . . . . . . . . . . . . . . . . . . . . 15

2.3.2 Communication failure due to ASDU address mismatch . . . 16

2.3.3 Issues with the new RTUs . . . . . . . . . . . . . . . . . . . 17

3 Phase II - Secondary Server Design, Implementation and Packet

Inspection & Analysis 18

3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

3.2 Design of the secondary system . . . . . . . . . . . . . . . . . . . . 18

3.2.1 Components of the secondary server . . . . . . . . . . . . . . 19

3.2.2 Packet capturing point identification . . . . . . . . . . . . . 21

3.2.3 Packet Capturing method . . . . . . . . . . . . . . . . . . . 21

3.2.4 Features of JAVA application . . . . . . . . . . . . . . . . . 23

3.2.5 Database Design . . . . . . . . . . . . . . . . . . . . . . . . 23

3.2.6 Connectivity to the front end . . . . . . . . . . . . . . . . . 24

3.3 Setting up the environment . . . . . . . . . . . . . . . . . . . . . . 24

3.4 Procedures followed, issues faced and solutions . . . . . . . . . . . . 26

3.4.1 Other issues . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

4 Phase III - Android and Web based Applications Development 29

4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

4.2 Android Application . . . . . . . . . . . . . . . . . . . . . . . . . . 30

4.2.1 Alarms table by Substation . . . . . . . . . . . . . . . . . . 32

4.2.2 Alarms Map . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

4.2.3 Navigator (Substation locator) . . . . . . . . . . . . . . . . . 33

4.2.4 Alarms History . . . . . . . . . . . . . . . . . . . . . . . . . 35

4.2.5 Substation by Live Alarms . . . . . . . . . . . . . . . . . . . 35

4.2.6 Substation by Building Name . . . . . . . . . . . . . . . . . 35

4.2.7 Substation by Street Name . . . . . . . . . . . . . . . . . . . 36

4.2.8 Substation by Zone . . . . . . . . . . . . . . . . . . . . . . . 36

SCADA System Integration of Satellite Substations in Colombo City viii

Page 11: final-year-project-latest

Contents EN4202 - Project

4.2.9 Customer by Account Number . . . . . . . . . . . . . . . . . 36

4.2.10 Customer by Name . . . . . . . . . . . . . . . . . . . . . . . 36

4.2.11 Customer by Telephone Number . . . . . . . . . . . . . . . . 37

4.2.12 Customer by Street Name . . . . . . . . . . . . . . . . . . . 37

4.2.13 Alarm Notification Service . . . . . . . . . . . . . . . . . . . 37

4.3 Desktop Application . . . . . . . . . . . . . . . . . . . . . . . . . . 39

4.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

4.3.2 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . 39

4.4 Daily email report . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

4.5 Challenges Faced . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

5 Phase IV - Experiment on Bypassing a Power Transformer Using

a Wireless Communication System 47

5.1 Problem Identification . . . . . . . . . . . . . . . . . . . . . . . . . 47

5.2 Existing Solutions/ Literature Survey . . . . . . . . . . . . . . . . 49

5.2.1 ABB-MCD80 - Power Line Carrier Coupling Devices . . . . 49

5.2.2 Other Patented Applications . . . . . . . . . . . . . . . . . . 50

5.3 Proposed Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

5.4 Coupling Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

5.5 Transmitter and Receiver . . . . . . . . . . . . . . . . . . . . . . . . 52

5.6 Power Supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

5.6.1 Problems faced in supplying power . . . . . . . . . . . . . . 53

5.6.2 Powering up the circuit using induced voltages in 11 kV

power line . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

5.6.3 Powering up the circuit using a solar panel and a battery

back up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

5.7 Electrical interference around a 11 kV line . . . . . . . . . . . . . . 57

5.7.1 Electric field . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

5.7.2 Magnetic field . . . . . . . . . . . . . . . . . . . . . . . . . . 60

5.8 How to overcome the electromagnetic interference . . . . . . . . . . 63

5.8.1 Estimation of impact of electric and magnetic field . . . . . 63

5.8.2 Electromagnetic Shielding . . . . . . . . . . . . . . . . . . . 66

5.9 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

SCADA System Integration of Satellite Substations in Colombo City ix

Page 12: final-year-project-latest

Contents EN4202 - Project

5.9.1 How to power up the system . . . . . . . . . . . . . . . . . . 67

5.9.2 How to overcome interference . . . . . . . . . . . . . . . . . 67

5.9.3 Recommended design . . . . . . . . . . . . . . . . . . . . . . 67

6 Conclusion 69

Bibliography xvi

A Configuration User Manual of Arctic IEC 104 Gateway and M2M

Gateway xvi

A.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi

A.2 Configuring the Arctic RTU . . . . . . . . . . . . . . . . . . . . . . xvii

A.2.1 Login to RTU . . . . . . . . . . . . . . . . . . . . . . . . . . xviii

A.2.2 Configuring Ethernet Settings . . . . . . . . . . . . . . . . . xviii

A.2.3 Configuring GPRS . . . . . . . . . . . . . . . . . . . . . . . xx

A.2.4 Configuring SSH - VPN . . . . . . . . . . . . . . . . . . . . xxi

A.2.5 Configuring I/O ports . . . . . . . . . . . . . . . . . . . . . xxii

A.3 Configuring M2M Gateway . . . . . . . . . . . . . . . . . . . . . . . xxiii

A.4 How to Access an Arctic RTU Remotely . . . . . . . . . . . . . . . xxvii

A.5 Important IP Addresses . . . . . . . . . . . . . . . . . . . . . . . . xxviii

B Program Codes xxix

B.1 Code for packet analyzing java application . . . . . . . . . . . . . . xxix

B.1.1 main for linux final v2.java . . . . . . . . . . . . . . . . . . . xxix

B.2 Android application codes . . . . . . . . . . . . . . . . . . . . . . . xxxviii

B.2.1 MainActivity.java . . . . . . . . . . . . . . . . . . . . . . . . xxxviii

B.2.2 NotificationMain.java . . . . . . . . . . . . . . . . . . . . . . xlviii

B.2.3 substation byALARMS.java . . . . . . . . . . . . . . . . . . lvii

B.2.4 alarms history.php . . . . . . . . . . . . . . . . . . . . . . . lx

B.2.5 notification.php . . . . . . . . . . . . . . . . . . . . . . . . . lxvi

B.2.6 map for notification.php . . . . . . . . . . . . . . . . . . . . lxvii

B.2.7 form customer account.php . . . . . . . . . . . . . . . . . . lxxii

B.2.8 data customer account.php . . . . . . . . . . . . . . . . . . . lxxiii

B.2.9 map3.php . . . . . . . . . . . . . . . . . . . . . . . . . . . . lxxviii

SCADA System Integration of Satellite Substations in Colombo City x

Page 13: final-year-project-latest

Contents EN4202 - Project

B.2.10 main.php . . . . . . . . . . . . . . . . . . . . . . . . . . . . lxxxiii

B.2.11 index.php . . . . . . . . . . . . . . . . . . . . . . . . . . . . lxxxviii

SCADA System Integration of Satellite Substations in Colombo City xi

Page 14: final-year-project-latest

List of Figures

2.1 SCADA Control Center View of Substations . . . . . . . . . . . . . 6

2.2 Proposed solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.3 Picture of a satellite substation in SCADA . . . . . . . . . . . . . . 9

2.4 Viola M2M Gateway . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2.5 Viola Arctic RTU . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2.6 System connectivity and data flow path . . . . . . . . . . . . . . . . 13

2.7 Arctic RTU I/O port panel Front View . . . . . . . . . . . . . . . . 14

2.8 I/O Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.9 ASDU Address mismatch shown in syslog of RTU . . . . . . . . . . 16

2.10 Error in IEC 104 I/O Ports . . . . . . . . . . . . . . . . . . . . . . 17

3.1 Basic system block diagram . . . . . . . . . . . . . . . . . . . . . . 19

3.2 CentOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

3.3 Wireshark - Packet analyzing tool . . . . . . . . . . . . . . . . . . . 20

3.4 DBMS used . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

3.5 Sample output of the tshark . . . . . . . . . . . . . . . . . . . . . . 23

3.6 EER diagram of the database . . . . . . . . . . . . . . . . . . . . . 24

3.7 Secondary Server Integration . . . . . . . . . . . . . . . . . . . . . . 25

4.1 Substation alarm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

4.2 Map view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

4.3 Alarms in a table view . . . . . . . . . . . . . . . . . . . . . . . . . 33

4.4 Alarms map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

4.5 Substation locator . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

4.6 Alarm History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

4.7 Substations by live alarms . . . . . . . . . . . . . . . . . . . . . . . 36

xii

Page 15: final-year-project-latest

List of Figures EN4202 - Project

4.8 Customer by account number . . . . . . . . . . . . . . . . . . . . . 37

4.9 Enable Notifications . . . . . . . . . . . . . . . . . . . . . . . . . . 38

4.10 Notification indication . . . . . . . . . . . . . . . . . . . . . . . . . 38

4.11 The web application . . . . . . . . . . . . . . . . . . . . . . . . . . 42

4.12 Email Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

5.1 Transformer used in CEB . . . . . . . . . . . . . . . . . . . . . . . 48

5.2 3 Phase Transformer . . . . . . . . . . . . . . . . . . . . . . . . . . 48

5.3 ABB-MCD80 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

5.4 ABB-MCD80 Application . . . . . . . . . . . . . . . . . . . . . . . 50

5.5 Bypassing the transformer using a wireless module . . . . . . . . . 51

5.6 Block Diagram of Proposed Solution . . . . . . . . . . . . . . . . . 51

5.7 Line trap and coupling circuit . . . . . . . . . . . . . . . . . . . . . 52

5.8 Schematic Diagram of a CT and Equivalent circuit . . . . . . . . . 54

5.9 Circuit Diagram of Solar power system with battery back up . . . . 56

5.10 A Small Solar Panel - 3V,70 mA . . . . . . . . . . . . . . . . . . . . 57

5.11 Typical electric fields of overhead lines . . . . . . . . . . . . . . . . 58

5.12 Typical electric fields of overhead lines . . . . . . . . . . . . . . . . 59

5.13 Typical magnetic fields from Botany Bay Cable Project . . . . . . . 61

5.14 Typical magnetic fields from EMFS.info . . . . . . . . . . . . . . . 61

5.15 Typical magnetic fields from EMFS.info for different designs . . . . 62

5.16 Placement of transmitter and receiver . . . . . . . . . . . . . . . . . 64

5.17 Recommended Design . . . . . . . . . . . . . . . . . . . . . . . . . 68

A.1 Arctic RTU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi

A.2 Port Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii

A.3 Login Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii

A.4 Prompt login details . . . . . . . . . . . . . . . . . . . . . . . . . . xviii

A.5 Ethernet Configurations . . . . . . . . . . . . . . . . . . . . . . . . xix

A.6 GPRS Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . xx

A.7 SSH - VPN Configurations . . . . . . . . . . . . . . . . . . . . . . . xxi

A.8 IEC 104 direct control IO . . . . . . . . . . . . . . . . . . . . . . . xxiii

A.9 M2M Gateway . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii

SCADA System Integration of Satellite Substations in Colombo City xiii

Page 16: final-year-project-latest

List of Figures EN4202 - Project

A.10 Opening the web UI . . . . . . . . . . . . . . . . . . . . . . . . . . xxiv

A.11 Login to M2M web UI . . . . . . . . . . . . . . . . . . . . . . . . . xxiv

A.12 Configuring SSH - VPN . . . . . . . . . . . . . . . . . . . . . . . . xxiv

A.13 Adding New Peer . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv

A.14 Adding Peer Details . . . . . . . . . . . . . . . . . . . . . . . . . . xxvi

A.15 SSH Key Handshake . . . . . . . . . . . . . . . . . . . . . . . . . . xxvi

A.16 Checking Peers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii

SCADA System Integration of Satellite Substations in Colombo City xiv

Page 17: final-year-project-latest

List of Tables

2.1 Currently using connections between SCADA and RTUs and their

costs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.2 Viola M2M Gateway specifications . . . . . . . . . . . . . . . . . . 10

2.3 Viola RTU specifications . . . . . . . . . . . . . . . . . . . . . . . . 11

2.4 Viola RTU I/O Port Specifications . . . . . . . . . . . . . . . . . . 14

5.1 National Radiation Laboratory Recordings . . . . . . . . . . . . . . 59

5.2 Actual field values for the selected conditions . . . . . . . . . . . . . 60

5.3 National Radiation Laboratory Recordings for distribution

substations[9] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

5.4 Actual Magnetic field values for the selected conditions . . . . . . . 63

5.5 Electric field strengths near Rx unit . . . . . . . . . . . . . . . . . . 65

5.6 Magnetic field strengths near Rx unit . . . . . . . . . . . . . . . . . 65

A.1 Important IP Addresses . . . . . . . . . . . . . . . . . . . . . . . . xxviii

xv

Page 18: final-year-project-latest

Chapter 1

Introduction

1.1 Background

SCADA (Supervisory Control And Data Acquisition) is an industrial control com-

puter system which is capable of gathering and analyzing real time data. This type

of access to real-time information allows governments, businesses and individuals

to make data driven decisions about how to improve their processes. These deci-

sions would be either impossible or take substantial time and resources to complete

without SCADA system. SCADA systems are used to monitor and control a plant

or equipment in industries such as telecommunications, water and waste control,

energy, oil and gas refining and transportation. SCADA systems can be relatively

simple, such as one that monitors environmental conditions of a small office build-

ing, or incredibly complex, such as a system that monitors all the activity in a

nuclear power plant or the activity of a municipal water system.

A SCADA system usually consists of the following subsystems:

• Remote terminal units (RTUs): RTUs normally connect to sensors in

the process and convert sensor signals to digital data. They have telemetry

hardware capable of sending digital data to the supervisory system, as well

as receiving digital commands from the supervisory system.

• Programmable logic controller (PLCs): PLCs connect to sensors in

the process and converting sensor signals to digital data. PLCs are not

capable of sending acquired data therefore data sending mechanism must

1

Page 19: final-year-project-latest

1.1. Background EN4202 - Project

be installed along with the PLC. But PLCs have more processing power

and controlling power over the RTUs. PLCs are sometimes used in place of

RTUs as field devices because they are more economical, versatile, flexible,

and configurable.

• A data transmission system is typically used to connect PLCs and RTUs

with control centers, data warehouses, and the enterprise. Examples of wired

telemetry media used in SCADA systems include leased telephone lines and

WAN circuits. Examples of wireless telemetry media used in SCADA sys-

tems include satellite (VSAT), licensed and unlicensed radio, cellular and

microwave.

• A data acquisition server is a software service which uses industrial protocols

to connect software services, via telemetry, with field devices such as RTUs

and PLCs. It allows clients to access data from these field devices using

standard protocols.

• A human- machine interface or HMI is the apparatus or device which presents

processed data to a human operator, and through this, the human operator

monitors and interacts with the process. The HMI is a client that requests

data from a data acquisition server.

• A supervisory (computer) system, gathering (acquiring) data on the process

and sending commands (control) to the SCADA system.

SCADA system can be used gather data from faraway places and control them

remotely. Here data received from wells are transmitted to the SCADA system

using microwave links. And control signals can also send through the same path

Data transmission can be achieved using a leased line, microwave link, buried

cable, telephone, radios, modems, satellites or mobile data network. There are

many options to consider when selecting the appropriate communication equip-

ment and can include either a public and/or private medium.

IEC 104 protocol is used to communicate between SCADA control system and

RTUs. It is a Master-Slave protocol which communicates over TCP IP. Since it

is a Master-Slave protocol for real communication/data transfer to happen there

SCADA System Integration of Satellite Substations in Colombo City 2

Page 20: final-year-project-latest

1.2. Problem Identification EN4202 - Project

must be at least one instance of a Master (usually the Control Centre acts as the

Master) and a Slave (RTU or IEDs act as slaves).

1.2 Problem Identification

Ceylon Electricity Board is having a distribution SCADA system for its 132/33/11

network in Colombo City. Primary Substations, Radial substations, Ring substa-

tions and Satellite substations are the main points the Colombo City distribution

network.

Even though the RING , Radial and Primary substations are connected to the

SCADA ,the satellite substations have not been added to the SCADA in large

scale.Therefore those satellite substations are not automated. If any change has

to be done,either to monitor or control,the technical officers will have to visit the

substation location physically. It take time and also have to spend additional cost

to maintain such system. If these substations could be automated ,that kind of

problems will not be faced.

1.3 Current CEB Development

Currently CEB has connected few satellite substations and other main stations

using several methods.Namely;

• SLT leased lines

• SLT IP VPN connections

• Dialog IP VPN connection

• CEB Fibre Optic connections

In the existing system, most of the Primary, Radial & Ring substations have

been linked to the SCADA system through Fibre, Leased lines (E1) and GPRS

communication. Approximately 10% out of satellite substations which are con-

nected to lease lines have already been connected to the SCADA system.

SCADA System Integration of Satellite Substations in Colombo City 3

Page 21: final-year-project-latest

1.4. Objectives EN4202 - Project

1.4 Objectives

The main objective of this project is to connect all of the Satellite substations

to the SCADA system in a cost effective manner.The secondary objective is to

provide mobile access to the SCADA control centre for the engineers of CEB .

1.5 Project Overview

1.5.1 Phase I

Under the phase I the main objective is to Connect the satellite substations to the

SCADA system using GPRS communication system and enable automation. After

the successful implementation of the system CEB will be able to connect over 500

satellite substations to the SCADA system in order to monitor and control.

1.5.2 Phase II

In phase II ,the main objective is to create a secondary server which will be ac-

cessed by the mobile devices in the next phase of the project.Packet capturing and

analyzing will be the biggest challenge that we will have to face in this phase.After

capturing the required packets a secondary data base is updated

1.5.3 Phase III

Creating an Android based application and a web based desktop application in

order to view the status and alarms at any satellite substation from any authorized

mobile phone. This will be a new development for the SCADA system because with

the introduction of mobile access, the engineers in CEB will be able to monitor

the system using their own mobile phone even when they are at home. They will

have to enter their Username and Password in order to access the system

1.5.4 Phase IV

Under the phase IV an experiment will be carried out on how to bypass a power

transformer using a wireless communication system.

SCADA System Integration of Satellite Substations in Colombo City 4

Page 22: final-year-project-latest

Chapter 2

Phase I - SCADA System

Integration

Main objective of this phase is to provide a financially feasible solution to con-

nect Ceylon Electricity Board satellite sub stations (Lowest level substations in

CEB distribution architecture) in Colombo Metropolitan area to their main con-

trol network (SCADA). CEB already had a method to connect their higher level

substations such as ring radial substations to the SCADA using Siemens RTUs

and SLT leased lines. Problem they had when extending that solution to above

mentioned scenario is the cost because there are around 500 satellite substations

are located around the Colombo metropolitan area alone. Siemens RTUs used in

the radial substations cost 2200 EURO. Currently CEB has three methods to con-

nect radial substations and SCADA network. Those methods and their respective

costs are mentioned in table 2.1.

Provider Type of connection cost

(per month)

Sri Lanka Telecom Leased Line 7100

Sri Lanka Telecom IP VPN 4800

Dialog Axiata PLC IP VPN 4500

Table 2.1: Currently using connections between SCADA and RTUs and their

costs

5

Page 23: final-year-project-latest

2.1. Proposed Solution EN4202 - Project

Therefore total implementation cost and operation cost for 500 units are not

affordable to the CEB. Other thing is that satellite substation itself provides only

4 signals even though Siemens RTU capable of handle much more data. Therefore

using a Siemens RTU is a waste of resources

Figure 2.1 shows all substations connected to Primary Substations ’C’ and

’H’(Center Nodes). All the nodes which are directly connected to primary substa-

tion are called radial substations and they are already connected to SCADA using

leased lines. All other nodes are the ones that need to be connected at the end of

this project.

Figure 2.1: SCADA Control Center View of Substations

2.1 Proposed Solution

Since the existing method is too costly to implement and operate here a new

solution is proposed to overcome above mentioned shortcomings. In this solution

a VPN connection is proposed instead of leased lines because VPN is suitable for

connecting large number of nodes which are spread within a large geographical

area using internet. And also a new RTU and a Gateway is introduced instead of

Siemens RTU. These RTUs are less costly than Siemens RTUs and have enough

capabilities to operate satellite substations.

In this solution a RTU will be installed in each and every satellite substation.

Sensor outputs and actuator inputs will be connected to that RTU. Then these

SCADA System Integration of Satellite Substations in Colombo City 6

Page 24: final-year-project-latest

2.2. Detail Design EN4202 - Project

RTUs will be connected to a Gateway in the control center using a VPN. Each

and every RTU will be registered in the Gateway. And this gateway is connected

to SCADA network. Illustration of this proposed solution is shown in figure 2.2

Figure 2.2: Proposed solution

2.2 Detail Design

As the first phase of this project it is planned to implement above proposed so-

lution. There are two main types of alarms generated in a substation. Double

inputs and single inputs. Double inputs take two sensor inputs and combine them

together to build one single value. Because there are two bits in a double input

there can be four values ’0’, ’1’, ’2’ and ’3’. Here ’0’ and ’3’ will indicate a dis-

turbed state which means there is a fault in that device and ’1’ and ’2’ represents

the two possible states. Single inputs only need one input and it directly gives

the state. Controlling commands also have two types as double commands and

single commands. The operation is similar to the input. RTU used in this project

has 8 input ports and 2 output ports. Therefore it is possible to give either 4

double inputs or 8 single inputs or a combination of these two. Also it can give

a double output or two single outputs since one single output needs two output

ports. In this phase it is planned to get one double input three single inputs and

SCADA System Integration of Satellite Substations in Colombo City 7

Page 25: final-year-project-latest

2.2. Detail Design EN4202 - Project

one give one double control command. List of alarms and their respective SCADA

indication symbols are shown below.

Earth Fault Alarm

Load Breaker Switch Indication

Other Alarms

Load breaker switch open and closes the current path. This switch is auto-

mated using RTU and can be controlled via SCADA controlling center. Position

of this switch will be return to the SCADA using a feedback path. Above sym-

bol is indicates that position in SCADA. Earth Fault alarm indicates any kind

of current leakage by blinking the earth fault alarm symbol. In addition to these

alarms SCADA will indicate any kind of communication link failure, RTU failure

and whether controlling command can be given by SCADA or not. As a safety

procedure there is a switch in the substation. If that switch is turned on remote

controlling will be disabled to prevent any harm that can be happen to personnel

in the field by accidental power up.

SCADA indication of a satellite substation is shown in the figure 2.3.

SCADA System Integration of Satellite Substations in Colombo City 8

Page 26: final-year-project-latest

2.2. Detail Design EN4202 - Project

Figure 2.3: Picture of a satellite substation in SCADA

Since this proposed solution carries critical data to CEB main control center

it is essential to have reliable and robust equipment in this system. Viola Systems

is a Finland based company which has developed RTUs and intermediate server

systems for similar kind of automation projects. Monitoring and controlling of

Whipp & Bourne GVR reclosers for the electrical distribution network in Moldova,

providing the communication for unmanned substations in the state of Himachal

Pradesh in India are some of the projects which have done by the Viola Systems

with similar objectives as mentioned above.

2.2.1 Viola M2M Gateway

Viola M2M Gateway is an industrial quality CentOS based server for secure com-

munication between central control room and remote sites with Arctic devices.

Figure 2.4: Viola M2M Gateway

SCADA System Integration of Satellite Substations in Colombo City 9

Page 27: final-year-project-latest

2.2. Detail Design EN4202 - Project

RTUs which are deployed in the sites can be connected to this Gateway via

GPRS/EDGE/3G or LTE. There are no direct restrictions on number of RTUs

that can be connected to M2M Gateway but it is advised to keep it fewer than

250. Some of other important technical specifications of this device are mentioned

in table 2.2.

Table 2.2: Viola M2M Gateway specifications

2.2.2 Viola Arctic RTU

Arctic RTU provides wireless monitoring and control of field devices via com-

mercial mobile network connectivity to central control systems like SCADA via

standard industrial protocols such as iec104.

Figure 2.5: Viola Arctic RTU

SCADA System Integration of Satellite Substations in Colombo City 10

Page 28: final-year-project-latest

2.2. Detail Design EN4202 - Project

This product includes advanced features such as automatic connection re-

establishment in case of fault, Reliable and secure automated two way communi-

cation, IEC-101 to IEC-104 TCP protocol conversion. Some of other important

technical specifications of this device are mentioned in table 2.3.

Table 2.3: Viola RTU specifications

2.2.3 Communication Between M2M Gateway and RTU

Communication between M2M Gateway and Arctic RTUs are done via internet

using GPRS. Since this communication uses internet it is susceptible for all kinds

of security threats. Therefore it is very important to have some kind of secu-

rity measurements in order to prevent security breaches. Here we used a VPN

connection to ensure a secure connection via internet. Since Ceylon Electricity

Board already had a VPN connection from Dialog Axiata PLC that same VPN

connection has been used in this project to minimize the cost. In addition to the

VPN connection SSH tunnels are used between each and every RTU and the M2M

SCADA System Integration of Satellite Substations in Colombo City 11

Page 29: final-year-project-latest

2.2. Detail Design EN4202 - Project

gateway to provide security and encryption.

2.2.4 System Connectivity

Viola RTUs are deployed in substations and these RTUs have a sim card which

allow RTUs to connect to Dialog VPN. Then packets will directed to M2M gateway

through VPN and Cisco 800 series router of Dialog is directly connected to M2M

Gateway.

A SSH tunnel is created between M2M Gateway and each and every RTU. If

there is ’N’ number of RTUs then ’N’ number of separate SSH tunnels need to be

created. Then these RTUs are registered in the M2M gateway. These registered

RTUs can be viewed on M2M gateway’s interface. Picture of this interface is

shown in figure A.16.

This web interface contains information about registered RTUs. SSH IP Pair,

Remote IP, current status of the RTU are some of these information.

The other ethernet port of Gateway is connected to a Primary RTU through a

switch. Then M2M gateway is pass all the packets which are coming from RTUs

to this primary RTU and it will also register and monitor these remote RTUs.

Finally this primary RTU will provide information which it has gathered from

remote RTUs to the SCADA network.

System connectivity and the data flow path is illustrated in the figure 2.6.

Components in the red boxes are already in the system and components which are

outside those boxes are the ones that added by this project.

SCADA System Integration of Satellite Substations in Colombo City 12

Page 30: final-year-project-latest

2.2. Detail Design EN4202 - Project

Figure 2.6: System connectivity and data flow path

2.2.5 System Configuration

To achieve above mentioned connectivity and data flow configurations had to be

made in following

• Arctic RTU

• M2M Gateway

• Configuring the RUGGEDCOM router by adding new static routes

• Define the new Arctic RTU in primary RTU

• Define the new RTU in the SCADA user interface

Arctic RTU Configurations

In Artic RTU following items need to be configured in order to achieve communi-

cation between SCADA and RTU

• Configuring Ethernet Settings

• Configuring GPRS

• Configuring SSH-VPN

• Configuring I/O Ports

SCADA System Integration of Satellite Substations in Colombo City 13

Page 31: final-year-project-latest

2.2. Detail Design EN4202 - Project

See Appendix A for detailed information on configuration of Artic RTU. Fig-

ures A.5 and A.8 show some configurations. IP Address plan is also in Appendix

A. Lot of configurations are common for all RTUs and some unique configurations

can also be found. Those configurations are specifically shown in Appendix A.

Arctic RTU 2920 which is used in this project has the capability to connect

sensors and actuators directly. Arctic RTU has I/O port panel to support this

facility and it can be seen in the figure 2.7.

Figure 2.7: Arctic RTU I/O port panel Front View

In this I/O port panel there are 15 ports. It includes 8 input ports, 4 output

ports, DC out, DC ground, Input common port. These port configurations are

shown in the table 2.4.

Table 2.4: Viola RTU I/O Port Specifications

Earth fault alarm, Local/Remote indication, Load breaker switch (LBS) status

are the main inputs connected to this panel. Double command to control load

SCADA System Integration of Satellite Substations in Colombo City 14

Page 32: final-year-project-latest

2.3. Challenges Faced EN4202 - Project

breaker switch is also going through this port panel. Connectivity of sensors and

actuators are shown in figure 2.8.

Figure 2.8: I/O Connectivity

M2M Gateway Configurations

M2M Gateway also has Ethernet settings and SSH-VPN settings to configure in

order to achieve successful communication between RTUs and SCADA. These

configuration details also described in the Appendix A.

2.3 Challenges Faced

2.3.1 Analyzing existing SCADA network and handling

Inter-operability issues

Before integrating the new system , it is important to analyze the existing system.

Analyzing the existing system was a bit challenging task . We had to bypass some

of the packets using our GPRS tunnel instead of leased lines or other fibre lines.

By analyzing the whole system we were able to select places where we have to

route our packets and accomplished our task.

SCADA System Integration of Satellite Substations in Colombo City 15

Page 33: final-year-project-latest

2.3. Challenges Faced EN4202 - Project

Also we had to analyze the inter-operability with the new system and the

existing system. It almost took about three to four months to fully analyze and

design the new system.

2.3.2 Communication failure due to ASDU address mis-

match

When we finished the first phase there was a communication alarm raised in every

18 seconds time. The alarm is there for 2 seconds and it appears again after

another 18 seconds .We set our common address in ICE-104 IO as 6155 and the

received address in syslog is 65535. The issue appears as per the figure ?? in the

syslog of the RTU.

Figure 2.9: ASDU Address mismatch shown in syslog of RTU

Many techniques were tried in order to solve this problem . We changed the

timeouts and increased the values. But it did not work. Finally we had to contact

the RTU manufacturers, that is Viola Systems in Finland and informed them

about the issue. They took about 2 weeks to give us a solution. Their Research

and Development department sent us a Patch file to install. After installing it we

could be able to solve the issue.

SCADA System Integration of Satellite Substations in Colombo City 16

Page 34: final-year-project-latest

2.3. Challenges Faced EN4202 - Project

2.3.3 Issues with the new RTUs

In this phase, first the communication method was changed from a leased line to

the new GPRS system with the existing Siemens RTU. We used new Viola RTU

only to communicate. All the inputs and outputs were connected to the Siemens

RTU. In the next stage our task was to completely remove the existing Siemens

RTU. When implementing that the IEC 104 I/O ports had to be configured ac-

cording to our requirement.

When we were trying to configure the IEC 104 I/O ports we noticed that the

firmware of the RTU had some issues.Because of that error message was shown as

per figure 2.10.

Figure 2.10: Error in IEC 104 I/O Ports

We had to contact Viola systems and had to do a firmware upgrade to the

RTU in order to configure the I/O ports. It was a bit difficult task and it was

done using PuTTY terminal emulator for connecting to Arctic . After that we

connected the inputs from the sensors directly to the new RTU and tested the

system and it worked well.

SCADA System Integration of Satellite Substations in Colombo City 17

Page 35: final-year-project-latest

Chapter 3

Phase II - Secondary Server

Design, Implementation and

Packet Inspection & Analysis

3.1 Introduction

As mentioned in the introduction in the phase II the main objective is to develop

and android and web based application which will help the on field technicians

and Engineers to monitor the state of the substations since they will not have

remote access to the SCADA control center.

For this, a separate system (secondary system) is implemented which will run

parallely along with the main SCADA system.

3.2 Design of the secondary system

In order to obtain this facility, the same information is provided to the SCADA

control center by each and every RTU must also be provided to this separate

system. But since there is no access to the SCADA database, obtaining the

information of the RTU status is made difficult. Since the only means of access for

the information is the raw packets communicated between the SCADA and each

RTU, a packet inspection method was proposed.

Once the packets have been captured from the main system, they should be

18

Page 36: final-year-project-latest

3.2. Design of the secondary system EN4202 - Project

Figure 3.1: Basic system block diagram

analyzed and the required information should be extracted. Then the information

is stored in a separate database which later be accessed by the Android application.

The basic system design block diagram is shown in the figure 3.1

3.2.1 Components of the secondary server

Operating System

The operating system used for the secondary server is Linux CentOS 7 64-bit

version Linux 3.10.0-229.el7.x86 64.

Figure 3.2: CentOS

Packet Analysis Application and installation

This application consists of two main components

1. Tshark for packet dissecting

SCADA System Integration of Satellite Substations in Colombo City 19

Page 37: final-year-project-latest

3.2. Design of the secondary system EN4202 - Project

2. JAVA application for data processing and database updating

Tshark is the terminal version of the Wireshark packet capturing software

(which was formally known as Ethereal). It will dissect the IEC-104 packets with

the inbuilt dissector and provide the output as a string to the JAVA applica-

tion.The Wireshark 1.10 is used in this scenario.

This string value is captured by the JAVA program and it will process it and

then the database will be updated accordingly. The JAVA program will also be

running in the LINUX server, therefore the JAVA Runtime Environment has to

be installed the linux system.In this instant the JRE 1.7.0 75 is installed.

Figure 3.3: Wireshark - Packet analyzing tool

Database Management System (DBMS)

All the captured and analyzed records are kept in this database. Android appli-

cation and the JAVA application both will query and update the database. An

open source DBMS- MySQL 5.6.24-3 is used as the DBMS in this scenario.

Figure 3.4: DBMS used

HTTP and PHP service

Both the HTTP and the PHP services are installed on the secondary server in order

to provide required services for the android application. Detailed description of

communication between the android application and these services are explained

in the Chapter 4. The installed version of the HTTP service is httpd 2.4.6-31

and the version of the PHP service is php 5.4.16-23

SCADA System Integration of Satellite Substations in Colombo City 20

Page 38: final-year-project-latest

3.2. Design of the secondary system EN4202 - Project

3.2.2 Packet capturing point identification

Once the need of the packet inspection and analysis is identified, the next require-

ment was to identifying the point where the packets should be extracted to the

secondary system. Such a point should posses the following characteristics,

• Packets from each RTU should pass through the point

• Point should be easily accessible

• Packets are needed to be readable (not encrypted)

There is only one point in the main system that possesses all these characteristics.

That is the network interface of the M2M gateway which communicates with the

SCADA system. Because, all the RTUs are handled by the M2M Gateway, the

Gateway itself decodes the packets before sending to the SCADA system and

unlike the SCADA, the Gateway is a separate server which is easily accessible.

Because of these reasons it is finalized that the packet sniffing point should be the

network interface of the M2M gateway which faces the SCADA system (eth1).

3.2.3 Packet Capturing method

Once the sniffing point is identified, next the method of capturing packets need to

be identified.

• Installing the Packet Capturing and Analysis block in the M2M Gateway

With this method Wireshark and JAVA program is installed in the M2M

Gateway they will run inside the gateway. Only the queries and updates to

the database will be sent to the secondary server.

But the issue with this method is that the M2M gateway is designed only

to run its main operation of managing the RTUs. Therefore installing other

services on a dedicated server is not recommended.

Also the Operating system of the M2M Gateway is Linux 5.6.24-3. Since

this is a very old Operating system, the newest wireshark and JAVA packages

with the iec-104 dissectors cannot be installed

SCADA System Integration of Satellite Substations in Colombo City 21

Page 39: final-year-project-latest

3.2. Design of the secondary system EN4202 - Project

• Installing Wireshark on the M2M Gateway while installing JAVA application

on the secondary server.

This method was considered if the secondary server is running with a Win-

dows operating system, because the real time packet analysis is not possible

with the Windows environment and therefore, wireshark alone should be

installed in the Gateway while filtered information is sent to the Secondary

server via SSH tunnel for the JAVA application.

Yet due to the outdated operating system of the M2M gateway this method

also is not feasible.

• Installing all the Packet Capturing and Analysis components on the Sec-

ondary server

This is considered as the best method of capturing and analyzing the packets

since the configuration of the M2M gateway does not needs to be changed.

Also the load on the Gateway is also less.

In this method the a onetime ssh tunnel is created between the M2M Gate-

way and the secondary server with the command to capture the packets of

the interface - eth1 of the M2M Gateway. The output of the tcpdump is then

stored in a fifo pipe on the secondary server and this fifo is fed to dumpcap

which is a long term packet capturing software which will make sure that

the captured packets are stored and managed in the secondary server. Once

the dumpcap stores the packets locally, periodically wireshark will analyze

the packets giving out the information to the JAVA application by using the

following commands

To dissect the single point information

tshark -r <dumcap output file> -Y 104asdu.typeid==30 -T fields -e

104asdu.cp56time -e 104asdu.addr -e 104asdu.ioa -e 104asdu.siq.spi

To dissect the double point information

tshark -r <dumcap output file> -Y 104asdu.typeid==31 -T fields -e

104asdu.cp56time -e 104asdu.addr -e 104asdu.ioa -e 104asdu.diq.dpi

Sample output of the above command is shown in the figure 3.5

SCADA System Integration of Satellite Substations in Colombo City 22

Page 40: final-year-project-latest

3.2. Design of the secondary system EN4202 - Project

Figure 3.5: Sample output of the tshark

3.2.4 Features of JAVA application

The application is the point where the tshark commands are passed to the linux

system. It will pass appropriate commands and also it will read the output as

well.

The output of the wireshark packet dissection will be given to the JAVA ap-

plication in the format given in the figure 3.5. It will break each record to its

appropriate values such as time stamp, asdu address, ioa address, and the status.

The application will receive these values under two scenarios. The first scenario

is the single point information and the second one is the double point information.

These two scenarios are processed in a sequence.

Once the required data to each field is acquired from the tshark output, then

the asdu address to substations name mapping and the alarm ioa to alarm name

mapping is loaded from the SQL query to the program. Once this information is

available, the program will update the alarm information to the alarms table in

the database.

3.2.5 Database Design

The EER diagram of the Database used in the system is given in the figure 3.6.

The JAVA application will update the alarms table whenever there is an new

alarm generated. The application will also obtain the ioa-alarm mapping and the

asdu-substation mapping from the database tables - asdu list and alarm list.

SCADA System Integration of Satellite Substations in Colombo City 23

Page 41: final-year-project-latest

3.3. Setting up the environment EN4202 - Project

Figure 3.6: EER diagram of the database

3.2.6 Connectivity to the front end

The packet capturing and the analysis is done within the network where the

SCADA system is located. But when it comes to the front end android appli-

cation, the requirement is that the application should be accessed by everyone

with the access to the Virtual Private Network (VPN) of the CEB. Therefore, the

HTTP and PHP services should be connected to the VPN as well.

For that another network interface was installed to the secondary server which

will gain access to the VPN of the CEB.

The integration of the secondary server with the SCADA system is given in

the figure 3.7

3.3 Setting up the environment

Once all the required modules has been installed in the system, each of the mod-

ules has to be initiated to ensure the packet capture and analysis is carried out

accurately. The steps that need to followed for this is given below.

SCADA System Integration of Satellite Substations in Colombo City 24

Page 42: final-year-project-latest

3.3. Setting up the environment EN4202 - Project

Figure 3.7: Secondary Server Integration

1. Create the fifo to pass the output of the ssh process to the dumpcap process

mkfifo <name and location of fifo>

2. Initiate the dumpcap process and start storing the packets captured in a

cyclic manner which will act as a buffer for tshark

dumpcap -i <path of fifo> -b duration:10 -b files:1 -w <dump

file name with location>

3. Create the ssh tunnel between the Secondary server and the M2M gateway

and pass the tcpdump command to be initiated by the M2M Gateway.

ssh <hostname or ip of remote pc> "/usr/sbin/tcpdump -s 0 -U

-n -w - -i eth1 not port 22" > <path of the fifo>

Once the connection is established the M2M Gateway will prompt a message

for the user password. Once authenticated, M2M gateway will provide the

packets via the ssh tunnel to the fifo that was created in the Secondary

server.

The packet capturing can be verified by the output of the dumpcap which

indicates the number of packets that is being captured.

SCADA System Integration of Satellite Substations in Colombo City 25

Page 43: final-year-project-latest

3.4. Procedures followed, issues faced and solutions EN4202 - Project

4. Once the remote capturing is initiated, then the JAVA application can be

run in the background.

After following these steps the back end of updating the database with the

data can be considered initiated.

3.4 Procedures followed, issues faced and solu-

tions

At the beginning of the project the knowledge the group members had on capturing

and analyzing packets were very little. Therefore a thorough study on the subject

had to be made. After analysis, there were many alternatives for the requirement

given.

In order to test each of the alternative before implementing them on actual

environment, a separate virtual environment was used. For that a LINUX sup-

ported Virtual Machine was installed with use of VMWare and tested as the M2M

Gateway.

Method I Installing tshark on the M2M Gateway and do the packet analysis

on the secondary server.

This was the first method which was tried out. The main reason to install

tshark in the M2M gateway was that the existing machine which was taken as the

secondary server was running in the Windows environment. Therefore, real-time

packet analysis was not possible on the secondary server. Therefore the idea was

to install tshark on the M2M Gateway and the packet analysis JAVA application

on the secondary server while the application runs the tshark with a command to

the M2M gateway via a ssh link. The output will be fed back to the secondary

server through the ssh link and then analyzed locally on the secondary server.

This method was successfully implemented and tested on the virtual machines.

For analysis, the packets were taken from a sample communication between the

RTU and the SCADA network previously.

The tested Virtual machine was installed with the CentOS 6.4. But the actual

M2M Gateway was operating on CentOS 5.6 environment. This was an issue on

SCADA System Integration of Satellite Substations in Colombo City 26

Page 44: final-year-project-latest

3.4. Procedures followed, issues faced and solutions EN4202 - Project

installing tshark on the actual environment. Because the tshark version which

supported the CentOS 5.6 version was only upto tshark version 1.0. But the

dissector for IEC-104 protocol was included only on tshark version 1.2 or later.

Therefore, the anticipated method for the packet analysis failed.

Method II Installing required dissectors manually

Since the tshark version which supported the Gateway did not support the

IEC-104 dissector, the next effort was to include the required dissectors externally

to the tshark version 1.0. This was tried out in two methods.

• Installing the dissector as a plugin

• Installing the dissector an inbuilt dissector

If the dissector is installed as a plugin, the software does not need to be installed

from the beginning. But if it is included as an inbuilt dissector, the software source

files, installation files etc. had to be changed as well.

Though the both methods were tried out, the both methods failed since the

source code for the IEC-104 dissector was designed for the newer version of the

tshark and it required modules which does not support older version of wireshark.

Method III Remote packet capturing with rpcap protocol

With failing both the above methods, the next option which was available

was to install tshark on secondary server and capture packets remotely. For this

the existing Windows OS environment had to be replaced with the linux system.

Therefore CentOS 7 was installed on the secondary server. Since the wireshark

supports remote packet capture with use of rpcap protocol, installing rpcap process

on the gateway was tried out. But the existing rcapd process was only compatible

with the windows environment. Therefore the process which enables the remote

packet capturing for tshark was not available for the M2M gateway.

Method IV Using fifo for remote packet capture

Eventually, tcpdump process was run on the remote server and the data was

fed to an fifo in the secondary server through a ssh link and then the packets were

SCADA System Integration of Satellite Substations in Colombo City 27

Page 45: final-year-project-latest

3.4. Procedures followed, issues faced and solutions EN4202 - Project

dumped with use of the dumpcap. This method was successful and is currently

used in the system.

3.4.1 Other issues

Internet connectivity When installing the required software applications to

the Secondary server, many other dependent repository installation was required.

If this is done manually by installing separate .rpm files, the time taken for the

installation procedure would have taken a lot of time. But as an easier method,

Yellowdog updater, modified (yum) was used so that it will automatically install

all the dependent repositories. But for that an uninterrupted internet connectivity

was required.

All the devices that is connected to the VPN is connected to the internet via a

proxy server. This server requires an authentication in order to provide access to

internet. But since the linux does not provide a login page in terminal, accessing

to the internet was not possible.

As the solution, a bypass from the proxy was requested from the CEB to the

IP address of the secondary server. After this bypass was provided uninterrupted

internet access was available for the secondary server.

Network Interface Card As mentioned in the design of the secondary server,

there were two network interface cards (NIC) required for the server. But out of

the box only one network interface was provided for the machine that was used

as the secondary server which was built on board of the machine. Therefore, a

separate NIC had to be bought and installed on the server.

At first the NIC provided by the CEB was TP Link - TF3200 and it was not

compatible with the CentOS 7 since, the NIC was a older version where the drivers

were not supported by the Operating System. Therefore a newer version had to

be bought.

Then a newer Network Interface Card - D-Link DFE-520tx was used to replace

the older one. Required drivers were available as .rpm file and once installed the

NIC was up and running to the required level.

SCADA System Integration of Satellite Substations in Colombo City 28

Page 46: final-year-project-latest

Chapter 4

Phase III - Android and Web

based Applications Development

4.1 Introduction

In modern world, most of the industries try to automate their business processes

with the use of mobile development technologies. Chief Engineer of CEB had the

vision of thinking one step ahead and make the employees of Ceylon Electricity

Board be familiarized with the latest technology. According to him, there was a

plan to give Tablet Computers to all of the engineers and field officers in CEB.

If the field officers could get alarm notifications to his mobile device in an event

of a power breakdown, it would increase the quality of service. Further, if they

are navigated to the faulty substation from the mobile device, it would reduce

the time to fix the breakdown. So in the development of our second phase of the

project, we had a great support and motive from the industry. Even though our

initial objective was to develop an Android Application, we extended our phase

with the following:

1. Android Application to view the alarms with new alarm notifications

2. Desktop Application with substation and customer information

3. Generate auto email to notify daily alarms

Android application and desktop application have similar functions. But an-

droid application is more focused on receiving live alarm notifications while desk-

29

Page 47: final-year-project-latest

4.2. Android Application EN4202 - Project

top application is used for database management. The daily email report would

enable management to get an update about the recent alarms generated. Fur-

ther it would assist them in identifying common patterns and involve in decision

making process.

Basically, four major alarms are considered in this development as per the

request of CEB. Those are the alarms that were retrieved in Phase I of the project.

They are,

1. Auxiliary Support Alarm

2. Control Alarm

3. RTU Alarm

4. Earth Fault Alarm

4.2 Android Application

Our initial requirement was to development of an Android based mobile applica-

tion to view the alarms of each substation. The basic application had two tabs to

display the substation specific alarms and its map view. Figure 4.1 and figure 4.2

show the two tabs in our project proposal.

Figure 4.1: Substation alarm Figure 4.2: Map view

SCADA System Integration of Satellite Substations in Colombo City 30

Page 48: final-year-project-latest

4.2. Android Application EN4202 - Project

Then the requirement was changed by adding further extensions. So the tab

layout was changed into slider view which is a more user friendly layout. For the

final design, the Android application consists of the following:

1. Alarms table by Substation

2. Alarms Map

3. Navigator (Substation locator)

4. Alarms History

5. Substation by Live Alarms

6. Substation by Building Name

7. Substation by Street Name

8. Substation by Zone

9. Customer by Account Number

10. Customer by Name

11. Customer by Telephone Number

12. Customer by Street Name

13. Alarm Notification Service

In the development of the application, the application should have the access to

the CEB internal network. So a VPN (Virtual Private Network) is required for the

process. CEB allowed us to use their own VPN to access their network by providing

us the credentials. So a user should have a VPN application in his mobile device in

order to run ’CEB Alarm viewer’. ’FortiClient’ is an example for freely available

VPN tool for Android devices. Only CEB staff have the access to this VPN,

therefore no separate login is required for ’CEB Alarm Viewer’ application. The

application creates a connection between the mobile device and internal network

of CEB Colombo City Control Center. A ’WebView’ is used to access the internal

network easily and efficiently. PHP scripts that are placed on the internal server

SCADA System Integration of Satellite Substations in Colombo City 31

Page 49: final-year-project-latest

4.2. Android Application EN4202 - Project

process the data and displays the output on Android application. So users access

a web page using android application. They enter their requirement and receives

the output in a web page where all the internal processes are handled by PHP

scripts. For each option in the application have separate PHP scripts stored in the

LINUX server that we have placed in the internal network of CEB. PHP scripts

are easy to handle inside the server and it allows to initiate ’MySQL’ queries

inside a PHP script. For the development, Eclipse IDE was used and entire code

is based on JAVA programming language. JAVA program creates the connection

between server and android device and PHP scripts process the data and provides

the output back to the application. Then JAVA program receives the feedback

and shows the users’ requirement. HTTPRequests in android were used to create

connection between mobile device and our secondary server placed in the Control

Center.

Basically, this phase of the project consists of the following stages:

1. Android application creates the connection between secondary server

2. PHP scripts access the database and process the required output

3. Output is sent back to the Android application

4.2.1 Alarms table by Substation

This option displays the current alarm status of a particular substation. Users

can enter the substation ID into the input box and view the substation specific

alarms. This option is important when field officers do changes in substations.

They can check the current status of the substation while work in progress. In the

past, they had to communicate with control center each and every time and check

whether alarms were generated or not. The application will display the alarms in

a table view as shown in Figure 4.3.

4.2.2 Alarms Map

This option would allow the user to filter substations by ID and alarm type and

view them on Google Maps which would give the exact point with zooming facility.

SCADA System Integration of Satellite Substations in Colombo City 32

Page 50: final-year-project-latest

4.2. Android Application EN4202 - Project

Figure 4.3: Alarms in a table view

If an field officer was asked to visit a particular substation, he could use this option

to search the relevant substation. Further, one input box is given to enter the

substation ID and alarm list is also available for filtering the required alarm. If

an engineer wants to find out all the substations which have RTU Alarm, then he

could use this option to filter all the substations and view them on Google maps

which enables engineers to identify common patterns.

In the development of this stage, we faced few challenges when getting coordi-

nates of the substations. CEB staff are using AutoCAD software to record their

substations and they have different format of coordinates. Those coordinates are

based on a reference point created by AutoCAD software. It does not have the

facility of zooming. And new streets or buildings are not updated. But we were

using general longitudes and latitudes in Google maps and latest information are

available in there. We could not recognize any one to one mapping from the co-

ordinates used by CEB. Therefore we had to manually find coordinates from the

address with the help of a technical officer. So we have to find the coordinates

manually at each time we install new substation.

4.2.3 Navigator (Substation locator)

This option is developed for the engineers and technical officers in the field. They

can enter the substation ID and view the shortest path from Control Center. This

was a requirement from CEB and they have had this navigation problem from

SCADA System Integration of Satellite Substations in Colombo City 33

Page 51: final-year-project-latest

4.2. Android Application EN4202 - Project

Figure 4.4: Alarms map

a long time. When an alarm is received, the user can navigate from the control

center even though he is not aware of the venue. Further, this option could be

developed to another level by using GPS coordinates. But the initial point was not

changed because most of the technical officers travel from the control center. As

shown in Figure 4.5, point A is the Control Center ans point B is the destination

where substation is located.

Figure 4.5: Substation locator

SCADA System Integration of Satellite Substations in Colombo City 34

Page 52: final-year-project-latest

4.2. Android Application EN4202 - Project

4.2.4 Alarms History

This option would give the users the opportunity to view the alarms generated

recently. The table view includes substation ID, type of alarms generated, occur-

rence date and occurrence time. This is very useful for the management rather

than field officers. As shown in Figure 4.6, RTU alarm and Earth Fault alarm are

changing at a rate in the particular substation. So the engineers can come to a

conclusion that this substation need to be fixed immediately.

Figure 4.6: Alarm History

4.2.5 Substation by Live Alarms

This option would give the user the opportunity to filter alarms by alarm type.

Users can view the specific alarms occurred in every substation such as auxiliary

alarm, control alarm, RTU alarm and earth fault alarm. As an example, all the

substations with RTU alarm will be displayed in Google maps if the user selects

RTU alarm as the alarm type. This option is used to fix some common errors

arising in all substations.

4.2.6 Substation by Building Name

This option would be helpful if substation ID is not remembered. So the users can

simply enter the building name and filter the alarms in that building.

SCADA System Integration of Satellite Substations in Colombo City 35

Page 53: final-year-project-latest

4.2. Android Application EN4202 - Project

Figure 4.7: Substations by live alarms

4.2.7 Substation by Street Name

This option would be used to identify the substations in a particular street. If

a specific alarm is generated in the same street, then engineers could identify a

particular faulty pattern in that area.

4.2.8 Substation by Zone

CEB has divided the substations into several zones to ease their operations. Some-

times they need to filter out the substations in a particular zone and view the

alarms of those substations. This option would be the best for that kind of anal-

ysis.

4.2.9 Customer by Account Number

CEB requires to access their customer information as well. CEB has given a

specific account number for each customer. If there is a particular need to identify

customer details filtered by their account number, users can retrieve their location

and other relevant information.

4.2.10 Customer by Name

In some instances, CEB requires to filter customer details by their name. This

option would provide this facility for the users.

SCADA System Integration of Satellite Substations in Colombo City 36

Page 54: final-year-project-latest

4.2. Android Application EN4202 - Project

Figure 4.8: Customer by account number

4.2.11 Customer by Telephone Number

In the case of a customer inquiry, there might be a need to filter customer infor-

mation by their telephone numbers.

4.2.12 Customer by Street Name

This option would enable the users to identify the customers resided in a particular

street. In a case of a power failure, users know the customers who are affecting

due to power failure.

4.2.13 Alarm Notification Service

This option would activate the alarm notification service. If the user enters into

this option, he will receive live updates of the alarms. If the user is not intended to

receive alarms, he has the option to tap ’Stop Notifications’ button and terminate

the service. Then he could use the application offline to view specific substation

details. If the user wants to receive live alarms, he could simply run the notification

service page in background which is shown in Figure 4.9. After a new alarm

is received, the user will get the notification as shown in Figure 4.10. He can

simply tap the notification and it will lead him to another page which displays

the substation location with current status of the alarms. The substation will be

displayed in Google maps and users will know exactly where the faulty substation

SCADA System Integration of Satellite Substations in Colombo City 37

Page 55: final-year-project-latest

4.2. Android Application EN4202 - Project

is located.

When the user enables the notification service, the application checks continu-

ously whether there is an active alarm in the system. The time interval is set to 10

seconds and therefore the maximum delay of a notification would be 10 seconds.

In this notification service, we got two options.

• Option 1 : After receiving a notification with sound, the user can view the

active alarm or the application will automatically generate new notifications

for every 10 seconds interval.

• Option 2 : Notification will be received once with the sound and never notify

again,

Finally, we came up with the design of setting the notification without termi-

nating. So the user will get the notifications until he view the faulty substation.

After he taps the notification, the notification service will be terminated temporar-

ily. After viewing the faulty substation, the user has the option either to turn on

notification service again or use the application offline. The idea behind this op-

tion is that, the engineers could fix the issue as soon as possible. So the probability

of missing any alarm woulld be minimized if they are reminded continuously.

Figure 4.9: Enable Notifications Figure 4.10: Notification indication

SCADA System Integration of Satellite Substations in Colombo City 38

Page 56: final-year-project-latest

4.3. Desktop Application EN4202 - Project

4.3 Desktop Application

4.3.1 Introduction

As per the requirement of the CEB, some of the functionalities in the Android

application were included in a web application in order to access through internal

network of the CEB. Then engineers can simply log in to the desktop application

and view current status of the alarms. They can access the application from a

VPN connection if they are not in the CEB premises. Further, two forms are

included in this application to update the substation and customer databases.

This is not included in the Android application because updating new entries is a

desk task rather than a field officer’s job.

4.3.2 Implementation

The web application should be accessible from the Local Area Network. So we

placed the source codes of the application in the secondary server where one net-

work card is connected to the internal network of the CEB. The application is

basically consists of PHP files which can access the MySQL database. The source

codes of the main PHP files are included in the Appendix B.

Users have to log in to the application by entering valid username and password.

This combinations are saved in the ’users’ table in ’ceb’ database. The address to

the web application as follows.

http://10.66.130.150/ceb

After entering the IP address, index.php file of the web application is loaded in

the browser. The following PHP scripts are used to restrict the unauthorized access

to the files in the web application. If someone is trying to access the application

without providing credentials, they will be directed to index.php which is the log

in page. Log in page is shown in Figure 4.11 (a).

<?php

session_start();

if (isset($_SESSION["user_name"]) && isset($_SESSION["user_id"])) {

header("location:index.php");

SCADA System Integration of Satellite Substations in Colombo City 39

Page 57: final-year-project-latest

4.3. Desktop Application EN4202 - Project

}

?>

<?php

session_start();

// Grab User submitted information

$email = $_POST["usr"];

$pass = $_POST["pword"];

if($email==’’){

echo "<script> alert(’Sorry, Username is empty, Please try again.!

Contact CEB to retrieve your credentials.. (admin)’);

window.history.back();</script>";

}

else{

// Connect to the database

$con = mysql_connect("localhost","root","root");

// Make sure we connected succesfully

if(! $con)

{

die(’Connection Failed’.mysql_error());

}

// Select the database to use

mysql_select_db("ceb",$con);

$result = mysql_query("SELECT users_email, users_pass FROM users WHERE

users_email = ’$email’");

if (!$result) { // add this check.

die(’Invalid query: ’ . mysql_error());

}

SCADA System Integration of Satellite Substations in Colombo City 40

Page 58: final-year-project-latest

4.3. Desktop Application EN4202 - Project

$row = mysql_fetch_array($result);

$_SESSION["user_name"] = $row["users_email"];

$_SESSION["user_id"] = $row["users_pass"];

if($row["users_email"]==$email && $row["users_pass"]==$pass){

header("Location:main.php");

exit;

}

else

echo "<script> alert(’Sorry, your credentials are not valid, Please

try again.!’); window.history.back();</script>";

}

?>

After logging in to the application, users have few options as shown in Figure

4.11 (b). The form which is used to update the substation details are also shown

in the Figure 4.11 (c). Further, there is another form to add customer details to

the database.

SCADA System Integration of Satellite Substations in Colombo City 41

Page 59: final-year-project-latest

4.4. Daily email report EN4202 - Project

(a) Login page

(b) Main page

(c) Add new substation

Figure 4.11: The web application

4.4 Daily email report

Alarms could be generated in the substations at any given point. Therefore, it

would be really useful for the management to get a report of live alarms generated

during a certain time period. We developed a script to generate an email at a

particular time (say 5.00pm) every day to notify the management with daily live

alarms. Sample email is shown in Figure 4.12.

For this process, CRONTAB in Linux shell was used. A free PHP mailer service

was used inside the secondary server and a PHP script is run at the particular

time we set. The command in the CRONTAB of Linux shell is as follows:

00 17 * * * /usr/bin/php -q /var/www/html/mailer/auto email.php

SCADA System Integration of Satellite Substations in Colombo City 42

Page 60: final-year-project-latest

4.4. Daily email report EN4202 - Project

Figure 4.12: Email Report

The following PHP script would generate the email at every time it runs in

the server.

<?php

require_once ’lib/swift_required.php’;

$transport = Swift_SmtpTransport::newInstance(’smtp.gmail.com’, 465,

"ssl") // enable ssl in php.ini in xampp

->setUsername(’ceb.scada’)

->setPassword(’cebscada’);

$mailer = Swift_Mailer::newInstance($transport);

$hostname_localhost ="10.66.130.150";

$database_localhost ="ceb";

$username_localhost ="root";

$password_localhost ="root";

$localhost

=mysql_connect($hostname_localhost,$username_localhost,$password_localhost)

or trigger_error(mysql_error(),E_USER_ERROR);

$body = "Hello,\r\n\r\nThis is the daily mail report of SCADA

Alarms!\r\n-------------------------------------------------------------------\r\n";

SCADA System Integration of Satellite Substations in Colombo City 43

Page 61: final-year-project-latest

4.4. Daily email report EN4202 - Project

mysql_select_db($database_localhost, $localhost);

$query_search = "select * from testing_table_01 WHERE alarm1=1 or

alarm2=1 or alarm3=1 or alarm4=1 order by rec_date desc, rec_time

desc LIMIT 20";

$query_exec = mysql_query($query_search) or die(mysql_error());

while ($line2 = mysql_fetch_array($query_exec)) {

$sub = $line2[’substation’];

$alarm1 = $line2[’alarm1’];

$alarm2 = $line2[’alarm2’];

$alarm3 = $line2[’alarm3’];

$alarm4 = $line2[’alarm4’];

$date = $line2[’rec_date’];

$time = $line2[’rec_time’];

$body .= ’Substation :’.$sub.’ Alarm 1 : ’.$alarm1.’ | Alarm 2 :

’.$alarm2.’ | Alarm 3 : ’.$alarm3.’ | Alarm 4 : ’.$alarm4.’ ||

Occurrence Date : ’.$date.’ | Occurrence Time : ’.$time.’’;

$body .="\r\n";

}

$body

.="--------------------------------------------------------------------------------------------------------------------------------------\r\n\r\n";

$body .="Legend : Alarm 1 > Auxiliary Supply Alarm, Alarm 2 > Control

Alarm, Alarm 3 > RTU Alarm, Alarm 4 > Earth Fault Alarm\r\n\r\n";

$body .="Cheers!\r\n";

$body .="Admin\r\n\r\n";

$body .="For the partial fulfilment of the project SCADA System

Integration of Distribution Substations in Colombo City. \r\n";

$body .="Contact CEB Colombo City Control Center for your

Inquires.\r\n\r\n";

$body .="This e-mail may contain confidential and/or privileged

information. If you are not the intended recipient or have

received this e-mail in error, please notify the sender immediately and

destroy this e-mail. Any unauthorised copying,disclosure

or distribution of the material in this e-mail is strictly

SCADA System Integration of Satellite Substations in Colombo City 44

Page 62: final-year-project-latest

4.4. Daily email report EN4202 - Project

forbidden..\r\n";

$message = Swift_Message::newInstance(’CEB Alarm Viewer’)

->setFrom(array(’[email protected]’ => ’Autogenerated by CEB’))

->setTo(array(’[email protected]’))

->setBody($body);

$result = $mailer->send($message);

if(!$result) {

echo "Mailer Error: " . $mailer->ErrorInfo;

} else {

echo "Message sent!";

}

?>

SCADA System Integration of Satellite Substations in Colombo City 45

Page 63: final-year-project-latest

4.5. Challenges Faced EN4202 - Project

4.5 Challenges Faced

Could not access the main SCADA network The initial objective of the

development of the Android application was to integrate all the substations in

Colombo City even the substations which are connected through leased lines. But

we could not get the permission to access the main SCADA database. Even though

we get the permission, the SCADA system was an outsourced system which was

designed such a way that we could not find a point easily to access the network.

Therefore we had to do our own packet inspection in order to generate data for

Android application. The packets sent to the SCADA system were copied and

analyzed separately to update the database in secondary server.

Updating longitudes and latitudes of the substations As mentioned in the

’Map View’ section, the coordinate system which was used by CEB was not com-

patible with our system. Therefore we had to find coordinates of the substations

manually. The coordinate system is as follows:

Substation : 0001, X-Coordinate : 262100.3, Y-Coordinate :

713100.0

VPN time-out In order to function the Android application well, the VPN

connection should be consistent. But some VPN application do not provide this

service and disconnect after a moment. So in the VPN application settings, the

connection should be made ’Always-up’.

Generating notifications At the initial stage of the development, generating

notifications was a huge issue as we tried to generate messages from the server.

Finally an alternative method was developed to check whether there is an alarm

generated in the server initiated by the mobile device rather than initiated from

server. This may consume the battery life of the Android device in a considerable

amount. Therefore, the option was given to the user to either turn on or off the

notification service as per the preference.

SCADA System Integration of Satellite Substations in Colombo City 46

Page 64: final-year-project-latest

Chapter 5

Phase IV - Experiment on

Bypassing a Power Transformer

Using a Wireless Communication

System

The main idea of carrying out this experiment is to overcome a major issue faced

in power line communication.Power line communication is a communication sys-

tem which is implemented on the existing power lines and after implementing the

system the cost of maintaining the system will be very low.That is a main advan-

tage of this system.There are a lot of experiments and research have undertaken

in this topic and our major concern limits to give a solution on how to bypass a

high voltage transformer in power line communication.

5.1 Problem Identification

In power line communication the signal can be sent through the wire until it meets

a transformer. An actual picture of a transformer used in Ceylon Electricity Board

is shown in the figure 5.1.

47

Page 65: final-year-project-latest

5.1. Problem Identification EN4202 - Project

Figure 5.1: Transformer used in CEB

The issue faced here is that there is no physical connection from on side of the

transformer to the other side. The transformer works using induced voltages from

the primary coil and the secondary coil. A diagram of a 3 phase transformer is

shown in the figure 5.2.

Figure 5.2: 3 Phase Transformer

As the per the above figure it is clear that the signal cannot be sent though

the transformer and we need to find an alternative way to bypass the signal from

the primary side to secondary side or from secondary side to the primary side.

Before moving on to a new solution to solve this problem it is important to

SCADA System Integration of Satellite Substations in Colombo City 48

Page 66: final-year-project-latest

5.2. Existing Solutions/ Literature Survey EN4202 - Project

have an idea about the existing solutions which have already been implemented

and available in the market.

5.2 Existing Solutions/ Literature Survey

5.2.1 ABB-MCD80 - Power Line Carrier Coupling Devices

Figure 5.3: ABB-MCD80

This equipment can bypass the transformer using coupling methods.The equip-

ment may cost a lot and may not feasible in Sri Lankan context for small scale

applications. It works as per figure 5.4.

Also this is a wired method and due to the complexity of the product the power

consumption is also high. If we place this product in many places in the grid the

cost will be very high .

SCADA System Integration of Satellite Substations in Colombo City 49

Page 67: final-year-project-latest

5.3. Proposed Solution EN4202 - Project

Figure 5.4: ABB-MCD80 Application

5.2.2 Other Patented Applications

There are other publications on researches carried out by different parties.

• Communication signal bypass around power line transformer.Patent Number

:4473816 - United States. This was published in 1984 and the application

uses a wired communication medium .

• Power meter bypass device and method for a power line communications

system - Patent Number: 7307510 B2 -United States.This was published

in 2005 and it is a passive devise which could bypass a signal for a meter

reading application. It uses a wired medium to bypass the signal.

5.3 Proposed Solution

Here we are concentrating on an experiment on using a wireless medium in order to

bypass a power transformer other than a wired medium.There are some advantages

in using a wireless medium compared to a wired medium.

There are a lot of induced currents and voltages because of the transformer

.By using a wireless medium those effects can be minimized and signal can be

recovered without affecting with unnecessary noises due to induced currents and

voltages.

SCADA System Integration of Satellite Substations in Colombo City 50

Page 68: final-year-project-latest

5.3. Proposed Solution EN4202 - Project

Figure 5.5: Bypassing the transformer using a wireless module

As per the above figure the transmitter and receiver pairs have been placed in

order to bypass the 11 kV - 400 V power transformer.

In the proposed solution there are mainly components.Namely;

• Power supply

• Coupling unit

• Transmitter

• Receiver

Apart from the above components , a signal amplifier can be put in place if

the received signal power is low.

Figure 5.6: Block Diagram of Proposed Solution

SCADA System Integration of Satellite Substations in Colombo City 51

Page 69: final-year-project-latest

5.4. Coupling Unit EN4202 - Project

5.4 Coupling Unit

Coupling unit has a high pass filter which filters out the required signal from

the 11 kV power line and then the signal is transmitted to the receiver.It uses

a coupling capacitor to connect the transmitter and receiver to the high voltage

line.It provides low impedance to the carrier signal and a high impedance to the

power line.

Apart from that a wave trap is placed in series to the power line to prevent

sending the high frequency signal into the station equipment.Wave trap and the

coupling devices [2] are placed as per figure 5.7.

Figure 5.7: Line trap and coupling circuit

5.5 Transmitter and Receiver

A Zigbee [8] module is used in order to transmit the signal . Zigbee is particularly

used because it has a lesser power consumption compared to other wireless meth-

ods and because of the easiness to use and handle.Some Zigbee modules have their

own processing unit itself and it very easy to implement and the space requirement

for the design is also reduced .

Zigbee modules operate at 2.4 MHz frequency [8] and can be applied for indoor

SCADA System Integration of Satellite Substations in Colombo City 52

Page 70: final-year-project-latest

5.6. Power Supply EN4202 - Project

transformers and also for outdoor transformers .When it is used indoor,the cover-

age will be reduced due to obstacles in between the transmitter and the receiver.

In order to reduce the effects from the transformer we can place the transmitter

and receiver far from the transformer .Therefore we may need transmitters and

receivers that can communicate in far distances. There are 30 m distance devices

(XBee) and also 90 m [8] distance devices (XBee-Pro) available in the market. For

our application the most suitable one is 30 m device.

5.6 Power Supply

These Zigbee modules(XBee-Pro) [8] can be powered up by giving 2.8-3.4 V and

they consume 45 mA when transmit and 50 mA when receive mode at 3.3 V.But

there is a lot of issues when powering up this circuit.

5.6.1 Problems faced in supplying power

Interference from the power transformer

There is an interference coming from the transformer to the circuit and it can have

adverse effects like induced currents and voltages on the circuit components. That

can be eliminated or minimized if we could place the transmitter and receiver far

from the transformer as mentioned above.

Interference from 11 kV power line

There is an electromagnetic interference near a 11 kV power line. Due to this

interference we will not be able to power up the circuit using a battery.The reason

is that we there will be induced voltages and currents apart from the battery power

supply.Therefore we need to find alternative ways to power up this circuit. That

is the main challenge in this method of bypassing the transformer with a wireless

communication method.

We were able to come up with two alternative methods of overcoming this issue

.They are described in the Section 5.7.

SCADA System Integration of Satellite Substations in Colombo City 53

Page 71: final-year-project-latest

5.6. Power Supply EN4202 - Project

5.6.2 Powering up the circuit using induced voltages in 11

kV power line

There are induced voltages and currents around the 11 kV power line.This induced

voltages can be used for several applications.

Current Transformer - CT

In the current transformer a coil is wound around the power line.The coil acts as the

secondary coil .There are several types of current transformers available.Namely

, Donut type,Wound type and Bar type [6] Schematic Diagram of a CT and

Equivalent circuit is shown in the below figure 5.8 [7]

Figure 5.8: Schematic Diagram of a CT and Equivalent circuit

The current induced can be calculated as per the below equation 5.1.

IS = IP

(NP

NS

)(5.1)

Here NP = 1 because it is the power line.

Then the equation becomes;

IS = IP

(1

NS

)(5.2)

NS can be changed depending on the amount of current required for the circuit.

And the voltage can be calculated as VS = IS ×R

This shows that the voltage induced in the current transformer is directly

proportional to the current flow through the 11 kV power line .When the load

SCADA System Integration of Satellite Substations in Colombo City 54

Page 72: final-year-project-latest

5.6. Power Supply EN4202 - Project

changes in the power line the current will vary and the voltage induced for the

circuit will also get differed from time to time. This will be a major disadvantage

in using a current transformer as the power source for our circuit.

Potential Transformer - PT

Potential transformer uses the same principle as the power transformers .The volt-

age induced is directly proportional to the number of winding as per the equation

5.3.

VP

VS

=NP

NS

(5.3)

Same as the CT ,NP = 1

Therefore becomes ;

VP

VS

=1

NS

(5.4)

But there is issues in providing a constant voltage to the application .There are

a lot of research [10] going on this topic.The main idea is to provide a constant

voltage to make the system reliable

5.6.3 Powering up the circuit using a solar panel and a

battery back up

This is the second alternative method of powering up the circuit. This acts as a

hybrid solution in which both solar panel and batter back up will power up the

communication system.

SCADA System Integration of Satellite Substations in Colombo City 55

Page 73: final-year-project-latest

5.6. Power Supply EN4202 - Project

The power set up can be shown as per figure 5.9 [5].

Figure 5.9: Circuit Diagram of Solar power system with battery back up

First the power is supplied either from the solar panel through D1 Schottky

Diode or from the battery back up through D2 Schottky diode depending on the

which has the higher voltage at that particular moment [5] .

D3 diode is in place in order to ensure that the batter is also charged by the

solar panel. The battery must be charged in order to operate the circuit in the

night time and on cloudy whether .

Diodes are used to correct the human errors made by reversing either battery

or solar panel polarity . Schottky diodes are specifically used because they have

a lower potential drop across them compared to other diodes.Apart from that the

battery voltage and the solar panel output voltage must be equal at least they

must have closer values .

SCADA System Integration of Satellite Substations in Colombo City 56

Page 74: final-year-project-latest

5.7. Electrical interference around a 11 kV line EN4202 - Project

Figure 5.10: A Small Solar Panel - 3V,70 mA

For our application 3V of voltage and approximately 50 mA current is sufficient.

When deciding upon a battery we have to calculate the exact required amount

of charging capacity in order to operate at night time. If 50 mA is required for

12 hours (Assuming 12 hours of night time ) we require at least a capacity of

50mAX12h = 600mAh .But the capacity must have some spare or contingency

capacity in order to cater for unexpected extra transmissions because transmission

requires more energy than receiving .

In this method the interference effects will arise and we will have to find a

solution for that. Otherwise the required voltage and current levels cannot be

maintained .

5.7 Electrical interference around a 11 kV line

Electric power transmission systems are well known for causing interference for

most electronic equipment in the vicinity. Interference from a high tension power

transmission in urban areas can be arisen because of two main systems[4].

• Electromagnetic interference due to overhead power lines

• Electromagnetic interference due to substations

In Sri Lanka power transmission and distribution grids consists of 220 kV, 132

kV, 33 kV, 11 kV, 415 V and 230 V lines. These lines carry different amounts of

SCADA System Integration of Satellite Substations in Colombo City 57

Page 75: final-year-project-latest

5.7. Electrical interference around a 11 kV line EN4202 - Project

current through their lines at different voltage levels. Due to these AC voltages

and currents there will be electric field and a magnetic field generate around these

lines. The actual field produced by an overhead line depends on several factors

such as current, voltage, phasing, clearance, height above ground and conductor

bundle.

Due to lack of measuring equipment and restrictions on accessing high voltage

lines this project’s designs described in this section solely depend on literature

carried out by third parties.

5.7.1 Electric field

Anything which uses or carries electricity is a source of power-frequency electric

fields. The strength (or amplitude) of the electric-field depends on the voltage of

the equipment or carrier. Typical values of electric field strengths are illustrated

figure 5.12 . These typical values are also varying from one location to another.

The voltage affects the electric field directly as well as through the size of the

line. The figure 5.12 [3] illustrate electric field strengths of different power lines.

Figure 5.11: Typical electric fields of overhead lines

Electric field strength Vs distance for an 11 kV power line is shown in figure

5.12 [3]. This is for untransposed phasing with minimum ground clearance of 5.5m

which is the normal case for distribution lines.

SCADA System Integration of Satellite Substations in Colombo City 58

Page 76: final-year-project-latest

5.7. Electrical interference around a 11 kV line EN4202 - Project

Figure 5.12: Typical electric fields of overhead lines

National radiation laboratory of New Zealand has also measured and published

the electric and magnetic field recordings at an existing 33kV to 11kV substation

and in the vicinity of an existing 66kV overhead line in 2004. The summary of

those recordings [9] is shown in table 5.1.

Location Typical electric field Typical magnetic field

(Volts per meter) (Microtesla)

At perimeter of substation 50 and 100 0.4

Location Maximum electric field Maximum magnetic field

(Volts per meter) (Microtesla)

Beneath 66kV line 73.6 0.21

Table 5.1: National Radiation Laboratory Recordings

EMFS.info is also provided actual electric field for different line designs. These

values are taken under different conditions including under the line scenario. These

values are shown in the table 5.2 [3] which is provided by the EMFS.info

SCADA System Integration of Satellite Substations in Colombo City 59

Page 77: final-year-project-latest

5.7. Electrical interference around a 11 kV line EN4202 - Project

Table 5.2: Actual field values for the selected conditions

5.7.2 Magnetic field

Magnetic fields are produced by the current flowing through the power line which

depends on the load of that power line. This load varies continuously with the

demand, time of the day, social factors such as holidays therefore magnetic fields

around power lines is tended to be vary much more than a electric field.

Magnetic field in the vicinity of high voltage power lines are measured and

recorded by various organizations around the world and here those findings are

used to approximate magnetic field around 11 kV power lines in Sri Lanka. Envi-

ronmental assessment carried by the ’EnergyAustralia’ includes recording of mag-

netic field strengths generated because of overhead power lines in Botany Bay

Cable project. Those recording are illustrated [1] here in figure 5.13 for the pur-

pose of understanding.

SCADA System Integration of Satellite Substations in Colombo City 60

Page 78: final-year-project-latest

5.7. Electrical interference around a 11 kV line EN4202 - Project

Figure 5.13: Typical magnetic fields from Botany Bay Cable Project

EMFS.info also recorded their measurements of magnetic field around 11 kV

power lines with different designs which gives a good illustration[3] of typical

magnetic field.

Figure 5.14: Typical magnetic fields from EMFS.info

SCADA System Integration of Satellite Substations in Colombo City 61

Page 79: final-year-project-latest

5.7. Electrical interference around a 11 kV line EN4202 - Project

Figure 5.15: Typical magnetic fields from EMFS.info for different designs

National Radiation Laboratory of New Zealand has conducted a survey to

collect radiation data in the vicinity of electric distribution substations and high

voltage power lines. Substation measurements were taken at one-meter intervals

along a line headed from the substation away into the neighboring section.

Location Typical electric field Typical magnetic field

(meters from substation) (Volts per metre) (Microtesla)

1 99.6 0.24

5 70.2 0.11

10 41.4 0.07

15 17.3 0.05

20 8.7 0.03

1 6.1 0.03

Table 5.3: National Radiation Laboratory Recordings for distribution

substations[9]

EMFS.info also provide a table[3] with maximum and typical magnetic field

values near 11 kV power line with the distance

SCADA System Integration of Satellite Substations in Colombo City 62

Page 80: final-year-project-latest

5.8. How to overcome the electromagnetic interference EN4202 - Project

Table 5.4: Actual Magnetic field values for the selected conditions

5.8 How to overcome the electromagnetic inter-

ference

5.8.1 Estimation of impact of electric and magnetic field

This project described a wireless solution for bypassing a transformer. As de-

scribed in Section 5.3 this solution has two main components. One component

will connect to 400v side while other connects to 11 kV side. Suggested place-

ments of the components are illustrated in figure 5.16.

SCADA System Integration of Satellite Substations in Colombo City 63

Page 81: final-year-project-latest

5.8. How to overcome the electromagnetic interference EN4202 - Project

Figure 5.16: Placement of transmitter and receiver

Zigbee module can transmit signals up to 30m therefore these two components

can be placed with a maximum separation of 30 m. This 30 m range is used to place

both components further from the substation in order avoid the interference from

substation. The receiving (Rx) component ( Both components are full duplex but

here side connected to 11 kV line is mentioned as Rx while other is Tx to avoid the

confusion)most likely will be placed under the high voltage power line to minimize

the feeder cable length. Tx unit will be placed near 400V line as far as possible

from the substation and high voltage line in order to minimize the interference.

Therefore Rx unit has more susceptible to electromagnetic interference than Tx

unit. Therefore all the estimations calculate hereafter are for the Rx unit.

Estimation for the electric field and magnetic field under following assumptions:

• Unit is placed under the power line or within 1m radius from power line

• Unit is placed at least 5m further away from the substation

• Minimum clearance of 5.5m

• Untransposed phasing is used

SCADA System Integration of Satellite Substations in Colombo City 64

Page 82: final-year-project-latest

5.8. How to overcome the electromagnetic interference EN4202 - Project

Electric field

Reference Typical electric field Maximum electric field

(Volts per meter) (Volts per meter)

National Radiation Laboratory 70.2 -

of New Zealand

EMFS.info 60-80 108

Table 5.5: Electric field strengths near Rx unit

Magnetic field

For static or slowly varying magnetic fields (below about 100 kHz) the Faraday

shielding is ineffective. Therefore in addition to the metal shielding another shield

is used to overcome magnetic interference. In these case shields made of high

magnetic permeability metal alloys can be used, such as sheets of Permalloy and

Mu-Metal. These materials provide suitable paths around the shield for magnetic

field waves. A sealed enclosure is the best way to minimize impact of magnetic

field but here in this case it is impossible because feeding cables and solar panels

must be able to reach outside. Therefore a sealed enclosure with holes for above

mentioned equipment parts is taken as a best magnetic shield.

Reference Typical magnetic field Maximum magnetic field

(Microtesla) (Microtesla)

National Radiation Laboratory 0.11 -

of New Zealand

EMFS.info 2-3 3.744

Botany Bay Cable Project 1.2 -

Table 5.6: Magnetic field strengths near Rx unit

According to the references in table 5.6 it is safe to estimate electric field

strength at 1m away from power line is around 80 - 110 Volts per meter and

magnetic field strength at 1m away from power line is around 2 - 4 micro Tesla.

SCADA System Integration of Satellite Substations in Colombo City 65

Page 83: final-year-project-latest

5.8. How to overcome the electromagnetic interference EN4202 - Project

Therefore electromagnetic shielding for the device is designed by taking these

values into consideration.

5.8.2 Electromagnetic Shielding

Electric-Field Shields

A perfectly conducting enclosure that completely surrounds a given volume pre-

vents anything within that volume from electrically coupling to anything outside

that volume. Therefore a sealed enclosure made by conductive material such as

metal will shield the device from outside electric fields. But the question here is

how to choose this material and what is the minimum conductivity this material

should have in order to cancel out electric radiation. That depends on the fre-

quency or time rate-of-change of the fields. As long as charges are able to move

freely enough to reorient themselves as fast as the field changes, cancellation of

the external fields will be achieved. Since power transmission lines operate under

low frequencies such as 50 Hz almost every metal will be a suitable material. Here

Aluminum is used as a shielding material because it has a good conductivity, hard

enough to contain the device and economically feasible.

Magnetic-Field Shields

For static or slowly varying magnetic fields (below about 100 kHz) the Faraday

shielding is ineffective. Therefore in addition to the metal shielding another shield

is used to overcome magnetic interference. In these case shields made of high

magnetic permeability metal alloys can be used, such as sheets of Permalloy and

Mu-Metal. These materials provide suitable paths around the shield for magnetic

field waves. A sealed enclosure is the best way to minimize impact of magnetic

field but here in this case it is impossible because feeding cables and solar panels

must be able to reach outside. Therefore a sealed enclosure with holes for above

mentioned equipment parts is taken as a best magnetic shield.

SCADA System Integration of Satellite Substations in Colombo City 66

Page 84: final-year-project-latest

5.9. Conclusion EN4202 - Project

5.9 Conclusion

After considering all the issues faced in implementing a feasible solution,we can

come up with a design of the communication system that bypasses the power

transformer.

5.9.1 How to power up the system

In order to power up the system , the hybrid solution can be used in which a solar

panel and a battery back up is in place . The methodology have been discussed in

detail in section 5.6.3 .It is a more reliable power supply than the induced current

or voltage methods which are discussed in section 5.6.2

The reason as to why such hybrid solution has been proposed is that it will

not require any external recharging and it provides continuous operation day and

night.

5.9.2 How to overcome interference

In order to overcome the interference effects, sealed enclosures made by conductive

material such as Aluminum and Mu metal will be used as per section 5.8.2. Two

separate shields can be used for electric interference and magnetic interference

because in low frequencies such as power line frequencies Farade cages does not

provide good shielding for magnetic fields.

5.9.3 Recommended design

By integrating all the above mentioned findings we can design a solution as per

figure 5.17 .The coupling unit,power supply ,processing unit ,transmitter and re-

ceiver are clearly shown in the figure.The shielding has been put in place in order

to avoid electric and magnetic interference

SCADA System Integration of Satellite Substations in Colombo City 67

Page 85: final-year-project-latest

5.9. Conclusion EN4202 - Project

Figure 5.17: Recommended Design

External power source with electromagnetic shielding is chosen to power up

the device rather then going into a power induce method due to several reasons.

Practical implementation of power induction method is difficult because of the

environmental condition dependencies and lack of testing equipment. External

power source ( Battery) with Electromagnetic shielding to avoid DC coupling is

a reliable solution than power induction. Therefore above mentioned method is

chosen.

In conclusion , this solution is a better solution than a wired communication

method when interference effects are considered due to induced currents in wires.

This can be applied in net metering and also in smart grid applications. Whenever

there is a power transformer to bypass, we can apply the solution.

During the experiment we had to face a lot of challenges due to lack of test-

ing capabilities .Above conclusions have been mainly made on findings from the

research papers .

SCADA System Integration of Satellite Substations in Colombo City 68

Page 86: final-year-project-latest

Chapter 6

Conclusion

The project was carried out for a period of 10 months time and at the end of the

project time line the required outcomes were fulfilled successfully. Apart from the

initial requirements ,there is a lot of value added services introduced to the project

with number of novel ideas .

The project was successfully handed over to the CEB with user supportive

documentation.Currently the implemented system is available online for the use

of CEB SCADA control centre and for the CEB engineers who are accessing the

SCADA from their mobile devices.

The experiment on how to bypass a power transformer using a wireless com-

munication system was also carried out in parallel with other objectives as the

final phase of the project. Due to the lack of testing equipment ,the research was

carried out using theoretical and conceptual methodologies.

The implementation of this research on how to bypass the transformer in power

line communication systems, can be done as a seperate project.It may require a

lot of lab experiments and opmitimizations in order to come with the optimum

solution.

Apart from the technical knowledge a lot of other management and soft skills

were gained throughout this project such as team building skills,negotiation skills,

communication skills and also change management skills.

69

Page 87: final-year-project-latest

Bibliography

[1] Electric and magnetic fields - appendix e of environmental assessment - energy

australia. In THE MANITOBA HVDC RESEARCH CENTRE JOURNAL,

pages 5–6, 2012.

[2] Power line carrier communication (plcc).

http://electrical-engineering-portal.com/

power-line-carrier-communication-plcc, 2012. [Online].

[3] Electric and magnetic fields and health. http://www.emfs.info/sources/

overhead/factors/voltage/, 2015. [Online].

[4] Alasdair and Jean Philips. Power lines, substations, underground cables

and net currents. http://www.powerwatch.org.uk/library/downloads/

substations_powerlines-20100607.pdf. [Online].

[5] David Cook. Simple solar power circuit with rechargeable battery backup.

http://www.robotroom.com/Solar-Recharging.html. [Online].

[6] P.E. Darrell G. Broussard. White paper : Design and construction of constant

voltage transformer. In FGE Consumer and Industrial Specification Engineer

Series, pages 2–3, May 2008.

[7] Lisa Ruchkall Dr. Dharshana Muthumuni and Dr. Rohitha Jayasinghe. Mod-

eling current transformer (ct) saturation for detailed protection studies. In

THE MANITOBA HVDC RESEARCH CENTRE JOURNAL, pages 1–2.

Manitoba HVDC Research Centre, December 2011.

[8] Digi International Inc. Product manual v1.xex- 802.15.4 protocol. https://

70

Page 88: final-year-project-latest

Bibliography EN4202 - Project

www.sparkfun.com/datasheets/Wireless/Zigbee/XBee-Datasheet.pdf,

2009. [Online].

[9] MainPower and New Zealand National Radiation Laboratory. Electromag-

netic fields fact sheet. pages 2–3, November 2004.

[10] Wijesinghe K.C. Lucas J.R. Perera R Mendis N.N.R, Yatiyana E.M.M.B. Se-

lecting current transformers. In First International Conference on Industrial

and Information Systems, pages 40–44. IEEE, August 2006.

SCADA System Integration of Satellite Substations in Colombo City 71

Page 89: final-year-project-latest

Appendix A

Configuration User Manual of

Arctic IEC 104 Gateway and

M2M Gateway

A.1 Introduction

Figure A.1: Arctic RTU

xvi

Page 90: final-year-project-latest

A.2. Configuring the Arctic RTU EN4202 - Project

This user manual explains the procedures and configurations that have to be made

when a new RTU is added to the system. There are two 5 major configurations

have to be made.

• Configuring Arctic RTU

• Configuring M2M Gateway

• Configuring the RUGGEDCOM router by adding new static routes

• Define the new Arctic RTU in primary RTU

• Define the new RTU in the SCADA user interface

A.2 Configuring the Arctic RTU

First login to the Arctic RTU using the network cable. The IP addresses must be

matched in order to establish a connection

Figure A.2: Port Identification

SCADA System Integration of Satellite Substations in Colombo City xvii

Page 91: final-year-project-latest

A.2. Configuring the Arctic RTU EN4202 - Project

After connecting the RTU, go to the web browser and type the IP address of

the RTU.

A.2.1 Login to RTU

First the following window will appear on the screen

Figure A.3: Login Screen

Figure A.4: Prompt login details

Enter the user name and password to login to the system. By default there

will not be any password and username will be root.

A.2.2 Configuring Ethernet Settings

After login to the system first go to the “Network” tab and select “Ethernet”

SCADA System Integration of Satellite Substations in Colombo City xviii

Page 92: final-year-project-latest

A.2. Configuring the Arctic RTU EN4202 - Project

Figure A.5: Ethernet Configurations

Put any Host name. Domain name is not required.

Ethernet IP address must be set along with its subnet mask. Subnet mast

will be 255.255.255.240 . Other settings must be left unchanged as per the above

figure.

SCADA System Integration of Satellite Substations in Colombo City xix

Page 93: final-year-project-latest

A.2. Configuring the Arctic RTU EN4202 - Project

A.2.3 Configuring GPRS

Go to the GPRS tab

Figure A.6: GPRS Configurations

• GPRS enabled : Yes

• Access Point Name(GPRS) : CEBMANAGE

• PIN code: NoPin

• GPRS username : dialog

• GPRS password : dialog

• Use GPRS as default route : Enabled

SCADA System Integration of Satellite Substations in Colombo City xx

Page 94: final-year-project-latest

A.2. Configuring the Arctic RTU EN4202 - Project

A.2.4 Configuring SSH - VPN

Go to the SSH-VPN tab

Figure A.7: SSH - VPN Configurations

Primary Server IP is the M2M gateway IP .It must be always 192.168.5.2

for any Arctic RTU Remote network IP starts from 10.10.10.1 and subnet mask

is 255.255.255.248.For a new RTU we must put the next IP address available and

subnet mask is always same as above. There is a public key which is in the

M2M gateways settings. We must copy that key and paste/insert in the Primary

SCADA System Integration of Satellite Substations in Colombo City xxi

Page 95: final-year-project-latest

A.2. Configuring the Arctic RTU EN4202 - Project

Server Key section. Public key is always the following.

1024 35 12354398804627370542121 07605813436929460212414221 20535370337

6987 4203185121097 146635890208566478238 2184249610201 857049739645668857079884

0 9753049 27793051419 0181397300896576 93362743299 38752840682965653615401

772410384191216972499523229 811644421287143034419459586 2212329754043512765

8972 199858611690045318912267288 3

Also there is Local SSH public key in the RTU. This local key get differs

from each Arctic RTU to RTU. It is an identity to that particular RTU. We must

copy it and insert to M2M gateway same as this. It is a kind of a hand shake.

After making the changes Apply and Commit

A.2.5 Configuring I/O ports

Go to the Application tab and then go to IEC 104 IO tab

• IEC-104 direct IO enabled : Yes

• TCP port to listen : 2404

• Common address must be taken from the primary RTU configurations.

• Double inputs: 2

• Double inputs start address: 1

• Single inputs: 3

• Single input start address: 10

• Double outputs : 1

• Double output start address: 20

Other setting must be left as per the above figure. Apply the settings and

reboot the Arctic RTU.

If this Application tab is not available or anything mentioned as “Error”, it

indicates that the firmware has not been updated. If that is the case, firmware

must be upgraded.

SCADA System Integration of Satellite Substations in Colombo City xxii

Page 96: final-year-project-latest

A.3. Configuring M2M Gateway EN4202 - Project

Figure A.8: IEC 104 direct control IO

A.3 Configuring M2M Gateway

Figure A.9: M2M Gateway

SCADA System Integration of Satellite Substations in Colombo City xxiii

Page 97: final-year-project-latest

A.3. Configuring M2M Gateway EN4202 - Project

Change the IP of the computer and connect to the M2M gateways Login to the

system by typing the IP address and port address in the web interface

Figure A.10: Opening the web UI

It should be https://10.66.130.151:10000

Figure A.11: Login to M2M web UI

• Username: viola-adm

• Password: violam2m

Go to SSH-VPN configuration page

Figure A.12: Configuring SSH - VPN

SCADA System Integration of Satellite Substations in Colombo City xxiv

Page 98: final-year-project-latest

A.3. Configuring M2M Gateway EN4202 - Project

Figure A.13: Adding New Peer

Then the following window will appear.

• Peer name can be as per the host name in Arctic

• IP pair eg. 10.0.0.1 - 10.0.0.2, 10.0.1.1 - 10.0.1.2, 10.0.X.1 - 10.0.X.2 etc X

could be from 1-255.

After 255 devices are added next IP range would be 10.1.0.1 - 10.1.0.2,

10.1.X.1 - 10.1.X.2 etc X could be from 1-255 (10.Y.X.1 - 10.Y.X.2 where X

is from 1-255 and Y is from 1-255)

• Routing Mode Tunnel the following network

• Remote network IP: This must be set according to the Arctic RTU network

• Remote network mask 255.255.255.240

SCADA System Integration of Satellite Substations in Colombo City xxv

Page 99: final-year-project-latest

A.3. Configuring M2M Gateway EN4202 - Project

Figure A.14: Adding Peer Details

After entering the information click on Confirm After that SSH-VPN hand

shakeexchange must be done as per the below figure.

Copy the Local SSH public Key from Arctic settings and insert it in M2M

gateway peer settings.

Figure A.15: SSH Key Handshake

If the handshake is successful and all the other configurations are correctly

done, the peer must be “Ok” when a peer check has been undertaken from the

M2M Gateway

SCADA System Integration of Satellite Substations in Colombo City xxvi

Page 100: final-year-project-latest

A.4. How to Access an Arctic RTU Remotely EN4202 - Project

Figure A.16: Checking Peers

A.4 How to Access an Arctic RTU Remotely

If you have SSH connection open to M2M GW, you can do the following to reach

the Arctic’s web UI Arctic (A1) GUI via M2M Gateway (instructions for Windows)

• Download PuTTY (http://www.chiark.greenend.org.uk/ sgtatham/putty/-

download.html)

• Go to PuTTY “Change settings” context menu and select SSH Tunnels

• Enter port 8080 as “Source port”

• Enter “¡Arctic IP¿:80” to “Destination”

• Click “Add” (Keep “local” and “auto” radio buttons as they are)

• Now in Forwarded ports section, you should see Arctics IP, HTTP port and

local 8080 port,e.g. as follows: L8080 10.10.10.10:80 (your IP may vary)

• Click Apply

• Open an SSH connection to M2M GW with putty

• Open a browser and connect to http://localhost:8080 The Arctic GUI page

should open and you can access its configuration and view the syslog

SCADA System Integration of Satellite Substations in Colombo City xxvii

Page 101: final-year-project-latest

A.5. Important IP Addresses EN4202 - Project

A.5 Important IP Addresses

Table A.1: Important IP Addresses

SCADA System Integration of Satellite Substations in Colombo City xxviii

Page 102: final-year-project-latest

Appendix B

Program Codes

B.1 Code for packet analyzing java application

B.1.1 main for linux final v2.java

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import java.io.*;

import java.util.*;

public class main_for_linux_final_v2 {

public static void main(String args[]){

main_for_linux_final_v2 ml = new main_for_linux_final_v2();

String single_multiple_packets_command = "tshark -r

/root/test/dump/dump* -Y \"104asdu.typeid==30 and

frame.cap_len>77\" -T fields -e 104asdu.cp56time -e

104asdu.addr -e 104asdu.ioa -e 104asdu.siq.spi";

xxix

Page 103: final-year-project-latest

B.1. Code for packet analyzing java application EN4202 - Project

String double_multiple_packets_command = "tshark -r

/root/test/dump/dump* -Y \"104asdu.typeid==31 and

frame.cap_len>77\" -T fields -e 104asdu.cp56time -e

104asdu.addr -e 104asdu.ioa -e 104asdu.diq.dpi";

int interrupt;

while(true){

interrupt =

ml.process_and_update_multiple(single_multiple_packets_command);

interrupt =

ml.process_and_update_multiple(double_multiple_packets_command);

try {

Thread.sleep(Integer.parseInt(args[0]));

} catch(InterruptedException ie) {}

}

}

String[] date_time_divide(String tstamp)

{

String month=tstamp.substring(0, 3);

String date=tstamp.substring(4,6);

String year=tstamp.substring(8,12);

String time = tstamp.substring(13,21);

String year_month_date =

year.concat("-").concat(month).concat("-").concat(date);

String [] result = new String [2];

result[0]=year_month_date;

result[1]=time;

SCADA System Integration of Satellite Substations in Colombo City xxx

Page 104: final-year-project-latest

B.1. Code for packet analyzing java application EN4202 - Project

return result;

}

void update_db(String[] date, String[] time,int[] station, int[]

ioa, int[] status, HashMap<Integer,String> substations,

HashMap<Integer,String> alarms)

{

int size = station.length;

Connection conn = null;

Statement stmt = null;

ResultSet rs = null;

try {

Class.forName("com.mysql.jdbc.Driver").newInstance();

String connectionUrl = "jdbc:mysql://localhost:3306/ceb";

String connectionUser = "java";

String connectionPassword = "";

conn = DriverManager.getConnection(connectionUrl,

connectionUser, connectionPassword);

stmt = conn.createStatement();

boolean update=false;

String sub_station ;

for(int i=0;i<size;i++)

{

update = true;

if(update)

{

stmt.execute("insert ignore into testing_table_01

(rec_date,rec_time,substation,"+alarms.get(ioa[i])+")

SCADA System Integration of Satellite Substations in Colombo City xxxi

Page 105: final-year-project-latest

B.1. Code for packet analyzing java application EN4202 - Project

value

(str_to_date(’"+date[i]+"’,’%Y-%b-%d’),’"+time[i]+"’,’"

+substations.get(station[i]) +"’,"+status[i]+");");

System.out.println("insert ignore into testing_table_01

(rec_date,rec_time,substation,"+alarms.get(ioa[i])+")

value

(str_to_date(’"+date[i]+"’,’%Y-%b-%d’),’"+time[i]+"’,’"

+substations.get(station[i]) +"’,"+status[i]+");");

update = false;

}

}

} catch (Exception e) {

e.printStackTrace();

}

finally {

try { if (rs != null) rs.close(); } catch (SQLException e) {

e.printStackTrace(); }

try { if (stmt != null) stmt.close(); } catch (SQLException e)

{ e.printStackTrace(); }

try { if (conn != null) conn.close(); } catch (SQLException e)

{ e.printStackTrace(); }

}

}

HashMap<Integer, String> update_substations()

{

Connection conn = null;

Statement stmt = null;

ResultSet rs = null;

String value;

SCADA System Integration of Satellite Substations in Colombo City xxxii

Page 106: final-year-project-latest

B.1. Code for packet analyzing java application EN4202 - Project

HashMap<Integer,String> substations = new

HashMap<Integer,String>();

try {

Class.forName("com.mysql.jdbc.Driver").newInstance();

String connectionUrl = "jdbc:mysql://localhost:3306/ceb";

String connectionUser = "java";

String connectionPassword = "";

conn = DriverManager.getConnection(connectionUrl,

connectionUser, connectionPassword);

stmt = conn.createStatement();

rs=stmt.executeQuery("select asdu, substation from

testing_table_04;");

while(rs.next())

substations.put(Integer.parseInt(rs.getString(1)),rs.getString(2));

} catch (Exception e) {

e.printStackTrace();

}

finally {

try { if (rs != null) rs.close(); } catch (SQLException e) {

e.printStackTrace(); }

try { if (stmt != null) stmt.close(); } catch (SQLException e)

{ e.printStackTrace(); }

try { if (conn != null) conn.close(); } catch (SQLException e)

{ e.printStackTrace(); }

}

return substations;

}

SCADA System Integration of Satellite Substations in Colombo City xxxiii

Page 107: final-year-project-latest

B.1. Code for packet analyzing java application EN4202 - Project

HashMap<Integer, String> update_alarms()

{

Connection conn = null;

Statement stmt = null;

ResultSet rs = null;

HashMap<Integer,String> alarms = new HashMap<Integer,String>();

try {

Class.forName("com.mysql.jdbc.Driver").newInstance();

String connectionUrl = "jdbc:mysql://localhost:3306/ceb";

String connectionUser = "java";

String connectionPassword = "";

conn = DriverManager.getConnection(connectionUrl,

connectionUser, connectionPassword);

stmt = conn.createStatement();

rs=stmt.executeQuery("select ioa, alarms from

testing_table_05;");

while(rs.next()){

alarms.put(Integer.parseInt(rs.getString(1)),rs.getString(2));

}

} catch (Exception e) {

e.printStackTrace();

}

finally {

try { if (rs != null) rs.close(); } catch (SQLException e) {

e.printStackTrace(); }

SCADA System Integration of Satellite Substations in Colombo City xxxiv

Page 108: final-year-project-latest

B.1. Code for packet analyzing java application EN4202 - Project

try { if (stmt != null) stmt.close(); } catch (SQLException e)

{ e.printStackTrace(); }

try { if (conn != null) conn.close(); } catch (SQLException e)

{ e.printStackTrace(); }

}

return alarms;

}

ArrayList<String> packet_reader(String command) throws IOException

{

ArrayList<String> data = new ArrayList<String>();

StringBuilder st= new StringBuilder();

Process p;

data.clear();

Process proc = new ProcessBuilder("/bin/bash",

"-c",command).start();

Reader reader = new InputStreamReader(proc.getInputStream());

int ch;

while ((ch = reader.read()) != -1){

if((char) ch != ’\n’){

st.append(Character.toString((char) ch));

}

else{

data.add(st.toString());

System.out.println(st);

st.delete(0, st.length());

}

}

SCADA System Integration of Satellite Substations in Colombo City xxxv

Page 109: final-year-project-latest

B.1. Code for packet analyzing java application EN4202 - Project

reader.close();

return data;

}

int process_and_update_multiple(String command)

{

HashMap<Integer,String> substations = new

HashMap<Integer,String>();

HashMap<Integer,String> alarms = new HashMap<Integer,String>();

ArrayList<String> data = new ArrayList<String>();

try {

data=packet_reader(command);

} catch (Exception e) {}

if(data.isEmpty())

return 2;

int occurances;

int dataLength = data.size();

String[] temp;

ArrayList<Integer> stationL = new ArrayList<Integer>();

ArrayList<Integer> ioaL = new ArrayList<Integer>();

ArrayList<Integer> statusL = new ArrayList<Integer>();

ArrayList<String> tstamp_dateL = new ArrayList<String>();

ArrayList<String> tstamp_timeL = new ArrayList<String>();

String[] time_divided = new String[2];

SCADA System Integration of Satellite Substations in Colombo City xxxvi

Page 110: final-year-project-latest

B.1. Code for packet analyzing java application EN4202 - Project

for(int i=0;i<data.size();i++) // processes the tshark output

and split to appropriate variables

{

occurances =

(data.get(i).length()-data.get(i).replace(",","").length()+3)/4;

//m=(p+3)/4 m- number of packets p - number of commas

temp=data.get(i).split("\t");

temp[0]=temp[0].replace(", ", "$$");

String [] tstamp=temp[0].split(",");;

for(int k=0;k<occurances;k++){

time_divided = date_time_divide(tstamp[k]);

tstamp_dateL.add(time_divided[0]);

tstamp_timeL.add(time_divided[1]);

stationL.add(Integer.parseInt(temp[1].split(",")[k]));

ioaL.add(Integer.parseInt(temp[2].split(",")[k]));

statusL.add(Integer.parseInt(temp[3].split(",")[k]));

}

}

int[] station = buildIntArray(stationL);

int[] ioa = buildIntArray(ioaL);

int[] status = buildIntArray(statusL);

String[] tstamp_date = tstamp_dateL.toArray(new

String[tstamp_dateL.size()]);

String[] tstamp_time = tstamp_timeL.toArray(new

String[tstamp_timeL.size()]);

substations= update_substations(); //updates the substation list

with the asdu address

alarms = update_alarms();

SCADA System Integration of Satellite Substations in Colombo City xxxvii

Page 111: final-year-project-latest

B.2. Android application codes EN4202 - Project

update_db(tstamp_date,tstamp_time,station,ioa,status,substations,alarms);

return 0;

}

int[] buildIntArray(ArrayList<Integer> integers) {

int[] ints = new int[integers.size()];

for (int i=0;i<integers.size();i++)

ints[i] = integers.get(i);

return ints;

}

}

B.2 Android application codes

B.2.1 MainActivity.java

package hiran.ceb.alarms;

import hiran.ceb.alarms.adapter.NavDrawerListAdapter;

import hiran.ceb.alarms.model.NavDrawerItem;

import java.util.ArrayList;

import android.app.Activity;

import android.app.Fragment;

import android.app.FragmentManager;

import android.content.res.Configuration;

import android.content.res.TypedArray;

import android.os.Bundle;

import android.os.Handler;

SCADA System Integration of Satellite Substations in Colombo City xxxviii

Page 112: final-year-project-latest

B.2. Android application codes EN4202 - Project

import android.support.v4.app.ActionBarDrawerToggle;

import android.support.v4.widget.DrawerLayout;

import android.util.Log;

import android.view.Menu;

import android.view.MenuItem;

import android.view.View;

import android.widget.AdapterView;

import android.widget.ListView;

import android.widget.Toast;

import ceb.hiran.alarms.R;

public class MainActivity extends Activity {

private DrawerLayout mDrawerLayout;

private ListView mDrawerList;

private ActionBarDrawerToggle mDrawerToggle;

// nav drawer title

private CharSequence mDrawerTitle;

// used to store app title

private CharSequence mTitle;

// slide menu items

private String[] navMenuTitles;

private TypedArray navMenuIcons;

private ArrayList<NavDrawerItem> navDrawerItems;

private NavDrawerListAdapter adapter;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

SCADA System Integration of Satellite Substations in Colombo City xxxix

Page 113: final-year-project-latest

B.2. Android application codes EN4202 - Project

mTitle = mDrawerTitle = getTitle();

// load slide menu items

navMenuTitles =

getResources().getStringArray(R.array.nav_drawer_items);

// nav drawer icons from resources

navMenuIcons = getResources()

.obtainTypedArray(R.array.nav_drawer_icons);

mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

mDrawerList = (ListView) findViewById(R.id.list_slidermenu);

navDrawerItems = new ArrayList<NavDrawerItem>();

// adding nav drawer items to array

// Table

navDrawerItems.add(new NavDrawerItem(navMenuTitles[0],

navMenuIcons.getResourceId(0, -1)));

// Map

navDrawerItems.add(new NavDrawerItem(navMenuTitles[1],

navMenuIcons.getResourceId(1, -1)));

// Navigator

navDrawerItems.add(new NavDrawerItem(navMenuTitles[2],

navMenuIcons.getResourceId(2, -1), true, "new"));

// Alarm History

navDrawerItems.add(new NavDrawerItem(navMenuTitles[3],

navMenuIcons.getResourceId(3, -1)));

// Substation Filter

navDrawerItems.add(new NavDrawerItem(navMenuTitles[4],

navMenuIcons.getResourceId(4, -1)));

// Substation Filter

navDrawerItems.add(new NavDrawerItem(navMenuTitles[5],

navMenuIcons.getResourceId(5, -1)));

SCADA System Integration of Satellite Substations in Colombo City xl

Page 114: final-year-project-latest

B.2. Android application codes EN4202 - Project

// Substation Filter

navDrawerItems.add(new NavDrawerItem(navMenuTitles[6],

navMenuIcons.getResourceId(6, -1)));

// Substation Filter

navDrawerItems.add(new NavDrawerItem(navMenuTitles[7],

navMenuIcons.getResourceId(7, -1)));

// Customer Filter

navDrawerItems.add(new NavDrawerItem(navMenuTitles[8],

navMenuIcons.getResourceId(8, -1)));

// Customer Filter

navDrawerItems.add(new NavDrawerItem(navMenuTitles[9],

navMenuIcons.getResourceId(9, -1)));

// Customer Filter

navDrawerItems.add(new NavDrawerItem(navMenuTitles[10],

navMenuIcons.getResourceId(10, -1)));

// Customer Filter

navDrawerItems.add(new NavDrawerItem(navMenuTitles[11],

navMenuIcons.getResourceId(11, -1)));

// notification service

navDrawerItems.add(new NavDrawerItem(navMenuTitles[12],

navMenuIcons.getResourceId(12, -1), true, "new"));

// Recycle the typed array

navMenuIcons.recycle();

mDrawerList.setOnItemClickListener(new SlideMenuClickListener());

// setting the nav drawer list adapter

adapter = new NavDrawerListAdapter(getApplicationContext(),

navDrawerItems);

mDrawerList.setAdapter(adapter);

// enabling action bar app icon and behaving it as toggle button

getActionBar().setDisplayHomeAsUpEnabled(true);

getActionBar().setHomeButtonEnabled(true);

SCADA System Integration of Satellite Substations in Colombo City xli

Page 115: final-year-project-latest

B.2. Android application codes EN4202 - Project

mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,

R.drawable.ic_drawer, //nav menu toggle icon

R.string.app_name, // nav drawer open - description for

accessibility

R.string.app_name // nav drawer close - description for

accessibility

) {

public void onDrawerClosed(View view) {

getActionBar().setTitle(mTitle);

// calling onPrepareOptionsMenu() to show action bar icons

invalidateOptionsMenu();

}

public void onDrawerOpened(View drawerView) {

getActionBar().setTitle(mDrawerTitle);

// calling onPrepareOptionsMenu() to hide action bar icons

invalidateOptionsMenu();

}

};

mDrawerLayout.setDrawerListener(mDrawerToggle);

if (savedInstanceState == null) {

// on first time display view for first nav item

displayView(0);

}

}

/**

* Slide menu item click listener

* */

private class SlideMenuClickListener implements

ListView.OnItemClickListener {

@Override

SCADA System Integration of Satellite Substations in Colombo City xlii

Page 116: final-year-project-latest

B.2. Android application codes EN4202 - Project

public void onItemClick(AdapterView<?> parent, View view, int

position,

long id) {

// display view for selected nav drawer item

displayView(position);

}

}

@Override

public boolean onCreateOptionsMenu(Menu menu) {

getMenuInflater().inflate(R.menu.main, menu);

return true;

}

@Override

public boolean onOptionsItemSelected(MenuItem item) {

// toggle nav drawer on selecting action bar app icon/title

if (mDrawerToggle.onOptionsItemSelected(item)) {

return true;

}

// Handle action bar actions click

switch (item.getItemId()) {

case R.id.action_settings:

Fragment fragment = null;

fragment = new About(); // About Us

FragmentManager fragmentManager = getFragmentManager();

fragmentManager.beginTransaction()

.replace(R.id.frame_container, fragment).commit();

setTitle("About Us");

return true;

case R.id.action_settings2:

Fragment fragment2 = null;

SCADA System Integration of Satellite Substations in Colombo City xliii

Page 117: final-year-project-latest

B.2. Android application codes EN4202 - Project

fragment2 = new Contact(); // Contact Us

FragmentManager fragmentManager2 = getFragmentManager();

fragmentManager2.beginTransaction()

.replace(R.id.frame_container, fragment2).commit();

setTitle("Contact Us");

return true;

case R.id.action_settings3:

this.finish(); // fragment Exit App Button

System.exit(0);

return true;

default:

return super.onOptionsItemSelected(item);

}

}

/* *

* Called when invalidateOptionsMenu() is triggered

*/

@Override

public boolean onPrepareOptionsMenu(Menu menu) {

// if nav drawer is opened, hide the action items

boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);

menu.findItem(R.id.action_settings).setVisible(!drawerOpen);

menu.findItem(R.id.action_settings2).setVisible(!drawerOpen);

menu.findItem(R.id.action_settings3).setVisible(!drawerOpen);

return super.onPrepareOptionsMenu(menu);

}

/**

* Diplaying fragment view for selected nav drawer list item

* */

private void displayView(int position) {

SCADA System Integration of Satellite Substations in Colombo City xliv

Page 118: final-year-project-latest

B.2. Android application codes EN4202 - Project

// update the main content by replacing fragments

Fragment fragment = null;

switch (position) {

case 0:

fragment = new Substation_byID();

break;

case 1:

fragment = new Map();

break;

case 2:

fragment = new Navigate();

break;

case 3:

fragment = new Alarms_history();

break;

case 4:

fragment = new Substaion_byALARMS();

break;

case 5:

fragment = new Substation_byNAME();

break;

case 6:

fragment = new Substation_bySTREET();

break;

case 7:

fragment = new Substation_byZONE();

break;

case 8:

fragment = new Customer_byACCOUNT();

break;

case 9:

fragment = new Customer_byNAME();

break;

case 10:

SCADA System Integration of Satellite Substations in Colombo City xlv

Page 119: final-year-project-latest

B.2. Android application codes EN4202 - Project

fragment = new Customer_byTELEPHONE();

break;

case 11:

fragment = new Customer_bySTREET();

break;

case 12:

fragment = new NotificationMain();

break;

default:

break;

}

if (fragment != null) {

FragmentManager fragmentManager = getFragmentManager();

fragmentManager.beginTransaction()

.replace(R.id.frame_container, fragment).commit();

// update selected item and title, then close the drawer

mDrawerList.setItemChecked(position, true);

mDrawerList.setSelection(position);

setTitle(navMenuTitles[position]);

mDrawerLayout.closeDrawer(mDrawerList);

} else {

// error in creating fragment

Log.e("MainActivity", "Error in creating fragment");

}

}

@Override

public void setTitle(CharSequence title) {

mTitle = title;

getActionBar().setTitle(mTitle);

}

SCADA System Integration of Satellite Substations in Colombo City xlvi

Page 120: final-year-project-latest

B.2. Android application codes EN4202 - Project

/**

* When using the ActionBarDrawerToggle, you must call it during

* onPostCreate() and onConfigurationChanged()...

*/

@Override

protected void onPostCreate(Bundle savedInstanceState) {

super.onPostCreate(savedInstanceState);

// Sync the toggle state after onRestoreInstanceState has occurred.

mDrawerToggle.syncState();

}

@Override

public void onConfigurationChanged(Configuration newConfig) {

super.onConfigurationChanged(newConfig);

// Pass any configuration change to the drawer toggles

mDrawerToggle.onConfigurationChanged(newConfig);

}

private boolean doubleBackToExitPressedOnce = false;

@Override

public void onBackPressed() {

if (doubleBackToExitPressedOnce) {

super.onBackPressed();

return;

}

this.doubleBackToExitPressedOnce = true;

// set home to table view of substations

displayView(0);

// make toast

SCADA System Integration of Satellite Substations in Colombo City xlvii

Page 121: final-year-project-latest

B.2. Android application codes EN4202 - Project

Toast.makeText(this, "Please click BACK again to exit",

Toast.LENGTH_SHORT).show();

new Handler().postDelayed(new Runnable() {

@Override

public void run() {

doubleBackToExitPressedOnce=false;

}

}, 2000);

}

}

B.2.2 NotificationMain.java

package hiran.ceb.alarms;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.util.ArrayList;

import java.util.List;

import java.util.Timer;

import java.util.TimerTask;

import org.apache.http.HttpEntity;

import org.apache.http.HttpResponse;

import org.apache.http.NameValuePair;

import org.apache.http.client.HttpClient;

import org.apache.http.client.ResponseHandler;

import org.apache.http.client.entity.UrlEncodedFormEntity;

import org.apache.http.client.methods.HttpPost;

import org.apache.http.conn.ClientConnectionManager;

SCADA System Integration of Satellite Substations in Colombo City xlviii

Page 122: final-year-project-latest

B.2. Android application codes EN4202 - Project

import org.apache.http.entity.InputStreamEntity;

import org.apache.http.impl.client.BasicResponseHandler;

import org.apache.http.impl.client.DefaultHttpClient;

import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;

import org.apache.http.message.BasicNameValuePair;

import org.apache.http.params.HttpParams;

import org.apache.http.util.EntityUtils;

import android.app.Fragment;

import android.app.NotificationManager;

import android.app.PendingIntent;

import android.app.ProgressDialog;

import android.app.TaskStackBuilder;

import android.content.Context;

import android.content.Intent;

import android.net.Uri;

import android.net.http.AndroidHttpClient;

import android.os.Bundle;

import android.os.Handler;

import android.support.v4.app.NotificationCompat;

import android.util.Log;

import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup;

import android.widget.Button;

import android.widget.Toast;

import ceb.hiran.alarms.R;

public class NotificationMain extends Fragment {

private NotificationManager mNotificationManager;

private int notificationID = 100;

private int numMessages = 0;

SCADA System Integration of Satellite Substations in Colombo City xlix

Page 123: final-year-project-latest

B.2. Android application codes EN4202 - Project

private ProgressDialog progDailog;

HttpPost httppost;

StringBuffer buffer;

HttpResponse response;

HttpClient httpclient;

List<NameValuePair> nameValuePairs;

@Override

public View onCreateView(LayoutInflater inflater, ViewGroup

container,

Bundle savedInstanceState) {

View rootView = inflater.inflate(R.layout.activity_main_2,

container, false);

// progress dialog to notify that the notification service has

been started

//progDailog = ProgressDialog.show(getActivity(), "Notification

Service Started","Tap anywhere to dismiss the dialog...",

true);

//progDailog.setCancelable(true);

// make toast

Toast.makeText(getActivity(), "Notification Service has been

started!", Toast.LENGTH_SHORT).show();

Button startBtn = (Button) rootView.findViewById(R.id.start);

startBtn.setOnClickListener(new View.OnClickListener() {

public void onClick(View view) {

displayNotification();

}

});

Button cancelBtn = (Button) rootView.findViewById(R.id.cancel);

SCADA System Integration of Satellite Substations in Colombo City l

Page 124: final-year-project-latest

B.2. Android application codes EN4202 - Project

cancelBtn.setOnClickListener(new View.OnClickListener() {

public void onClick(View view) {

cancelNotification();

}

});

Button updateBtn = (Button) rootView.findViewById(R.id.update);

updateBtn.setOnClickListener(new View.OnClickListener() {

public void onClick(View view) {

updateNotification();

}

});

final Handler handler = new Handler();

Timer timer = new Timer();

TimerTask doAsynchronousTask = new TimerTask() {

@Override

public void run() {

handler.post(new Runnable() {

@SuppressWarnings("unchecked")

public void run() {

try {

getActivity().runOnUiThread(new Runnable() {

public void run() {

// tv222.setText("testing!!!");

// dialog.dismiss();

//dialog =

ProgressDialog.show(getActivity(),"",

"Validating user...", true);

new Thread(new Runnable() {

public void run() {

check_alarm();

//displayNotification();

numMessages = 0;

SCADA System Integration of Satellite Substations in Colombo City li

Page 125: final-year-project-latest

B.2. Android application codes EN4202 - Project

}

}).start();

}

});

} catch (Exception e) {

// TODO Auto-generated catch block

}

}

});

}

};

timer.schedule(doAsynchronousTask, 0, 10000);

return rootView;

}

protected void displayNotification() {

Log.i("Start", "notification");

/* Invoking the default notification service */

NotificationCompat.Builder mBuilder =

new NotificationCompat.Builder(getActivity());

mBuilder.setContentTitle("New Alarm! *CEB Alarm Viewer*");

mBuilder.setContentText("Tap here for more information!");

mBuilder.setTicker("New Alarm Alert! *CEB Alarm Viewer*");

mBuilder.setSmallIcon(R.drawable.alarm);

/* Increase notification number every time a new notification

arrives */

mBuilder.setNumber(++numMessages);

/* Sound updated by Hiran */

SCADA System Integration of Satellite Substations in Colombo City lii

Page 126: final-year-project-latest

B.2. Android application codes EN4202 - Project

Uri sound = Uri.parse("android.resource://" +

getActivity().getPackageName() + "/" +

R.drawable.rooster_alarm_cut);

mBuilder.setSound(sound);

/* Creates an explicit intent for an Activity in your app */

Intent resultIntent = new Intent(getActivity(),

AfterNotification.class);

TaskStackBuilder stackBuilder =

TaskStackBuilder.create(getActivity());

stackBuilder.addParentStack(AfterNotification.class);

/* Adds the Intent that starts the Activity to the top of the

stack */

stackBuilder.addNextIntent(resultIntent);

PendingIntent resultPendingIntent =

stackBuilder.getPendingIntent(

0,

PendingIntent.FLAG_UPDATE_CURRENT

);

mBuilder.setContentIntent(resultPendingIntent);

mNotificationManager = (NotificationManager)

getActivity().getSystemService(Context.NOTIFICATION_SERVICE);

/* notificationID allows you to update the notification later

on. */

mNotificationManager.notify(notificationID, mBuilder.build());

}

protected void cancelNotification() {

Log.i("Cancel", "notification");

SCADA System Integration of Satellite Substations in Colombo City liii

Page 127: final-year-project-latest

B.2. Android application codes EN4202 - Project

//mNotificationManager.cancel(notificationID);

getActivity().finish();

Intent intent = new Intent(getActivity(), MainActivity.class);

startActivity(intent);

//System.exit(0);

}

protected void updateNotification() {

Log.i("Update", "notification");

/* Invoking the default notification service */

NotificationCompat.Builder mBuilder =

new NotificationCompat.Builder(getActivity());

mBuilder.setContentTitle("Updated Message");

mBuilder.setContentText("Tap here for FAQ page.");

mBuilder.setTicker("Updated Message Alert!");

mBuilder.setSmallIcon(R.drawable.alarm);

/* Increase notification number every time a new notification

arrives */

mBuilder.setNumber(++numMessages);

/* Creates an explicit intent for an Activity in your app */

Intent resultIntent = new Intent(getActivity(),

NotificationView.class);

TaskStackBuilder stackBuilder =

TaskStackBuilder.create(getActivity());

stackBuilder.addParentStack(NotificationView.class);

SCADA System Integration of Satellite Substations in Colombo City liv

Page 128: final-year-project-latest

B.2. Android application codes EN4202 - Project

/* Adds the Intent that starts the Activity to the top of the

stack */

stackBuilder.addNextIntent(resultIntent);

PendingIntent resultPendingIntent =

stackBuilder.getPendingIntent(

0,

PendingIntent.FLAG_UPDATE_CURRENT

);

mBuilder.setContentIntent(resultPendingIntent);

mNotificationManager = (NotificationManager)

getActivity().getSystemService(Context.NOTIFICATION_SERVICE);

/* Update the existing notification using same notification ID

*/

mNotificationManager.notify(notificationID, mBuilder.build());

}

void check_alarm(){

HttpClient httpclient = new DefaultHttpClient();

HttpPost httppost = new

HttpPost("http://10.66.130.150/login/notification.php");

try { // Check alarm notification

HttpResponse response = httpclient.execute(httppost);

//response.getEntity().consumeContent();

final HttpEntity entity = response.getEntity();

BufferedReader buffer;

String line = null;

SCADA System Integration of Satellite Substations in Colombo City lv

Page 129: final-year-project-latest

B.2. Android application codes EN4202 - Project

try {

buffer = new BufferedReader(new

InputStreamReader(entity.getContent()), 2048);

// Read first line

line = buffer.readLine();

if(line.equals("New Alarm")) {

displayNotification();

} else {

}

} catch (IllegalStateException e1) {

} catch (IOException e1) {

}

} catch (IOException e) { // TODO Auto-generated catch block

e.printStackTrace(); }

}

// To settle error

public static DefaultHttpClient getThreadSafeClient() {

DefaultHttpClient client = new DefaultHttpClient();

ClientConnectionManager mgr = client.getConnectionManager();

HttpParams params = client.getParams();

client = new DefaultHttpClient(new

ThreadSafeClientConnManager(params,

mgr.getSchemeRegistry()), params);

return client;

}

SCADA System Integration of Satellite Substations in Colombo City lvi

Page 130: final-year-project-latest

B.2. Android application codes EN4202 - Project

////////////////////////////////////////////////////////////////////////////

}

B.2.3 substation byALARMS.java

package hiran.ceb.alarms;

import android.app.AlertDialog;

import android.app.ProgressDialog;

import android.content.DialogInterface;

import android.os.Bundle;

import android.app.Fragment;

import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup;

import android.webkit.WebView;

import android.webkit.WebViewClient;

import ceb.hiran.alarms.R;

public class Substaion_byALARMS extends Fragment {

private ProgressDialog progDailog;

@Override

public View onCreateView(LayoutInflater inflater, ViewGroup

container,

Bundle savedInstanceState) {

View rootView = inflater.inflate(R.layout.fragment_top_rated,

container, false);

SCADA System Integration of Satellite Substations in Colombo City lvii

Page 131: final-year-project-latest

B.2. Android application codes EN4202 - Project

progDailog = ProgressDialog.show(getActivity(), "Loading

Alarms","Please wait...", true);

progDailog.setCancelable(true);

final String url =

"http://10.66.130.150/ceb_android/android_database_check_02.php";

WebView wv = (WebView)rootView.findViewById(R.id.webView1);

wv.getSettings().setJavaScriptEnabled(true);

wv.getSettings().setLoadWithOverviewMode(true);

wv.getSettings().setBuiltInZoomControls(true);

wv.getSettings().setUseWideViewPort(true);

wv.setWebViewClient(new WebViewClient() {

@Override

public boolean shouldOverrideUrlLoading(WebView view, String

url) {

progDailog.show();

view.loadUrl(url);

return true;

}

@Override

public void onPageFinished(WebView view, final String url) {

progDailog.dismiss();

}

@Override

public void onReceivedError(final WebView wv, int errorCode,

String description, String failingUrl) {

SCADA System Integration of Satellite Substations in Colombo City lviii

Page 132: final-year-project-latest

B.2. Android application codes EN4202 - Project

try {

wv.stopLoading();

} catch (Exception e) {

}

try {

wv.clearView();

} catch (Exception e) {

}

if (wv.canGoBack()) {

wv.goBack();

}

wv.loadUrl("about:blank");

AlertDialog alertDialog = new

AlertDialog.Builder(getActivity()).create();

alertDialog.setTitle("Error Loading Page");

alertDialog.setMessage("No internet connection was

found!\nPlease Turn ON Mobile Data and check VPN

connection!");

alertDialog.setButton("Try Again!!", new

DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int which) {

wv.loadUrl(url);

}

});

alertDialog.show();

super.onReceivedError(wv, errorCode, description,

failingUrl);

}

});

wv.loadUrl(url);

return rootView;

}

SCADA System Integration of Satellite Substations in Colombo City lix

Page 133: final-year-project-latest

B.2. Android application codes EN4202 - Project

}

B.2.4 alarms history.php

<!DOCTYPE html>

<html>

<head>

<meta name="viewport" content="width=device-width">

<meta charset="utf-8">

<title>CEB</title>

<style>

html, body {

margin: 2px;

padding: 2px

}

</style>

<style type="text/css">

#legend {

/*background-image: -webkit-linear-gradient(top left,

#FFFFFF 0%, #00A3EF 100%);*/

background: #FFF;

border: 2px solid;

border-color: #000;

padding: 10px;

margin: 5px;

height: 100px;

width: 150px;

font-size: 12px;

font-family: Arial, sans-serif;

}

.color {

border: 1px solid;

SCADA System Integration of Satellite Substations in Colombo City lx

Page 134: final-year-project-latest

B.2. Android application codes EN4202 - Project

height: 12px;

width: 12px;

margin-right: 3px;

float: left;

}

.red {

background: #C00;

}

.yellow {

background: #FF3;

}

.green {

background: #6F0;

}

</style>

<link rel="stylesheet" href="css/animate.css"> <!-- Optional -->

<link rel="stylesheet" href="css/liquid-slider.css">

<!-- Only for the demo (not required) -->

<link

href=’http://fonts.googleapis.com/css?family=Open+Sans|Lobster’

rel=’stylesheet’ type=’text/css’>

<link rel="stylesheet"

href="http://yui.yahooapis.com/pure/0.2.0/pure-min.css">

<link rel="stylesheet" type="text/css" href="classname.css">

<?php

$con = mysql_connect("localhost", "root", "root");

$db = mysql_select_db(’ceb’);

SCADA System Integration of Satellite Substations in Colombo City lxi

Page 135: final-year-project-latest

B.2. Android application codes EN4202 - Project

?>

<script src="http://ajax.googleapis.com/ajax/libs/

jquery/1.9.1/jquery.min.js"> </script>

</head>

<body >

<?php

$db = mysql_select_db(’ceb’);

$query_Recordset7 = "select * from testing_table_01 WHERE alarm1=2 or

alarm2=2 or alarm3=1 or alarm4=1 order by rec_date desc, rec_time

desc LIMIT 20;";

$Recordset7 = mysql_query($query_Recordset7) or die(mysql_error());

?>

<table style="border:2px solid black;" width="30%" cellpadding="10"

cellspacing="0">

<tr>

<td width="20%" bgcolor="#E5E5E5"><div

align="left"><strong>Substation</strong></div></td>

<td width="10%" bgcolor="#E5E5E5"><div

align="center"><strong>Auxiliary Supply

Alarm</strong></div></td>

<td width="10%" bgcolor="#E5E5E5"><div

align="center"><strong>Control

Alarm</strong></div></td>

SCADA System Integration of Satellite Substations in Colombo City lxii

Page 136: final-year-project-latest

B.2. Android application codes EN4202 - Project

<td width="10%" bgcolor="#E5E5E5"><div

align="center"><strong>RTU Alarm</strong></div></td>

<td width="10%" bgcolor="#E5E5E5"><div

align="center"><strong>Earth Fault

Alarm</strong></div></td>

<td width="10%" bgcolor="#E5E5E5"><div

align="center"><strong>Occurrence

Date</strong></div></td>

<td width="10%" bgcolor="#E5E5E5"><div

align="center"><strong>Occurrence

Time</strong></div></td>

</tr>

<?php

$i = 1;

while ($row7 = mysql_fetch_array($Recordset7)) {

?>

<tr>

<td bgcolor="#FFFFFF"><div align="center"><?php

echo $row7[’substation’]; ?></div></td>

<?php if ($row7[’alarm1’] == "0") { ?>

<td bgcolor="#FFA500"><div

align="center"><?php echo "Disturb";

?></div></td>

<?php } else if ($row7[’alarm1’] == "1") { ?>

<td bgcolor="#00FF00"><div

align="center"><?php echo "ON";

SCADA System Integration of Satellite Substations in Colombo City lxiii

Page 137: final-year-project-latest

B.2. Android application codes EN4202 - Project

?></div></td>

<?php } else if ($row7[’alarm1’] == "2") { ?>

<td bgcolor="#FF0000"><div

align="center"><?php echo "OFF";

?></div></td>

<?php } else if ($row7[’alarm1’] == "3") { ?>

<td bgcolor="#FFA500"><div

align="center"><?php echo "Disturb";

?></div></td> <?php } ?>

<?php if ($row7[’alarm2’] == "0") { ?>

<td bgcolor="#FFA500"><div

align="center"><?php echo "Disturb";

?></div></td>

<?php } else if ($row7[’alarm2’] == "1") { ?>

<td bgcolor="#00FF00"><div

align="center"><?php echo "ON";

?></div></td>

<?php } else if ($row7[’alarm2’] == "2") { ?>

<td bgcolor="#FF0000"><div

align="center"><?php echo "OFF";

?></div></td>

<?php } else if ($row7[’alarm2’] == "3") { ?>

<td bgcolor="#FFA500"><div

align="center"><?php echo "Disturb";

?></div></td> <?php } ?>

<?php if ($row7[’alarm3’] == "1") { ?>

<td bgcolor="#FF3300"><div

align="center"><?php echo "True";

?></div></td>

<?php } else if ($row7[’alarm3’] == "0") { ?>

SCADA System Integration of Satellite Substations in Colombo City lxiv

Page 138: final-year-project-latest

B.2. Android application codes EN4202 - Project

<td bgcolor="#00FF00"><div

align="center"><?php echo "False";

?></div></td> <?php } ?>

<?php if ($row7[’alarm4’] == "1") { ?>

<td bgcolor="#FF3300"><div

align="center"><?php echo "True";

?></div></td>

<?php } else if ($row7[’alarm4’] == "0") { ?>

<td bgcolor="#00FF00"><div

align="center"><?php echo "False";

?></div></td> <?php } ?>

<td bgcolor="#FFFFFF"><div align="center"><?php

echo $row7[’rec_date’]; ?></div></td>

<td bgcolor="#FFFFFF"><div align="center"><?php echo

$row7[’rec_time’]; ?></div></td>

<?php

$i++;

}

?>

</tr>

</table>

</body>

</html>

SCADA System Integration of Satellite Substations in Colombo City lxv

Page 139: final-year-project-latest

B.2. Android application codes EN4202 - Project

B.2.5 notification.php

<?php

$hostname_localhost ="10.66.130.150";

$database_localhost ="ceb";

$username_localhost ="root";

$password_localhost ="root";

$localhost =

mysql_connect($hostname_localhost,$username_localhost,$password_localhost)

or

trigger_error(mysql_error(),E_USER_ERROR);

mysql_select_db($database_localhost, $localhost);

$query_search = "select * from testing_table_01 order by rec_date desc,

rec_time desc LIMIT 1;";

$query_exec = mysql_query($query_search) or die(mysql_error());

$rows = mysql_num_rows($query_exec);

while ($line2 = mysql_fetch_array($query_exec)) {

$sub = $line2[’substation’];

$alarm1 = $line2[’alarm1’];

$alarm2 = $line2[’alarm2’];

$alarm3 = $line2[’alarm3’];

$alarm4 = $line2[’alarm4’];

}

if($alarm1 == 2 || $alarm2 == 2 || $alarm3 == 1 || $alarm4 == 1 ) {

echo "New Alarm";

}

else {

echo "False Alarm";

}

?>

SCADA System Integration of Satellite Substations in Colombo City lxvi

Page 140: final-year-project-latest

B.2. Android application codes EN4202 - Project

B.2.6 map for notification.php

<!DOCTYPE html>

<html>

<head>

<meta name="viewport" content="width=device-width">

<meta charset="utf-8">

<title>CEB</title>

<style>

html,body, #map-canvas {

height: 100%;

width=device-width;

margin-top: 0px;

margin-bottom: 0px;

margin-left: 0px;

margin-right: 5px;

padding: 0px

}

body {

text-align:left;

background:#000000;

font-family:georgia;

font-size:22px;

text-shadow:1px 1px 1px #FFF;

}

</style>

<link rel="stylesheet" type="text/css" href="classname.css">

<script type="text/javascript"

src="https://maps.googleapis.com/maps/api/

js?v=3.exp&sensor=false"> </script>

<?php

SCADA System Integration of Satellite Substations in Colombo City lxvii

Page 141: final-year-project-latest

B.2. Android application codes EN4202 - Project

$con = mysql_connect("localhost", "root", "root");

$db = mysql_select_db(’ceb’);

?>

<script type="text/javascript">

var gmarkers = [];

function start() {

var myLatlng =

<?php

$qry22 = "select * from testing_table_01 WHERE alarm1=1 or alarm2=1 or

alarm3=1 or alarm4=1 order by rec_date, rec_time asc LIMIT 1;";

$res22 = mysql_query($qry22);

while ($line22 = mysql_fetch_array($res22)) {

$sub2 = $line22[’substation’];

}

$qry1 ="SELECT * FROM testing_table_02 WHERE substation=’$sub2’;";

$ref = mysql_query($qry1);

while ($line2 = mysql_fetch_array($ref)) {

$cell_id = $line2[’substation’];

$lat = $line2[’latitude’];

$lon = $line2[’longitude’];

echo ("new google.maps.LatLng(" . $lat . "," . $lon . ");");

}

?>

var mapOptions = {

zoom: 13,

center: myLatlng

};

SCADA System Integration of Satellite Substations in Colombo City lxviii

Page 142: final-year-project-latest

B.2. Android application codes EN4202 - Project

var map = new

google.maps.Map(document.getElementById(’map-canvas’),

mapOptions);

var jArray = [];

var jArray2 = [];

var gmarkers = [];

jArray = [<?php

$qry2 = "select * from testing_table_01 WHERE alarm1=1 or alarm2=1 or

alarm3=1 or alarm4=1 order by rec_date, rec_time asc LIMIT 1;";

$res2 = mysql_query($qry2);

$n = 1;

while ($line2 = mysql_fetch_array($res2)) {

$sub = $line2[’substation’];

$alarm1 = $line2[’alarm1’];

$alarm2 = $line2[’alarm2’];

$alarm3 = $line2[’alarm3’];

$alarm4 = $line2[’alarm4’];

$qry = "SELECT * FROM testing_table_02 WHERE substation=’$sub’;";

$res = mysql_query($qry);

while ($line = mysql_fetch_array($res)) {

$lat = $line[’latitude’];

$lon = $line[’longitude’];

}

if ($n > 1) {

echo (", [ ’" . $sub . "’, " . $lat . ", " . $lon . ", " .

$alarm1 . "," . $alarm2 . ", ’" . $alarm3 . "’,’" . $alarm4

. "’]");

SCADA System Integration of Satellite Substations in Colombo City lxix

Page 143: final-year-project-latest

B.2. Android application codes EN4202 - Project

} else {

echo ("[ ’" . $sub . "’, " . $lat . ", " . $lon . ", " . $alarm1

. "," . $alarm2 . ", ’" . $alarm3 . "’,’" . $alarm4 . "’]");

}

$n = $n + 1;

}

?>];

for (var i = 0; i < jArray.length; i++) {

var newMarker = new

google.maps.LatLng(jArray[i][1], jArray[i][2]);

//var newMarker = new google.maps.LatLng(6.883271,

79.881369);

var marker = new google.maps.Marker({

position: newMarker,

map: map,

icon: ’powersubstation.png’

});

var html = "<table>" +

"<tr><td>Substation ID: </td><td><input

type=’text’ value=" + jArray[i][0] + "

id=’name1’ class=’textbox’/> </td>

</tr>" +

"<tr><td>Alarm 01: "+ jArray[i][3] +

"&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;

</td>"+

"<td>Alarm 02: "+ jArray[i][4] + "</td></tr>"+

"<tr><td>Alarm 03: "+ jArray[i][5] +

"&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;

</td>"+

"<td>Alarm 04: "+ jArray[i][6] + "</td></tr>";

//document.getElementById("name1").value =

this.get(’title’);

SCADA System Integration of Satellite Substations in Colombo City lxx

Page 144: final-year-project-latest

B.2. Android application codes EN4202 - Project

marker[’infowindow’] = new

google.maps.InfoWindow({content: html});

google.maps.event.addListener(marker, "click",

function() {

this[’infowindow’].open(map, this);

});

gmarkers.push(marker);

}

}

google.maps.event.addDomListener(window, ’load’, start);

function goBack()

{

window.history.back()

}

</script>

</head>

<body>

<table>

<tr>

<div id="map-canvas" style="border:solid 2px #000;"></div>

</br></tr>

<tr><br>

<center>Copyright <sup>&#169;</sup> CEB Alarm Viewer, 2014 </center>

</br></tr>

</table>

</body>

</html>

SCADA System Integration of Satellite Substations in Colombo City lxxi

Page 145: final-year-project-latest

B.2. Android application codes EN4202 - Project

B.2.7 form customer account.php

<!DOCTYPE html>

<html>

<head>

<meta name="viewport" content="width=device-width">

<meta charset="utf-8">

<title>CEB Alarm Viewer</title>

<style>

html{

height: 80px;

margin: 0px;

padding: 0px

}

body {

text-align:left;

background-image: url(’substation.jpg’);

font-family:georgia;

font-size:15px;

text-shadow:0.2px 0.2px 0.2px #FFF;

}

</style>

<link rel="stylesheet" href="style.css"/>

<link rel="stylesheet" type="text/css" href="classname.css">

<link rel="shortcut icon" href="images/favicon.ico"

type="image/x-icon"/>

<script type="text/javascript"

src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/

jquery.min.js"></script>

<link rel="stylesheet" type="text/css"

href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/

themes/south-street/jquery-ui.css">

SCADA System Integration of Satellite Substations in Colombo City lxxii

Page 146: final-year-project-latest

B.2. Android application codes EN4202 - Project

<script type="text/javascript"

src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/

jquery-ui.min.js"></script>

<script type="text/javascript"

src="js/jquery.ui.datepicker.validation.js"></script>

</head>

<body>

<div style="border:dotted 0.5px #000; color:#FFFFFF; ">

<form id="form1" name="form1" method="GET"

action="data_customer_account.php" target="iframe_map" >

<tr><td><label>Select Customer Account # :

<input type="text" size="20" name="substation"

id="validBeforeDatepicker" class="textbox"/>

<br>

<label>

<input name="submit" type="submit" class="classname"

align="left" value="Load Data" />

</label>

</form>

</div>

</body>

</html

B.2.8 data customer account.php

<!DOCTYPE html>

<html>

<head>

<meta name="viewport" content="width=device-width">

SCADA System Integration of Satellite Substations in Colombo City lxxiii

Page 147: final-year-project-latest

B.2. Android application codes EN4202 - Project

<meta charset="utf-8">

<title>CEB</title>

<style>

html, body {

margin: 2px;

padding: 2px

}

</style>

<style type="text/css">

#legend {

/*background-image: -webkit-linear-gradient(top left,

#FFFFFF 0%, #00A3EF 100%);*/

background: #FFF;

border: 2px solid;

border-color: #000;

padding: 10px;

margin: 5px;

height: 100px;

width: 150px;

font-size: 12px;

font-family: Arial, sans-serif;

}

.color {

border: 1px solid;

height: 12px;

width: 12px;

margin-right: 3px;

float: left;

}

.red {

background: #C00;

SCADA System Integration of Satellite Substations in Colombo City lxxiv

Page 148: final-year-project-latest

B.2. Android application codes EN4202 - Project

}

.yellow {

background: #FF3;

}

.green {

background: #6F0;

}

</style>

<link rel="stylesheet" href="css/animate.css"> <!-- Optional -->

<link rel="stylesheet" href="css/liquid-slider.css">

<!-- Only for the demo (not required) -->

<link

href=’http://fonts.googleapis.com/css?family=Open+Sans|Lobster’

rel=’stylesheet’ type=’text/css’>

<link rel="stylesheet"

href="http://yui.yahooapis.com/pure/0.2.0/pure-min.css">

<link rel="stylesheet" type="text/css" href="classname.css">

<?php

$con = mysql_connect("localhost", "root", "root");

$db = mysql_select_db(’ceb’);

$sub = $_GET[’substation’];

?>

<!--///kml code////-->

<script type="text/javascript"

src="js/jquery-1.4.1.min.js"></script>

SCADA System Integration of Satellite Substations in Colombo City lxxv

Page 149: final-year-project-latest

B.2. Android application codes EN4202 - Project

<!--///CODE STARTS HERE//-->

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/

jquery.min.js"></script>

</head>

<body >

<?php

$db = mysql_select_db(’ceb’);

$query_Recordset7 = "SELECT * FROM testing_table_03 where account =

’$sub’";

$Recordset7 = mysql_query($query_Recordset7) or die(mysql_error());

?>

<table style="border:2px solid black;" width="30%" cellpadding="10"

cellspacing="0">

<tr>

<td width="100%" bgcolor="#E5E5E5"><div

align="center"><strong>Account

Number</strong></div></td>

<td width="100%" bgcolor="#E5E5E5"><div

align="center"><strong>Telephone

Number</strong></div></td>

<td width="100%" bgcolor="#E5E5E5"><div

align="center"><strong>Customer’s

Name</strong></div></td>

SCADA System Integration of Satellite Substations in Colombo City lxxvi

Page 150: final-year-project-latest

B.2. Android application codes EN4202 - Project

<td width="100%" bgcolor="#E5E5E5"><div

align="center"><strong>Street

Name</strong></div></td>

<td width="100%" bgcolor="#E5E5E5"><div

align="center"><strong>Zone</strong></div></td>

<td width="100%" bgcolor="#E5E5E5"><div

align="center"><strong>Longitude</strong></div></td>

<td width="100%" bgcolor="#E5E5E5"><div

align="center"><strong>Latitude</strong></div></td>

</tr>

<?php

$i = 1;

while ($row7 = mysql_fetch_array($Recordset7)) {

?>

<tr>

<td width="100%" bgcolor="#FFFFFF"><div

align="center"><?php echo $row7[’account’];

?></div></td>

<td width="100%" bgcolor="#FFFFFF"><div

align="center"><?php echo $row7[’id_num’];

?></div></td>

<td width="100%" bgcolor="#FFFFFF"><div

align="center"><?php echo $row7[’id_name’];

?></div></td>

<td width="100%" bgcolor="#FFFFFF"><div

align="center"><?php echo $row7[’id_street’];

?></div></td>

SCADA System Integration of Satellite Substations in Colombo City lxxvii

Page 151: final-year-project-latest

B.2. Android application codes EN4202 - Project

<td width="100%" bgcolor="#FFFFFF"><div

align="center"><?php echo $row7[’id_zone’];

?></div></td>

<td width="100%" bgcolor="#FFFFFF"><div

align="center"><?php echo $row7[’longitude’];

?></div></td>

<td width="100%" bgcolor="#FFFFFF"><div

align="center"><?php echo $row7[’latitude’];

?></div></td>

<?php

$i++;

}

?>

</tr>

</table>

</body>

</html>

B.2.9 map3.php

<!DOCTYPE html>

<html>

<head>

<meta name="viewport" content="width=device-width">

<meta charset="utf-8">

SCADA System Integration of Satellite Substations in Colombo City lxxviii

Page 152: final-year-project-latest

B.2. Android application codes EN4202 - Project

<title>CEB</title>

<style>

html,body, #map-canvas {

height: 100%;

width=device-width;

margin-top: 0px;

margin-bottom: 0px;

margin-left: 0px;

margin-right: 5px;

padding: 0px

}

body {

text-align:left;

background:#000000;

font-family:georgia;

font-size:22px;

text-shadow:1px 1px 1px #FFF;

}

</style>

<link rel="stylesheet" type="text/css" href="classname.css">

<script type="text/javascript"

src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false">

</script>

<?php

$con = mysql_connect("localhost", "root", "root");

$db = mysql_select_db(’ceb’);

$alarm=$_GET[’alarm’];

?>

<script type="text/javascript">

SCADA System Integration of Satellite Substations in Colombo City lxxix

Page 153: final-year-project-latest

B.2. Android application codes EN4202 - Project

var gmarkers = [];

function start() {

//alert("start");

var myLatlng = new google.maps.LatLng(6.883271,

79.881369);

var mapOptions = {

zoom: 13,

center: myLatlng

};

var map = new

google.maps.Map(document.getElementById(’map-canvas’),

mapOptions);

var jArray = [];

var jArray2 = [];

var gmarkers = [];

jArray = [<?php

if($alarm==’alarm’){

$qry2 = "SELECT * FROM testing_table_01 WHERE alarm1=1 or alarm2=1 or

alarm3=1 or alarm4=1;;";

}

else{

$qry2 = "SELECT * FROM testing_table_01 WHERE $alarm=1;";

}

$res2 = mysql_query($qry2);

$n = 1;

while ($line2 = mysql_fetch_array($res2)) {

$sub = $line2[’substation’];

SCADA System Integration of Satellite Substations in Colombo City lxxx

Page 154: final-year-project-latest

B.2. Android application codes EN4202 - Project

$alarm1 = $line2[’alarm1’];

$alarm2 = $line2[’alarm2’];

$alarm3 = $line2[’alarm3’];

$alarm4 = $line2[’alarm4’];

$qry = "SELECT * FROM testing_table_02 WHERE substation=’$sub’;";

$res = mysql_query($qry);

while ($line = mysql_fetch_array($res)) {

$lat = $line[’latitude’];

$lon = $line[’longitude’];

}

if ($n > 1) {

echo (", [ ’" . $sub . "’, " . $lat . ", " . $lon . ", " .

$alarm1 . "," . $alarm2 . ", ’" . $alarm3 . "’,’" . $alarm4

. "’]");

} else {

echo ("[ ’" . $sub . "’, " . $lat . ", " . $lon . ", " . $alarm1

. "," . $alarm2 . ", ’" . $alarm3 . "’,’" . $alarm4 . "’]");

}

$n = $n + 1;

}

?>];

for (var i = 0; i < jArray.length; i++) {

var newMarker = new

google.maps.LatLng(jArray[i][1], jArray[i][2]);

//var newMarker = new google.maps.LatLng(6.883271,

79.881369);

var marker = new google.maps.Marker({

position: newMarker,

map: map,

icon: ’powersubstation.png’

SCADA System Integration of Satellite Substations in Colombo City lxxxi

Page 155: final-year-project-latest

B.2. Android application codes EN4202 - Project

});

var html = "<table>" +

"<tr><td>Substation ID: </td><td><input

type=’text’ value=" + jArray[i][0] + "

id=’name1’ class=’textbox’/> </td>

</tr>" +

"<tr><td>Alarm 01: "+ jArray[i][3] +

"&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;

</td>"+

"<td>Alarm 02: "+ jArray[i][4] + "</td></tr>"+

"<tr><td>Alarm 03: "+ jArray[i][5] +

"&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;

</td>"+

"<td>Alarm 04: "+ jArray[i][6] + "</td></tr>";

//document.getElementById("name1").value =

this.get(’title’);

marker[’infowindow’] = new

google.maps.InfoWindow({content: html});

google.maps.event.addListener(marker, "click",

function() {

this[’infowindow’].open(map, this);

});

gmarkers.push(marker);

}

}

google.maps.event.addDomListener(window, ’load’, start);

function goBack()

{

window.history.back()

SCADA System Integration of Satellite Substations in Colombo City lxxxii

Page 156: final-year-project-latest

B.2. Android application codes EN4202 - Project

}

</script>

</head>

<body>

<table>

<tr><button onclick="goBack()" class="classname2">Go

Back</button>

</tr>

</table>

<table>

<tr>

<div id="map-canvas" style="border:solid 2px #000;"></div>

</br></tr>

<tr><br>

<center>Copyright <sup>&#169;</sup> CEB Alarm Viewer, 2014 </center>

</br></tr>

</table>

</body>

</html>

B.2.10 main.php

<?php

session_start();

$name = $_SESSION["user_name"];

if ("" == $name) {

header("location:index.php");

exit();

}

?>

SCADA System Integration of Satellite Substations in Colombo City lxxxiii

Page 157: final-year-project-latest

B.2. Android application codes EN4202 - Project

<!DOCTYPE html>

<html>

<head>

<title>CEB Alarm Viewer</title>

<link href="tabmenu/tabmenu.css" rel="stylesheet" type="text/css" />

<script src="tabmenu/tabmenu.js" type="text/javascript"></script>

<link rel="shortcut icon" href="images/cebLogo_trans.gif"

type="image/x-icon"/>

<!-- Stylesheets -->

<link rel="stylesheet" href="css/style5.css">

</head>

<body style="padding:0px 20px;" >

<!-- HEADER -->

<div id="header">

<div class="page-full-width cf">

<div id="login-intro" class="fl">

<h1>CEB Colombo City - Online Portal</h1>

<h5>Created by FYP Group @ ENTC - UoM</h5>

</div> <!-- login-intro -->

</div> <!-- end full-width -->

</div> <!-- end header -->

<ul id="tabmenu">

<li>

<a href="android_database_check_01.php"

target="iframe1">Alarms Table</a>

<ul>

<li><a href="android_database_check_01.php" target="iframe1"

>Filtered by Substation</a></li>

SCADA System Integration of Satellite Substations in Colombo City lxxxiv

Page 158: final-year-project-latest

B.2. Android application codes EN4202 - Project

<li><a href="android_database_check_02.php"

target="iframe1">Filtered by Alarm Type</a></li>

</ul>

</li>

<li>

Alarms Map

<ul>

<li><a href="map_substation.php" target="iframe1">Filtered

by Substation</a></li>

<li><a href="map_alarm.php" target="iframe1">Filtered by Alarm

Type</a></li>

</ul>

</li>

<li>

<a href="navigation_main.php" target="iframe1">Navigator</a>

<ul>

<li><a href="navigation_main.php" target="iframe1"

>Substation Locator</a></li>

</ul>

</li>

<li>

<a href="alarms_history.php" target="iframe1">Alarms History</a>

</li>

<li>

<a href="substation_id.php" target="iframe1">Substation

Details</a>

<ul>

<li><a href="substation_id.php" target="iframe1">Locations

by Substation ID</a></li>

<li><a href="substation_name.php" target="iframe1">Locations by

Building Name</a></li>

<li><a href="substation_street.php" target="iframe1">Locations

by Street Name</a></li>

SCADA System Integration of Satellite Substations in Colombo City lxxxv

Page 159: final-year-project-latest

B.2. Android application codes EN4202 - Project

<li><a href="substation_zone.php" target="iframe1">Locations by

Zone</a></li>

<li><a href="substation_live_alarms.php"

target="iframe1">Locations with Live Alarms</a></li>

<li><a href="substation_geo.php" target="iframe1">Locations by

Geographical Area</a></li>

</ul>

</li>

<li>

<a href="customer_account.php" target="iframe1">Customer

Information</a>

<ul>

<li><a href="customer_account.php" target="iframe1">Filtered

by Account Number</a></li>

<li><a href="customer_telephone.php" target="iframe1">Filtered

by Telephone Number</a></li>

<li><a href="customer_name.php" target="iframe1">Filtered by

Name</a></li>

<li><a href="customer_street.php" target="iframe1">Filtered by

Street Name</a></li>

<li><a href="customer_zone.php" target="iframe1">Filtered by

zone</a></li>

</ul>

</li>

<li>

<a href="form_sub.php" target="iframe1">Update Database</a>

<ul>

<li><a href="form_sub.php" target="iframe1">Substation

Location</a></li>

<li><a href="form_customer.php" target="iframe1">Customer

Information</a></li>

</ul>

SCADA System Integration of Satellite Substations in Colombo City lxxxvi

Page 160: final-year-project-latest

B.2. Android application codes EN4202 - Project

</li>

<li>

<a href="about.html" target="iframe1">Other</a>

<ul>

<li><a href="about.html" target="iframe1">Under

Construction</a></li>

<li><a href="about.html" target="iframe1">Under

Construction</a></li>

</ul>

</li>

<li>

<a href="about.html" target="iframe1">About Us</a>

</li>

<li>

<a href="logout.php" style="color:red;">Log Out</a>

</li>

</ul>

<div style="width:100%; height:1000px; font: 0.8em Arial; color:#666;">

<iframe id="frame1" src="android_database_check_01.php"

width="100%" height="100%" vspace="0" name="iframe1"

frameborder="0"></iframe>

</div>

<!-- FOOTER -->

<div id="footer">

<p>&copy; Copyright <a> CEB Alarm Viewer, 2014</a>. All rights

reserved.</p>

</div> <!-- end footer -->

</body>

</html>

SCADA System Integration of Satellite Substations in Colombo City lxxxvii

Page 161: final-year-project-latest

B.2. Android application codes EN4202 - Project

B.2.11 index.php

<?php

session_start();

if (isset($_SESSION["user_name"]) && isset($_SESSION["user_id"])) {

header("location:main.php");

}

?>

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="utf-8">

<title>Login to CEB</title>

<!-- Stylesheets -->

<link rel="stylesheet" href="css/style3.css">

<link rel="stylesheet" href="css/style4.css">

<link rel="shortcut icon" href="images/ceb.jpg" type="image/x-icon"/>

<!-- Optimize for mobile devices -->

<meta name="viewport" content="width=device-width,

initial-scale=1.0"/>

<meta name="google-translate-customization"

content="407f1bb6144b87e6-fdff6563c0e7d9ec-ga886862366998e02-f"></meta>

</head>

<body>

<!-- HEADER -->

<div id="header">

<div class="page-full-width cf">

<div id="login-intro" class="fl">

SCADA System Integration of Satellite Substations in Colombo City lxxxviii

Page 162: final-year-project-latest

B.2. Android application codes EN4202 - Project

<h1>Login to CEB Colombo City - Online Portal</h1>

<h5>Enter your credentials below</h5>

</div> <!-- login-intro -->

<!-- Change this image to your own company’s logo -->

<!-- The logo will automatically be resized to 39px height. -->

<a href="ceb.php" class="fr"><img width="100px" height="100px"

src="images/pic_1.jpg" /></a>

</div> <!-- end full-width -->

</div> <!-- end header -->

<!-- MAIN CONTENT -->

<div id="content">

<form name="loginform" action="validate_login.php" method="post"

id="login-form">

<fieldset>

<p>

<label for="login-username">username</label>

<input type="text" id="usr" name="usr" class="round

full-width-input" autofocus />

</p>

<p>

<label for="login-password">password</label>

SCADA System Integration of Satellite Substations in Colombo City lxxxix

Page 163: final-year-project-latest

B.2. Android application codes EN4202 - Project

<input type="password" id="login-password" name="pword"

class="round full-width-input" />

</p>

<p>I’ve <a href="forgot_password.php">forgotten my

password</a>.</p>

<input type="submit" name="submit" value="Login"

class="button round blue image-right ic-right-arrow"/>

</fieldset>

<br/><div class="information-box round">Just click on the "LOG

IN" button to continue, Contact CEB for your login

details.</div>

</form>

</div> <!-- end content -->

<center>Change the language : <div

id="google_translate_element"></div></center>

<script type="text/javascript">

function googleTranslateElementInit() {

new google.translate.TranslateElement({pageLanguage: ’en’, layout:

google.translate.TranslateElement.InlineLayout.SIMPLE},

’google_translate_element’);

}

</script>

<script type="text/javascript" src="//translate.google.com/translate_a/

element.js?cb=googleTranslateElementInit"></script>

<!-- FOOTER -->

<div id="footer">

SCADA System Integration of Satellite Substations in Colombo City xc

Page 164: final-year-project-latest

B.2. Android application codes EN4202 - Project

<p>&copy; Copyright <a> CEB Alarm Viewer, 2014</a>. All rights

reserved.</p>

</div> <!-- end footer -->

</body>

</html>

SCADA System Integration of Satellite Substations in Colombo City xci