Methods of Integration
Download
Report
Transcript Methods of Integration
Ignition Interoperability:
Merging OT & IT
Travis Cox
Co-Director of Sales Engineering / Inductive Automation
Session Outline
•
•
•
•
•
•
•
The Need for Open Standards
Ignition as a Communications Hub
Benefits of Merging OT & IT
Common Ignition Integrations
Methods of Integration
Best Practices, Techniques, and Examples
Security
The Need for Open Standards
Why Open Standards Are Essential
S1
S1
A1
S2
A1
S2
A2
S3
A2
S3
A3
S4
Without Standards
A3
S4
With Standards
Why Open Standards Are Essential
•
•
•
•
•
Universally Known
Ensure Interoperability
Accelerate Projects
Creates Better Solutions
Save $$$
Common Open Standards
SOAP
REST
Ignition as a Communications Hub
Benefits of Merging OT & IT
•
•
•
•
•
•
•
•
•
Faster Development and Integration
Higher Quality & Quantity of Information
One Interface for Operators
More Productivity
Reduced costs
Lower Risks
Reduce Paper and Manual Data Entry
Protect Your Investment for the Future
Easier to Upgrade Pieces of the Architecture
Common Ignition Integrations: ERP
Enterprise Resource Planning
A category of business-management software typically a suite of integrated applications - that an
organization can use to collect, store, manage and
interpret data from many business activities.
Integration:
•
•
•
Web Services
IBM MQ
SQL
Common Ignition Integrations: CMMS
Computerized Maintenance
Management System
Computer software designed to simplify
maintenance management.
Integration:
•
Web Services
Common Ignition Integrations: BI
Business Intelligence & Analytics
A set of techniques and tools for the acquisition
and transformation of raw data into meaningful
and useful information for business analysis
purposes.
Integration:
•
•
•
Web Services
SQL
MQTT
Common Ignition Integrations: Machine Learning
Machine Learning
The study of pattern recognition and computational
learning theory in artificial intelligence.
Integration:
•
•
•
Web Services
SQL
MQTT
Common Ignition Integrations: DMS
Document Management System
A system (based on computer programs in the
case of the management of digital documents)
used to track, manage and store documents and
reduce paper.
Integration:
•
Web Services
Common Ignition Integrations: VSOM
Video Surveillance Operations
Manager
Configure and manage video throughout your
enterprise.
Integration:
•
Web Services
Methods of Integration: SQL
Methods of Integration: SQL
JDBC – Java Database
Connectivity Driver
API for Java that defines how a client
may access a database.
Built-in JDBC Drivers:
•
•
•
•
•
•
MySQL
Microsoft SQL Server
Oracle
PostgreSQL
IBM DB2
Firebird
JDBC to ODBC Bridge
ODBC – Open Database
Connectivity
An open standard application programming
interface (API) for accessing a database. By using
ODBC statements in a program, you can access
files in a number of different databases including:
•
•
•
Microsoft Access
Microsoft Excel
3rd Party ODBC Drivers
Free 14 Day Trial
http://www.easysoft.com
Methods of Integration: SQL
2 Methods
Direct to Database Behind 3rd
Party Application
Through a Middleware Database
Methods of Integration: SQL Permissions
Permissions dictate how Ignition can interact with the database. IT
departments are hesitant to give read / write access to their databases.
Possible Scenarios:
•
•
•
•
Read-Only
Read / Write – Must Understand Schema (not recommended)
Stored Procedures – Preferred Method
Middleware Database – Mutual Understanding of Schema
Methods of Integration: Stored Procedures
Stored Procedure
A subroutine available to applications that access
a relational database management system
(RDMS). Helpful in controlling access to data,
preserving data integrity, and improving
productivity.
•
•
•
•
•
Like a Function Call for SQL
Controls Access to Data
Preserves Data Integrity
Eliminates Understanding Schema
Improves Productivity
Where can you use Stored
Procedures in Ignition?
•
•
•
•
Property Binding
Transaction Groups
Reporting
Scripting
Stored Procedure – Property Binding
SQL Server
EXEC sp_WorkOrders 0
MySQL
CALL sp_WorkOrders(0)
Oracle
EXEC sp_WorkOrders(0)
Stored Procedure – Transaction Group
Stored Procedure – Reporting
Execute the stored
Procedure the same
way as binding
Stored Procedure - Scripting
Example #1 - Inputs
Example #2 – Inputs & Outputs
call = system.db.createSProcCall("sp_WOrkOrders")
call.registerInParam(1, system.db.INTEGER, 0)
system.db.execSProcCall(call)
results = call.getResultSet()
table = event.source.parent.getComponent("Table")
table.data = results
call = system.db.createSProcCall("sp_GetNextSeq")
call.registerInParam(1, system.db.INTEGER, 1)
call.registerOutParam(2, system.db.VARCHAR)
call.registerOutParam(3, system.db.INTEGER)
system.db.execSProcCall(call)
print call.getOutParamValue(2)
print call.getOutParamValue(3)
Middleware Database Best Practices
Things to Think About
•
•
•
•
Use Last Modified Timestamps
Use a Queue for Messaging
Create a Heartbeat
Create an Error / Audit Log
Methods of Integration: Web Services
Web Service
A software system designed to support interoperable machine-to-machine interaction over a network (HTTP
or HTTPS).
SOAP
REST
A protocol specification for exchanging structured
information in the implementation of web services
in computer networks.
Representational State Transfer (REST) is an
architectural style that specifies constraints, such
as the uniform interface, that if applied to a web
service induce desirable properties, such as
performance, scalability, and modifiability, that
enable services to work best on the Web.
Methods of Integration: Web Services
2 Methods
Ignition Calls External Web
Service
3rd Party Application Calls an
Ignition Web Service
Request
Request
HTTP
HTTP
Response
Requires
WebDev
Module
Response
Web Services – SOAP
Python suds Package
The SUDS library is a SOAP-based web services client developed for Python. It is extremely simple to use
and practically eliminates the need for the user to understand or even view the WSDL of a web service.
Example Code:
WSDL
from suds.client import Client
client = Client("http://www.w3schools.com/xml/tempconvert.asmx?WSDL")
far_value = 78
cels_value = client.service.FahrenheitToCelsius(far_value)
print cels_value
Function
to Call
Web Services – REST
Built-in Ignition System Functions
Ignition has built-in scripting functions to communicate with a REST API.
Functions:
•
•
•
•
system.net.httpGet
system.net.httpPost
system.net.httpPut
system.net.httpDelete
Web Services – REST
system.net.httpGet
Used to bring data into Ignition from a 3rd party REST API.
Example Code:
station = "KSMF"
url = "http://w1.weather.gov/xml/current_obs/%s.xml" % station
response = system.net.httpGet(url)
print response
Web Services – REST
system.net.httpPost
Used to send information to a 3rd party REST API.
url = "https://api.inductiveautomation.com/modules/add"
headers = {"Session-ID": "123456789"}
data = {"module_id": moduleID, "module_name": moduleName}
jsonData = system.util.jsonEncode(data)
try:
result = system.net.httpPost(url=url, contentType=“application/json",
postData=jsonData, headerValues=headers)
except Exception, e:
system.gui.messageBox("API call failed." + str(e))
Web Services – JSON
JSON – JavaScript Object Notation
An open-standard format that uses human-readable text to transmit data objects consisting of attribute–value
pairs. Commonly used in RESTful web services.
data = {"module_id": moduleID, "module_name": moduleName}
jsonData = system.util.jsonEncode(data)
try:
result = system.net.httpPost(url=url, contentType=“application/json",
postData=jsonData, headerValues=headers)
result = system.util.jsonDecode(result)
except Exception, e:
system.gui.messageBox("API call failed." + str(e))
Web Services – Authentication
Basic HTTP Authentication
Depends on the web service, but typically you use basic HTTP authentication to verify your identity. Ignition’s
scripting functions has this built in.
REST
system.net.httpPost(url=url, contentType=“application/json",
postData=jsonData, headerValues=headers,
username=“admin”, password=“password”)
SOAP
from suds.client import Client
client = Client(url, username=“admin”, password=“password”)
Web Services – Headers
HTTP Headers
Some web services require you to put authorization or special information in the header sent along with your
request.
REST
headers = {"Session-ID": "123456789"}
system.net.httpPost(url=url, contentType=“application/json",
postData=jsonData, headerValues=headers)
SOAP
token = client.factory.create(“AuthToken”)
token.username = “admin”
token.password = “password”
client.set_options(soapheaders=token)
Web Services – Scripting Best Practices
Define Scripting Functions
•
•
•
•
Use shared Scope – available in client and gateway
Script is updated in one place
Less error prone and easier to use
Any duplicate code should be a function!!!
Definition
def getWorkOrders(showClosed):
import system
…
return result
shared.ws.getWorkOrders(False)
Function
Call
Methods of Integration: Scripting Best Practices
•
•
•
•
Use try…except for error handling
Log errors and create alarms
If a task has to go through, use a queue
Comment code!!!
Property Binding – runScript Expression
runScript Expression Function
• Turn poll rate off
• Return proper datatype for property
• Great for tables, just remember to use
system.dataset scripting functions
• Don’t use if script takes a really long time, it
will hang the UI
Methods of Integration: WebDev
Allows you to directly program against the web server inside the Ignition
Gateway.
•
•
•
•
•
•
3rd party applications can get or send data from Ignition
HTTP Get, Post, Put, Delete, Head, Options, Trace
Supports HTTPS
Supports Basic HTTP Authentication
Supports Authentication and Role Checking
Find on downloads page under “IA Labs” tab
WebDev – Get Data
Get Information
from Ignition
A 3rd party application can
get any data from Ignition:
tag values, tag history,
alarms, etc.
Example URL:
http://192.168.1.5:8088/main/system/webdev/rest/workorders?closed=0
WebDev – Post Data
Send Information
to Ignition
A 3rd party application can
send any data to Ignition.
• Make sure to send
acknowledgement back
• Direct support for JSON
Methods of Integration: Middleware MQTT
MQTT
Message-Oriented
Middleware (MOM)
Infrastructure
MQTT Transmission
MQTT Transmission Module
Takes Ignition tag change events and publishes
them as MQTT messages to a MQTT server
(broker).
•
•
Publish any Tag (OPC, Memory, Query,
Expression)
Scripting Function to Publish Data
system.cirruslink.engine.publish
MQTT Engine
MQTT Engine Module
Quickly and easily create connections to MQTT
servers and start receiving data (subscribe).
•
•
Self-Learning Data Tags
Automatic System Health Metrics
Methods of Integration: Middleware IBM MQ
IBM MQ
IBM's Messaging solution for Enterprise and IBM's
Message Oriented Middleware offering. It allows
independent and potentially non-concurrent
applications on a distributed system to securely
communicate with each other.
Integration:
•
Web Services
Knowing Which Method
How do I know which method to use? Once I know the method, what
are the possible inputs and outputs?
•
•
•
•
•
Talk to IT
Contact Vendor
Get Connection Information and Endpoints (URLs)
Get Documentation or Programmers Guide
Understand the Inputs and Outputs
Integration Data Flow
Where do I perform the integration?
You need to ask:
•
•
•
•
•
When an operator uses the runtime?
When a tag changes or event fires?
On a schedule or timer?
Is Ignition getting it from a 3rd party application?
Is a 3rd party application getting it from Ignition?
Security
• Use TLS/SSL (HTTPS)
• Setup Proper Permissions (Read-Only, Read/Write)
• Turn on Auditing
Questions?
Thank You