YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

tag search not returning values C# 2.0 Options · View
BenH
#1 Posted : Saturday, July 10, 2010 3:39:30 AM
Rank: Newbie
Groups: Member

Joined: 7/10/2010
Posts: 5
Location: Hoquiam, WA
The following code should bring back a list of tags

private static void GetTags()
{
try
{
// open pi server connection
mySDK = new PISDK.PISDKClass();
myServer = mySDK.Servers["PI"];
myServer.Open(String.Empty);
string tagFilterSql = "pointsource='M'";
//string tagFilterSql = "tag='*power.meter*'";
PISDK.PointList myPointList = new PISDK.PointList();
//aSynch = new PISDKCommon.PIAsynchStatus();
myPointList = myServer.GetPoints(tagFilterSql, new PISDKCommon.PIAsynchStatus());
Console.WriteLine("Number of points: "+myPointList.Count.ToString());

}
catch (System.Exception ex)
{
WriteToLog(ex.ToString(), true);
}
}

When I run it from the console I get the following:

C:\svn\VisualStudio\EnergyMeters\EnergyMeters\bin\Debug>energymeters
Number of points: 0

Here is the screenshot of the tags I should be getting back
https://mail.ghplp.com/Pub/PiTagList.JPG
Sponsor  
 

OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System.
We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ  or contact OSIsoft vCampus for more details.
RJK Solutions
#2 Posted : Saturday, July 10, 2010 8:45:21 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 617
Location: Cheshire, United Kingdom.
If you run the code without a PIAsynchStatus, what result do you get?
Principal Consultant
Real-Time Data Management @ Wipro Technologies
BenH
#3 Posted : Sunday, July 11, 2010 1:19:11 AM
Rank: Newbie
Groups: Member

Joined: 7/10/2010
Posts: 5
Location: Hoquiam, WA
I can't, as my version of the api requires two arguements, with no overload for one.
BenH
#4 Posted : Tuesday, July 13, 2010 7:55:11 PM
Rank: Newbie
Groups: Member

Joined: 7/10/2010
Posts: 5
Location: Hoquiam, WA
This is somewhat lame, but passing a null object works (I saw this on another post with a completely different method)

myPointList = myServer.GetPoints(tagFilterSql, null);
RJK Solutions
#5 Posted : Tuesday, July 13, 2010 9:04:37 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 617
Location: Cheshire, United Kingdom.
Hi Ben,

Sorry for not getting back to you sooner.
That is what I was getting at in my earlier post. When you pass an asynch object the tag search is started but focus in your console app immediately returns to the point where you check the count property. When using asynch you need to check the status and wait until it has finished before checking the count. Using null performs the call synchronously so it waits for the tag search to complete before printing out the count. You are probably only talking about milliseconds of processing giving the wrong impression that the asynch code isn't working.

Hope this helps...

Rhys.
Principal Consultant
Real-Time Data Management @ Wipro Technologies
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.