public DeviceModelList ReadDevices() { string devicesDir = Path.Join(_configBaseDir, "devices"); if (!Directory.Exists(devicesDir)) { return new DeviceModelList() { new DeviceModel() } } ; string[] deviceBaseDirs = Directory.GetDirectories(devicesDir); DeviceModelList devices = new DeviceModelList(); foreach (string deviceBaseDir in deviceBaseDirs) { DeviceModel device = new DeviceModel(); device.DeviceId = Path.GetFileName(deviceBaseDir); //device Info device.Info = JsonSerializer.Deserialize <DeviceInfo>( File.ReadAllText(Path.Join(deviceBaseDir, "device.wdspec.json"))); //monitor rules device.MonitorRules = JsonSerializer.Deserialize <MonitorRuleList>( File.ReadAllText(Path.Join(deviceBaseDir, "monitorRules.json"))); device.PropertyRules = JsonSerializer.Deserialize <PropertyRuleModelList>( File.ReadAllText(Path.Join(deviceBaseDir, "propertyRules.json"))); string[] layerFiles = Directory.GetFiles(deviceBaseDir, "*.wdlayer.json"); foreach (string layerFile in layerFiles) { LayerModel layer = JsonSerializer.Deserialize <LayerModel>(File.ReadAllText(layerFile)); device.Layers.Add(layer.LayerId, layer); } devices.Add(device); } return(devices); }
public void LoadDevices() { IDeviceReader deviceReader = Container.Resolve <IDeviceReader>(); DeviceManager deviceManager = Container.Resolve <DeviceManager>(); DeviceModelList deviceModels = deviceReader.ReadDevices(); List <IStreamDeckRefHandle> deckRefHandles = StreamDeck.EnumerateDevices().ToList(); //TODO Add support for multuple devices var deviceModel = deviceModels.First(); foreach (IStreamDeckRefHandle streamDeckRefHandle in deckRefHandles) { deviceModel.Info.HardwareId = streamDeckRefHandle.DevicePath; IStreamDeckBoard board = streamDeckRefHandle.Open(); deviceManager.AddDevice(board, deviceModel); } }
public IHttpActionResult GetDevices() { var devices = new DeviceModelList(db.Devices); return(this.Ok(devices)); }