public override void processMessage(D2LogicalModel d2LogicalModel)
        {
            if (logWrapper.isDebug())
            {
                logWrapper.Debug("NTIS Model Predefined Location Update");
            }

            linkShapeStaticDataStore.clearDataStore();
            nwkLinkStaticDataStore.clearDataStore();
            anprRouteStaticDataStore.clearDataStore();
            hatrisSectionStaticDataStore.clearDataStore();
            nwkNodeStaticDataStore.clearDataStore();
            alternateRouteStaticDataStore.clearDataStore();

            PredefinedLocationsPublication predefinedLocationsPublication = (PredefinedLocationsPublication)d2LogicalModel.payloadPublication;

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

                PredefinedLocationContainer[] predefinedLocationContainerList = predefinedLocationsPublication.predefinedLocationContainer;

                for (int predefinedLocationContainerListPos = 0; predefinedLocationContainerListPos < predefinedLocationContainerList.Length; predefinedLocationContainerListPos++)
                {
                    PredefinedLocationContainer predefinedLocationContainer = predefinedLocationContainerList[predefinedLocationContainerListPos];
                    processPredefinedLocationContainer(predefinedLocationContainer, publicationTime);
                }
            }

            if (logWrapper.isDebug())
            {
                logWrapper.Debug("NTIS Model Predefined Location Update Complete");
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        public override void processMessage(D2LogicalModel d2LogicalModel)
        {
            if (logWrapper.isDebug())
            {
                logWrapper.Debug("NTIS Model VMS Tables Update");
            }

            vmsStaticDataStore.clearDataStore();
            matrixSignalStaticDataStore.clearDataStore();

            VmsTablePublication vmsTablePublication = (VmsTablePublication)d2LogicalModel.payloadPublication;

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

                VmsUnitTable[] vmsUnitTableList = vmsTablePublication.vmsUnitTable;

                for (int vmsUnitTableListPos = 0; vmsUnitTableListPos < vmsUnitTableList.Length; vmsUnitTableListPos++)
                {
                    VmsUnitTable vmsUnitTable = vmsUnitTableList[vmsUnitTableListPos];
                    processVmsUnitTable(vmsUnitTable, publicationTime);
                }
            }

            if (logWrapper.isDebug())
            {
                logWrapper.Debug("NTIS Model VMS Tables Update Complete");
            }
        }
예제 #4
0
        public putDatex2DataResponse GetDeliverFVDTrafficDataResponse(D2LogicalModel deliverFVDTrafficDataRequest)
        {
            log.Info("Handling Fused FVD and Sensor PTD Request");

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


            ElaboratedDataPublication elaboratedDataPublication = deliverFVDTrafficDataRequest.payloadPublication as ElaboratedDataPublication;

            if (elaboratedDataPublication != null)
            {
                ElaboratedData[] trafficDataList = filterEnumerableByType(elaboratedDataPublication.elaboratedData, typeof(TrafficSpeed))
                                                   .ToArray();
                ElaboratedData[] travelTimeDataList = filterEnumerableByType(elaboratedDataPublication.elaboratedData, typeof(TravelTimeData))
                                                      .ToArray();

                log.Info("Publication Time is " + elaboratedDataPublication.publicationTime);
                log.Info("Time Default is  " + elaboratedDataPublication.timeDefault);
                log.Info("Total Traffic Data objects  are " + trafficDataList.Length);
                log.Info("Total Travel Time Data objects  are " + travelTimeDataList.Length);
            }

            log.Info("Fused FVD and Sensor PTD Request: Processing Completed Successfuly");

            return(new putDatex2DataResponse {
                d2LogicalModel = new D2LogicalModel()
            });
        }
예제 #5
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");
            }
        }
예제 #6
0
        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 GetDeliverSensorTrafficDataResponse(D2LogicalModel request)
        {
            log.Info("Handling Fused Sensor-only PTD Request!");

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


            ElaboratedDataPublication elaboratedDataPublication = request.payloadPublication as ElaboratedDataPublication;

            if (elaboratedDataPublication != null)
            {
                log.Info("Publication Time is " + elaboratedDataPublication.publicationTime);
                log.Info("Time Default is  " + elaboratedDataPublication.timeDefault);
                log.Info("Total Elaborated Data objects  are " + elaboratedDataPublication.elaboratedData.Length);
            }

            log.Info("Fused Sensor-only PTD Request: Processing Completed Successfuly");

            return(new putDatex2DataResponse {
                d2LogicalModel = new D2LogicalModel()
            });
        }
