資源簡介
PI 的AFSDK 使用方法, PI API 是很舊的,AFSDK 最新訪問方法。

代碼片段和文件信息
using?OSIsoft.AF;
using?OSIsoft.AF.Asset;
using?PISDK;
using?System;
using?System.Collections.Generic;
using?System.IO;
using?System.Linq;
using?System.Runtime.InteropServices;
using?System.Text;
using?System.Threading;
using?System.Windows.Forms;
namespace?ConsoleApplicationPIGetData
{
????class?CustomObj
????{
????????public?string?SerialNo;
????}
????class?Program
????{
????????//[DllImport(“piapi32.dll“)]
????????//private?static?extern?int?pipt_digpointers(int?pt?ref?int?digcode?ref?int?dignumb);
????????//[DllImport(“piapi32.dll“)]
????????//private?static?extern?int?pipt_pointtype(int?pt?ref?string?state);
????????//[DllImport(“piapi32.dll“)]
????????//private?static?extern?int?pipt_findpoint(string?tagname?ref?int?pt);
????????//[DllImport(“piapi32.dll“?CharSet?=?CharSet.Auto)]
????????//private?static?extern?int?pisn_getsnapshot(int?pt?ref?float?rval?ref?int?istat?ref?int?timedate);
????????//[DllImport(“piapi32.dll“?CharSet?=?CharSet.Auto)]
????????//private?static?extern?int?piut_connect(string?procname);
????????//[DllImport(“piapi32.dll“?CharSet?=?CharSet.Auto)]
????????//private?static?extern?int?piut_disconnect();
????????//[DllImport(“piapi32.dll“?CharSet?=?CharSet.Auto)]
????????//static?extern?Int32?piut_setservernode(string?servername);
????????//[DllImport(“piapi32.dll“?CharSet?=?CharSet.Auto)]
????????//static?extern?Int32?piut_login(string?UserName?string?UserPW?ref?Int32?validate);
????????//[DllImport(“piapi32.dll“?CharSet?=?CharSet.Auto)]
????????//static?extern?Int32?pisn_getsnapshots(Int32[]?pt?float[]?rval?Int32[]?istat?Int32[]?timedate?Int32[]?error?Int32?count);
????????public?static?void?WriteLog(string?attributeName?string?logPath)
????????{
????????????try
????????????{
????????????????if?(File.Exists(logPath))
????????????????{
????????????????????using?(StreamWriter?sw?=?File.AppendText(logPath))
????????????????????{
????????????????????????sw.WriteLine(String.Format(“{0}“?attributeName));
????????????????????}
????????????????}
????????????????else
????????????????{
????????????????????using?(StreamWriter?sw?=?File.CreateText(logPath))
????????????????????{
????????????????????????sw.WriteLine(String.Format(“{0}“?attributeName));
????????????????????}
????????????????}
????????????}
????????????catch?(Exception?ex)
????????????{
????????????????Thread.Sleep(100);
????????????}
????????}
????????static?void?Main(string[]?args)
????????{
????????
????????????List?sapDataDVOList?=?new?List()?;
????????????Dictionary?pointMap?=?new?Dictionary();
????????????List?ptList?=?new?List();
????????????string?path?=?Application.StartupPath?+?“\\DCS1Points.txt“;
????????????string?logPath?=?Application.StartupPath?+?“\\log.txt“;
????????????int?nRet?=?0;
????????????if?(File.Exists(path))
????????????{
????????????????//nRet?=?piut_connect(“172.168.100.
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????144??2016-06-30?14:26??app.config
?????目錄???????????0??2016-05-31?15:23??bin\
?????目錄???????????0??2016-07-04?09:55??bin\Debug\
?????文件???????10752??2016-07-04?09:55??bin\Debug\ConsoleApplicationPIGetData.exe
?????文件?????????144??2016-06-30?14:26??bin\Debug\ConsoleApplicationPIGetData.exe.config
?????文件???????17920??2016-07-04?09:55??bin\Debug\ConsoleApplicationPIGetData.pdb
?????文件???????22984??2016-08-14?15:55??bin\Debug\ConsoleApplicationPIGetData.vshost.exe
?????文件?????????144??2016-06-30?14:26??bin\Debug\ConsoleApplicationPIGetData.vshost.exe.config
?????文件?????????490??2013-03-05?08:06??bin\Debug\ConsoleApplicationPIGetData.vshost.exe.manifest
?????文件?????1102272??2016-05-26?21:09??bin\Debug\DCS1Points.txt
?????文件??????238592??2013-05-02?18:21??bin\Debug\Interop.PISDK.dll
?????文件???????21504??2013-05-02?18:21??bin\Debug\Interop.PISDKCommon.dll
?????文件???????12288??2013-05-02?18:21??bin\Debug\Interop.PISDKDlg.dll
?????文件???????22016??2013-05-02?18:21??bin\Debug\Interop.PITimeServer.dll
?????文件??????673971??2016-05-31?18:12??bin\Debug\log.txt
?????文件?????4187856??2016-05-23?12:00??bin\Debug\OSIsoft.AFSDK.dll
?????文件????????4042??2016-06-30?14:26??ConsoleApplicationPIGetData.csproj
?????文件?????????943??2016-06-29?22:56??ConsoleApplicationPIGetData.sln
?????目錄???????????0??2016-05-31?15:23??obj\
?????目錄???????????0??2016-07-04?09:55??obj\Debug\
?????文件?????????611??2016-08-14?15:55??obj\Debug\ConsoleApplicationPIGetData.csproj.FileListAbsolute.txt
?????文件???????10752??2016-07-04?09:55??obj\Debug\ConsoleApplicationPIGetData.exe
?????文件???????17920??2016-07-04?09:55??obj\Debug\ConsoleApplicationPIGetData.pdb
?????文件????????7130??2016-06-30?14:26??obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件???????????0??2016-06-30?14:26??obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
?????文件???????????0??2016-06-30?14:26??obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
?????文件???????????0??2016-06-30?14:26??obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
?????目錄???????????0??2016-05-31?15:23??obj\Debug\TempPE\
?????文件?????8148688??2016-05-23?12:01??OSIsoft.AF.UI.dll
?????文件?????4187856??2016-05-23?12:00??OSIsoft.AFSDK.dll
?????文件???????13317??2016-06-30?14:22??Program?-?副本.cs
............此處省略3個文件信息
評論
共有 條評論