1 Reply Latest reply on Nov 25, 2016 1:50 PM by gregor

    Creating a database programtically

    StuartHemming

      I have a bunch of Templates exported as XML. Some represent items that will have data collected against them, some represent items to be used in a hierarchy.

       

      So, lets say my templates folder contains

      A.xml, B.xml, C.xml and a number of data point elements X.xml, Y.xml and Z.xml.

       

      I want to put code together that will allow someone to say this is my structure, go create it, and pass in a description that represents this...

       

      A

      |-B

        |-X

      |-C

      |-Y

         |-Z

       

      Now if that was all it was I know I could create the hierarchy, export it and just reimport it on demand. But. I want the user to be able to describe the shape of the hierearchy at run time, so the could have just as easily asked for...

      A

      |-B

      |-C

         |-Z

       

      The problem is that I can't seem to work out how to import a template in to a particular point in my existing hierarchy. PISystem.ImportXML() doesn't seem to know how to do this.

       

      Is it possible?

        • Re: Creating a database programtically
          gregor

          Hello Stuart,

           

          Yes, it is possible to programmatically create an AF Database, to programmatically create Element and Attribute Templates, to programmatically create Elements with parent child relationships based on templates or without using a Template and it's as well possible to programmatically add Attributes to an Element or child Attributes to an Attribute.

           

          I understand there might be different ways to create asset structures because e.g. different departments have different requirements. In that regards it may be reasonable to have different asset views realized in different AF Databases even the equipment more or less is the same. There should however be some kind of common sense about how to look at an infrastructure to allow communication between members of different departments. Having each user define its own view is likely very convenient to users as long as they don't need to communicate to each other. As soon as they have to, they will be doing hard to find a common understanding.

           

          The Export / Import functionality offered with PI System Explorer is intended to backup an existing infrastructure or to duplicate it. It's not designed to create individual infrastructures.

          You may gain more flexibility by using the PI Builder Add-in to Microsoft Excel. If this is still not sufficient, you will need to create your own custom application e.g. based on AF SDK as a tool for users to create their individual Asset Databases.