示例#1
0
        public override void processMessage(D2LogicalModel d2LogicalModel)
        {
            if (logWrapper.isDebug())
            {
                logWrapper.Debug("ANPR Update");
            }

            MeasuredDataPublication measuredDataPublication = (MeasuredDataPublication)d2LogicalModel.payloadPublication;

            if (measuredDataPublication != null)
            {
                DateTime publicationTime = measuredDataPublication.publicationTime;

                SiteMeasurements[] siteMeasurementsList = measuredDataPublication.siteMeasurements;

                if (logWrapper.isDebug())
                {
                    logWrapper.Debug("ANPR Update(" + siteMeasurementsList.Length + " objects)");
                }

                for (int siteMeasurementsListPos = 0; siteMeasurementsListPos < siteMeasurementsList.Length; siteMeasurementsListPos++)
                {
                    SiteMeasurements siteMeasurements = siteMeasurementsList[siteMeasurementsListPos];
                    processSituation(siteMeasurements, publicationTime);
                }
            }

            if (logWrapper.isDebug())
            {
                logWrapper.Debug("ANPR Update Complete");
            }
        }
        public void Handle(D2LogicalModel deliverANPRTrafficDataRequest)
        {
            log.Info("New AnprTrafficDataService received.");

            // Validate the D2Logical Model
            if (!ExampleDataCheckOk(deliverANPRTrafficDataRequest))
            {
                throw new SoapException("Incoming request does not appear to be valid!", SoapException.ClientFaultCode);
            }

            try
            {
                MeasuredDataPublication measuredDataPublication = deliverANPRTrafficDataRequest.payloadPublication as MeasuredDataPublication;

                if (measuredDataPublication != null)
                {
                    List <SiteMeasurements> siteMeasurementsInPayload = measuredDataPublication.siteMeasurements.ToList();

                    log.Info("Got MeasuredDataPublication from request");
                    log.Info("Number of Site Measurements in payload: " + siteMeasurementsInPayload.Count());
                    foreach (SiteMeasurements measurementsForSite in siteMeasurementsInPayload)
                    {
                        extractTravelTimesFromSiteMeasurements(measurementsForSite);
                    }
                }

                log.Info("AnprTrafficDataService: Processed successfuly");
            }
            catch (Exception e)
            {
                log.Error("Error while obtaining MeasuredDataPublication.");
                log.Error(e.Message);
                throw new SoapException("Error while obtaining MeasuredDataPublication.", SoapException.ServerFaultCode, e);
            }
        }
        public void Handle(D2LogicalModel request)
        {
            log.Info("New TMUTrafficDataResponse Received.");

            if (!ExampleDataCheckOk(request))
            {
                throw new SoapException("Incoming request does not appear to be valid!", SoapException.ClientFaultCode);
            }

            try
            {
                MeasuredDataPublication measuredDataPublication = request.payloadPublication as MeasuredDataPublication;

                if (measuredDataPublication != null)
                {
                    SiteMeasurements[] siteMeasurementsArray = measuredDataPublication.siteMeasurements;
                    foreach (SiteMeasurements siteMeasurements in siteMeasurementsArray)
                    {
                        extractTrafficDataFromSiteMeasurements(siteMeasurements);
                    }
                    log.Info("TMUTrafficDataResponse : processed successfully.");
                }
            }
            catch (Exception e)
            {
                log.Error("Error while obtaining MeasuredDataPublication.");
                log.Error(e.Message);
                throw new SoapException("Error while obtaining MeasuredDataPublication.", SoapException.ServerFaultCode, e);
            }
        }
        public putDatex2DataResponse GetDeliverTMUTrafficDataResponse(D2LogicalModel request)
        {
            log.Info("NEW DeliverTMUTrafficDataRequest Received!");

            if (!ExampleDataCheckOk(request))
            {
                throw new SoapException("Incoming request does not appear to be valid!", SoapException.ClientFaultCode);
            }

            MeasuredDataPublication measuredDataPublication = request.payloadPublication as MeasuredDataPublication;

            if (measuredDataPublication != null)
            {
                SiteMeasurements[] siteMeasurementsArray = measuredDataPublication.siteMeasurements;
                foreach (SiteMeasurements siteMeasurements in siteMeasurementsArray)
                {
                    _SiteMeasurementsIndexMeasuredValue[] measuredValueArray = siteMeasurements.measuredValue;
                    foreach (_SiteMeasurementsIndexMeasuredValue siteMeasurementsIndexMeasuredValue in measuredValueArray)
                    {
                        MeasuredValue measuredValue = siteMeasurementsIndexMeasuredValue.measuredValue;
                        BasicData     basicData     = measuredValue.basicData;

                        if (basicData is TrafficFlow)
                        {
                            VehicleFlowValue value = ((TrafficFlow)basicData).vehicleFlow;
                            log.Info("Vehicle flow rate : " + value.vehicleFlowRate);
                        }
                        else if (basicData is TrafficSpeed)
                        {
                            float speed = ((TrafficSpeed)basicData).averageVehicleSpeed.speed;
                            log.Info("Traffic speed : " + speed);
                        }
                        else if (basicData is TrafficHeadway)
                        {
                            float headWay = ((TrafficHeadway)basicData).averageTimeHeadway.duration;
                            log.Info("Traffic Headway : " + headWay);
                        }
                        else if (basicData is TrafficConcentration)
                        {
                            float percentage = ((TrafficConcentration)basicData).occupancy.percentage;
                            log.Info("Traffic concentration percentage : " + percentage);
                        }
                    }
                }
            }

            return(new putDatex2DataResponse {
                d2LogicalModel = new D2LogicalModel()
            });
        }
