Performance Equation to Hold Last value on a tag

Discussion created by gkrueger on Jan 9, 2013
Latest reply on Jan 22, 2013 by fbatista

Does anyone know a good way to perform a hold last value function using PE's that have if...then statements in them?  


In my application, I have a PE which is examining another PI tag, when that PI tag equals a specific value, then the PE sets itself equal to the value in another tag.  To explain a little more, consider the first tag is the ID tag, the second tag is the process value...so when IDtag = "Vessel 1" then the PE sets itself to whatever value is stored in the "PH.Common" tag which is a PH tag that has the readings for all the vessels.  When the ID is no longer Vessel 1, then I want the PH to hold this new value that it just got (so maybe calling it last value is not accurate...it is the most recent value).


Right now I'm using a statement like this: if (Ucase(Left('VESID.AGG',4)) = "1002" and (NextEvent('PH.AGG','*-10s') > '*-10s') and 'PH.AGG' <> "Calc Failed") then 'PH.AGG' else PrevVal('PH_OFFLINE.VES-02-FIN.LSDL.CCPD','*').  The issue with this is that the PrevVal is not returning the most recent value (which is the snapshot), it's getting one before that.  What I'm seeing is this tag records the new value and then the next scan it goes right back to the value before.  For example  if the values in the tag are  6, 7, 6  and a new reading of 7.5 comes in, I'll see 6, 7, 6, 7.5 , 6  with the last 6 having a timestamp of one scan after the 7.5.   I'm looking for a way to get it to hold onto that 7.5 after the VESID.AGG tag gets a new value.


The NextEvent clause is making sure there was a recent sample...in some cases one of the other values might get sampled, but PH wasn't measured for that sample so I don't want it putting a sample not related to vessel 1 into the PH for vessel 1.


I'm also wondering if this might be a case where I should be using ACE instead of PE's.  I haven't worked with ACE before, and this project is on tight timeline so I don't really have the time to learn ACE right now.  I was hoping to get the functionality I need using the PE's which are a little more straight forward to configure.


Any help is appreciated...I'm hoping my explanation is enough for a reader to understand what I'm trying to do.  This project is for entry of lab data, I tried to convince this customer to use manual entry, but they were all gung ho for using OPC connections to the analyzers and now I have to try to make it work.  Aargghh!  They have 10 analyzers which can make measurements on any of 40 vessels.  Our strategy is to take the OPC streams, collect them into a single set of tags with the values for all analyzers, then filter them based on VESID into tags for each vessel.  I've gotten the OPC stream collection to work, but the filtering to vessel tags is what's giving me the issues.