aarloe

Need help capturing error message from IPICalculation

Discussion created by aarloe Employee on Feb 24, 2011
Latest reply on Feb 26, 2011 by charlie@osisoft.com

Hello,

 

I am writing an app the accepts a list of PI tags common to 2 servers, and attempts to do an EventCount on each server for each tag in the list. The goal is to determine whether an archive merge has succeeded by comparing the number of events for a couple tags on each server. I know that DataLink can do this calculation, but I am trying to develop something that does not require installing Office, or any of the other overhead needed for that. It's a pretty simple app that can be run without a major installation.

 

Anyways, I am running into problems when it comes to error handling with the IPICalculation. My code looks something like this:

 
PIValues pivals = new PIValues();
String filterExpression = "EventCount('" + tag.Name + "', '" + StartTimeTextBox.Text + "', '" + EndTimeTextBox.Text + "')";
IPICalculation iPICalc = (IPICalculation)PIServer;
try
{
    pivals = iPICalc.Calculate("*", "*", filterExpression, PISDK.SampleTypeConstants.stRecordedValues, "");
}
catch (System.Runtime.InteropServices.COMException comExc)
{
    MessageBox.Show(comExc.Message);
}

The problem I am having is when I test the app against a server with a really low tuning parameter value for ArcMaxCollect (say 2048, the minimum). Instead of catching the PISDK error message of -11091 "Event collection exceeded the maximum allowed", it just keeps going. I know my Try/Catch works sometimes, because I've manually edited the filter expression to contain some invalid PE Syntax, and the try catch gets those messages and lets the user know about it.

 

Is there a difference between the error message I'm trying to capture (the -11091 ArcMaxCollect error) and the error messages I know that I can capture (the invalid PE Syntax) ? If so, how could I go about programatically catch the various types of error messages? Thanks in advance, 

 

 

Outcomes