AnsweredAssumed Answered

Delayed connection \ Reconnecting to PI database using PIAPI

Question asked by gsauer on May 9, 2016
Latest reply on May 12, 2016 by gregor

In order to increase the robustness of my proprietary interface I have been unable to establish a delayed connection or re-connection to PI database.  The interface is written in C++ and uses the PIAPI.  The interface itself works fine in normal operation which means with the database running and trust properly established it can connect, buffers and updates data without any problem:

 

 

A simplified version of the steps followed are:

    1)  The interface stops and then restarts the PIBUFSS (this is to make sure the interface itself is loaded after the the buffering subsystem.

    2)   It then uses LoadLibrary(L"PIAPI32"); and gets handles to all of the functions to be used.

    3)   It then calls piut_setappidentity(...)

    4)   It then calls piut_setprocname(...)

    5)   It then calls piut_connect(...)

    6)  Followed by piut_login(Username, Password, &valid);

    7)  Read the PI points from the database:

          while (true) {

                 int32 rc = pipt_nextptwsourcelong(m_InterfaceName, &pt);

                 if (rc != 0) {

                 break;

            }

     8)  Send updates

 

 

To test the a delayed connection I disable the trust for the interface. I then follow steps 1) and 2) above.  Thereafter I call

piut_netnodeinfo

in order to check the connection which returns FALSE due to the trust failure.

The interface then repeats waiting  a minute and doing a retry attempt by 1) FreeLibrary (on the PIAPI32) and then 2) a stop / start of the PIBUFSS then checking the connection with PIUT_NETNODEINFO.

 

After enabling the trust, I can see that the connection seems to be ok.  I can even call PIBUFSS -cfg and see that the connections to primary and secondary database are registered but I am unable to complete the sequences 3) -> 8) above.

 

I have to restart the interface, then everything runs.

 

Any ideas? - and thanks for suggestions

Outcomes