PointGetNext (function)

Syntax 1 PointGetNext(timeOutMs, point1 [,... [, point16])
Syntax 2 PointGetNext(timeOutMs, PointArray)
Description To return the next point value from a list of points with a timeout.
Comments (CimBasic) Timeout values (milliseconds) can be as follows:

-

1

0

Positive

Integer

Point1 is a point object with an outstanding request. Up to 16 points can be specified on the function call. Alternatively, the user may pass an array of point objects. The function returns the object whose value changed or empty. Parameter: timeOutMs, pointn, PointArray.
Example (CimBasic)
' Trace the values of 2 point as they change or trace timeout if neither
' point change in 1 second.
Sub Main()
   Dim Point1 as new Point       ' Declare Point Object
   Dim Point2 as new Point       ' Declare Point Object
   Point1.Id = "TANK_LEVEL"      ' Set the Id
   Point2.Id = "TANK_TEMP"       ' Set the Id
   Point1.OnChange               ' Register OnChange request
   Point2.OnChange               ' Register OnChange request
   Dim Result as Point           ' Declare result pointer
Top :
   ' Set result equal to result of waiting on Point1 and Point2
   ' to change for 1 second
   Set Result = PointGetNext(1000, Point1, Point2)
   if Result is Nothing then      ' Nothing is returned if timeout
      Trace "TimeOut"
   Else
     ' Otherwise Result is Point1 or Point2 depending on which one
     ' changed last.
      Trace Result.Id & " " & str$(Result.TimeStamp) & Result.Value
   end if
   goto top
End Sub
Comments (.NET) PointGetNext has been ported to .NET as follows:
Point Cimplicity.PointGetNext(int TimeOutMs, Point[] points);
PointGetNext takes an array of Point objects, which is different from CimBasic where CimBasic functions take variable arguments with each being a Point object. Otherwise .NET and CimBasic behavior is the same for this function.
Example (.NET)
using System;
using System.Collections.Generic;
using Proficy.CIMPLICITY;
public class PGN
{
  public void Main()
  {
    Point[] array = new Point[3];
    
    using (Point one = new Point(), two = new Point(), three = new Point())
    {
      one.Id = "PGN_1";
      one.OnChange();
      
      two.Id = "PGN_2";
      two.OnChange();
      
      three.Id = "PGN_3";
      three.OnChange();
      
      array[0] = one;
      array[1] = two;
      array[2] = three;
      
      try
      {
        Point result;
        
        do
        {
          result = Cimplicity.PointGetNext(30000, array);
        
          if (result != null)
          {
            Cimplicity.Trace("Point that changed is " + result.Id);
          }
        } while (result != null);
      }
      catch (Exception x)
      {
        Cimplicity.Trace("Failure: " + x.Message);
      }
      finally
      {
        Cimplicity.Trace("No more changes after 30 seconds");
      }
    }
  }
}