【问题标题】:AspenTech InfoPlus 21 - How to connect and query dataAspenTech InfoPlus 21 - 如何连接和查询数据
【发布时间】:2019-03-03 15:23:31
【问题描述】:

我将被授予访问 AspenTech InfoPlus 21 端点的权限,但这些系统似乎相当陈旧,而且(公开)记录得并不好。 我需要查询一些数据(即探索数据库中的内容)。我有几个关于连接和查询 InfoPlus 21 历史学家的问题。

  1. 如何连接到 InfoPlus 21 服务器(最好是以编程方式)?我主要使用mac,可以通过VM使用linux和windows。真的,欢迎提出工作解决方案的想法。

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

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

【问题讨论】:

    标签: sql sql-server historian aspen


    【解决方案1】:

    InfoPlus21 是包含不同标签结构的模板列表的进程历史数据库,例如IP_AnalogDef、IP_DescreteDef、IP_TextDef 等。基于来自 DCS/OPC/任何其他历史数据库的过程标签,创建 IP21 记录,每个记录在历史数据库中充当一个表。

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

    ANS2:

    您可以尝试使用 SELECT 语句从 IP21 Historian 获取数据,使用它的最终用户组件 SQLPlus 或在 excel 插件上。例如

    SELECT NAME, IP_DESCRIPTION, IP_PLANT_AREA, IP_ENG_UNITS FROM IP_ANALOGDEF  

    结果:

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

    【讨论】:

      【解决方案2】:

      欢迎加入工业 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();
      
      }
      

      【讨论】:

      • 嘿伙计,你想举一个更具体的例子吗? xD 我很乐意为您提供代表
      • 给你:我添加了一个c#示例来调用webservice。如果您需要查询数据的示例,可以将 SQLPLUS_COMMAND_ALLRECORDS 替换为上述答案中的查询,来自 Sami Ullah Khan
      【解决方案3】:

      您还可以使用 Aspentech Process Data REST Web API。有一个 Aspentech 本地网页,其中包含许多示例,您可以在其中学习如何使用它。 URL 将是这样的:

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

      Aspentech ProcessData REST API Samples home page

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

      Aspen Process Data Rest API History sample

      【讨论】:

        【解决方案4】:

        我可能回复晚了,但我想与 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!
        

        【讨论】:

          【解决方案5】:

          如果您喜欢 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

          【讨论】:

            猜你喜欢
            • 2022-12-17
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2012-03-19
            • 2011-09-22
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多