8 Replies Latest reply on Oct 27, 2014 8:28 AM by asorokina

    AFLibrary translations

    larry.mcdonald

      Using the code below (AFSDK 2.6), we read an XML file (myLibraryFile.xml) that contains the definitions of AFElementTemplates and AFEnumerations.  

       
      myLibrary = afDatabase.PISystem.Libraries.Add("myLibraryFile.xml", "My.Library");
      afDatabase.PISystem.CheckIn();
      
      myLibrary.Import(afDatabase);
      afDatabase.CheckIn();
      

       This works, but we have a requirement that the attribute names need to be translated into different languages.  Testing with Cyrillic characters, the error occurs:  

       

      A first chance exception of type 'System.OperationCanceledException' occurred in OSIsoft.AFSDK.dll Additional information: Error occurred on line 332, column 9, near 'AFAttributeTemplate' while processing Element Template 'My.Element.Template': An invalid character '?' was used in the name '????????? ??????? ??????'. Parameter name: name

       

      Using the same file (myLibraryFile.xml), I can use PI System Explorer and import the file to create AFElementTemplates and AFEnumerations -- and the Cyrillic characters are imported successfully.  Is there a different function that I should be using through the AFSDK to successfully read and import the XML file that contains Cyrillic characters?

        • Re: AFLibrary translations
          asorokina

          Hi Larry,

           

          The issue happens within the routine that parses the XML and creates the library. I can reproduce the issue, which looks (at first glance) to be due to the XML parsing not respecting encodings such as UTF8. We'll see what the developers say.

           

          Here is an alternative approach that works for me with Cyrillic characters (with no library creation involved):

           
                      AFDatabase afDatabase = afServ.Databases.Add("BelkaDB");           
                      var importOptions = PIImportMode.AllowCreate | PIImportMode.AllowUpdate;           
                      afServ.ImportXml(afDatabase, importOptions,"BelkaDB.xml");
                      afServ.CheckIn();
          

           

           

          Regards,

           

          Anna

            • Re: AFLibrary translations
              larry.mcdonald

              Thanks Anna -- the above changed worked for importing AF Templates.  Now I am facing a similar issue where I save PI attributes in Cyrillic.  I use the code: 

               

              piPoint.SetAttribute("EngUnits", engineeringUnit);
              piPoint.SetAttribute("descriptor", descriptor);

               

              var errors = piPoint.SaveAttributes(

               

              new string[]
              {
              "EngUnits",
              "descriptor",
              });

               

              I do not receive any errors (and it works in English), but when I look in ProcessBook or Pi System Management Tools, the EngUnits and descriptor are showing question marks (???) for Cyrillic characters.  If I use Pi System Management Tools (Pi Point Builder) and paste Cyrillic characters directly into the EngUnits field and save the Pi Tag, the value seems to stick.  This seems to point to the API (SaveAttributes function) that is not working correctly.

               

              I have installed Windows Language Pack, Process Book Language Pack (using ProcessBook 2012 SP2), AF Client/AF Server Language Packs.

               

              Any ideas or setup steps to get Cyrillic characters to save using the AFSDK?

               

              Thanks,

               

              Larry

                • Re: AFLibrary translations
                  ekuwana

                  PIServer does not have Unicode support. This old posting may help:

                   

                  vcampus.osisoft.com/.../4952.aspx

                    • Re: AFLibrary translations
                      jking

                      Here is a Knowledge base article that talks about all of this:

                       

                      techsupport.osisoft.com/.../KB00454

                       

                      The article is not the most up-to-date but most of the information on there still holds true especially in regards to how strings are stored in the PI server.  I hope this helps.

                        • Re: AFLibrary translations
                          asorokina

                          Hi Larry,

                           

                           

                           

                          SetAttributes works fine on my test PI Server locally. Could you please try running your application locally on the PI Server? What is your system language for non-Unicode programs (control panel->Regional and Language Options) ? 

                           

                           This is my code snippet just in case:

                           
                                      try
                                      {
                                          PIServer _piserver = PIServers.GetPIServers()["MyPIServer"];
                                          PIPoint point = PIPoint.FindPIPoint(_piserver, 15);
                          
                                          point.SetAttribute(PICommonPointAttributes.EngineeringUnits, "блаблабла");
                                          point.SaveAttributes(PICommonPointAttributes.EngineeringUnits);
                                      }
                                      catch (Exception ex)
                                      {
                                          Console.WriteLine(ex.ToString());
                                      }
                          

                           

                           

                          Regards,

                           

                          Anna

                            • Re: AFLibrary translations
                              larry.mcdonald

                              Hi Anna,

                               

                              I am testing with a local PI Server with same results.  I have converted my computer to as much Russian as I can find (Russian language pack for Windows).  The system language for non-Unicode programs has been set to Russian.  I have verified programmatically that the default system code page is 1251 (Cyrillic).

                               

                              I have the following setup (but have tried with other variations as well):

                               

                              AF Server 2014 R2

                               

                              PI Server 2012 + Patch

                               

                              AF Client 2014 R2

                               

                              PI ProcessBook 2014

                               

                              AF Server 2014 R2 MUI

                               

                              AF Client 2014 R2 MUI

                               

                              PI ProcessBook 2014 MUI

                               

                              Still, after executing the code (even used the text "блаблабла"), when viewing the units in ProcessBook or System Managment Tools, the engunits are displayed as ????????.

                               

                              Can you share your computer setup and PI/AF versions.

                               

                              Thanks,

                               

                              Larry

                      • Re: AFLibrary translations
                        jshaver

                        Hi Anna and Larry,

                         

                        The root cause of the problem with importing a Cyrillic library to populate an AFDatabase has been found and has been scheduled for inclusion in the next AF release.  The AF work item number is 113061.

                         

                        Regards,

                         

                        Jeff

                          • Re: AFLibrary translations
                            asorokina

                            Hi Larry,

                             

                            I have Russian Language pack for Windows (2008 R2), no MUIs. chcp returns 866. Language settings in SDK Utility (Tools->Set Language) is set to 1049 (rus).

                             

                            PI Server 3.4.390.16, AF SDK 2.5.2.5396.

                             

                            The application was created with AF SDK 2.6.0.5843

                             

                            Regards,

                             

                            Anna