3 Replies Latest reply on Nov 17, 2014 2:48 PM by Gregor

    execution time

    cfaure

      Hello all,

       

       

       

      I developped my own interface and I have the following problem :

       

       

       

      1) The call of the following procedure takes more than 2,5 seconds :

       

      ret = piPointInput.ArchiveStrVar(G_server_name);

       

      2,5 seconds is the difference of the measure of the time before and after the call of the function.

       


       

      2) The procedure contains the following code lines:

       

       

       

      bool pi_pointInput::ArchiveStrVar(string serverName)
      {
          
          bool ret = false;

          // pi_server
          pi_server piServer;     // refer to the pi_server class
          HRESULT errorNb;      // _com_err error number
          _bstr_t errorDescr;   // _com_err error description


          // SELECT PI SERVER
          errorNb = 0;
          ret = piServer.selectServer(serverName, errorDescr, errorNb);
        
          return ret;
      } // end ArchiveStrVar

       


      If I measure the time at the beginning of the function and just before the return of the function, the difference is about 300ms.

       


       

      3) the content of selectServer is :

       

      bool pi_server::selectServer(string serverName, _bstr_t &errorDescr, HRESULT &errorNb)
      {
          IPISDKPtr pPISDK(__uuidof(PISDK));
          ServersPtr pServers;
          bool ret = TRUE;

          // select list of servers
          pServers = pPISDK->Servers;
         
          if(pPISDK != NULL) pPISDK.Release();
          if(pServers != NULL) pServers.Release();

       


          return ret;
      }

       


       

      Do you see something wrong ? perhaps in the release of the variables ?

       

      If I comment the  pServers = pPISDK->Servers; line, the mesure in 1) is about 100 ms, instead of 2,5s.

       

       

       

      Thank you for your help !

       

      Cyril

        • Re: execution time

          Hello Cyril,

           

          How does your custom interface chose what PI Server to connect? Do you use a configuration file, a registry entry or the PI Data Archive node configured as default? It appears as if you are using the servers name (string serverName). Have you tried using serverName as selector or do you iterate through the list of servers and connect to the one that matches serverName?

           

          At this point I must admit that I am doing hard with C++. So please apologize if the answer to some question is obvious from the code snippets you've included with your post. Are you connecting to the PI Data Archive when you like to send updates and close the connection afterwards or are you keeping the connection open while your interface is running?

           

          As far as I can see, the issue is with retrieving the known servers list. How many entries does your known servers list have? Can you please check if there are any abandoned connections that currently do not resolve? If so, please try if a cleanup of the known servers table helps.

           

          Finally I have some questions that may turn out to be of philosophical nature.

           

          Why C++?

           

          Why PI SDK and not the Rich Data Access AF SDK? The latter is a .NET library which supports bulk calls and multi threading. You may gain performance far beyond what PI SDK can offer. PI Buffer Subsystem is supported too.

            • Re: execution time
              cfaure

              Hello Gregor,

               

              I found the issue. It was a problem of class instantiation and lost of server connection.

               

              Thank you. It's your questions that make me asking the right questions.

               

               

               

              I chose C++ because it was the only language I knowed. And nobody at Osisoft tells me that it's not a good choice.

               

              And PI SDK for the same reason, I asked a lot of questions about PI SDK or PI API before beginning the development and nobody told me about AF SDK.

               

               

               

              Regards,

               

              Cyril

                • Re: execution time

                  Hello Cyril,

                   

                  Cyril Faure

                  I found the issue. It was a problem of class instantiation and lost of server connection.

                   

                  Thank you for sharing the good news.

                   

                  Cyril Faure

                  I chose C++ because it was the only language I knowed. And nobody at Osisoft tells me that it's not a good choice.

                   

                  I didn't intend to say C++ is a bad choice. To me it's more or less a question of readability and that's where I am doing hard with C++. One question that can be discussed contrary is if code should be managed or unmanaged. I am unsure if we officially recommend creating managed code and as far as I know with C++ it is possible to create managed and unmanaged code. Therefore I consider the choice of development language a personal preference. I also don't want to argue if the development cycle takes longer with C++ compared to e.g. C #. The major advantage that I would see is that C# and VB.Net can be considered somehow common and the majority of examples and code snippets you will find in vCampus forums are C# or VB.Net.

                   

                  Cyril Faure

                  And PI SDK for the same reason, I asked a lot of questions about PI SDK or PI API before beginning the development and nobody told me about AF SDK.

                   

                  This is sad and I am sorry we brought AF SDK into the discussion late. Again, I didn't say that developing against PI SDK is illegal but was questioning the decision. I can only suggest you looking into some C# examples based on AF SDK, if you find some time.