使用VBA从PI DataLink中提取数据

问题描述:

我正在使用VBA从PI Server中提取大量数据.我正在使用以下代码:

I am pulling huge amount of data from PI Server using VBA. I am using the following code:

**Dim myValues As PIValues

Set myValues = PIMath.GetInterpolatedValues_Point(inputPIPoint,
    PIMath.StringToPITimeFormat(StartDate),
    PIMath.StringToPITimeFormat(NextDate), "10s")**

将MyValues中存储的所有值复制到工作表中的列的最快方法是什么?我正在使用For Loop:

What is the fastest way to copy all the values stored in MyValues to a column in a worksheet? I am using For Loop:

For k = 1 To myValues.Count

Worksheets("Sheet6").Cells(k, 2).value = myValues(k)

但是当我使用多个PI Tag并将时间间隔更改为5秒时,这会极大地减慢该过程.

But it is extremely slowing down the process as I use multiple PI Tags and change time interval to 5 seconds.

此外,如何在每个完整循环结束时将 myValues 设置为空?这就是我想要做的:

Also, how can I set myValues to empty at the end of every full loop? This is what I am trying to do:

  1. MyValues 包含从日期1st到2nd的数据
  2. 应清除 MyValues 中的所有PI点
  3. MyValues 包含从日期2nd到3rd的数据
  1. MyValues contains the data from Date 1st to 2nd
  2. All the PI points in MyValues should be cleared
  3. MyValues contains the data from Date 2nd to 3rd

类似的东西

Worksheets("Sheet6").Range("B1").Resize(UBound(myValues)+1,1).Value = _
                                       Application.Transpose(myValues)