예제 #8
0
        public override void processMessage(D2LogicalModel d2LogicalModel)
        {
            if (logWrapper.isDebug())
            {
                logWrapper.Debug("FusedFVDAndSensorData Update");
            }

            fusedFVDAndSensorDataStore.clearDataStore();

            ElaboratedDataPublication elaboratedDataPublication = (ElaboratedDataPublication)d2LogicalModel.payloadPublication;

            if (elaboratedDataPublication != null)
            {
                DateTime         publicationTime    = elaboratedDataPublication.publicationTime;
                DateTime         timeDefault        = elaboratedDataPublication.timeDefault;
                ElaboratedData[] elaboratedDataList = elaboratedDataPublication.elaboratedData;

                if (logWrapper.isDebug())
                {
                    logWrapper.Debug("FusedFVDAndSensorData Update(" + elaboratedDataList.Length + " objects)");
                }

                for (int elaboratedDataListPos = 0; elaboratedDataListPos < elaboratedDataList.Length; elaboratedDataListPos++)
                {
                    ElaboratedData elaboratedData = elaboratedDataList[elaboratedDataListPos];
                    processSituation(elaboratedData, publicationTime, timeDefault);
                }
            }

            if (logWrapper.isDebug())
            {
                logWrapper.Debug("FusedFVDAndSensorData Update Complete");
            }
        }
        /// <summary>
        /// Check that the D2LogicalModel is not null, and contains an Exchange object.
        /// </summary>
        /// <param name="d2LogicalModel"></param>
        /// <returns>true if valid, false otherwise</returns>
        public bool ExampleDataCheckOk(D2LogicalModel d2LogicalModel)
        {
            if (d2LogicalModel == null)
            {
                log.Error("D2LogicalModel is null! Incoming request does not appear to be valid.");
                return(false);
            }

            // Exchange must not be null.
            if (d2LogicalModel.exchange == null)
            {
                log.Error("Exchange is null! Incoming request does not appear to be valid.");
                return(false);
            }

            if (d2LogicalModel.payloadPublication == null)
            {
                log.Error("PayloadPublication is null! Incoming request does not appear to be valid");
                return(false);
            }

            if (d2LogicalModel.payloadPublication.feedType == null)
            {
                log.Error("FeedType is null! Incoming request does not appear to be valid");
                return(false);
            }

            log.Debug("Data checked");
            return(true);
        }
        public putDatex2DataResponse GetNtisModelNotificationDataResponse(D2LogicalModel deliverNtisModelNotificationDataRequest)
        {
            log.Info("Handling Ntis Model Notification Request!");

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

            if (deliverNtisModelNotificationDataRequest.payloadPublication != null)
            {
                GenericPublication genericPublication = deliverNtisModelNotificationDataRequest.payloadPublication as GenericPublication;

                log.Info("Ntis model publication time: " + genericPublication.publicationTime);
                log.Info("Generic publication name: " + genericPublication.genericPublicationName);

                _GenericPublicationExtensionType genericPublicationExtension = genericPublication.genericPublicationExtension;
                NtisModelVersionInformation      ntisModelVersionInformation = genericPublicationExtension.ntisModelVersionInformation;

                log.Info("Network model - file name " + ntisModelVersionInformation.modelFilename);
                log.Info("Network model - version " + ntisModelVersionInformation.modelVersion);
                log.Info("Network model - publication time " + ntisModelVersionInformation.modelPublicationTime);
            }


            log.Info("Ntis Model Notification Data Request: Processing Completed Successfuly");

            return(new putDatex2DataResponse {
                d2LogicalModel = new D2LogicalModel()
            });
        }
        public void Handle(D2LogicalModel deliverFVDTrafficDataRequest)
        {

            log.Info("New FusedFvdAndSensorTrafficData received");
            ElaboratedDataPublication elaboratedDataPublication = null;

            try
            {

                elaboratedDataPublication = (ElaboratedDataPublication) deliverFVDTrafficDataRequest.payloadPublication;

                if (elaboratedDataPublication != null) {

                    ElaboratedData[] elaboratedDataList = elaboratedDataPublication.elaboratedData;
                    log.Info("Number of data items in the publication: " + elaboratedDataList.Length);

                    foreach (ElaboratedData dataItem in elaboratedDataList)
                    {
                        extractTrafficDataFromElaboratedData(dataItem);
                    }

                }
                log.Info("FusedFvdAndSensorTrafficData: processed successfully.");

            }
            catch (Exception e) {
                log.Error(e.Message);
            }

        }
