8 Replies Latest reply on Sep 7, 2016 12:48 PM by JanvanderVen

    Adding Data Sources to a Coresight Custom Symbol programmatically

    JanvanderVen

      Hi all,

       

      In order to make my custom Coresight symbol easy to use, I made in the following way:

      1) The user drops the parent attribute on the display

      2) Using the PI Web API the child elements and their relevant attributes are looked up

      3) The symbol is rendered for the first time

      4) Using the web api new data is read and the symbol updates itself

       

      If you then double click on the symbol the trend that is shown is of the first attribute only, which I completely expected by the way, How could Coresight know what's going on?

       

      I then found out what is displayed on that TrendPopup: The scope.symbol.DataSources.

       

      So once I had retrieved the children through the web api, I added the ones I wanted to that DataSources array. Et voila, the double click trend showed them all.

       

      But more things happened: The added datasources also came back in the dataUpdate function!

       

      This means that I can simplify my customization:

      1) The user drops the parent attribute on the display

      2) Using the PI Web API the child elements and their relevant attributes are looked up

      3) Add these to scope.symbol.DataSources array

      4) Use the Coresight data pump to update the symbol.

       

      Now my questions are:

      1) Are there any drawbacks to this scenario?

      2) Will this remain possible when the Coresight Extensibility is released?

       

       

      Kind regards,

       

      Jan

        • Re: Adding Data Sources to a Coresight Custom Symbol programmatically
          Marcos Vainer Loeff

          Hi Jan,

           

          Could you please share some code snippets from your custom symbol in order to understand better what you have described above?

           

          Thanks!

          • Re: Adding Data Sources to a Coresight Custom Symbol programmatically
            pthivierge

            Hello Jan,

             

            To your questions

            1) Are there any drawbacks to this scenario?

            If this works already that most-likely means this is fine.  Maybe Jason Golla can confirm.

            (Javascript is so easy to extend )

             

            edit: added jason reply to the answer.

            From Jason Golla:

            you are doing what I expected people would do, that is, find out how we are doing stuff in PI Coresight and hack at it to get it to do what you need it to do. Basically you are leveraging how we represent data sources internally, but this is an undocumented feature, as we didn't know what the future would hold for how we would do our data representation and we wanted to keep it open to change if we needed to. That being said, I do not believe this functionality is changing in the up coming PI Coresight 2016 R2 release.

             

             

            2) Will this remain possible when the Coresight Extensibility is released?

            Maybe/Maybe not, however if you write your JavaScript code in a way that it can be re-used, such your main logic sits in functions that takes parameters, you should be fine to migrate easily when time comes.

            Using PI Web API like you do is also a very good approach as this is clearly in the path for the future.

             

             

             

            hope this helps!

            • Re: Adding Data Sources to a Coresight Custom Symbol programmatically
              jgolla

              Hey Jan!

               

              For question #1, you are doing what I expected people would do, that is, find out how we are doing stuff in PI Coresight and hack at it to get it to do what you need it to do. Basically you are leveraging how we represent data sources internally, but this is an undocumented feature, as we didn't know what the future would hold for how we would do our data representation and we wanted to keep it open to change if we needed to. That being said, I do not believe this functionality is changing in the up coming PI Coresight 2016 R2 release.

               

              For question #2, I can not say. We are still working through the extensibility model, so any undocumented features could change. As far as the future of extensibility, perhaps Tom LeBay could talk more about that.

              1 of 1 people found this helpful