コード例 #1
0
        /// <summary>
        /// Try to parse the given XML representation of a GetServiceAuthorisation response.
        /// </summary>
        /// <param name="Request">The GetServiceAuthorisation request leading to this response.</param>
        /// <param name="GetServiceAuthorisationResponseXML">The XML to parse.</param>
        /// <param name="GetServiceAuthorisationResponse">The parsed GetServiceAuthorisation response.</param>
        /// <param name="CustomSendGetServiceAuthorisationResponseParser">An optional delegate to parse custom GetServiceAuthorisationResponse XML elements.</param>
        /// <param name="CustomMeterReportParser">An optional delegate to parse custom MeterReport XML elements.</param>
        /// <param name="HTTPResponse">The correlated HTTP response of this eMIP response.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(GetServiceAuthorisationRequest Request,
                                       XElement GetServiceAuthorisationResponseXML,
                                       out GetServiceAuthorisationResponse GetServiceAuthorisationResponse,
                                       CustomXMLParserDelegate <GetServiceAuthorisationResponse> CustomSendGetServiceAuthorisationResponseParser = null,
                                       CustomXMLParserDelegate <MeterReport> CustomMeterReportParser = null,
                                       HTTPResponse HTTPResponse       = null,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                GetServiceAuthorisationResponse = new GetServiceAuthorisationResponse(

                    Request,

                    GetServiceAuthorisationResponseXML.MapValueOrFail("transactionId", Transaction_Id.Parse),
                    GetServiceAuthorisationResponseXML.MapValueOrFail("authorisationValue", ConversionMethods.AsAuthorisationValue),
                    GetServiceAuthorisationResponseXML.MapValueOrFail("serviceSessionId", ServiceSession_Id.Parse),
                    GetServiceAuthorisationResponseXML.MapBooleanOrFail("intermediateCDRRequested"),

                    GetServiceAuthorisationResponseXML.MapValueOrFail("requestStatus", RequestStatus.Parse),
                    GetServiceAuthorisationResponseXML.MapValueOrNullable("salePartnerOperatorId", s => Provider_Id.Parse(s.Replace("*", "-"))),
                    GetServiceAuthorisationResponseXML.MapValueOrNullable("userContractIdAlias", Contract_Id.Parse),

                    GetServiceAuthorisationResponseXML.MapElements("meterLimitList",
                                                                   "meterReport",
                                                                   s => MeterReport.Parse(s,
                                                                                          CustomMeterReportParser,
                                                                                          OnException)),

                    GetServiceAuthorisationResponseXML.MapValueOrNull("parameter"),

                    HTTPResponse

                    );


                if (CustomSendGetServiceAuthorisationResponseParser != null)
                {
                    GetServiceAuthorisationResponse = CustomSendGetServiceAuthorisationResponseParser(GetServiceAuthorisationResponseXML,
                                                                                                      GetServiceAuthorisationResponse);
                }

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(DateTime.UtcNow, GetServiceAuthorisationResponseXML, e);

                GetServiceAuthorisationResponse = null;
                return(false);
            }
        }
コード例 #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            // Get the next image.
            VisionImage image = GetNextImage();

            // Create the meter arc (stores information about the meter).
            MeterArc arc = Algorithms.GetMeterArc(MeterNeedleColor.DarkOnLight,
                                                  new LineContour(new PointContour(53, 75), new PointContour(101, 134)),
                                                  new LineContour(new PointContour(203, 75), new PointContour(155, 138)));

            // Read the meter.
            MeterReport report = Algorithms.ReadMeter(image, arc);

            // Display results.
            image.Overlays.Default.AddOval(new OvalContour(report.EndOfNeedle.X - 2, report.EndOfNeedle.Y - 2, 5, 5), Rgb32Value.RedColor, DrawingMode.PaintValue);
            speedKnob1.Value = report.Percentage;
            speedBox.Text    = String.Format("{0:0.0}", report.Percentage);
            imageViewer1.Attach(image);
        }
