10 Replies Latest reply on Jul 15, 2013 9:38 AM by Eiko Willemsen

    Use of substitution variables in configstring DataReference

    Eiko Willemsen

      Hello,

       

      We use a datareference to get data from a WCF service.

       

      For modifying the configurationstring we use a custom form that contains a filtering mechanism to finally select one or more rows from a collection.

       

      When the configuration form is loaded this collection is filled from a WCF service. The adress of the WCF service is configured in an AF element at a static address. (\\SEVER\DB\\SytemOptions\WebService)

       

      To retreive this address we now use the default PISystem to connect to AF and get the address. Now our problem is: The client is used to connect to The TEST, ACCEPTANCE and PRODUCTION environment. When the default Server is PRODUCTION but we are connected to the TEST environment, the datareference will get the address from the default (PRODUCTION) database and filles the collection with data of the PRODUCTION environment.

       

      ofcourse we could fill the servername as part of the configuration string but we want the configurationstring to be independent of the connected server because we want to be able to export the elementes from ACCEPTANCE to PRODUCTION without having to modify all configurationsstrings of the datareferences. 

       

      My question is:

       

      Is there a way to configure a variable (eg %SERVER%) in the config string that is translated to the Server that is connected and not to the default Server? This way we could always fill the collection of the form with the data from the webservice of the connected environment.

       

      If this is not possible, is there another way to retreive the connected server or database while we use the form for editing the configurationstring?

       

      Regards,  Jeroen Gelderman

        • Re: Use of substitution variables in configstring DataReference

          Instead of using %Server% store your required PI Server/Collective name in a top level Attribute and reference that in your configuration string. Then switching between environments you just change the top level attribute. It enforces the required PI Server regardless of defaults on the client.

           

          For example,

           

          \\%@\SystemOptions|PIServerName%\sinusoid

            • Re: Use of substitution variables in configstring DataReference
              Eiko Willemsen

              our config string contains a lot of values that are used for the filtering in the editor window

               

              If I use a %variable% as part of the config string, I just get the same string back in my editor window and not the translated value. How can I reference an Attribute this way?

               

              Our users are switching the connection in the AF client between ACCEPTANCE and PRODUCTION all the time. They compare the configurations of these environments with each other.

               

              We dont want our users to change an attribute all the time when switching environment.

               

              Is there any other solution to this problem?

                • Re: Use of substitution variables in configstring DataReference

                  Is your hierarchy driven by Element & Attribute Templates?

                   

                  The only reason you'd get the substitution parameter string back as you set it is if you gave an invalid AFPath. If you give a correct path then it resolves.

                   

                  On the switching of environments, then you are going to have to be explicit at some point on defining which environment you want to connect to. You've already found relying on the default PI Server can cause problems, any other solutions that use assumptions is going to give you the same/similar issues.

                    • Re: Use of substitution variables in configstring DataReference
                      cmanhard

                      Attribute substitution requires the @ sign --   %@\SystemOptions|PIServerName%  - it looks like you may have missed it. 

                       

                      Prior to AF 2.5, if you use a substitution variable in the PI Point DR in an attribute, as opposed to an attribute template, the editor in PSE would automatically resolve and replace the configuration with the resolved / substituted value.  Because of requests similar to yours, AF 2.5 will leave the substitution syntax in place when editing attributes as well as attribute templates. Even with 2.5, you will need to use the "Shift-Click" on the settings button in PSE to see the raw configuration string.

                       

                      Note that without substitution syntax, AF will resolve the tag and store the point id of the tag within the configuration string.  Again, this can be seen by using a "Shift-Click" on the Settings button in PSE, or exporting XML. With the point id in the configuration string, AF does not need to resolve the tag prior to use.  If AF detects substitution syntax anywhere in the configuration string, it will not store the point id.  Thus, be aware that the dynamic resolving of the server and tag will affect performance. While the difference may not be detectable within PSE, if you use a query to evaluate tens of thousands of attribute values in this manner, it will matter.

                       

                       

                        • Re: Use of substitution variables in configstring DataReference
                          Eiko Willemsen

                          This is not about a PI Point DR but a custom DR with an Editor Window to configure the settings.

                           

                          If I use the substitution, the configstring looks like: see picture:

                           

                           6574.TSDMConfigDR.png

                           

                          The editor window is just parsing the configuration string and fills the textboxes/comboboxes

                           

                          2211.TSDMConfigEditor.png

                           

                          If I define a new PIpoint datareference I see the Substitution is working there but not for the custom DataReference
                          I hope I did something wrong or there is another option to solve this.

                           


                           

                            • Re: Use of substitution variables in configstring DataReference
                              cmanhard

                              Sorry, there is no built in method for doing attribute value substitution in AF.  The SubstituteParameters base class implementation ignores attribute values  substitutions.  There are some helpers though.

                               

                              AFDataReference.GetAttribute(string) can be used for changing any attribute string path into an actual attribute.  That way, you are using consistent path evaluation with AF.  In the example above, you would pass the string "\SystemOptions|PIServerName" to get back the attribute.  Converting this attribute into a string involves calling GetValue, checking for .IsGood, then replacing your substitution string with Convert.ToString(afValue.Value, CultureInfo.InvariantCulture)