예제 #12
0
        /// <summary>
        /// Check that the D2LogicalModel is not null, and contains an Exchange object.
        /// </summary>
        /// <param name="d2LogicalModel"></param>
        /// <returns>true if valid, false otherwise</returns>
        public bool ExampleDataCheckOk(D2LogicalModel d2LogicalModel)
        {
            if (d2LogicalModel == null)
            {
                log.Error("D2LogicalModel is null! Incoming request does not appear to be valid.");
                return false;
            }

            // Exchange must not be null.
            if (d2LogicalModel.exchange == null)
            {
                log.Error("Exchange is null! Incoming request does not appear to be valid.");
                return false;
            }

            if (d2LogicalModel.payloadPublication == null)
            {
                log.Error("PayloadPublication is null! Incoming request does not appear to be valid");
                return false;
            }

            if (d2LogicalModel.payloadPublication.feedType == null)
            {
                log.Error("FeedType is null! Incoming request does not appear to be valid");
                return false;
            }

            log.Debug("Data checked");
            return true;
        }
        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 deliverFVDTrafficDataRequest)
        {
            log.Info("New FusedFvdAndSensorTrafficData received");
            ElaboratedDataPublication elaboratedDataPublication = null;

            try
            {
                elaboratedDataPublication = (ElaboratedDataPublication)deliverFVDTrafficDataRequest.payloadPublication;

                if (elaboratedDataPublication != null)
                {
                    ElaboratedData[] elaboratedDataList = elaboratedDataPublication.elaboratedData;
                    log.Info("Number of data items in the publication: " + elaboratedDataList.Length);

                    foreach (ElaboratedData dataItem in elaboratedDataList)
                    {
                        extractTrafficDataFromElaboratedData(dataItem);
                    }
                }
                log.Info("FusedFvdAndSensorTrafficData: processed successfully.");
            }
            catch (Exception e) {
                log.Error(e.Message);
            }
        }
