Exemplo n.º 1
0
        private void extractTrafficDataFromSiteMeasurements(SiteMeasurements measurementsForSite)
        {
            String siteGUID = measurementsForSite.measurementSiteReference.id;

            log.Info("TMU site ID: " + siteGUID);
            log.Info("Number of measurements for TMU site: " + measurementsForSite.measuredValue.Length);

            // There can be a number of measured values reported for the site
            foreach (_SiteMeasurementsIndexMeasuredValue measuredValue in measurementsForSite.measuredValue)
            {
                MeasuredValue mv        = measuredValue.measuredValue;
                BasicData     basicData = mv.basicData;

                // The index number of the site measurement is important - as this
                // relates the data
                // to the NTIS reference model, which adds context to the value
                // (e.g. lane information,
                // or vehicle characteristics)
                int index = measuredValue.index;

                // Determine what class (type) of traffic data is contained in the
                // basic data
                if (basicData.GetType() == typeof(TrafficFlow))
                {
                    TrafficFlow flow = (TrafficFlow)basicData;
                    log.Info("[Measurement Index : " + index + "] Vehicle Flow Rate: " + flow.vehicleFlow.vehicleFlowRate);

                    if (flow.vehicleFlow.dataError)
                    {
                        MultilingualStringValue[] errorReason = flow.vehicleFlow.reasonForDataError.values;
                        foreach (MultilingualStringValue value in errorReason)
                        {
                            log.Info("    Data in error. Reason: \"" + value.Value + "\"");
                        }
                    }
                }
                else if (basicData.GetType() == typeof(TrafficSpeed))
                {
                    TrafficSpeed speed = (TrafficSpeed)basicData;
                    log.Info("[Measurement Index : " + index + "] Average Speed: " + speed.averageVehicleSpeed.speed);
                }
                else if (basicData.GetType() == typeof(TrafficHeadway))
                {
                    TrafficHeadway headway = (TrafficHeadway)basicData;
                    log.Info("[Measurement Index : " + index + "] Average Headway: " + headway.averageTimeHeadway.duration);
                }
                else if (basicData.GetType() == typeof(TrafficConcentration))
                {
                    TrafficConcentration concentration = (TrafficConcentration)basicData;
                    log.Info("[Measurement Index : " + index + "] Traffic Occupancy (%): " + concentration.occupancy.percentage);
                }
                else
                {
                    log.Error("Unexpected traffic data type contained in publication: " + basicData.GetType().Name.ToString());
                }
            }
        }
        private void processSituation(ElaboratedData elaboratedData, DateTime publicationTime, DateTime timeDefault)
        {
            LocationByReference locationByReference = null;
            BasicData           basicData           = elaboratedData.basicData;



            if (basicData.GetType() == typeof(TrafficHeadway))
            {
                TrafficHeadway data = (TrafficHeadway)basicData;
                locationByReference = (LocationByReference)data.pertinentLocation;
            }
            else if (basicData.GetType() == typeof(TrafficFlow))
            {
                TrafficFlow data = (TrafficFlow)basicData;
                locationByReference = (LocationByReference)data.pertinentLocation;
            }
            else if (basicData.GetType() == typeof(TrafficConcentration))
            {
                TrafficConcentration data = (TrafficConcentration)basicData;
                locationByReference = (LocationByReference)data.pertinentLocation;
            }
            else if (basicData.GetType() == typeof(TrafficSpeed))
            {
                TrafficSpeed data = (TrafficSpeed)basicData;
                locationByReference = (LocationByReference)data.pertinentLocation;
            }
            else if (basicData.GetType() == typeof(TravelTimeData))
            {
                TravelTimeData data = (TravelTimeData)basicData;
                locationByReference = (LocationByReference)data.pertinentLocation;
            }
            else
            {
                logWrapper.Warning("basicData instance of -" + basicData.GetType().ToString());
            }

            String linkIdentifier = null;

            if (locationByReference != null)
            {
                linkIdentifier = basicData.GetType().ToString() + locationByReference.predefinedLocationReference.id;

                if (logWrapper.isTrace())
                {
                    logWrapper.Trace("Processing Fused Sensor Only Identifier(" + linkIdentifier + ")");
                }

                FusedSensorOnlyData fusedSensorOnlyData = new FusedSensorOnlyData(linkIdentifier, publicationTime, timeDefault, elaboratedData);
                fusedSensorOnlyDataStore.updateData(fusedSensorOnlyData);
            }
            else
            {
                logWrapper.Error("Failed to Process elaboratedData, " + elaboratedData.ToString());
            }
        }
        private void extractTrafficDataFromElaboratedData(ElaboratedData dataItem)
        {
            // Location is always specified as LocationByReference (referenced to a
            // single Network Link)
            LocationByReference location = (LocationByReference)dataItem.basicData.pertinentLocation;

            log.Info("Data for Network Link: " + location.predefinedLocationReference.id);

            BasicData basicData = dataItem.basicData;

            // Determine what class (type) of traffic data is contained in the basic
            // data
            if (basicData.GetType() == typeof(TrafficSpeed))
            {
                TrafficSpeed speed = (TrafficSpeed)basicData;
                log.Info("Average Speed: " + speed.averageVehicleSpeed.speed);
            }
            else if (basicData.GetType() == typeof(TravelTimeData))
            {
                TravelTimeData travelTimeData = (TravelTimeData)basicData;
                log.Info("Travel Time: " + travelTimeData.travelTime.duration);
                log.Info("Free Flow Travel Time: " + travelTimeData.freeFlowTravelTime.duration);
                log.Info("Normally Expected Travel Time: " + travelTimeData.normallyExpectedTravelTime.duration);
            }
            else if (basicData.GetType() == typeof(TrafficFlow))
            {
                TrafficFlow flow = (TrafficFlow)basicData;
                log.Info("Traffic Flow: " + flow.vehicleFlow.vehicleFlowRate);
            }
            else if (basicData.GetType() == typeof(TrafficConcentration))
            {
                TrafficConcentration concentration = (TrafficConcentration)basicData;
                log.Info("Occupancy (%age): " + concentration.occupancy.percentage);
            }
            else if (basicData.GetType() == typeof(TrafficHeadway))
            {
                TrafficHeadway headway = (TrafficHeadway)basicData;
                log.Info("Headway: " + headway.averageTimeHeadway.duration);
            }
            else
            {
                log.Error("Unexpected traffic data type contained in publication: " + dataItem.GetType().ToString());
            }
        }