Reference an attribute of type text in an equation

Hello,

I'm currently using PI System Explorer 2014 R2 SP1 and I'm trying to reference an attribute value of type String in an equation attribute.

 

I've a situation like this:

 

A1: TextValue

A2: True/False

A3: AnotherTextValue

A4: if A2 then A1 else A3

 

The same template works fine if A1 and A3 aren't of type String and I coulnd't find a concrete answer on why this isn't possible.

The error returned on A4 is "Data was not available for attribute 'A1': TextValue

 

I hope this community I'm posting in is the right one, if not, I'm sorry and please feel free to move it to its specific spot.

 

Thanks in advance.

Parents Reply Children
  • Hi Stephen,

     

    Thanks for the tip, I've tried but the result is this:


    afImage.png.png

     

    I'm attaching the code: http://pastebin.com/C8vbS4bt

  • Hi Massimo,

    I had a look at your xml file, the reason your  getting this error is because of the configuration that is already applied to your "Value" Attribute.

    Could you remove the formula reference at your Value attribute and make it none and then try the analysis given by Stephen and that will work

  • Hi,

    Thanks everyone, it "works" but not as I intended and maybe this isn't the right way to do it.

     

    I'd like this analysis to run whenever the three attributes I reference changes but it seems the attributes I reference aren't made for triggering this type of analysis.

     

    I guess I could trigger it manually everytime I need the updated Value when I access it from AF SDK but I'm wondering if it's the right way to do it, is there any better solution? (Or am I trying to kill an ant with a bazooka? meaning I shouldn't bother trying to optimize these things).

     

    Thanks in advance, again.

     

    p.s.This is the code I'm using to run the analysis, I've noticed that the code that should trace the error isn't logging anything to AFTrace, this occurred if CurrentCase was null.

    analysis.AnalysisRule.CurrentCase = new AFCase(analysis);
    OSIsoft.AF.Analysis.AFAnalysisRuleState rs = new OSIsoft.AF.Analysis.AFAnalysisRuleState(analysis.AnalysisRule.GetConfiguration());
    rs.SetExecutionTimeAndPopulateInputs(new AFTime(DateTime.Now));
    analysis.AnalysisRule.CurrentCase.Run();
    var publishResult = analysis.AnalysisRule.Publish();
    return attribute.GetValue().ToString();
    

  • Hi Massimo,

     

    Have you configured the Scheduling for Event-Triggered for “Any Input”? According to my tests, this option works as long as the input is using the PI Point Data Reference. If no data reference is defined, then the trigger won't work. This is the result I have obtained on my environment.

     

    Therefore, there are 3 things for you to try:

     

    - Keep using your code to trigger the calculation which isn’t a great solution.

    - Use Periodic Scheduling with a small time period if possible.

    -Create string PI Points on the PI Data Archive and map the attributes you already have to those PI Points by setting up the PI Point data reference for each attribute.

     

    Hope it helps!