예제 #15
0
        public override void processMessage(D2LogicalModel d2LogicalModel)
        {
            if (logWrapper.isDebug())
            {
                logWrapper.Debug("NTIS Model Measurement Site Tables Update");
            }

            tameStaticDataStore.clearDataStore();
            midasStaticDataStore.clearDataStore();
            anprStaticDataStore.clearDataStore();
            tmuStaticDataStore.clearDataStore();

            MeasurementSiteTablePublication measurementSiteTablePublication = (MeasurementSiteTablePublication)d2LogicalModel.payloadPublication;

            if (measurementSiteTablePublication != null)
            {
                DateTime publicationTime = measurementSiteTablePublication.publicationTime;
                MeasurementSiteTable[] measurementSiteTableList = measurementSiteTablePublication.measurementSiteTable;

                for (int measurementSiteTableListPos = 0; measurementSiteTableListPos < measurementSiteTableList.Length; measurementSiteTableListPos++)
                {
                    MeasurementSiteTable measurementSiteTable = measurementSiteTableList[measurementSiteTableListPos];
                    processMeasurementSiteTable(measurementSiteTable, publicationTime);
                }
            }

            if (logWrapper.isDebug())
            {
                logWrapper.Debug("NTIS Model Measurement Site Tables Update Complete");
            }
        }
        private void HandleEventUpdate(D2LogicalModel d2LogicalModel)
        {
            lock (LockEventUpdates)
            {
                try
                {
                    SituationPublication situationPublication = (SituationPublication)d2LogicalModel.payloadPublication;
                    if (situationPublication != null)
                    {
                        Situation[] situations = situationPublication.situation;
                        log.Info(NumberOfEventsInPayload + situations.Length);

                        foreach (Situation situation in situations)
                        {
                            // Only have 1 situationRecord per situation (index=0)
                            processEventData(situation);
                        }
                    }
                }
                catch (Exception e)
                {
                    log.Error(e.Message);
                }
            }
        }
        public void Handle(D2LogicalModel deliverGetFusedSensorOnlyTrafficDataRequest)
        {
            log.Info("New FusedSensorOnlyTrafficData received.");

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

            ElaboratedDataPublication elaboratedDataPublication = null;

            try
            {
                elaboratedDataPublication = (ElaboratedDataPublication)deliverGetFusedSensorOnlyTrafficDataRequest.payloadPublication;

                if (elaboratedDataPublication != null)
                {
                    ElaboratedData[] elaboratedDataList = elaboratedDataPublication.elaboratedData;

                    log.Info("Number of data items in the publication: " + elaboratedDataList.Length);

                    foreach (ElaboratedData dataItem in elaboratedDataList)
                    {
                        extractTrafficDataFromElaboratedData(dataItem);
                    }

                    log.Info("FusedSensorOnlyTrafficData: processed successfully.");
                }
            } catch (Exception e)
            {
                log.Error(e.Message);
            }
        }
        public void Handle(D2LogicalModel deliverNtisModelNotificationDataRequest)
        {
            log.Info("New NtisModelNotificationService received.");

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

            if (deliverNtisModelNotificationDataRequest.payloadPublication != null)
            {

                GenericPublication genericPublication = deliverNtisModelNotificationDataRequest.payloadPublication as GenericPublication;

                log.Info("Ntis model publication time: " + genericPublication.publicationTime);
                log.Info("Generic publication name: " + genericPublication.genericPublicationName);

                _GenericPublicationExtensionType genericPublicationExtension = genericPublication.genericPublicationExtension;
                NtisModelVersionInformation ntisModelVersionInformation = genericPublicationExtension.ntisModelVersionInformation;

                log.Info("Network model - file name " + ntisModelVersionInformation.modelFilename);
                log.Info("Network model - version " + ntisModelVersionInformation.modelVersion);
                log.Info("Network model - publication time " + ntisModelVersionInformation.modelPublicationTime);

            }

            log.Info("NtisModelNotificationService: Processing Completed Successfuly");
        }
        public static void processDATEXIIUpdateXML(object source, ElapsedEventArgs e)
        {
            working++;
            if (logWrapper.isDebug() == true)
            {
                logWrapper.Debug("Polling for messages");
            }

            UpdateMessage xml = null;

            lock (messageQueue){
                if (messageQueue.Count() > QUEUE_EMPTY)
                {
                    xml = messageQueue.Dequeue();
                }
            }
            while (xml != null)
            {
                try {
                    XmlSerializer myDIISerializer = new XmlSerializer(typeof(D2LogicalModel));
                    XmlReader     xmlReader       = XmlReader.Create(new StringReader(Encoding.ASCII.GetString(xml.Buffer)));
                    Boolean       soap            = true;
                    try {
                        xmlReader.ReadStartElement("Envelope", "http://schemas.xmlsoap.org/soap/envelope/");
                        xmlReader.ReadStartElement("Body", "http://schemas.xmlsoap.org/soap/envelope/");
                    } catch (XmlException ex)
                    {
                        soap = false;
                    }
                    D2LogicalModel d2lm = (D2LogicalModel)myDIISerializer.Deserialize(xmlReader);
                    if (soap)
                    {
                        xmlReader.ReadEndElement();
                        xmlReader.ReadEndElement();
                    }
                    string feedType = FeedType.getFeedType(d2lm.payloadPublication.feedType);
                    DATEXIIProcessService datexiiProcessService = datexiiProcessServiceFactory.getServiceType(feedType);
                    if (datexiiProcessService != null)
                    {
                        datexiiProcessService.processMessage(d2lm);
                    }
                } catch (Exception ex)
                {
                    logWrapper.Error(ex.ToString());
                }
                lock (messageQueue){
                    if (messageQueue.Count() > QUEUE_EMPTY)
                    {
                        xml = messageQueue.Dequeue();
                    }
                    else
                    {
                        xml = null;
                    }
                }
            }
            working--;
        }
