Aspentech Infoplus 21 - How to Connect and Query Data

AspenTech InfoPlus 21 - How to connect and query data

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!

How to query data from an AspenTech IP21 Historian using PHP?

As asked by @DaveTheAI, I am sharing how I solve the issue here:

I was able to read data from AspenTech historians using pyODBC connector.
At first you need to make sure that you have the required ODBC drivers installed (I am using Windows). Important point here is to have compatible drivers with your python/anaconda version: 32/64 bits

After that:

import pyodbc
#---- Connect to IP21
conn = pyodbc.connect("DRIVER={AspenTech ODBC driver for Production Record Manager};HOST=hostname;PORT=port")

#---- Query string
tag = 'YOUR_TAG'
start = '2019-01-01 12:00:00'
end = '2019-01-02 12:00:00'
sql = "select TS,VALUE from HISTORY "\
"where NAME='%s'"\
"and PERIOD = 60*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!

How to query data from txt file into AspenTech IP21 Historian?

This issue is resolved by myself after multiple attempts. All i had to do is changed the txt format to below format and run the query

      A                  B
NAME VALUE
----------------------------------------

testTag 10 6 7 9

testTag2 18 15 15 19

SQLPLus Query:

local tagname char(24);
local value real;
local x,y integer;

y=2;

for x = y to 5 do

wait 00:00:05.00;

for (select line as ln from 'c:\data\Data.txt') do

tagname = substring(1 of ln between' ');

value = substring (x of ln between ' ');

UPDATE ip_analogdef SET IP_INPUT_VALUE = value,
QSTATUS(IP_INPUT_VALUE) = 'Good'
where name=tagname;

y=y+1;

end;
end;

AspenTech IP.21 Data Timezone

In AspenTech IP21 SqlPlus, every timestamps you are relevant to server timezone.
If you are only interested in UTC offset (beware, timezone is not just that), you can ask the server its current time, and do the calculation:

--something like that :
WRITE GETDBTIME;

Also, if you have right on the server, you could call a system command (check the doc for the correct syntax) to have the name of the Timezone:

SYSTEM 'tzutil /g';

Screenshot with result



Related Topics



Leave a reply



Submit