AspenTech InfoPlus 21 - How to connect and query data
Asked Answered
R

6

11

I will be given access to an AspenTech InfoPlus 21 endpoint, but the systems seems to be quite legacy and not very well (publicly) documented. I will need to query some data (i.e. explore what is in the database). I had a few questions regarding connecting and querying InfoPlus 21 historians.

  1. How can I connect to the InfoPlus 21 server (in the best case programmatically)? I am mostly using mac, can use linux and windows through a VM. Really, and ideas for working solutions are welcome.

  2. How can I query data from InfoPlus 21 (in the bet case programmatically) and what does the data look like? Any pointers etc. would be very helpful.

I have some experience using NoSQL (mongodb) and SQL (postgres and mysql) databases, but couldn't really find anything useful for aspentech infoplus 21 on the web. Any help would be greatly appreciated.

Raskind answered 3/3, 2019 at 15:23 Comment(0)
K
3

I may be responding late but i thought to share query code with Python. This Python code fetches data from Aspen IP21 with time interval of 5 minutes & considers current time minus 2 days. Obviously you may edit this code as per your requirement. But i didnt found any code which considers real time as refernece to modify your query. Hope it will help Python enthusiast-: """

import pandas as pd
import pyodbc
from datetime import datetime
from datetime import timedelta
#---- Connect to IP21
conn = pyodbc.connect("DRIVER={AspenTech SQLplus};HOST=10.XXX;PORT=10014")
#---- Query string
tag = 'TI1XXX/DACB.PV'
end = datetime.now()
start = end-timedelta (days=2)
end = end.strftime("%Y-%m-%d %H:%M:%S")
start=start.strftime("%Y-%m-%d %H:%M:%S")
sql = "select TS,VALUE from HISTORY "\
        "where NAME='%s'"\
        "and PERIOD = 300*10"\
        "and REQUEST = 2"\
        "and REQUEST=2 and TS between TIMESTAMP'%s' and TIMESTAMP'%s'" % (tag, start, end)
data = pd.read_sql(sql,conn) # Pandas DataFrame with your data!
Kenyon answered 2/6, 2020 at 3:54 Comment(1)
I've been trying to find this damned driver without success. Care to share where you downloaded it ?Aruwimi
I
9

InfoPlus21 is process historian containing list of templates of different tag structure e.g. IP_AnalogDef, IP_DescreteDef, IP_TextDef etc. Based on process tags from DCS/OPC/Any other historian, the IP21 records are created and each record acts as a table in historian.

ANS1: Aspentech software is only windows based compatibility however IP21 aspenONE Process Explorer is web based and therefore you can access it over any operating system using host url.

ANS2:

you can try SELECT statement to get data from IP21 Historian using it's end-user component SQLPlus or on excel add-ins. e.g.

SELECT NAME, IP_DESCRIPTION, IP_PLANT_AREA, IP_ENG_UNITS FROM IP_ANALOGDEF  

RESULTS: RESULT OF ABOVE QUERY

I hope this help you understand better. Otherwise you need to first learn the structure of your IP21 historian tags to build the query e.g. If it has customized structure, then you have to build your own.

Irisirisa answered 4/3, 2019 at 5:12 Comment(0)
C
6

Welcome in industrial-IT !
For these technology, the best option is the 'AspenTech SqlPlus ODBC driver'.

That been said, you are talking about an endpoint on a fairly old IP21 server, so I suppose it is something like http://.../SQLPlusWebService/SQLplusWebService.asmx.
In that case, it is the SOAP wrapper around SqlPlus: you will not have to install the Windows ODBC driver... But you will still have to learn SqlPlus syntax.

In order to have more information about it, you can ask AspenTech, also you can install the SqlPlus client 'Aspen SqlPlus', and check the help file in "C:\Program Files (x86)\AspenTech\InfoPlus.21\db21\code\ipsqlplus.chm"

EDIT: here is an example in c#, to list all records:

    static void Main(string[] args)
    {
    const string SERVER_HOST = "SERVERHOST";
    const string SERVER_URL = "http://{0}/SQLPlusWebService/SQLplusWebService.asmx";

    const string SOAP12 =
        "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
        + "<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">"
        + "<soap12:Body>"
        + "<ExecuteSQL xmlns=\"http://www.aspentech.com/SQLplus.WebService/\">"
        + "<command>{0}</command>"
        + "</ExecuteSQL>"
        + "</soap12:Body>"
        + "</soap12:Envelope>";

    const string SQLPLUS_COMMAND_ALLRECORDS =
        "SELECT * FROM all_records";

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
        string.Format(SERVER_URL, SERVER_HOST));
    // If required by the server, set the credentials.
    request.Credentials = CredentialCache.DefaultCredentials;

    request.ContentType = "application/soap+xml; charset=utf-8";
    request.Method = "POST";

    XmlDocument soapEnvelopeDocument;
    soapEnvelopeDocument = new XmlDocument();
    soapEnvelopeDocument.LoadXml(string.Format(SOAP12, SQLPLUS_COMMAND_ALLRECORDS));

    byte[] bytes;
    bytes = Encoding.UTF8.GetBytes(soapEnvelopeDocument.OuterXml);
    request.ContentLength = bytes.Length;
    using (Stream stream = request.GetRequestStream())
    {
        stream.Write(bytes, 0, bytes.Length);
    }

    // Get the response.
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    // Display the status.
    Console.WriteLine(response.StatusDescription);
    // Get the stream containing content returned by the server.
    Stream dataStream = response.GetResponseStream();
    // Open the stream using a StreamReader for easy access.
    StreamReader reader = new StreamReader(dataStream);
    // Read the content.
    string responseFromServer = reader.ReadToEnd();
    // Display the content.
    Console.WriteLine(responseFromServer);
    // Cleanup the streams and the response.
    reader.Close();
    dataStream.Close();
    response.Close();

}
Conformity answered 4/3, 2019 at 16:37 Comment(2)
hey man, do you feel like giving a more concrete example? xD I'd love to give the reps to youRaskind
Here you go: I added a c# example to call webservice. If you need an example to query data, you can replace SQLPLUS_COMMAND_ALLRECORDS by the query in the answer above, from Sami Ullah KhanConformity
C
3

You can also use the Aspentech Process Data REST Web API. There is an Aspentech native Web page with lots of samples where you can learn how to use it. The URL will be like this:

http://<your server name>/ProcessData/samples/sample_home.html

Aspentech ProcessData REST API Samples home page

If you know better the Aspentech IP21 database structure, you can use the "SQL" option in the above image. If no, I suggest you to use the the "History" option. History will allow you to query data just passing the tag name, map (useful to custom tags where you can have multiple maps) and time range. It is also available some filtering options and the request type you want to do (POST, GET, etc.). Here is an example of usage for this "History" option:

Aspen Process Data Rest API History sample

Chiclayo answered 15/5, 2019 at 18:16 Comment(0)
K
3

I may be responding late but i thought to share query code with Python. This Python code fetches data from Aspen IP21 with time interval of 5 minutes & considers current time minus 2 days. Obviously you may edit this code as per your requirement. But i didnt found any code which considers real time as refernece to modify your query. Hope it will help Python enthusiast-: """

