3 Replies Latest reply on Aug 18, 2017 2:57 PM by Roger Palmen

    Custom symbol: how to approach a more complex symbol with multiple inputs and types of data?

    Roger Palmen

      I'm currently building a custom symbol that provides a specific visualisation on customer requirement. The symbol takes an element as input (DatasourceBehaviors.Multiple), and uses the datashape "Table". From the set of attributes defined on the element, and thus added to the sourcelist of the symbol, it derives the following:

      • Using a batched call to the PI Web API, for a number of attributes the WebID is retrieved
      • From a number of attributes, the value is taken using the regular dataupdates on the symbol
      • On the same dataupdate, a batched call to the PI Web API is used to return plotvalues using the WebIDs previously returned

       

      Now this raises a few questions if i'm doing this the right way:

      1. Every time i get the dataupdate, it will perform the plotvalues call. This seems rather wasteful to me as 95% percent of the data won't change. I think i can't use the DataShape: 'TimeSeries' / DataQueryMode: CS.Extensibility.Enums.DataQueryMode.ModePlotValues, as the data i need to plot is NOT over the same data range as the display.
      2. The plotvalues return as 4 separate sets of data with values and timestamps. If these are called with the same parameters (starttime, endtime, intervals), do they always return the same number of results? On my amCharts charting lib, i need to provide a dataset with a single timestamp for all plotvalues. How to combine the results to ensure i can add the separate sets into one dataset for the chart?

       

      Or maybe my approach should be different altogether?

      The approach in PI-Coresight-Custom-Symbols/Community Samples/OSIsoft/amcharts-trend at master · osisoft/PI-Coresight-Custom-Symbols · G… does not have this specific problem as this example only plots the first item...

        • Re: Custom symbol: how to approach a more complex symbol with multiple inputs and types of data?
          Roger Palmen

          Now some more detail to add: of the 4 plotvalues datasets i get, two are fed by PI Points and have values at the interval start- and endtimes, and several values in between. The other two are more static, and only have values at start- and endtime. Is it a coincidence that these match? All 4 go into a batch PI Web API call with start -1d and end *, so is the webAPI ensuring these are resolved equal for all queries in the batch?

          • Re: Custom symbol: how to approach a more complex symbol with multiple inputs and types of data?
            Eugene Lee

            Hi Roger,

            If these are called with the same parameters (starttime, endtime, intervals), do they always return the same number of results? On my amCharts charting lib, i need to provide a dataset with a single timestamp for all plotvalues.

            For different PI tags and AF attributes, the number of results might be different with plotvalues and the timestamps are hard to control. It is better to use interpolatedvalues to ensure that the timestamps for all datasets are the same.

             

            All 4 go into a batch PI Web API call with start -1d and end *, so is the webAPI ensuring these are resolved equal for all queries in the batch?

             

            The default value for the startTime and endTime parameters are '*-1d' and '*'. So it is not the PI Web API ensuring that they are equal. i.e. you can use different starttimes and endtimes for each query in the batch.

            This seems rather wasteful to me as 95% percent of the data won't change.

            In my opinion, it might be simpler like this codewise than the alternative which is to cache the existing data and only fetch new events and then add them to the dataset.

              • Re: Custom symbol: how to approach a more complex symbol with multiple inputs and types of data?
                Roger Palmen

                Hi Eugene,

                 

                Thanks for thinking along with me!

                 

                I already decided to go for interpolated values too to make sure the datasets are equal, and that any interpolation behaviour required to match the datasets does not end up at the client. That would be a major pain anyways!

                 

                Wrt the Batch call, if i have 4 batch calls, each using * as end time, they could potentially be executed at different times, so we could have 4 different timestamps of "*". So that's why i was wondering. I did not see that effect though, but still wondering if this is by design, or by coincidence...

                 

                Re-querying is easiest, but just seems very wasteful and not very scaleable. I'm not sure how e.g. the stock trend is working, that might use the Channels options of the PI Web API and have logic builtin to update the dataset.