示例#5
0
        public void Handle(D2LogicalModel deliverMIDASTrafficDataRequest)
        {
            log.Info("New MidasTrafficDataService received.");
            MeasuredDataPublication measuredDataPublication = null;

            // Validate the D2Logical Model
            if (!ExampleDataCheckOk(deliverMIDASTrafficDataRequest))
            {
                throw new SoapException("Incoming request does not appear to be valid!", SoapException.ClientFaultCode);
            }

            // MeasuredDataPublication class contains the feed description, feed
            // type, site measurements, publication time and other header information.
            try
            {
                measuredDataPublication = deliverMIDASTrafficDataRequest.payloadPublication as MeasuredDataPublication;

                if (measuredDataPublication != null)
                {
                    List <SiteMeasurements> siteMeasurementsInPayload = measuredDataPublication.siteMeasurements.ToList();
                    log.Info("Number of Site Measurements in payload: " + siteMeasurementsInPayload.Count);

                    // Eash MIDAS site is encapsulated within a SiteMeasurements object.
                    // Cycle through these to get to the sensor readings for a MIDAS site.
                    foreach (SiteMeasurements siteMeasurement in siteMeasurementsInPayload)
                    {
                        log.Debug("measurementDataPublication ID is " + siteMeasurement.measurementSiteReference.id);
                        log.Debug("measurementDataPublication time default is " + siteMeasurement.measurementTimeDefault.ToString());

                        // Cycle through the MeasuredValues to get the individual sensor readings for a MIDAS site.
                        foreach (_SiteMeasurementsIndexMeasuredValue singleMeasuredValue in siteMeasurement.measuredValue)
                        {
                            extractTrafficDataFromSiteMeasurements(siteMeasurement);
                        }
                        log.Info("MidasTrafficDataService: processed successfully.");
                    }
                }
            }
            catch (Exception e)
            {
                log.Error("Error while obtaining MeasuredDataPublication.");
                log.Error(e.Message);
                throw new SoapException("Error while obtaining MeasuredDataPublication.", SoapException.ServerFaultCode, e);
            }
        }
        public override void processMessage(D2LogicalModel d2LogicalModel)
        {
            if (logWrapper.isInfo())
            {
                logWrapper.Info("TMU Update");
            }

            MeasuredDataPublication measuredDataPublication = (MeasuredDataPublication)d2LogicalModel.payloadPublication;

            if (measuredDataPublication != null)
            {
                DateTime publicationTime = measuredDataPublication.publicationTime;

                SiteMeasurements[] siteMeasurementsList = measuredDataPublication.siteMeasurements;

                if (logWrapper.isDebug())
                {
                    logWrapper.Debug("TMU Update(" + siteMeasurementsList.Length + " objects)");
                }

                Dictionary <String, LinkedList <SiteMeasurements> > siteMeasurementsIndex =
                    new Dictionary <String, LinkedList <SiteMeasurements> >();

                for (int siteMeasurementsListPos = 0; siteMeasurementsListPos < siteMeasurementsList.Length; siteMeasurementsListPos++)
                {
                    SiteMeasurements siteMeasurements = siteMeasurementsList[siteMeasurementsListPos];
                    processSituation(siteMeasurements, publicationTime, siteMeasurementsIndex);
                }

                foreach (String tmuIdentifier in siteMeasurementsIndex.Keys)
                {
                    TMUData tmuData = new TMUData(tmuIdentifier, publicationTime, siteMeasurementsIndex[tmuIdentifier]);

                    tmuDataStore.updateData(tmuData);
                }
            }

            if (logWrapper.isDebug())
            {
                logWrapper.Debug("TMU Update Complete");
            }
        }
