|
|
Rank: Member Groups: Member
Joined: 7/30/2009 Posts: 12 Location: Chandigarh
|
Hi,
I need your assistance in one issue. As per our requirement I have to create a function which will accept ElementName, CommaSepratedAttributeName and return attribute Values.
In my function I called AFElement.FindElements() method which is returning list of elements, now I started the loop and fetching the attribute values.
But My problem is that it is taking long time. I need a function which will take less time. Please find my code below
PISystems systems = new PISystems(); mySystem = (PISystem)systems[serverName].PISystem; myDB = (AFDatabase)mySystem.Databases[afDatabase].Database;
string[] strAtrr = commaSepratedAttributes.Split(','); myElements = (AFElements)myDB.Elements; AFNamedCollectionList<AFElement> AFElementsList = AFElement.FindElements(myDB, null, elementTemplate, AFSearchField.Template, true, AFSortField.Name, AFSortOrder.Ascending, 1000);
foreach (AFElement Afelement in AFElementsList) { StrAttrVal = new StringBuilder(); if (intLen > 0) { int intLength = 0; while (intLength <= intLen) { string strAttribute = strAtrr[intLength]; StrAttrVal.Append(Afelement.Attributes[strAttribute].GetValue().Value); if (intLength < intLen) StrAttrVal.Append(","); intLength += 1; } } }
Please advise me, Thanks in Advance!!!!.
Thanks, Sandeep Narang
|
|
|
|
|
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: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 612 Location: Cheshire, United Kingdom.
|
Hi Sandeep, Using a root AFElement usually is slower than providing no root, you have not root element. (good) Are you using Wildcards for the element template name string? How many elements are present in your DB and how many would you expect to be returned? Is the bottleneck with the FindElements method or retrieving the AFAttribute values? Rhys. Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Member Groups: Member
Joined: 7/30/2009 Posts: 12 Location: Chandigarh
|
Hi,
I am providing Element Template name as an input and based on that i am searching the elements. Returned would be 400 . Functions is getting longtime while retrieving the AFAttribute values. It is taking around 3 minutes in foreach loop.
Thanks, Sandeep Narang
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 612 Location: Cheshire, United Kingdom.
|
What Data References are your Attributes using? Sounds like the data retrieval for the Attributes is the bottleneck - presuming PI Point DR, is there a delay between your application and the PI server(s) directly? Edit: What I am getting at it is, if you retrieve data for a case the value is retrieved from the AF's SQL Server (where the case value is stored). If not then the Data Reference is invoked so you are at the mercy of the communication of the DR. Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Member Groups: Member
Joined: 7/30/2009 Posts: 12 Location: Chandigarh
|
Hi,
Thanks for your reply.I am new to PI...I don't know how to use DR and AFCase.... It would be nice if you can post the code also......
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 612 Location: Cheshire, United Kingdom.
|
You use an AFCase in conjunction with an AFModel & AFAnalysis. As this has been temporarily limited in AF 2.0 & 2.1 I doubt this is a solution for your problem. Have you tried using an AttributeList object to get your values? (As suggested on vCampus) Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Member Groups: Member
Joined: 7/30/2009 Posts: 12 Location: Chandigarh
|
Yes, I Have tried AttributeList object to get the values, but it was taking too much time also...
|
|
|
Rank: Member Groups: Member
Joined: 7/30/2009 Posts: 12 Location: Chandigarh
|
Hi Rhys,
Can you provide me some examples or tips of AF, AFCase, AFDataReference? Actually in our case we need to retrieve the values only and that would be helpful for me to solve this problem and also to understand the AF ...
Thanks, Sandeep Narang
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 612 Location: Cheshire, United Kingdom.
|
Hi Sandeep, So rather than repeat what OSI wrote I will point you towards chapter 3 & 4 of the AF 2 User Guide on Modelling and Analyses. A snippet: Quote:"After you create a model, you can do an analysis on the model using Analysis Rules. These rules allow for different calculations to be done on a model. A case represents a specific time range of a model analysis." So for example, you may have some daily calculations for a model that you want to perform. Your case would span the day/24h for an Analysis on a Model. Couple of things you can look towards - using the AF compatability layer or programmatically create analysis rules, cases etc. Before you get to an AFCase you need: (AFDatabase -> AFModel -> AFAnalysis -> AFCase). Of course there is no problem in writing your own Analysis Rule to perform your custom logic/calculations, then create cases based on your rules. Out of interest, if you took the 400 Attributes from AF are they all using the PI Point DR? If so, have you tried performing 400 snapshot retrievals from the same machine you are running your AF custom code from? Just in case there is a network issue or performance issue with your PI server. Kind Regards, Rhys. Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Member Groups: Member
Joined: 7/30/2009 Posts: 12 Location: Chandigarh
|
Hi Rhys,
Thanks for your suggestion. I was able to resolve the issue. Your assistance is much appreciated!
Thanks, Sandeep Narang
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 612 Location: Cheshire, United Kingdom.
|
Sandeep....glad to help!! Fancy sharing how you resolved your issue? (In case others have the same issue). Cheers, Rhys. Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Member Groups: Member
Joined: 7/30/2009 Posts: 12 Location: Chandigarh
|
Actually I used Attribute list and there was some network glitch between my system and PI DB (Some installation was going on that system). 
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 612 Location: Cheshire, United Kingdom.
|
OK cool - at least it is resolved now :-) Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
|
Guest
|