コード例 #3
0
        /// <summary>
        /// Try to parse the given XML representation of an eMIP heartbeat request.
        /// </summary>
        /// <param name="SetServiceAuthorisationRequestXML">The XML to parse.</param>
        /// <param name="CustomSendSetServiceAuthorisationRequestParser">An optional delegate to parse custom SetServiceAuthorisationRequest XML elements.</param>
        /// <param name="CustomMeterReportParser">An optional delegate to parse custom MeterReport XML elements.</param>
        /// <param name="SetServiceAuthorisationRequest">The parsed heartbeat request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        /// 
        /// <param name="HTTPRequest">The correlated HTTP request of this eMIP request.</param>
        /// <param name="Timestamp">The optional timestamp of the request.</param>
        /// <param name="CancellationToken">An optional token to cancel this request.</param>
        /// <param name="EventTrackingId">An optional event tracking identification for correlating this request with other events.</param>
        /// <param name="RequestTimeout">An optional timeout for this request.</param>
        public static Boolean TryParse(XElement                                                 SetServiceAuthorisationRequestXML,
                                       CustomXMLParserDelegate<SetServiceAuthorisationRequest>  CustomSendSetServiceAuthorisationRequestParser,
                                       CustomXMLParserDelegate<MeterReport>                     CustomMeterReportParser,
                                       out SetServiceAuthorisationRequest                       SetServiceAuthorisationRequest,
                                       OnExceptionDelegate                                      OnException         = null,

                                       HTTPRequest                                              HTTPRequest         = null,
                                       DateTime?                                                Timestamp           = null,
                                       CancellationToken?                                       CancellationToken   = null,
                                       EventTracking_Id                                         EventTrackingId     = null,
                                       TimeSpan?                                                RequestTimeout      = null)
        {

            try
            {

                SetServiceAuthorisationRequest = new SetServiceAuthorisationRequest(

                                                     HTTPRequest,

                                                     //ToDo: What to do with: <partnerIdType>eMI3</partnerIdType>?
                                                     SetServiceAuthorisationRequestXML.MapValueOrFail       ("partnerId",                Partner_Id.Parse),

                                                     //ToDo: What to do with: <operatorIdType>eMI3</operatorIdType>
                                                     SetServiceAuthorisationRequestXML.MapValueOrFail       ("operatorId",               Operator_Id.Parse),

                                                     //ToDo: What to do with: <targetOperatorIdType>eMI3</targetOperatorIdType>
                                                     SetServiceAuthorisationRequestXML.MapValueOrFail       ("targetOperatorId",         Operator_Id.Parse),

                                                     //ToDo: What to do with: <EVSEIdType>eMI3</EVSEIdType>
                                                     SetServiceAuthorisationRequestXML.MapValueOrFail       ("EVSEId",                   EVSE_Id.Parse),

                                                     SetServiceAuthorisationRequestXML.MapValueOrFail       ("userId",                   s => User_Id.Parse(s,
                                                         SetServiceAuthorisationRequestXML.MapValueOrFail   ("userIdType",               UserIdFormatsExtensions.Parse))),

                                                     SetServiceAuthorisationRequestXML.MapValueOrFail       ("requestedServiceId",       Service_Id.Parse),
                                                     SetServiceAuthorisationRequestXML.MapValueOrFail       ("serviceSessionId",         ServiceSession_Id.Parse),
                                                     SetServiceAuthorisationRequestXML.MapValueOrFail       ("authorisationValue",       ConversionMethods.AsRemoteStartStopValue),
                                                     SetServiceAuthorisationRequestXML.MapBooleanOrFail     ("intermediateCDRRequested"),

                                                     SetServiceAuthorisationRequestXML.MapValueOrNullable   ("transactionId",            Transaction_Id.Parse),
                                                     SetServiceAuthorisationRequestXML.MapValueOrNullable   ("userContractIdAlias",      Contract_Id.Parse),

                                                     SetServiceAuthorisationRequestXML.MapElements          ("meterLimitList",
                                                                                                             "meterReport",              xml => MeterReport.Parse(xml,
                                                                                                                                                                  CustomMeterReportParser,
                                                                                                                                                                  OnException)),
                                                     SetServiceAuthorisationRequestXML.ElementValueOrDefault("userContractIdAlias"),
                                                     SetServiceAuthorisationRequestXML.MapValueOrNullable   ("bookingId",                Booking_Id.Parse),

                                                     Timestamp,
                                                     CancellationToken,
                                                     EventTrackingId,
                                                     RequestTimeout

                                                 );


                if (CustomSendSetServiceAuthorisationRequestParser != null)
                    SetServiceAuthorisationRequest = CustomSendSetServiceAuthorisationRequestParser(SetServiceAuthorisationRequestXML,
                                                                                                    SetServiceAuthorisationRequest);

                return true;

            }
            catch (Exception e)
            {

                OnException?.Invoke(DateTime.UtcNow, SetServiceAuthorisationRequestXML, e);

                SetServiceAuthorisationRequest = null;
                return false;

            }

        }