AspenTech InfoPlus 21-如何连接和查询数据

时间:2019-03-03 15:23:31

标签: sql sql-server historian aspen

我将获得访问AspenTech InfoPlus 21端点的权限,但是这些系统似乎很旧,并且没有(公开)记录良好。 我将需要查询一些数据(即浏览数据库中的内容)。关于连接和查询InfoPlus 21历史学家,我有几个问题。

  1. 如何连接到InfoPlus 21服务器(最好是以编程方式)?我主要使用Mac,可以通过VM使用Linux和Windows。的确,欢迎提供解决方案的想法。

  2. 如何查询InfoPlus 21中的数据(以打赌方式进行编程),数据是什么样的?任何指针等都将非常有帮助。

我在使用NoSQL(mongodb)和SQL(postgres和mysql)数据库方面有一些经验,但是在Web上找不到任何对aspentech infoplus 21有用的东西。任何帮助将不胜感激。

5 个答案:

答案 0 :(得分:6)

InfoPlus21是过程历史记录器,其中包含不同标签结构的模板列表,例如IP_AnalogDef,IP_DescreteDef,IP_TextDef等。基于DCS / OPC /任何其他历史学家的过程标签,创建IP21记录,每个记录都充当历史学家中的表。

ANS1: Aspentech软件仅基于Windows的兼容性,而IP21 aspenONE Process Explorer是基于Web的,因此您可以使用主机URL通过任何操作系统进行访问。

ANS2:

您可以尝试使用其最终用户组件SQLPlus或excel外接程序上的SELECT语句从IP21 Historian获取数据。例如

SELECT NAME, IP_DESCRIPTION, IP_PLANT_AREA, IP_ENG_UNITS FROM IP_ANALOGDEF  

结果: RESULT OF ABOVE QUERY

我希望这可以帮助您更好地理解。否则,您首先需要学习IP21历史记录器标签的结构以构建查询,例如如果它具有定制的结构,则必须构建自己的结构。

答案 1 :(得分:4)

欢迎工业IT!
对于这些技术,最好的选择是“ AspenTech SqlPlus ODBC驱动程序”。

话虽如此,您正在谈论的是相当旧的IP21服务器上的端点,所以我想它就像http://.../SQLPlusWebService/SQLplusWebService.asmx
在那种情况下,它是SqlPlus的SOAP包装器:您将不必安装Windows ODBC驱动程序...但是您仍然必须学习SqlPlus语法。

为了获得有关它的更多信息,您可以询问AspenTech,也可以安装SqlPlus客户端“ Aspen SqlPlus”,并在其中检查帮助文件。 “ C:\ Program Files(x86)\ AspenTech \ InfoPlus.21 \ db21 \ code \ ipsqlplus.chm”

编辑:这是c#中的示例,列出所有记录:

    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();

}

答案 2 :(得分:1)

我可能迟到了,但我想与Python共享查询代码。此Python代码以5分钟的时间间隔从Aspen IP21提取数据,并考虑当前时间减去2天。显然,您可以根据需要编辑此代码。但是我没有找到任何将实时视为参考的代码来修改您的查询。希望对Python爱好者有帮助: “”“

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!

答案 3 :(得分:1)

如果您进入 Ruby 世界,我已经创建了一个 gem 来简化连接并使您可以在进程资源管理器中从 SQLplus 或 REST API 进行查询。

例如:

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')

然后您就可以对 IP21 运行正常的查询,而不受 Windows 世界的束缚。

看看https://github.com/rhuanbarreto/ip21-ruby

答案 4 :(得分:0)

您还可以使用Aspentech Process Data REST Web API。有一个Aspentech原生网页,其中包含许多示例,您可以在其中学习如何使用它。该网址将如下所示:

http:///ProcessData/samples/sample_home.html

Aspentech ProcessData REST API Samples home page

如果您更好地了解了Aspentech IP21数据库结构,则可以使用上图中的“ SQL”选项。如果否,建议您使用“历史记录”选项。历史记录可让您查询仅传递标签名称,地图(对可以有多个地图的自定义标签有用)和时间范围的数据。它还提供一些过滤选项和您想要执行的请求类型(POST,GET等)。这是此“历史记录”选项的用法示例:

Aspen Process Data Rest API History sample