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

C # save to archive Options · View
TomGagnon
#1 Posted : Thursday, February 11, 2010 11:34:55 PM
Rank: Newbie
Groups: Member

Joined: 2/11/2010
Posts: 1
Location: Decatur IL
I'm converting a VB app (runs as service) to C# / PISDK.

I've had several years working with PI / VBA, VB6 / API and SDK but I'm new to C#, so there is a learning curve.

Essentially, the app uses csv files containing 3 items per line (Tag, Date, Value)
I want to walk thru each line, parse it out, validate the TAG, then insert the value into PI for that Tag and the TimeStamp in the csv file.
(Most dates are within the last 24 hours).

I know I'll have to validate that the TAG is in the system and will do that, but I'm struggling with the line below

PIServer.PIPoints[txtTagWrite.Text].Data.UpdateValue(txtValueWrite.Text,"*-100s", PISDK.DataMergeConstants.dmReplaceDuplicates, null);

What do I have to do to stick something like "2/08/2010 18:00" in place of the "*-100s" parameter?

Looks to like your web site is unique to the pi developers world. Thanks for putting it on line.
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.
Michael
#2 Posted : Friday, February 12, 2010 8:55:11 AM
Rank: Advanced Member
Groups: Member

Joined: 12/3/2009
Posts: 71
Location: Germany/Pennsylvania
Hi Tom,

Simply pass the timestamp as the second parameter. It can be a string too. But I would suggest to convert it into a date first to be sure it is a date. Using strings is dangerous because the format depends on the regional settings. Easy if everything is US, if not you are in the hell.

You can use the PIValue object to store value and timestamp.

Michael
RJK Solutions
#3 Posted : Friday, February 12, 2010 9:07:22 AM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 612
Location: Cheshire, United Kingdom.
Hi Tom,

Welcome to the forum Smile
I think I have a few guys from your company registered on here now. BigGrin

I have been through a few VB.Net to C# conversions, it was a learning curve when I went through them seen as though I started out as a VB only guy. There are a few syntax gotcha's with doing a conversion using PISDK so be sure to post back when you hit them.

Michael is right (as always BigGrin ) that you can pass the absolute date as a string. If you are working across time zones then be sure to make use of the PITime objects and TimeZone object from the connecting server. Also, if you are writing back to a collective then you need to manage passing the data around the collective members (e.g. PItoPI) until we get PISDK v1.4.

By the way, any reason why you are not using PI-BatchFL or PI-UFL for loading in the files to PI?

I like to think OSI followed my example of a PI developers forum, they do have a subscription based OSISoft vCampus now.

Cheers,

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.