• 大小: 186KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-05-19
  • 语言: C#
  • 标签: Pi,.net  C#  

资源简介

用C#编写的PI数据库读取实时、历史、极值数据。可以直接使用勒

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

using PISDK;
using PITimeServer;
using PISDKCommon;
using PISDKDlg;

namespace PiUtinity
{
    /// 
    /// PI操作类
    /// 

    public class PiHelper
    {
        Server server = null;
        PISDK.PISDK pisdk = null;
        string uid = null;
        string pwd = null;
        int piPort = 5450;
        string hostName = null;
        string piConnectionString = ““;
        /// 
        /// PiHelper构造函数
        /// 

        /// pi服务器名
        /// 登录服务器的用户id
        /// 登录密码
        /// pi服务器端口
        public PiHelper(string hostName string uid string pwd int piPort)
        {
            this.hostName = hostName;
            this.uid = uid;
            this.pwd = pwd;
            this.piPort = piPort;
            piConnectionString = string.Format(“UID={0};PWD={1};port={2};Host={3};“  uid pwd piPorthostName);
            try
            {
                pisdk = new PISDK.PISDKClass();
                foreach (Server server in pisdk.Servers)
                {
                    if (server.Name.Equals(hostName))
                    {
                        this.server = server;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(“初始化PIServer发生错误:“ + ex.Message);
            }
        }
        ~PiHelper()
        {
            if (this.server != null)
            {
                this.server.Close();
            }
        }

        protected void Dispose(bool disposing)
        {
            //释放非托管资源
            if (this.server != null)
            {
                System.Runtime.InteropServices.Marshal.ReleaseComobject(this.server);
            }
            if (this.pisdk != null)
            {
                System.Runtime.InteropServices.Marshal.ReleaseComobject(this.pisdk);
            }
            GC.Collect();
        }

        public void Dispose()
        {
            this.Dispose(true);
            GC.ReRegisterForFinalize(this);
        }
        /// 
        /// 从Pi数据库获取历史数据
        /// 

        /// 查询条件,例如:tag=‘MM-001-1-S1-0300-S-1000672-022-001‘
        /// 起始时间
        /// 结束是假你
        /// 查询方式,年,月,日
        /// 过滤条件,如果不需要过滤,请传空
        /// 显示方式
        /// 
        public virtual DataTable GetHistoryDataFromPI(string tagName DateTime startTime DateTime endTime string filter FilteredViewConstants fvc Querystyle qs)
        {
            if (this.server == null)
            {
                t

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     238592  2013-05-02 18:21  PiUtinity\bin\Debug\Interop.PISDK.dll

     文件      21504  2013-05-02 18:21  PiUtinity\bin\Debug\Interop.PISDKCommon.dll

     文件      12288  2013-05-02 18:21  PiUtinity\bin\Debug\Interop.PISDKDlg.dll

     文件      22016  2013-05-02 18:21  PiUtinity\bin\Debug\Interop.PITimeServer.dll

     文件      11776  2013-05-02 18:21  PiUtinity\bin\Debug\PiUtinity.dll

     文件      19968  2013-05-02 18:21  PiUtinity\bin\Debug\PiUtinity.pdb

     文件       6190  2013-05-02 18:21  PiUtinity\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件     238592  2013-05-02 18:21  PiUtinity\obj\Debug\Interop.PISDK.dll

     文件      21504  2013-05-02 18:21  PiUtinity\obj\Debug\Interop.PISDKCommon.dll

     文件      12288  2013-05-02 18:21  PiUtinity\obj\Debug\Interop.PISDKDlg.dll

     文件      22016  2013-05-02 18:21  PiUtinity\obj\Debug\Interop.PITimeServer.dll

     文件       1650  2013-05-02 18:21  PiUtinity\obj\Debug\PiUtinity.csproj.FileListAbsolute.txt

     文件        904  2013-05-02 18:21  PiUtinity\obj\Debug\PiUtinity.csproj.ResolveComReference.cache

     文件      11776  2013-05-02 18:21  PiUtinity\obj\Debug\PiUtinity.dll

     文件      19968  2013-05-02 18:21  PiUtinity\obj\Debug\PiUtinity.pdb

     文件      14554  2013-05-02 18:21  PiUtinity\PiHelper.cs

     文件       3823  2013-04-24 22:24  PiUtinity\PiUtinity.csproj

     文件       1374  2013-04-24 21:51  PiUtinity\Properties\AssemblyInfo.cs

     文件        536  2013-04-25 15:52  PiUtinity\QueryStlye.cs

     目录          0  2013-04-24 21:51  PiUtinity\obj\Debug\TempPE

     目录          0  2013-05-02 18:21  PiUtinity\bin\Debug

     目录          0  2013-05-02 18:21  PiUtinity\obj\Debug

     目录          0  2013-04-24 21:51  PiUtinity\bin

     目录          0  2013-04-24 22:20  PiUtinity\lib

     目录          0  2013-04-24 21:51  PiUtinity\obj

     目录          0  2013-04-24 21:51  PiUtinity\Properties

     目录          0  2013-04-24 22:20  PiUtinity

----------- ---------  ---------- -----  ----

               681319                    27



............此处省略0个文件信息

评论

共有 条评论