예제 #20
0
        // This method implements an interface method in the supplierPushInterface class (in autogenerated supplierPush.cs file)
        //
        // Ideally, this method should not return anything, but the  supplierPushInterface in the autogenerated supplierPush.cs demands it
        //
        public putDatex2DataResponse putDatex2Data(putDatex2DataRequest request)
        {
            int hhh = 1;

            lock (syncLock)
            {
                try
                {
                    D2LogicalModel d2LogicalModel = request.d2LogicalModel;
                    string         feedType       = d2LogicalModel.payloadPublication.feedType;
                    if (feedType.Contains("ANPR Journey Time Data"))
                    {
                        anprTrafficDataService.Handle(d2LogicalModel);
                    }
                    else if (feedType.Contains("MIDAS Loop Traffic Data"))
                    {
                        midasTrafficDataService.Handle(d2LogicalModel);
                    }
                    else if (feedType.Contains("TMU Loop Traffic Data"))
                    {
                        tmuTrafficDataService.Handle(d2LogicalModel);
                    }
                    else if (feedType.Contains("Fused Sensor-only PTD"))
                    {
                        fusedSensorOnlyTrafficDataService.Handle(d2LogicalModel);
                    }
                    else if (feedType.Contains("Fused FVD and Sensor PTD"))
                    {
                        fusedFvdAndSensorTrafficDataService.Handle(d2LogicalModel);
                    }
                    else if (feedType.Contains("VMS and Matrix Signal Status Data"))
                    {
                        vmsDataService.Handle(d2LogicalModel);
                    }
                    else if (feedType.Contains("NTIS Model Update Notification"))
                    {
                        ntisModelNotificationService.Handle(d2LogicalModel);
                    }
                    else if (feedType.Contains("Event Data"))
                    {
                        eventDataService.Handle(d2LogicalModel);
                    }
                    else
                    {
                        throw new Exception("Unrecognised feed type");
                    }
                }
                catch (Exception e)
                {
                    log.Info(e.Message);
                    throw e;
                }
            }

            // Return the message sent
            return(new putDatex2DataResponse(request.d2LogicalModel));
        }
 public void MyTestInitialize()
 {
     // Define message data
     model = new D2LogicalModel();
     model.modelBaseVersion = "2";
     exchange = new Exchange();
     supplierIdentification = new InternationalIdentifier();
     exchange.supplierIdentification = supplierIdentification;
     model.exchange = exchange;
     model.exchange.supplierIdentification.country = CountryEnum.gb;
     model.exchange.supplierIdentification.nationalIdentifier = "gb";
 }
        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 void Handle(D2LogicalModel deliverEventDataRequest)
        {

            log.Info("New EventData received.");

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

            SituationPublication situationPublication = null;
            try
            {

                situationPublication = (SituationPublication)deliverEventDataRequest.payloadPublication;

                if (situationPublication != null)
                {

                    Situation[] situations = situationPublication.situation;

                    log.Info("Number of Events in payload: " + situations.Length);

                    foreach (Situation situation in situations)
                    {

                        // Only have 1 situationRecord per situation (index=0)
                        SituationRecord situationRecord = situation.situationRecord[0];

                        // Different types of event/situation record contain some common information and 
                        // some type-specific data items and should be handled accordingly
                        processCommonEventData(situationRecord);

                        if (situationRecord.GetType() == typeof(MaintenanceWorks))
                        {
                            processMaintenanceWorksEvent((MaintenanceWorks)situationRecord);
                        }

                    }

                    log.Info("EventData: processed successfully.");

                }

            }
            catch (Exception e)
            {
                log.Error(e.Message);
            }

        }
        private void ProcessEventsInFullRefresh(D2LogicalModel request, Dictionary <String, SituationRecord> tempEventCache)
        {
            SituationPublication situationPublication = (SituationPublication)request.payloadPublication;

            if (situationPublication != null)
            {
                Situation[] situations = situationPublication.situation;
                log.Info(NumberOfEventsInPayload + situations.Length);
                foreach (Situation situation in situations)
                {
                    RefreshEvent(situation.situationRecord[0], tempEventCache);
                }
            }
        }
        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()
            });
        }
예제 #26
0
        public putDatex2DataResponse GetDeliverVMSTrafficDataResponse(D2LogicalModel VMSTrafficData)
        {
            log.Info("Handling VMS Traffic Data");
            // Validate the D2Logical Model
            if (!ExampleDataCheckOk(VMSTrafficData))
            {
                throw new SoapException("Incoming request does not appear to be valid!", SoapException.ClientFaultCode);
            }


            VmsPublication payloadPublication = VMSTrafficData.payloadPublication as VmsPublication;

            if (payloadPublication != null)
            {
                VmsUnit vmsUnit = payloadPublication.vmsUnit[0];
                if (vmsUnit != null)
                {
                    log.Info(string.Format("Vmsunit GUID: {0}", vmsUnit.vmsUnitReference.id));

                    IList<_VmsUnitVmsIndexVms> vmsIndexList = vmsUnit.vms;
                    if (vmsIndexList != null && vmsIndexList.Count > 0)
                    {
                        _VmsUnitVmsIndexVms vmsUnitVmsIndexVms = vmsIndexList[0];
                        IList<_VmsMessageIndexVmsMessage> vmsMessageList = vmsUnitVmsIndexVms.vms.vmsMessage;
                        if (vmsMessageList.Count > 0)
                        {
                            VmsMessage vmsMessage = vmsMessageList[0].vmsMessage;
                            IList<_TextPage> textPageList = vmsMessage.textPage;
                            if (textPageList.Count > 0)
                            {
                                _TextPage textPage = textPageList[0];
                                VmsText vmsText = textPage.vmsText;
                                IList<_VmsTextLineIndexVmsTextLine> vmsTextLineList = vmsText.vmsTextLine;
                                if (vmsTextLineList.Count > 0)
                                {
                                    _VmsTextLineIndexVmsTextLine vmsTextLineIndexVmsTextLine = vmsTextLineList[0];
                                    log.Info(string.Format("vms text line {0}", vmsTextLineIndexVmsTextLine.vmsTextLine.vmsTextLine));
                                }
                            }
                        }
                    }
                }
            }

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

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

        }
        public void Handle(D2LogicalModel d2LogicalModel)
        {
            log.Info(PublicationType + " : received...");
            log.Info(NumberOfEventsInCache + EventCache.Count());
            if (IsEventFullRefresh(d2LogicalModel))
            {
                HandleFullEventRefresh(d2LogicalModel);
            }
            else
            {
                HandleEventUpdate(d2LogicalModel);
            }

            log.Info(PublicationType + " : processed successfully.");
            log.Info(NumberOfEventsInCache + EventCache.Count());
        }
        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() };

        }