示例#7
0
        public putDatex2DataResponse GetDeliverAnprTrafficDataResponse(D2LogicalModel deliverANPRTrafficDataRequest)
        {
            log.Info("New DeliverANPRTrafficDataRequest received.");

            // Validate the D2Logical Model
            if (!ExampleDataCheckOk(deliverANPRTrafficDataRequest))
            {
                throw new SoapException("Incoming request does not appear to be valid!", SoapException.ClientFaultCode);
            }


            MeasuredDataPublication measuredDataPublication = deliverANPRTrafficDataRequest.payloadPublication as MeasuredDataPublication;

            log.Info("Got MeasuredDataPublication from request");

            log.Info("Feed Type " + measuredDataPublication.feedType);

            log.Info("ANPR Request: Processing Completed Successfuly");

            return(new putDatex2DataResponse {
                d2LogicalModel = new D2LogicalModel()
            });
        }
示例#8
0
        public putDatex2DataResponse GetDeliverMidasTrafficDataResponse(D2LogicalModel deliverMIDASTrafficDataRequest)
        {
            log.Info("New DeliverMIDASTrafficDataRequest received.");
            MeasuredDataPublication measuredDataPublication = null;

            // Validate the D2Logical Model
            if (!ExampleDataCheckOk(deliverMIDASTrafficDataRequest))
            {
                throw new SoapException("Incoming request does not appear to be valid!", SoapException.ClientFaultCode);
            }

            // MeasuredDataPublication class contains the feed description, feed
            // type, site measurements, publication time and other header information.
            try
            {
                measuredDataPublication = deliverMIDASTrafficDataRequest.payloadPublication as MeasuredDataPublication;

                if (measuredDataPublication != null && measuredDataPublication.headerInformation != null)
                {
                    // Eash MIDAS site is encapsulated within a SiteMeasurements object.
                    // Cycle through these to get to the sensor readings for a MIDAS site.
                    foreach (SiteMeasurements siteMeasurement in measuredDataPublication.siteMeasurements)
                    {
                        log.Debug("measurementDataPublication ID is " + siteMeasurement.measurementSiteReference.id);
                        log.Debug("measurementDataPublication time default is " + siteMeasurement.measurementTimeDefault.ToString());

                        // Cycle through the MeasuredValues to get the individual sensor readings for a MIDAS site.
                        foreach (_SiteMeasurementsIndexMeasuredValue singleMeasuredValue in siteMeasurement.measuredValue)
                        {
                            int index = singleMeasuredValue.index;

                            // Each sensor reading has an index. This represents the lane number the sensor reading is for.
                            // On retrieving the index, you can use getLaneNumberFromTrafficDataIndex to get the lane number.
                            int laneNumber = GetLaneNumberFromTrafficDataIndex(index);
                            log.Debug("lane number is " + laneNumber);

                            // To determine what type the sensore reading is, cast the basic data value to the appropriate
                            // type and retrieve the value of interest.
                            MeasuredValue mv        = singleMeasuredValue.measuredValue;
                            BasicData     basicData = mv.basicData;

                            if (basicData is TrafficFlow)
                            {
                                // For a lane, TrafficFlow will appear 4 times. i.e.
                                // flow1, flow2 ... flow4. It will appear in order.
                            }
                            else if (basicData is TrafficSpeed)
                            {
                                // Now you have TrafficSpeed. Cast it appropriately
                                // to retrieve values you are interested in.
                            }
                            else if (basicData is TrafficHeadway)
                            {
                                // Now you have TrafficHeadway. Cast it appropriately
                                // to retrieve values you are interested in.
                            }
                            else if (basicData is TrafficConcentration)
                            {
                                // Now you have TrafficConcentration. Cast it
                                // appropriately to retrieve values you are
                                // interested in.
                            }
                        }
                    }

                    // You can convert the site measurements to you model objects
                    // and subsequently persist/manipulate your model objects.
                    List <TrafficData> trafficData = ConvertToModelObjects(measuredDataPublication.siteMeasurements.ToList());
                }
            }
            catch (Exception e)
            {
                log.Error("Error while obtaining MeasuredDataPublication.");
                log.Error(e.Message);
                throw new SoapException("Error while obtaining MeasuredDataPublication.", SoapException.ServerFaultCode, e);
            }

            return(new putDatex2DataResponse {
                d2LogicalModel = new D2LogicalModel()
            });
        }