3 Replies Latest reply on Apr 6, 2011 1:56 AM by hanyong

    Exporting PI Data to XML [new tutorial] and Export AF data to Excel [new blog post]

    hanyong

      For people who are looking at ways to sharing data from PI System with applications or other systems using XML format. There is now a tutorial on in the Library section (under "White Papers and Tutorials"->"Miscellaneous") that shows you a couple of methods to do this using different tools.

       

      On top of the tutorial, I have a add-on about exporting AF data to Excel in the form of a blog post here.

       

      Take a look at it and do not hesitate to give me any feedback or comments on both of them =)

        • Re: Exporting PI Data to XML [new tutorial] and Export AF data to Excel [new blog post]
          MichaelvdV@Atos

          Those are great whitepapers! Thanks!

           

          About the tutorial 'exporting PI data to XML'.

           

          I would like to point out that:

          
          

          new XmlSerializer(_Results[0].GetType());

           

          is somewhat of an unsafe uption. If an empty resultset is returned, the GetType() will throw a nullreference/index out of bound exception. Maybe a typeof(<type>) is better suited, because the foreach loop will account for an empty Results array.

           

          As an addition to the XMLSerializer, the DataContractSerializer (XML) or (maybe offtopic) the DataContractJSONSerializer (JSON) could be used. JSON offers better info-to-size ratio. 

           

          If you want more control over the format, would you have to use XSLT? Because we don't have access to the generated properties of the Service Reference (well, we have, but we cannot change the serialization format, because then the calls to the webservice will fail). Maybe then LinqToXML (with PI WebServices or even the PISDK) are a good option.

           

           

          • Re: Exporting PI Data to XML [new tutorial] and Export AF data to Excel [new blog post]

            A straight forward way to export data from PI and AF to an XML file is using PI Notifications via the XML Delivery Channel. 

             

            The XML Delivery Channel essentially allows you to write the contents that typically goes to a PI Notifications Email to be instead written to an XML file.  Optionally, you can also apply an XSL transform.  

             

             Note that PI Notifications can trigger based on a PI event or on a clock/time schedule.

             

            You can search for XML Delivery Channel in the vCampus forum - a user has even posted the DLL that you can register; full source code has also been posted.  See details here:

             

            http://vcampus.osisoft.com/discussion_hall/generic_forums/f/13/p/1207/8048.aspx

              • Re: Exporting PI Data to XML [new tutorial] and Export AF data to Excel [new blog post]
                hanyong

                Thanks guys for the feedback.

                 

                @Michael: Sorry for the lack of response, I've totally missed out your post until I've received a notification about Gopal posting to this thread. To your point on:

                 

                Michael @ Atos Origin

                is somewhat of an unsafe uption. If an empty resultset is returned, the GetType() will throw a nullreference/index out of bound exception. Maybe a typeof(<type>) is better suited, because the foreach loop will account for an empty Results array.

                Good suggestion! I should make a new revision with your suggested changes =) 

                Michael @ Atos Origin

                As an addition to the XMLSerializer, the DataContractSerializer (XML) or (maybe offtopic) the DataContractJSONSerializer (JSON) could be used. JSON offers better info-to-size ratio. 

                If you want more control over the format, would you have to use XSLT? Because we don't have access to the generated properties of the Service Reference (well, we have, but we cannot change the serialization format, because then the calls to the webservice will fail). Maybe then LinqToXML (with PI WebServices or even the PISDK) are a good option.


                Definitely nice suggestions here. I'd say that ultimately the user would have to make the final decision about the format (XML or JSON) and how they would like to transform the XML to suit how their application would consume the information from PI System. These would open up the options available to the other community members that are looking for solutions for exchanging data between systems. If we get more feedback from the other users, we can better refine the papers to suit their needs =)

                 

                @ Gopal: Indeed, exporting data to XML via PI Notifications and XML Delivery Channel is a great option, especially when users need to trigger this data exchange with an event or a notification.