16 Replies Latest reply on Oct 3, 2011 9:49 PM by spilon

    KPIDemo/Silverlight Error

    Halenger

      I'm trying to replicate Lonnie's KPIDemo13 SilverLight project and keep getting the following error:

       

      System.ServiceModel.CommunicationException was unhandled by user code
        Message=An error occurred while trying to make a request to URI 'http://xxx:81/PIWebServices/PITimeSeries.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.
        StackTrace:
             at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
             at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
             at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
             at KPIDemo13.PIWebService.PITimeSeriesClient.PITimeSeriesClientChannel.EndGetPISummaryData(IAsyncResult result)
             at KPIDemo13.PIWebService.PITimeSeriesClient.KPIDemo13.PIWebService.IPITimeSeries.EndGetPISummaryData(IAsyncResult result)
             at KPIDemo13.PIWebService.PITimeSeriesClient.OnEndGetPISummaryData(IAsyncResult result)
             at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
        InnerException: System.Security.SecurityException
             Message=""
             StackTrace:
                  at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
                  at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
                  at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
             InnerException: System.Security.SecurityException
                  Message=Security error.
                  StackTrace:
                       at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
                       at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
                       at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__1(Object sendState)
                  InnerException: 
       

       

      I'm not sure on where to go from here... I've edited the web.config file for BasicHttp and set impersonateCallerForAllOperations="true".  I've also verified my PI WebServices are/is working as I used the WCFStorm shareware as recommended in the PI Web Services 2010 User's Guide.  Be easy on my, I'm a systems integrator, not a developer..... yet.

       

       

       

      Kind Regards,

       

      John

       

       

        • Re: KPIDemo/Silverlight Error
          dtakara

          Hi John,

           

          You may want to take a look at this thread. Please let us know if some of the hints there help you.

            • Re: KPIDemo/Silverlight Error
              Halenger

              Thanks! I finally got back to this and got it to work!

               

              I'm learning alot from this demo (via reverse engineering) and have one further question:  Instead of wanting the average of a PI Tag, I'm using "PISummaryMannerSummaryValue.Total" to find the total consumption of a flow meter.  I can't seem to find a way to program a conversion factor of 1440 (flow meter is in GPM) into the returned total number...  The User Guide doesn't explain how this can be achieved, but it does say I can use the PISummaryMannerSummaryValue enumeration (pg 76).

               

              Thanks!

                • Re: KPIDemo/Silverlight Error
                  Ahmad Fattahi

                  It should be using the same UOM of the underlying object. For example, if you are retrieving the total of a tag with a UOM set to GPM, then it's natural to return then total in the same UOM. Do you see anywhere in the documentation that you can get the summary result (total in this case) in a different UOM than the underlying attribute?

                   

                  Glad you found the example useful!

                    • Re: KPIDemo/Silverlight Error
                      Halenger

                      Hi Ahmad... Thanks for responding.  I think I understand what you are saying with regards to the OUM, but the total I'm trying to find comes from a performance equation that is calculating the flow every 15 minutes (So I have 4 flow readings every hour).  I do have the engineering units in GPM, but what I'm use-to-doing in excel/datalink is do a calculation formula with a conversion factor of 1440 to get my total gallons consumed within the specified time range.  I also have other systems (steam, chilled water, and electricity) where I'm doing the same as far as using a performance equation to calculate my rate...  But I may use different conversion factors (like 24 for lbs./hour to give me total lbs) ini excel/datalink.

                       

                      So on the programming side, what you are saying is probably correct but I just don't understand how/why at this point because I get a NullReferenceException error if the PI tag is not a temperature.  In order for me to use the total enumeration on a performance equation flow mentioned above, I reamed out the uom code Lonnie had in his demo:

                       
                                  string uom;
                                  uom = e.Result[0].UOM.ToString();
                                  string deg = '\u00B0'.ToString();
                                  uom = uom.Replace("DEG. ", deg);
                                  this.uom.Text = uom;
                      

                       The value I get from doing this is equivalent to using 1 for a conversion factor in DataLink.

                       

                      What has me most confused (I'm new to programming ) is the \u00B0....  I'm not sure where that is being pulled from?  Thanks for any light on this...

                        • Re: KPIDemo/Silverlight Error
                          Halenger

                          Of  course, doing a google search reveals to me the \u00B0 is indeed the degree symbol...  So... yeah...

                           

                          That line of code shouldn't mean a thing to this then...

                           

                          So then am I incorrect with using the "PISummaryMannerSummary.Total" enumeration if I NEED to use a conversion factor?

                            • Re: KPIDemo/Silverlight Error
                              Ahmad Fattahi

                              I can think of two solutions for you. One of them is to consider using an explicit numerical conversion in your code depending on the UOM's of the input and output. So, in this case you would explicitly adjust the result of the Total by a factor of 1440.

                               

                              Another option is to make another PE tag on your PI Server based off of the original PE tag to incorporate the conversion for you on the source. So you would only need to call the Total (or any other summary calculation for that matter) in your PI Web Services code using the new PE tag.

                                • Re: KPIDemo/Silverlight Error
                                  Halenger

                                  Excellent!  Thanks Ahmad - I chose to go with your first option and is working great...

                                   

                                  I've been struggling now trying to code this project to look at an AF attribute with a data reference as a formula (I'm adding child attributes to get a total water consumption for the building, i.e. multiple meters in a building).  I don't see in the User's Guide where this would not be allowed.  

                                   

                                  I'm successful in pointing to an attribute that is referenced to a PI Point, but I get nothing when using the GetPISummaryData method on a data reference as a formula.  I'm having most difficulty scripting this to look at an AF attribute using GetPIArchiveData (which I think is what I'd want to use instead of GetPISummaryData)...  Is what I want to do here even possible wit using PI Web Services 2010 R2?

                                    • Re: KPIDemo/Silverlight Error
                                      Ahmad Fattahi

                                      Make sure your path is correct. A Path designates a unique source of PI System data, such as a PI point or an AF Element attribute. It is comprised of three tokens assembled in this format: <Source Designator>:\\<Server>\<Path to Item> (For more informaiton on each token please refer to the PI Web Services User Manual. Here are some examples you could use:

                                       

                                      pi:\\piserver1\sinusoid

                                       

                                      pi:sinusoid

                                       

                                      pe:\\piserver1\'sinusoid'*2

                                       

                                      af:\\afserver1\PIDS01\PIWS01|piserver1, where PIDS01 is an AF database and piserver1 points to a PI Server

                                       

                                      af:\\afserver1\PIDS01\PIWS01|pi, where pi is an attribute whose value is the constant 3.1415926535

                                       

                                      af:\\afserver1\PIDS01\PIWS01|BoilingPoint; degree Fahrenheit, where BoilingPoint is an attribute whose value is the constant 100 º C

                                        • Re: KPIDemo/Silverlight Error
                                          Halenger

                                          I know I have the correct path as I mentioned, in the same element, I point to an attribute referencing a PI point okay... however a data reference in the form of a formula I return nothing.  I had looked at the examples inside the manual (the same as you posted) and notived they show only af paths that are referencing PI point or constants... there is not an example of referencing an attribute that is a calculation.  My understanding is with PI Web Services 2010 R2 I should be able to do this...  If it IS possible, what should be done and/or are their any limitations?

                                           

                                          I'd hate to have to reference to all PI points (meters) for a building, as this defeats what I've already implemented in AF.

                                            • Re: KPIDemo/Silverlight Error
                                              Ahmad Fattahi

                                              Sure I understand the logic and purpose here and agree with you. Unfortunately you are out of luck here. This is what the programming reference says about the path when you use af:

                                               

                                              "<database>\&#123;<element>\&#125;+|<attribute>[;uom], where the attribute token is an AF data reference to a PI tag or a scalar type"

                                               

                                              This is consistent with the examples. Would it make sense for you to build the calculation on the PI Server (PE), and add a PI tag-referenced attribute to your AF template which then would be accessible through PI Web Services?

                                                • Re: KPIDemo/Silverlight Error
                                                  Lonnie Bowling

                                                  Hi John,

                                                   

                                                  Sorry I didn't response to any of your questions, for some reason my email subscription was turned off for this topic and I monitor the boards via. email.  I'm glad you have worked through the problems so far and it looks like you are adding new features, that is great!   Sorry for the uom formatting stuff, that was just to make the UI look pretty, I should have commented it better.  Anyway, if you have any more problems or questions about the demo stuff I will be looking at this thread now and happy to help how I can.

                                                   

                                                  Code on brother!

                                                   

                                                  Lonnie

                                                    • Re: KPIDemo/Silverlight Error
                                                      Halenger

                                                      @Ahmad: Thanks for the clarification on the type of attribute that can be referenced...  Makes sense at this point; perhaps this feature will be available in future releases (referencing formula attributes)?

                                                       

                                                      @Lonnie: Thanks so much Lonnie! I appreciate the support...  My next venture I'd like to do is work on the AreaSeries in the toolbox to make my own trend.  Hopefully I can find some time today to get into this.  Once I know/learn how to bind the data to an object like that I may venture on buying other toolkits from component one.  You're example has certainly started me down a path I'm SO excited about...  (vCampus All-Star nomination coming up )

                                                        • Re: KPIDemo/Silverlight Error
                                                          Ahmad Fattahi

                                                          John,

                                                           

                                                          I agree this would be a natural and valuable feature addition. I am asking the PI Web Services team to chime in on any specific details. In the meantime, please take a look at the product road map for PI Web Services here.

                                                          • Re: KPIDemo/Silverlight Error
                                                            smohr

                                                            Actually, its a little more complicated than that.  While formula data references weren't explicitly supported, there is no reason why this should not work.  As an experiment, I created a simple formula that used another attribute (PI tag DR).  The latter started out with the config string:

                                                             

                                                            \\server\sinusoid;RelativeTime=*-30M;CaseMethod=EndTime;UOM=Hz

                                                             

                                                            This worked fine with the development version of our next release and AF SDK 2.3, but failed with PI WS 2010 R2.  It turns out a lower layer of our stack (in the released version) emulates AF SDK 2.2 behavior and there have been subtle changes in config string behavior.  When I stripped off everything after the tag (defaults added for me by PI System Explorer), I was able to retrieve my data using PI WS 2010 R2.  If it is feasible for you to strip your underlying attributes down to their essential config strings, you might be able to get this working.

                                                              • Re: KPIDemo/Silverlight Error
                                                                Lonnie Bowling

                                                                Hi John,

                                                                 

                                                                I'm really glad to hear you are excited about silverlight/PI.  I have used component one controls and they are excellent! I think their grid control is one of the best out there.

                                                                 

                                                                The nice thing about learning silverlight is that you will be all set for when windows 8 comes out, I think xaml/c# will be the platform of choice for application development, so you are investing in a great area.  Another aspect of leaning silverlight is getting an understanding of how services work.  At first it can be very confusing, but this is really the future of writing applications.  Services with rich UI's, it's the bomb!  If you are going to be at vCampus Live! 2011, come and check out my talk, I will be talking about that subject in relation to cloud services (Azure).

                                                                 

                                                                Lonnie

                                                                • Re: KPIDemo/Silverlight Error

                                                                  Stephen Mohr

                                                                  This worked fine with the development version of our next release and AF SDK 2.3, but failed with PI WS 2010 R2.  It turns out a lower layer of our stack (in the released version) emulates AF SDK 2.2 behavior and there have been subtle changes in config string behavior.  When I stripped off everything after the tag (defaults added for me by PI System Explorer), I was able to retrieve my data using PI WS 2010 R2.  If it is feasible for you to strip your underlying attributes down to their essential config strings, you might be able to get this working.
                                                                  As Steve pointed out, this works in our next release (2010 R3, expected by the end of the year) - this problem was addressed in the lower layer Steve referred to.

                                                                   

                                                                  In the meantime, I'm afraid the workaround is to strip the attributes down to a simpler config string...