/// <summary> /// Gets the signal inventory for all intersection. Signal inventory = name and id of each intersection /// </summary> /// <returns>List of intersection inventory items</returns> public List <IntersectionInventoryItem> GetSignalInventory() { if (inventory.Count == 0) { // Create the client var client = new TmddEnhancedServiceClient(); // Create the inventory request. var request = 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 }, }; try { var response = client.dlIntersectionSignalInventoryRequest(request); for (int i = 0; i < response.intersectionsignalinventoryitem.Length; i++) { IntersectionInventoryItem inv = new IntersectionInventoryItem(); inv.Name = response.intersectionsignalinventoryitem[i].deviceinventoryheader.devicename; inv.ID = response.intersectionsignalinventoryitem[i].deviceinventoryheader.deviceid; inventory.Add(inv); } } catch (Exception ex) { inventory = null; LogError(ex.Message); } } return(inventory); }
/// <summary> /// Request list of traffic controllers from Traffic Management Center /// </summary> /// <param name="orgId"></param> private static void SubmitIntersectionSignalInventoryRequest(string orgId) { Console.WriteLine("\nSubmitting IntersectionSignalInventoryRequest..."); // Create the client var client = new TmddEnhancedServiceClient(); // Create the inventory request. var request = 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 }, }; try { var response = client.dlIntersectionSignalInventoryRequest(request); // What this message returns is an array of IntersectionSignalInventory items. // Iterate through the collection to inspect the objects. for (int i = 0; i < response.intersectionsignalinventoryitem.Length; i++) { var item = response.intersectionsignalinventoryitem[i]; // Save this ID so we can create a subscription using it later. if (i == 0 && Guid.TryParse(item.deviceinventoryheader.deviceid, out var intersectionId)) { _firstIntersectionSignalId = intersectionId; } Console.WriteLine( "\nOrganization ID: {0}\nOrganization Name: {1}\nDevice Id: {2}\nDevice Name: {3}\nDevice Location: {4}, {5}", item.deviceinventoryheader.organizationinformation.organizationid, item.deviceinventoryheader.organizationinformation.organizationname, item.deviceinventoryheader.deviceid, item.deviceinventoryheader.devicename, item.deviceinventoryheader.devicelocation.latitude, item.deviceinventoryheader.devicelocation.longitude); } } catch (FaultException fe) { Console.WriteLine("Fault exception encountered: {0}", fe.Message); } catch (Exception ex) { Console.WriteLine("Exception encountered: {0}", ex.Message); } }