|
|
Rank: Member Groups: Member
Joined: 1/14/2010 Posts: 28 Location: UK
|
Hi All,
I've got a lil problem for you all to think about.
Scenario: We have text/CSV files which update our PI system every morning which contain compliance results. these come in under pointsource F (for example). We have Location 1 set to 1 so that the timestamp is picked up from the CSV file and not created by pi. that works fine.
in this file are two results which are the same, but 1 is a scheduled result and the other is a spot check result.
the client is only interested in seeing the results and not have 2 values. Basically they want to concat the results.
I have written a query using the Pi PE which returns only 1 value, however the timestamp is the time at which the calculation runs and not the timestamp of the sample.
Does anyone know of a way i can write the performance equation which will produce the result i want, and only return the results timestamp? can this be done in Pi PE?
cheers
Pho
|
|
|
|
|
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.
|
|
|
Rank: Advanced Member Groups: Member
Joined: 12/3/2009 Posts: 71 Location: Germany/Pennsylvania
|
Hi Pho
You wrote you have 2 results, so I believe that you store the data in 2 PITags (one for the scheduled, one for the spot check). Right? How about the timestamps? Do you have one for each of the result types?
If your PIPE tag is an event triggered one, set location3 to a non-zero value.
|
|
|
Rank: Member Groups: Member
Joined: 1/14/2010 Posts: 28 Location: UK
|
Hi Michael, You are correct, we have 1 PITag for the scheduled result and 1 PItag for the spot check. yes, Both of the tags have their own timestamp. (the timestamp is the time the sample was taken) My PIPE tag isnt event triggered, as there are two tags to trigger from. mind you, we haven't do an event to trigger from more then one tag, so i suppose you can do that? - not sure how. I'll give it a go though. Thanks Michael. anymore ideas are welcome o
|
|
|
Rank: Advanced Member Groups: Member
Joined: 5/14/2009 Posts: 35 Location: UK
|
Hey Pho, As Michael said it's all to do with Location3. Check out the event triggered OMS calcs and you'll see they're set with Loc3=1 for this same reason. Location1 is set to 1 because that's the batch file loader interface ID so you still need that.
.
|
|
|
Rank: Member Groups: Member
Joined: 1/14/2010 Posts: 28 Location: UK
|
Cool,
cheers for that i've set them up with the locations 1 and 3 as suggested. The problem being now is working how to to event trigger the calc off both the OMS tags.
my current calc is:
IF yearday(PrevEvent('Spotcheck.tag')) > yearday(PrevEvent('Scheduled:tag')) THEN ('Spotcheck:tag') ELSE ('Scheduled:tag').
i've also got one in there as:
IF yearday(PrevEvent('Spotcheck:tag', 'T')) > yearday(PrevEvent('Scheduled:tag', 'T')) THEN ('Spotcheck:tag') ELSE IF yearday(PrevEvent('Scheduled:tag', 'T')) > yearday(PrevEvent('Spotcheck:tag', 'T')) THEN ('Scheduled:tag') ELSE "No Data"
Both return the same value and the values i'm expecting, just not the timestamp at present as they aren't event tags.
Cheers
|
|
|
Rank: Advanced Member Groups: Member
Joined: 5/14/2009 Posts: 35 Location: UK
|
Check out the "weekly calcs" for examples of how to play with the timestamps. One lot of calcs does the value and the other set messes with the timestamp. There should be something in there that gives you a clue. Iirc there are two calcs, one gives the value and the other gives the timestamp based on the the same calculation. If you just want the day it ran then the examples should be there too.
Haven't got time to work on this right now, everybody wants the moon on a stick on a Friday.
.
|
|
|
Rank: Member Groups: Member
Joined: 1/14/2010 Posts: 28 Location: UK
|
Cool, cheers mate
i've set up a couple of other test tags since my last post which do something like that. Just awaiting results. They aren't events though.
|
|
|
Rank: Advanced Member Groups: Member
Joined: 5/14/2009 Posts: 35 Location: UK
|
Think I misunderstood what you want.
You have two values come in timestamped 5 days ago. You have a PE that selects one or the other based on whichever is the newest value. You can't use event triggering because there are two tags involved, so you're left with scheduled calcs.
Do they actually want the latest value showing or just the "concatenated" value for that time? If they don't need the latest value then you could always schedule this calc to run often, stick compression on with a long compmax and let the recalculator do it's work.
.
|
|
|
Rank: Member Groups: Member
Joined: 1/14/2010 Posts: 28 Location: UK
|
yeah you got it.
2 values coming in. a scheduled value which should happen once a week, but in case that sample cannot be taken for whatever reason, then the other sample point is used.
the sample is the same ie ammonia.
so the client wants the latest value to show with the timestamp of that sample.
I thought about concat but that doesn't do it. Hence why my calc looks at the timestamp and picks the latest value between the two samples. but yes, as you said because my only real option is to use scheduled calcs (as you said events wont work as there are two source tags to run from)
I have set the calc to run every 24 hrs (as the source tags only update once a day if the sample is present anyway) so it pulls out the lastest and last known value, but the timestamp is the time at which the scheduled calc runs and not the timestamp of the sample.
does that make sence ?
cheers
|
|
|
Rank: Advanced Member Groups: Member
Joined: 5/14/2009 Posts: 35 Location: UK
|
If you run the calc every hour with compression set to a day then you'll be within an hour of the actual timestamp. You could go faster but as the readings are sporadic I think an hour should be close enough for what they need.
Then again, if you're doin the comparison calc on yearday you could end up with 24 values so I'd go with the midnight run. Might want to test it though.
.
|
|
|
Rank: Member Groups: Member
Joined: 1/14/2010 Posts: 28 Location: UK
|
Cheers mate,
one of my previous test calcs is running every 15 mins with compression on. another is running every hour now since you've said that.
i've played about with location 3 as well, so i guess we will see what the results come out as.
Thanks for your help on this mate.
|
|
|
Rank: Member Groups: Member
Joined: 1/14/2010 Posts: 28 Location: UK
|
thinking about the calc,
i think i'm going to do another test calc with this:
if (prevevent('A') < prevevent('B')) then (if (prevevent('B') > '*-3601s') then ('B') else (nooutput())) else (if (prevevent('A') > '*-3601s') then ('A') else (nooutput()))
with a 1 hr scan class.
that way there will only be a written value, if something has changed.
what does anyone think?
|
|
|
Rank: Member Groups: Member
Joined: 1/14/2010 Posts: 28 Location: UK
|
OK People, this is the calc i've come up with. if (prevevent('Tag A') < prevevent('Tag B')) then (if (prevevent('Tag B') > '*-301s') then ('Tag B') else (nooutput())) else (if (prevevent(#Tag A') > '*-301s') then ('Tag A') else (nooutput())) This is schedulled to run every hour, the recalculator is on with compression. This calc brings through the correct timestamp but it just doesn't write a value. It says no sample. Yet the timestamp is perfect and matchs the CSV file the data comes from. Anyone any ideas what i'm doing wrong?
|
|
|
Rank: Advanced Member Groups: Member
Joined: 5/14/2009 Posts: 35 Location: UK
|
First thing I'd do is find out which "else" is doing the NoSample...
if (prevevent('Tag A') < prevevent('Tag B')) then (if (prevevent('Tag B') > '*-301s') then ('Tag B') else "1") else (if (prevevent(#Tag A') > '*-301s') then ('Tag A') else "2")
.
|
|
|
Rank: Member Groups: Member
Joined: 1/14/2010 Posts: 28 Location: UK
|
Cheers, good idea!
i'll give that a go.
Osisoft have also confirmed the (NoOutput) function has a bug in it which wont be resolved until the new version of Pi is realeased later this year.
|
|
|
Rank: Member Groups: Member
Joined: 1/14/2010 Posts: 28 Location: UK
|
ThePIman wrote:First thing I'd do is find out which "else" is doing the NoSample...
if (prevevent('Tag A') < prevevent('Tag B')) then (if (prevevent('Tag B') > '*-301s') then ('Tag B') else "1") else (if (prevevent(#Tag A') > '*-301s') then ('Tag A') else "2")
. OK i've tried it and the first "else" appears to be doing it. the results came back as 1.
|
|
|
|
Guest
|