예제 #29
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);
            }
        }
예제 #30
0
        public void Handle(D2LogicalModel deliverEventDataRequest)
        {
            log.Info("New EventData received.");

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

            SituationPublication situationPublication = null;

            try
            {
                situationPublication = (SituationPublication)deliverEventDataRequest.payloadPublication;

                if (situationPublication != null)
                {
                    Situation[] situations = situationPublication.situation;

                    log.Info("Number of Events in payload: " + situations.Length);

                    foreach (Situation situation in situations)
                    {
                        // Only have 1 situationRecord per situation (index=0)
                        SituationRecord situationRecord = situation.situationRecord[0];

                        // Different types of event/situation record contain some common information and
                        // some type-specific data items and should be handled accordingly
                        processCommonEventData(situationRecord);

                        if (situationRecord.GetType() == typeof(MaintenanceWorks))
                        {
                            processMaintenanceWorksEvent((MaintenanceWorks)situationRecord);
                        }
                    }

                    log.Info("EventData: processed successfully.");
                }
            }
            catch (Exception e)
            {
                log.Error(e.Message);
            }
        }
 public putDatex2DataResponse putDatex2Data(putDatex2DataRequest request)
 {
     try
     {
         D2LogicalModel d2LogicalModel = request.d2LogicalModel;
         string         feedType       = d2LogicalModel.payloadPublication.feedType;
         if (feedType.Contains("ANPR Journey Time Data"))
         {
             return(anprTrafficDataService.GetDeliverAnprTrafficDataResponse(d2LogicalModel));
         }
         else if (feedType.Contains("MIDAS Loop Traffic Data"))
         {
             return(midasTrafficDataService.GetDeliverMidasTrafficDataResponse(d2LogicalModel));
         }
         else if (feedType.Contains("TMU Loop Traffic Data"))
         {
             return(tmuTrafficDataService.GetDeliverTMUTrafficDataResponse(d2LogicalModel));
         }
         else if (feedType.Contains("Fused Sensor-only PTD"))
         {
             return(SensorTrafficDataService.GetDeliverSensorTrafficDataResponse(d2LogicalModel));
         }
         else if (feedType.Contains("Fused FVD and Sensor PTD"))
         {
             return(fvdTrafficDataService.GetDeliverFVDTrafficDataResponse(d2LogicalModel));
         }
         else if (feedType.Contains("VMS and Matrix Signal Status Data"))
         {
             return(vmsDataService.GetDeliverVMSTrafficDataResponse(d2LogicalModel));
         }
         else if (feedType.Contains("NTIS Model Update Notification"))
         {
             return(ntisModelNotificationService.GetNtisModelNotificationDataResponse(d2LogicalModel));
         }
         else
         {
             throw new Exception("Unrecognised feed type");
         }
     }
     catch (Exception e)
     {
         log.Info(e.Message);
         throw e;
     }
 }
        private void ProcessEventsUpdatedAfterFullRefreshPublicationTime(D2LogicalModel request, Dictionary <String, SituationRecord> tempEventCache)
        {
            DateTime fullRefreshPublicationTime = request.payloadPublication.publicationTime;

            log.Info("Full Refresh Publication Time: " + fullRefreshPublicationTime);
            foreach (SituationRecord record in tempEventCache.Values)
            {
                if (IsEventUpdatedAfterFullRefreshPublicationTime(record, fullRefreshPublicationTime))
                {
                    EventCache.Add(record.id, record);
                    log.Info("Keeping cached version of event: " + record.id + " as it has been updated after the Full Refresh Publication Time.");
                }
                else
                {
                    log.Info("Discarding cached version of event: " + record.id + " as it is older than the Full Refresh Publication Time.");
                }
            }
        }
