Device |
Get all parents
Namespace: Gamanet.C4.SDK
Assembly: Gamanet.C4.SimpleClient (in Gamanet.C4.SimpleClient.dll) Version: 2026.0.0.733
Syntax
C#
public ISimpleCollection<SimpleDeviceV1> GetAllParents( Guid deviceId, Properties properties, bool includeNode )
Parameters
- deviceId Guid
- The device identifier.
- properties Properties
- The properties.
- includeNode Boolean
- if set to true include node.
Return Value
ISimpleCollection<SimpleDeviceV1>Collection of devices
Implements
ISimpleClientDeviceRepositoryV3.GetAllParents(Guid, Properties, Boolean)Example
This example demonstrates how to retrieve all parent devices of a given device based on device ID, with optional filtering properties (None, Basic, All) and an option to include Node (true, false).
C#
using System; using Gamanet.C4.SDK; using Gamanet.C4.SimpleInterfaces; public class Example { static void Main() { // Create instance of simple client var client = new SimpleClient(ConnectorConfiguration.HttpClient); ConnectionInfoV1 token; // Connect to local server var connectionResult = client.Connect(new Uri("https://localhost/"), "Support", "support", out token); if (connectionResult != ConnectionResult.Successful) { Console.WriteLine("Connection unsuccessful, result: {0}", connectionResult); return; } Console.WriteLine("Connection result: {0}", connectionResult); Console.WriteLine(); // You need to have installed the Demo Access Device package from https://my.c4portal.com/plugins/ var exampleBusCategory = client.EntityDefinitions.Get(Guid.Parse("4810e0c6-9391-490c-a646-ca9643dd1ca5")).Id; var examplePanelCategory = client.EntityDefinitions.Get(Guid.Parse("822caeea-b66b-4f60-ab43-bc14240cb6ec")).Id; var exampleDoorCategory = client.EntityDefinitions.Get(Guid.Parse("dcd0cea7-8de9-4458-afa7-cd1e94b56028")).Id; // Create the Example Device (Bus Controller) var exampleBusController = new SimpleDeviceV1( Guid.NewGuid(), "BUS", EntityRoot.Device, exampleBusCategory ); // Create the Example Device (Panel) var examplePanel = new SimpleDeviceV1( Guid.NewGuid(), "PANEL", exampleBusController.Id, examplePanelCategory ); // Create the Example Device (Door) var exampleDoor = new SimpleDeviceV1( Guid.NewGuid(), "DOOR", examplePanel.Id, exampleDoorCategory ); // Create devices in db client.Devices.Create(exampleBusController); client.Devices.Create(examplePanel); client.Devices.Create(exampleDoor); // Now we are goint to get all parent devices of a panel, including the panel node var exampleResult = client.Devices.GetAllParents(examplePanel.Id, Properties.None, true); foreach (var device in exampleResult) { Console.WriteLine(device.Name); } // Disconnect from server client.Disconnect(); } }
See Also