public IDevice CreateDevice(ILogger logger, ITransportFactory transportFactory, ITelemetryFactory telemetryFactory, IConfigurationProvider configurationProvider, InitialDeviceConfig config) { var device = new EngineDevice(logger, transportFactory, telemetryFactory, configurationProvider); device.Init(config); return device; }
protected virtual void InitDeviceInfo(InitialDeviceConfig config) { dynamic initialDevice = SampleDeviceFactory.GetSampleSimulatedDevice(config.DeviceId, config.Key); DeviceProperties = DeviceSchemaHelper.GetDeviceProperties(initialDevice); Commands = CommandSchemaHelper.GetSupportedCommands(initialDevice); HostName = config.HostName; PrimaryAuthKey = config.Key; }
public void Init(InitialDeviceConfig config) { InitDeviceInfo(config); Transport = TransportFactory.CreateTransport(this); _telemetryController = TelemetryFactory.PopulateDeviceWithTelemetryEvents(this); InitCommandProcessors(); }
public async Task AddOrUpdateDeviceAsync(InitialDeviceConfig deviceConfig) { var devicesTable = await AzureTableStorageHelper.GetTableAsync(_storageConnectionString, _deviceTableName); var deviceEnity = new DeviceListEntity() { DeviceId = deviceConfig.DeviceId, HostName = deviceConfig.HostName, Key = deviceConfig.Key }; var operation = TableOperation.InsertOrReplace(deviceEnity); await devicesTable.ExecuteAsync(operation); }
public async Task<List<InitialDeviceConfig>> GetDeviceListAsync() { List<InitialDeviceConfig> devices = new List<InitialDeviceConfig>(); var devicesTable = await AzureTableStorageHelper.GetTableAsync(_storageConnectionString, _deviceTableName); TableQuery<DeviceListEntity> query = new TableQuery<DeviceListEntity>(); foreach (var device in devicesTable.ExecuteQuery(query)) { var deviceConfig = new InitialDeviceConfig() { HostName = device.HostName, DeviceId = device.DeviceId, Key = device.Key }; devices.Add(deviceConfig); } return devices; }