예제 #33
0
        public override void processMessage(D2LogicalModel d2LogicalModel)
        {
            if (logWrapper.isInfo())
            {
                logWrapper.Info("VMSAndMatrix Update");
            }

            bool   fullRefresh = false;
            string feedType    = d2LogicalModel.payloadPublication.feedType;

            if (feedType.ToLower().Contains(FULL_REFRESH_TEXT))
            {
                if (logWrapper.isInfo())
                {
                    logWrapper.Info("VMS Full Refresh received");
                }
                fullRefresh = true;
                vMSDataStore.clearDataStore();
            }

            VmsPublication payloadPublication = (VmsPublication)d2LogicalModel.payloadPublication;
            DateTime       publicationTime    = payloadPublication.publicationTime;

            if (payloadPublication != null)
            {
                VmsUnit[] vmsUnits = payloadPublication.vmsUnit;

                if (logWrapper.isInfo())
                {
                    logWrapper.Info("VMS Update(" + vmsUnits.Length + " objects)");
                }

                for (int vmsUnitsPos = 0; vmsUnitsPos < vmsUnits.Length; vmsUnitsPos++)
                {
                    VmsUnit vmsUnit = vmsUnits[vmsUnitsPos];
                    processVmsUnit(vmsUnit, publicationTime, fullRefresh);
                }
            }

            if (logWrapper.isInfo())
            {
                logWrapper.Info("VMSAndMatrix Update Complete");
            }
        }
        public override void processMessage(D2LogicalModel d2LogicalModel)
        {
            if (logWrapper.isDebug())
            {
                logWrapper.Debug("Event Update");
            }

            bool   fullRefresh = false;
            String feedType    = d2LogicalModel.payloadPublication.feedType;

            if (feedType.ToLower().Contains(fullRefreshText))
            {
                logWrapper.Info("Event Full Refresh received");
                fullRefresh = true;
                lock (eventDataStore){
                    eventDataStore.clearDataStore();
                }
            }

            SituationPublication situationPublication = (SituationPublication)d2LogicalModel.payloadPublication;
            DateTime             publicationTime      = situationPublication.publicationTime;

            if (situationPublication != null)
            {
                Situation[] situationList = situationPublication.situation;

                if (logWrapper.isDebug())
                {
                    logWrapper.Debug("Event Update(" + situationList.Length + " objects)");
                }

                for (int situationListPos = 0; situationListPos < situationList.Length; situationListPos++)
                {
                    Situation situation = situationList[situationListPos];
                    processSituation(situation, publicationTime, fullRefresh);
                }
            }

            if (logWrapper.isDebug())
            {
                logWrapper.Debug("Event Update Complete");
            }
        }
        public void Handle(D2LogicalModel VMSTrafficData)
        {

            log.Info("New VMSTrafficData received.");

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

            try
            {

                VmsPublication vmsPublication = (VmsPublication) VMSTrafficData.payloadPublication;

                if (vmsPublication != null) {

                    VmsUnit[] vmsUnits = vmsPublication.vmsUnit;

                    log.Info("Number of VMS/Matrix Units in payload: " + vmsUnits.Length);

                    // The publication can contain status info for more than one
                    // unit
                    foreach (VmsUnit vmsUnit in vmsUnits)
                    {
                        extractStatusInformationFromUnitData(vmsUnit);
                    }

                    log.Info("VMSTrafficData: Processing Completed 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 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");
            }
        }
        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);
            }

        }
 private void HandleFullEventRefresh(D2LogicalModel request)
 {
     lock (LockEventUpdates)
     {
         try
         {
             log.Info("Processing Event Data Full Refresh.");
             Dictionary <String, SituationRecord> tempEventCache = new Dictionary <string, SituationRecord>(EventCache);
             EventCache.Clear();
             ProcessEventsInFullRefresh(request, tempEventCache);
             ProcessEventsUpdatedAfterFullRefreshPublicationTime(request, tempEventCache);
             ProcessRefreshedEventData();
             tempEventCache.Clear();
             log.Info("Finished processing Event Data Full Refresh.");
         }
         catch (Exception e)
         {
             log.Error(e.Message);
         }
     }
 }
        public override void processMessage(D2LogicalModel d2LogicalModel)
        {
            GenericPublication          genericPublication          = (GenericPublication)d2LogicalModel.payloadPublication;
            NtisModelVersionInformation ntisModelVersionInformation = genericPublication.genericPublicationExtension.ntisModelVersionInformation;

            DateTime publicationTime = ntisModelVersionInformation.modelPublicationTime;
            String   modelVersion    = ntisModelVersionInformation.modelVersion;
            String   modelFilename   = ntisModelVersionInformation.modelFilename;

            numberOfNetworkModelRetries = MAX_NUMBER_OF_NETWORK_MODEL_RETRIES;

            if (ntisNetworkModelBaseURL != null)
            {
                updateNetworkModel(null, null);
                //datexiiNetworkModelUpdateService.updateNetworkModel(ntisNetworkModelBaseURL, ntisNwkModelUsername, ntisNwkModelPassword);
            }
            else
            {
                logWrapper.Error("NTIS_NETWORK_MODEL_BASE_URL is not set in application.properties file");
            }
        }
        public void Handle(D2LogicalModel deliverGetFusedSensorOnlyTrafficDataRequest)
        {

            log.Info("New FusedSensorOnlyTrafficData received.");

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

            ElaboratedDataPublication elaboratedDataPublication = null;

            try
            {

                elaboratedDataPublication = (ElaboratedDataPublication) deliverGetFusedSensorOnlyTrafficDataRequest.payloadPublication;

                if (elaboratedDataPublication != null)
                {

                    ElaboratedData[] elaboratedDataList = elaboratedDataPublication.elaboratedData;

                    log.Info("Number of data items in the publication: " + elaboratedDataList.Length);
                
                    foreach (ElaboratedData dataItem in elaboratedDataList)
                    {
                        extractTrafficDataFromElaboratedData(dataItem);
                    }

                    log.Info("FusedSensorOnlyTrafficData: processed successfully.");

                }
                
            } catch (Exception e)
            {
                log.Error(e.Message);
            }

        }
        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() };

        }
