Device |
Get Devices by profile/summary>
Namespace: Gamanet.C4.SDK
Assembly: Gamanet.C4.SimpleClient (in Gamanet.C4.SimpleClient.dll) Version: 2026.0.0.733
Syntax
C#
public ISimpleCollection<SimpleDeviceV1> GetAllByProfile( Guid profileId )
Parameters
- profileId Guid
- The profile identifier.
Return Value
ISimpleCollection<SimpleDeviceV1>Collection of devices
Implements
ISimpleClientDeviceRepositoryV3.GetAllByProfile(Guid)Example
The following example illustrates how SimpleClient filter all devices by profile
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(); // Create the Example Device (Bus Controller) var exampleBusController = new SimpleDeviceV1( Guid.NewGuid(), "BUS", EntityRoot.Device, Guid.Parse("9c2246aa-5d43-414f-85d4-8c3b4e657236") ); client.Devices.Create(exampleBusController); // Create ProfileDeviceData for example profile var exampleDeviceData = new ProfileDeviceDataV1(Guid.NewGuid()) { DeviceIds = new SimpleCollection<Guid> { exampleBusController.Id }, Data = new Dictionary<string, object> { ["Enabled"] = true, ["TimeReset"] = "12:00:00" } }; // Create device type data for profile var exampleDeviceTypeData = new ProfileDeviceTypeDataV1(Guid.NewGuid()) { DeviceTypeId = exampleBusController.CategoryId, Data = { ["Enabled"] = true } }; // Create example profile for Bus Controller var exampleProfile = new ProfileV1(Guid.NewGuid(), "Example Device Profile") { Description = "Example device profile", ExternalNumber = "1", DeviceData = new SimpleCollection<ProfileDeviceDataV1> { exampleDeviceData, }, DeviceTypeData = new SimpleCollection<ProfileDeviceTypeDataV1> { exampleDeviceTypeData, }, }; client.Profiles.Create(exampleProfile); // Check if profile exists var getProfile = client.Profiles.Get(exampleProfile.Id); if (getProfile != null) { Console.WriteLine($"Profile name: {getProfile.Name}"); } // Here we get the devices matching the example profile var exampleResult = client.Devices.GetAllByProfile(exampleProfile.Id); // Output should contain device name 'BUS' foreach (var device in exampleResult) { Console.WriteLine(device.Name); } // Disconnect from server client.Disconnect(); } }
See Also