import pandas as pd
import pyodbc
from datetime import datetime
from datetime import timedelta
#---- Connect to IP21
conn = pyodbc.connect("DRIVER={AspenTech SQLplus};HOST=10.XXX;PORT=10014")
#---- Query string
tag = 'TI1XXX/DACB.PV'
end = datetime.now()
start = end-timedelta (days=2)
end = end.strftime("%Y-%m-%d %H:%M:%S")
start=start.strftime("%Y-%m-%d %H:%M:%S")
sql = "select TS,VALUE from HISTORY "\
        "where NAME='%s'"\
        "and PERIOD = 300*10"\
        "and REQUEST = 2"\
        "and REQUEST=2 and TS between TIMESTAMP'%s' and TIMESTAMP'%s'" % (tag, start, end)
data = pd.read_sql(sql,conn) # Pandas DataFrame with your data!
Kenyon answered 2/6, 2020 at 3:54 Comment(1)
I've been trying to find this damned driver without success. Care to share where you downloaded it ?Aruwimi
U
2

If you are into the Ruby world, I have made a gem that simplifies the connection and makes you query from both SQLplus or the REST API in process explorer.

For example:

require 'ip21' # If you are using Ruby. Don't need require if you use Rails

IP21.new(
    auth: {
        account: 'john.doe',
        domain: 'contoso.com',
        password: 'set_your_own_password'
    },
    sqlplus_address: '127.0.0.1',
    ip21_address: '127.0.0.1',
).query('SELECT IP_PLANT_AREA, Name, IP_DESCRIPTION FROM IP_AnalogDef')

Then you can run normal queries to IP21, without being tied to the Windows world.

Have a look on https://github.com/rhuanbarreto/ip21-ruby

Uniflorous answered 25/3, 2021 at 8:2 Comment(0)
C
0

At our site, we install the 'AspenTech SqlPlus ODBC driver' on a SQL Server instance and create linked servers to our Aspen databases. This gives a powerful means to integrate our historical data into stored procedures we use for reporting/analysis purposes. In most cases, you must wrap the historian queries within an OPENQUERY statement, but the results retrieved can then be stored in a temporary table and manipulated or returned directly. We use this method to create SSRS reports for the entire manufacturing facility which spans multiple buildings and multiple historians and other datasources, all centralized to one SQL Server which stores very little of its own data.

Cannae answered 12/4, 2023 at 13:24 Comment(1)
Can you share where one can find this driver please ? Have searched online but no success so far and the aspen support takes too long to reply our emails.Aruwimi

© 2022 - 2024 — McMap. All rights reserved.