Пример #1
0
        private ICcuDevice CreateDevice(ICcuDeviceInfo deviceInfo, IEnumerable <ICcuDeviceInfo> deviceInfos)
        {
            var device = new CcuDevice(deviceInfo, XmlRpcApi);

            device.AddChannels(
                deviceInfos
                .Where(x => x.IsChannel && x.Parent == deviceInfo.Address)
                .Select(x => new CcuDeviceChannel(device, x, XmlRpcApi)));

            return(device);
        }
Пример #2
0
        public async Task <ICcuDevice> GetDeviceAsync(string deviceAddress)
        {
            var deviceInfo = await GetDeviceInfoAsync(deviceAddress).ConfigureAwait(false);

            var device = new CcuDevice(deviceInfo, XmlRpcApi);

            var channelInfos = new List <ICcuDeviceInfo>();

            foreach (var channelAddress in deviceInfo.Children)
            {
                var channelInfo = await GetDeviceInfoAsync(channelAddress);

                channelInfos.Add(channelInfo);
            }

            device.AddChannels(channelInfos.Select(channelInfo => new CcuDeviceChannel(device, channelInfo, XmlRpcApi)));

            return(device);
        }