10 Replies Latest reply on Aug 27, 2010 10:38 PM by spilon

    PISDK Installation

    ptulou

      Hello,

       

      I've been developing a Windows service that talks primarily with the PI OPC interface.  However for one feature we would like to access the PISDK directly.  Our current test setup has my service on one machine and the PI server on another.  It is my understanding that the PISDK would need to be installed on the same machine as my application in order to access it, is that correct?  If so, is there a way I can install just the PISDK on that machine?  Alternatively, is there a way I can remotely access the PISDK accross machines?  On the OSI PI machine, I'm using the May vCampus installation.

       

      Thank you for your help,

       

      paul

        • Re: PISDK Installation
          JMessinger

          Paul,

           

          Yes, you will need to install the PI-SDK on the local machine where your Windows service will run, if you want to make use of any of the PI-SDK functions. This would be the same as for any library that you would want to access from your application.

           

          There is an install kit for just the PI-SDK, so you can install the SDK without the need to install other applications that may be dependant on the PI-SDK. This install kit should be within your vCampus software bundle.

           

           

            • Re: PISDK Installation
              ptulou

              Thanks John!  I've got the PISDK installed now.  I installed the x64 version on the machine in question.  However, now I'm getting a very odd error that I'm hoping someone can shed some light on:

               

              System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'System.Collections.IEnumerable'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{496B0ABE-CDEE-11D3-88E8-00902754C43A}' failed due to the following error: 'No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))' and the COM component does not support IDispatch::Invoke calls for DISPID_NEWENUM.

               

              Do I need to use one of my licenses for this PISDK installation?  I was hoping the PI Server license would cover that.

               

              It looks like I get through several basic PISDK calls and then it blows up when I try access Server.PointClasses.

                • Re: PISDK Installation

                  Paul Tulou

                  Do I need to use one of my licenses for this PISDK installation?  I was hoping the PI Server license would cover that.
                  From a licensing standpoint, your vCampus membership provides you with the development license for the PI Data Access products, which include PI SDK. While the PI Server can only be installed in one instance (with a machine-specific license file), you can install the PI SDK on more than one machine - as long as this is for development purposes. As John pointed out, there is a separate setup kit for PI SDK.

                   

                  When comes time to deploy/run your PI SDK-based applications within the organization, you need to ensure you have the appropriate runtime license. This is covered by the legacy Data Access Package (DAP) license, or with the PI System Access (PSA) license. Talk to your account manager for more information on this.

                   

                  Paul Tulou

                  It looks like I get through several basic PISDK calls and then it blows up when I try access Server.PointClasses
                  Can you share some of the code you are using, and indicate where it is you get the exception?

                    • Re: PISDK Installation
                      ptulou

                      Are there permissions I need to change on the PI Server in order to allow access from other machines?  I tried a test on my development PC that has PI Server and the SDK installed.  I tried to connect to the remote machines PI Server from that and when I do it looks like the connection is never made.  All I have to do for the local installed PI Server is check the check box next to the name in the PI System Management Tools.  When I do the same thing with the remote PI Server, it never connects so that I can browse tags, etc.  Both PI Servers are vCampus installs.

                       

                      here's code.  I'm using reflection to load the assemblies, etc.  This all works when I run the code form my local machine that has both PISDK and the PI Server installed on it.

                      publicList<string> GetPointClassNames(string piServerName) 
                      {
                          if (string.IsNullOrEmpty(piServerName))
                              thrownewArgumentNullException("piServerName");

                          Assembly piSdkAssembly = GetPiSdkAssembly();
                          Type serverType = piSdkAssembly.GetType(serverClass);
                          Type pointClassesType = piSdkAssembly.GetType("PISDK.PointClasses");
                          Type pointClassType = piSdkAssembly.GetType(pointClassClass);
                          object serversObject = GetServersObject(piSdkAssembly);
                          object serverObject = GetServerObject(piSdkAssembly, serversObject, piServerName);
                          List<>string> pointClassNames = newList<>string>();
                          object pointClassesObject = serverType.GetProperty(pointClassesProperty).GetValue(serverObject, null);
                          object enumeratorObject = pointClassesType.GetMethod("GetEnumerator").Invoke(pointClassesObject, null);
                          IEnumerator enumerator = (IEnumerator)enumeratorObject;

                          while (enumerator.MoveNext())
                          {
                              object pointClass = enumerator.Current;
                              string pointClassName = pointClassType.GetProperty(nameProperty).GetValue(pointClass, null).ToString();
                              intClassNames.Add(pointClassName);
                          }

                          return pointClassNames;
                      }

                        • Re: PISDK Installation
                          ptulou

                          Actually, I was in the middle of some edits when I posted that code. And that code actually fixed the issue. Basically I changed it from doing an IEnumerable cast on the PointClasses class to doing an invoke on PointClasses.GetEnumerator() and then casting that result to an IEnumerator. Now, I get a seperate error which I believe relates more to logging into the PI Server from other machines than anything else. Here's the exception:


                          System.Runtime.InteropServices.COMException (0x80040402): Unable to open a session on a server.
                          [-10431] Authentication method is disabled by current server policy

                          This is the code that's getting the server. Once again, this works for the local PI Server, but not a remote one.


                          private static object GetServerObject(Assembly assembly, object serversObject, string name)
                          {
                             Type serverType = assembly.GetType(serverClass);
                             object serverObject = null;
                             IEnumerator enumerator = ((IEnumerable)serversObject).GetEnumerator();
                             while (enumerator.MoveNext())
                             {
                                serverObject = enumerator.Current;
                                string serverName = serverType.GetProperty(nameProperty).GetValue(serverObject, null).ToString();
                                if (serverName == name)
                                   break;
                             }
                             return serverObject;
                          }

                          Thanks for your help, paul

                            • Re: PISDK Installation
                              ptulou

                              I have no idea why I can't get the formatting right on these posts.

                                • Re: PISDK Installation

                                  Paul Tulou

                                  I have no idea why I can't get the formatting right on these posts.
                                  I edited your previous post with the code snippet, such that it is more readable. Essentially, when you copy from Microsoft applications such as Word or Visual Studio, there is a lot of "invisible metadata" that comes with the text you're copying... the text editor is then trying to make sense of it and display it in HTML. Depending on your font settings (and everybody may have different settings), the end result may be interpreted differently. That also includes how line feeds are being interpreted (they need to be transformed into either "BR" or "P" HTML tags).

                                   

                                  With that said, you might to run your code/text in Notepad prior to importing it in the post editor.
                                  If you really do care about formatting and colours, then you can copy/paste the code into the post editor, go into the HTML option on the toolbar above, and then remove unnecessary HTML tags...

                                • Re: PISDK Installation

                                  Paul Tulou

                                  And that code actually fixed the issue. ... 
                                  Now, I get a seperate error which I believe relates more to logging into the PI Server from other machines than anything else. ...  
                                  Authentication method is disabled by current server policy
                                  This has to do with the security settings of your PI System and the various authentication/connection mechanisms. Depending on how your PI Server is configured, a local connection may be more privileged than a remote one, and you may or may not be allowed to connect using a username/password.

                                   

                                  I strongly recommend you take a look at the "PI Server 2010 Configuring PI Server Security" manual, available on the vCampus Library, under the vCampus PI Products Kit > Server Products > PI Server branch.

                                   

                                  Also, you are getting away from programming here... back to basic connection and security. I recommend you open the "AboutPI-SDK" utility on that remote machine, click on Connections and test the connection from there. Since this is more a PI System administration/configuration issue, please contact the regular Technical Support team and they'll help you with that.

                                   

                                  I also suggest you take a look at the PI System Manager I: Essential Skills training course (online on vCampus or instructor-led) and the PI Programming 101 webinar (under the vCampus Auditorium).

                                • Re: PISDK Installation

                                  Paul Tulou

                                  here's code.  I'm using reflection to load the assemblies, etc. 
                                  Not too sure why you are using reflection here... you could simply instantiate the top-level PI SDK object, connect to a PI Server and list its Point Classes.

                                   

                                  Something like:

                                  public List<string> GetPointClassNames(string piServerName)
                                  {
                                      PISDK.PISDK myPISDK = new PISDK.PISDKClass();
                                      PISDK.Server myServer = myPISDK.Servers[piServerName];
                                      PISDK.PointClasses pointClassesType = myServer.PointClasses;

                                      List<string> pointClassNames = new List<string>();
                                      foreach (PISDK.PointClass pointClassType in pointClassesType)
                                              pointClassNames.Add(pointClassType.Name);

                                      return pointClassNames;
                                  }

                                    • Re: PISDK Installation

                                      Quick note on my previous example: depending on your application implementation, you'll probably want to declare and instantiate the PISDK.PISDK and PISDK.Server variables elsewhere (somewhere with a larger scope, where they get initialized and leveraged by other classes and methods).