Device |
Create new device.
Namespace: Gamanet.C4.SDK
Assembly: Gamanet.C4.SimpleClient (in Gamanet.C4.SimpleClient.dll) Version: 2026.0.0.733
Syntax
C#
public void Create( SimpleDeviceV1 device )
Parameters
- device SimpleDeviceV1
- The device.
Implements
ISimpleClientDeviceRepositoryV1.Create(SimpleDeviceV1)Example
The following example illustrates how the SimpleClient creates a device.
The following example illustrates how the SimpleClient creates a partition and assign a detector under it.
The following example illustrates how the SimpleClient creates a device.
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(); var newDevice = new SimpleDeviceV1(Guid.NewGuid(), "BUS", EntityRoot.Device, entityDefinitionId); // all custom enums values should be passed to data in string format newDevice.Data["Level"] = "MessageLevel.Silent"; newDevice.Data["Country"] = "States.UnitedStates"; // create device under device root in db client.Devices.Create(newDevice); var result = client.Devices.Get(newDevice.Id, Properties.None); Console.WriteLine(result.Name); // Disconnect from server client.Disconnect(); } }
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 new instance of bus controller var busControllerDevice = new SimpleDeviceV1(Guid.NewGuid(), "Bus Controller", EntityRoot.Device, busControllerEntityDefinitionId); // create bus controller in db client.Devices.Create(busControllerDevice); // create new instance of access panel var panel = new SimpleDeviceV1(Guid.NewGuid(), "AccessPanel", busControllerDevice.Id, accessPanelEntityDefinitionId); // create access panel under bus controller in db client.Devices.Create(panel); // create new instance of partition var partition = new SimpleDeviceV1(Guid.NewGuid(), "Partition", panel.Id, groupEntityDefinitionId); // create partition under access panel in db client.Devices.Create(partition); // create new instance of detector var detector = new SimpleDeviceV1(Guid.NewGuid(), "Detector", panel.Id, detectorEntityDefinitionId); // create detector under access panel in db client.Devices.Create(detector); // create new instance of device reference var deviceRef = new SimpleDeviceV1(detector.Id, partition.Name, // name of referenced device partition.Id, // parent for device reference Guid.Parse("EE91BC13-CDB0-43F3-A868-DA794207F9AB")); //device ref // assign device ref to detector under partition client.Devices.Create(deviceRef); var result = client.Devices.GetAll(); Console.WriteLine("All created devices: \n"); foreach(var device in result) { Console.WriteLine(device.Name); } // Disconnect from server client.Disconnect(); } }
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 new instance of bus controller var busControllerDevice = new SimpleDeviceV1(Guid.NewGuid(), "Bus Controller", EntityRoot.Device, busControllerEntityDefinitionId); // create bus controller in db client.Devices.Create(busControllerDevice); // create new instance of access panel var panel = new SimpleDeviceV1(Guid.NewGuid(), "AccessPanel", busControllerDevice.Id, accessPanelEntityDefinitionId); // create access panel under bus controller in db client.Devices.Create(panel); // create new instance of door var door = new SimpleDeviceV1(Guid.NewGuid(), "Door", panel.Id, doorEntityDefinitionId); // create partition under access panel in db client.Devices.Create(door); // create new instance of access level var newAccessLevel = new SimpleDeviceV1(Guid.NewGuid(), // new Id "Access Level 1", // name of the access level EntityRoot.AccessLevelRoot, // parent is access level root Guid.Parse("06B77FBA-997B-4125-A76B-71EA71B4370D")); // category access level client.Devices.Create(newAccessLevel); // create new instance of device reference var deviceRef = new SimpleDeviceV1(door.Id, door.Name, // name of the device newAccessLevel.Id, // parent for device reference Guid.Parse("EE91BC13-CDB0-43F3-A868-DA794207F9AB")); //device ref // assign device ref to detector under partition client.Devices.Create(deviceRef); var result = client.Devices.GetAll(); Console.WriteLine("Names of devices: \n"); foreach (var device in result) { Console.WriteLine(device.Name); } // Disconnect from server client.Disconnect(); } }
See Also