3 Replies Latest reply on Mar 18, 2019 4:49 PM by gregor

    AFData.PlotValues problem with multiple calls

    cymerman

      Hi, I have specific problem and I dont know how to handle it...

       

      please look at my code:

       

      List<AFAttribute> values...
      
      var afValues1 = values[0].Data.PlotValues(new AFTimeRange(new AFTime(criteriaStartTime), new AFTime(criteriaEndTime)),
      plotDataInterval,
      values[0].DefaultUOM);
      

       

      Im using it to get values for plot for specific element, and... it works, let say that when im doing a request i have in response 14 values what is fine for me, but when I have multiple request in same time for getting data for plots (I have view when i can show multiple plots) i have random situations when getting those plot values returns list with one element with value:

       

      afValues1[0]:PI Data Archive '%@\ConfigurationItems|PIServer%' was not found

      Value:System.InvalidOperationException: PI Data Archive '%@\ConfigurationItems|PIServer%' was not found

         at OSIsoft.AF.Asset.DataReference.PIPointHelper.ResolvePIServer(IDataReference dataReference, String serverName, String serverId, String& resolvedServerName, String& resolvedServerId, Boolean& nameSubstituted, Boolean& configuredServerIdInvalid)

         at OSIsoft.AF.Asset.DataReference.SinglePIPointResolvedConfiguration.Resolve(IDataReference dataReference, SinglePIPointConfiguration config)

         at OSIsoft.AF.Asset.DataReference.PIPointDR.GetSinglePIPointResolvedConfiguration(IDataReference context)

         at OSIsoft.AF.Asset.DataReference.PIPointDR.PlotValues(AFTimeRange timeRange, Int32 intervals, AFAttributeList inputAttributes, AFValues[] inputValues, List`1 inputTimes)

         at OSIsoft.AF.Data.Query.PlotValuesQuery.ExecuteQueryForSource(AFDataReference dataReference)

         at OSIsoft.AF.Data.Query.MultipleValuesQuery.OSIsoft.AF.Data.IExecutableDataQuery<OSIsoft.AF.Asset.AFValues>.ExecuteQueryForSource(AFAttribute attribute, AFDataReference dataReference, UOM desiredUOM)

       

      In moment when it happens im trying to retry operation (even multiple times) but it ends in same result.

       

      Do you have any ideas why it happening and what I have to do to have responses all the time, even when it would be a lot of requests.

       

      And maybe information that i tried to get same data by WebApi, in multiple tabs for same url and for every request I had correct response.

        • Re: AFData.PlotValues problem with multiple calls
          gregor

          Hello Tomasz,

           

          Can you share information on how you instantiate the PISystem object? Is it that you create a new instance with each (PlotValues) data request and execute multiple parallel data requests?

            • Re: AFData.PlotValues problem with multiple calls
              cymerman

              Hi, Im creating PiSystem object at start of application and I tired to do it in pararell but also sequentially and in both ways was same result.

               

              What I did for now and what looks fine is reconnect PiSystem for every try of getting values, beginning from getting element from structure.

               

              Maybe I should do additional connection for every request, maybe it would be better.

                • Re: AFData.PlotValues problem with multiple calls
                  gregor

                  Hello Tomasz,

                   

                  No. Please create a single PISystem object and keep the connection open while your application is running. Please do not close the connection nor create a separate PISystem instance with each call for data.

                   

                  The PISystem (and PIServer) object is capable handling connection problems on its own. When instantiating PISystem, you create an instance in the context of your application, the server and the user account. When attempting to create additional instances for the same server in the same user context and the same application, the existing instance will be used. When you close or destroy the PISystem instance in one thread and another thread attempts to retrieve data, you are running into problems. Hence please use a single PISystem instance only, unless you connect multiple servers and / or connect using different user contexts.

                  1 of 1 people found this helpful