AnsweredAssumed Answered

AF Data Pipe Update on Attribute Changes

Question asked by neilg on Mar 19, 2018
Latest reply on Mar 26, 2018 by dmoler

Hi World,

 

We have an AFDataPipe which is monitoring weather station data in attributes linked to the weather station PI Points.


The attributes are:
Measured Wind Speed points to 'M.WS1.MWINDSPEED'

Measured Ambient Temperature points to 'M.WS1.OBS_MTEMP'

where 'WS1' = Weather Station 1

and Closest Weather Station|ID = WS1

The PI Tag names for the telemetered attributes are built from an ID attribute (M.%@Closest Weather Station|ID%_OBS_MTEMP).

 

We have an AF Analyses (runs periodically) which switches the current weather station to another one if the current weather station data goes stale. It does this by changing the Closest Weather Station|ID attribute which all the telemetered tags derive their tag names from.

 

This means that if WS1 goes stale the Analyses will switch the attributes as below:

Measured Wind Speed points to 'M.WS2.MWINDSPEED'

Measured Ambient Temperature points to 'M.WS2.OBS_MTEMP'

and Closest Weather Station|ID = WS2

When the switch happens the AFDataPipe still keeps receiving data from WS1 and does not get data from WS2.

 

I have done research on it and came across this post https://pisquare.osisoft.com/message/74306-re-how-does-af-attributes-subscription-work and implemented the suggested approach but it does not work when AF Analyses changes the ID attribute.


I basically get all changes from the AFDatabase and apply it to the AFDataPipe (AFDataChangeMonitor object in the below code) before attempting to retrieve events from the AFDataPipe. Also of note is that the AFDBCookie is retrieved once on startup and the same object is retained on subsequent calls.

 

 

I also tried removing and re-adding the changed attributes but an error comes up when trying to remove the changed attribute:

 

{[Measured Wind Speed, System.InvalidOperationException: stream not found in Upstream Pipe

   at OSIsoft.AF.PI.PIPipeToAFPipeTransformer.QueueRemovePIPointSignup(PIPoint inputStream, AFAttribute stream)

   at OSIsoft.AF.PI.PIPipeToAFPipeTransformer.OSIsoft.AF.Data.IAFEventSource<OSIsoft.AF.Asset.AFAttribute>.QueueRemoveSignup(AFAttribute stream, Object routingToken)

   at OSIsoft.AF.Data.AFDataPipeAggregator`2.OSIsoft.AF.Data.IAFEventSource<TStream>.QueueRemoveSignup(TStream stream, Object routingToken)

   at OSIsoft.AF.Data.AFDataPipeSplitter.QueueRemoveSignup(Int32 streamIndex, AFAttribute stream, Object routingToken)

   at OSIsoft.AF.Data.AFDataPipeSplitter.SplitStream.OSIsoft.AF.Data.IAFEventSource<OSIsoft.AF.Asset.AFAttribute>.QueueRemoveSignup(AFAttribute stream, Object routingToken)

   at OSIsoft.AF.Data.AFDataPipeCalculator.QueueRemoveSignup(AFAttribute stream, Object routingToken)

   at OSIsoft.AF.Data.AFDataPipe.RemoveSignups(IList`1 attributes)]}

 

Are there any other things I can try? Or am I doing something incorrectly with the code above?

Outcomes