Exemplo n.º 1
0
        /// <summary>
        /// Queries the TMDD client for the timing inventory of an intersection
        /// </summary>
        /// <param name="id">ID of the intersection</param>
        /// <param name="client">TMDD client</param>
        /// <returns>The instersection signal timing inventory</returns>
        private IntersectionSignalTimingInventory PerformTimingInventoryQuery(string id, TmddEnhancedServiceClient client)
        {
            IntersectionSignalTimingInventory returnValue = null;

            var request = new IntersectionSignalTimingInventoryRequest
            {
                deviceinformationrequestheader = new DeviceInformationRequest
                {
                    deviceinformationtype = Constants.DeviceInformationTypes.Inventory,
                    devicetype            = Constants.DeviceTypes.SignalController,
                    authentication        = new Authentication
                    {
                        userid   = Username,
                        password = Password
                    },

                    // This is the caller's "organization id".  In a production environment,
                    // this should be assigned by the Traffic Management Center administrator.
                    organizationrequesting = new OrganizationInformation
                    {
                        organizationid = 1.ToString()
                    },

                    // This is the organization id of the organization you are requesting
                    // inventory for.  This is found by inspecting the
                    // centerActiveVerification response or the organizationInformation response.
                    // If you omit this, you will receive inventory for all organizations
                    // at this endpoint. This endpoint is specific to this test server and
                    // contains only a sample city's data.
                    // Here we are simply passing it what was passed to this method.
                    organizationinformation = new OrganizationInformation()
                    {
                        organizationid = orgId
                    },
                    devicefilter = new DeviceInformationRequestFilter()
                    {
                        deviceidlist = new DeviceInformationRequestFilterDeviceidlist()
                        {
                            deviceid = new[] { id }
                        }
                    },
                }
            };

            try
            {
                var response = client.dlIntersectionSignalTimingInventoryRequest(request);
                if (response.intersectionsignaltiminginventoryitem.Length > 0)
                {
                    returnValue = response.intersectionsignaltiminginventoryitem[0];
                }
            }
            catch (Exception ex)
            {
                LogError(ex.Message);
            }
            return(returnValue);
        }
Exemplo n.º 2
0
        private static void SubmitInventorySignalTimingInventoryRequest(string orgId)
        {
            Console.WriteLine("\nSubmitting InventorySignalTimingInventoryRequest...");

            // Create the client
            var client = new TmddEnhancedServiceClient();

            var request = new IntersectionSignalTimingInventoryRequest
            {
                deviceinformationrequestheader = new DeviceInformationRequest
                {
                    deviceinformationtype = Constants.DeviceInformationTypes.Inventory,
                    devicetype            = Constants.DeviceTypes.SignalController,
                    authentication        = new Authentication
                    {
                        userid   = Username,
                        password = Password
                    },

                    // This is the caller's "organization id".  In a production environment,
                    // this should be assigned by the Traffic Management Center administrator.
                    organizationrequesting = new OrganizationInformation
                    {
                        organizationid = 1.ToString()
                    },

                    // This is the organization id of the organization you are requesting
                    // inventory for.  This is found by inspecting the
                    // centerActiveVerification response or the organizationInformation response.
                    // If you omit this, you will receive inventory for all organizations
                    // at this endpoint. This endpoint is specific to this test server and
                    // contains only a sample city's data.
                    // Here we are simply passing it what was passed to this method.
                    organizationinformation = new OrganizationInformation()
                    {
                        organizationid = orgId
                    },
                    devicefilter = new DeviceInformationRequestFilter()
                    {
                        deviceidlist = new DeviceInformationRequestFilterDeviceidlist()
                        {
                            deviceid = new[] { "b3c0fe11-bbe0-4dd2-9a6d-a77700e13754" }
                        }
                    },
                }
            };

            try
            {
                var response = client.dlIntersectionSignalTimingInventoryRequest(request);

                // What this message returns is an array of IntersectionSignalTimingPatternInventory items.
                // Iterate through the collection to inspect the objects.
                foreach (var item in response.intersectionsignaltiminginventoryitem)
                {
                    // Print out some retrieved data
                    if (item.intervals?.intervals != null && item.intervals.intervals.Any())
                    {
                        Console.WriteLine(
                            "\nOrganization ID: {0}\nOrganization Name: {1}\nDevice Id: {2}\nInterval #: {3}\nInterval Time: {4}",
                            item.organizationinformation.organizationid,
                            item.organizationinformation.organizationname,
                            item.deviceid,
                            item.intervals.intervals[0].intervalidentifier,
                            item.intervals.intervals[0].IntervalTime);
                    }
                    else if (item.phases != null && item.phases.phases.Any())
                    {
                        Console.WriteLine(
                            @"\nOrganization ID: {0}\nOrganization Name: {1}\nDevice Id: {2}\Phase 1 Min Green: {3}",
                            item.organizationinformation.organizationid,
                            item.organizationinformation.organizationname,
                            item.deviceid,
                            item.phases.phases[0].MinGreen);
                    }
                }
            }
            catch (FaultException fe)
            {
                Console.WriteLine("Fault exception encountered: {0}", fe.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception encountered: {0}", ex.Message);
            }
        }