예제 #42
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()
            });
        }
        public putDatex2DataResponse GetDeliverSensorTrafficDataResponse(D2LogicalModel request)
        {
            log.Info("Handling Fused Sensor-only PTD Request!");

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


            ElaboratedDataPublication elaboratedDataPublication = request.payloadPublication as ElaboratedDataPublication;

            if (elaboratedDataPublication != null)
            {
                log.Info("Publication Time is " + elaboratedDataPublication.publicationTime);
                log.Info("Time Default is  " + elaboratedDataPublication.timeDefault);
                log.Info("Total Elaborated Data objects  are " + elaboratedDataPublication.elaboratedData.Length);
            }

            log.Info("Fused Sensor-only PTD Request: Processing Completed Successfuly");

            return new putDatex2DataResponse { d2LogicalModel = new D2LogicalModel() };
        }
        public void CheckErrorInDeliverANPRTrafficDataTest()
        {
            IAnprTrafficDataService anprTrafficDataService = new AnprTrafficDataService();
            DeliverANPRTrafficDataRequest deliverANPRTrafficDataRequest = new DeliverANPRTrafficDataRequest();

            model = null; // This will be checked by ExampleDataCheckOk(d2LogicalModel)

            deliverANPRTrafficDataRequest.D2LogicalModel = model;
            string expected = "DeliverANPRTrafficDataResponse: Successful Delivery";
            string actual;
            // This should cause a SoapException
            actual = (anprTrafficDataService.GetDeliverAnprTrafficDataResponse(deliverANPRTrafficDataRequest)).status;

            Assert.AreEqual(expected, actual);
        }
        public void CheckErrorInGetDeliverAverageJourneyTimeResponseTest()
        {
            IAverageJourneyTimeService averageJourneyTimeService = new AverageJourneyTimeService();
            DeliverAverageJourneyTimeRequest deliverAverageJourneyTimeRequest = new DeliverAverageJourneyTimeRequest();

            model = null; // This will be checked by ExampleDataCheckOk(d2LogicalModel)

            deliverAverageJourneyTimeRequest.D2LogicalModel = model;
            string expected = "DeliverAverageJourneyTimeRequest: Successful Delivery";
            string actual;
            // This should cause a SoapException
            actual = (averageJourneyTimeService.GetDeliverAverageJourneyTimeResponse(deliverAverageJourneyTimeRequest)).status;

            Assert.AreEqual(expected, actual);
        }
        public void CheckErrorInGetTMUTrafficDataResponseTest()
        {
            ITMUTrafficDataService tmuTrafficDataService = new TMUTrafficDataService();
            DeliverTMUTrafficDataRequest deliverTMUTrafficDataRequest = new DeliverTMUTrafficDataRequest();

            model = null;
            deliverTMUTrafficDataRequest.d2LogicalModel = model;

            tmuTrafficDataService.GetDeliverTMUTrafficDataResponse(deliverTMUTrafficDataRequest);
        }
        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() };
        }