Asle Frantzen

'Invalid Data' when getting AF attribute

Discussion created by Asle Frantzen Champion on Dec 15, 2011
Latest reply on Jan 11, 2012 by Asle Frantzen

Ok, so I'm getting 'Invalid Data' when reading a couple of AF attributes through an ACE calculation scheduled to run once per day.

 

(I'm also seeing the same for another ACE which is triggered by a PI tag arriving 1-2 times a day)

 

 

 

I have recently upgraded from ACE 2.1.1.2 to the newest (2010 R2 SP1) and the AF server is version 2.1.1.3624. The attributes I'm reading from are formulas, and they in turn read from a couple of other formulas and pi tag references each.

 

After a lot of debugging I was stuch with an impression that maybe some "warm-up time" would be required, so even though I didn't get any errors when querying the AF SDK I tried to re-run the GetValue(..) function immediately. This seemed to work, but it's not a very good situation. Even if it's enough for this little project I have a new, more extensive ACE+AF project coming up so I'm interested in finding out why I see this behaviour.

 

 

 

Here is code I'm using at the moment:

 
If (AFElement.FindElementsByPath(afAttributePaths, Nothing, afErrors).Count = 1) Then
    myAttribute = AFElement.FindElementsByPath(afAttributePaths, Nothing, afErrors).First.Attributes(AF_Attribute_Path.Split("|")(1))

    If (Not IsDBNull(myAttribute)) Then
    
         'Important: Cast to PIValue since AFValue gives "Wrong type" in the archive      
         TempVar = myAttribute.GetValue(aceAFTime).ToPIValue()

         'Validate the double value, retry once if problems, then SendDataToPI = False if still error
         If (Double.TryParse(TempVar.Value.ToString(), tempValue)) Then
             OutputTag.Value = tempValue
             If Logging Then
                  log.WriteEntry("Debug: Attribute " + AF_Attribute_Path.Split("|")(1) + " is " + tempValue.ToString() + " at: " + TempVar.TimeStamp.LocalDate.ToString())
             End If
         Else
             If Logging Then
                  log.WriteEntry("Debug: Problems collecting the attribute " + AF_Attribute_Path.Split("|")(1) + " - trying again")
             End If

             'Retrying...
             TempVar = myAttribute.GetValue(aceAFTime).ToPIValue()

             If (Double.TryParse(TempVar.Value.ToString(), tempValue)) Then
                  If Logging Then
                      log.WriteEntry("Debug: Second attempt of collecting the attribute " + AF_Attribute_Path.Split("|")(1) + " ok, value is " + tempValue.ToString() + " at: " + TempVar.TimeStamp.LocalDate.ToString())
                  End If
                  OutputTag.Value = tempValue
             Else
                  If Logging Then
                      log.WriteEntry("Debug: Second attempt of collecting the attribute " + AF_Attribute_Path.Split("|")(1) + " also failed")
                  End If
                  OutputTag.SendDataToPI = False
             End If
         End If
    Else

         If Logging Then
             log.WriteEntry("Error: Attribute " + AF_Attribute_Path.Split("|")(1) + " is null: " + DateTime.Now.ToString() + ". Error returned from AF: " + afErrors.First.ToString())
         End If
         OutputTag.SendDataToPI = False
    End If
End If

 

Outcomes