本文整理汇总了C#中IDevice.GetSubDevices方法的典型用法代码示例。如果您正苦于以下问题:C# IDevice.GetSubDevices方法的具体用法?C# IDevice.GetSubDevices怎么用?C# IDevice.GetSubDevices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDevice
的用法示例。
在下文中一共展示了IDevice.GetSubDevices方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintSensorsAndSubDevices
static void PrintSensorsAndSubDevices(IDevice device, string prefix)
{
if (!device.Valid || !device.Present)
return;
device.Refresh(true);
if (device is ISensor)
{
if (device is ILED)
{
ILED led = (ILED)device;
IControllableSensor controllableLED = (IControllableSensor)device;
/*{
IFixedColorController _ledController = (IFixedColorController)ControllerRegistry.Get("LED.CorsairLink.SingleColor").New();
_ledController.Value = new Color(255, 1, 1);
controllableLED.Controller = _ledController;
}*/
IController ledController = controllableLED.Controller;
Console.Out.WriteLine(prefix + "- " + led.Name + " = " + led.Value + " " + led.Unit.GetPostfix());
if (ledController != null)
Console.Out.WriteLine(prefix + "\t" + ((ledController == null) ? "N/A" : ledController.Name));
if (ledController is IFixedColorController)
{
Console.Out.WriteLine(prefix + "\t\t" + ((IFixedColorController)ledController).Value.ToString());
}
}
else if(device is IFan && device is IControllableSensor)
{
IFan fan = (IFan)device;
IControllableSensor controllableFan = (IControllableSensor)device;
/*if (fan.GetParent().Name.Contains("Commander Mini"))
{
IFixedNumberController _fanController = (IFixedNumberController)ControllerRegistry.Get("CorsairLink.FanFixedPercentController").New();
_fanController.Value = 40;
controllableFan.Controller = _fanController;
}*/
IController fanController = controllableFan.Controller;
Console.Out.WriteLine(prefix + "- " + fan.Name + " = " + fan.Value + " " + fan.Unit.GetPostfix());
if (fanController != null)
Console.Out.WriteLine(prefix + "\t" + ((fanController == null) ? "N/A" : fanController.Name));
if(fanController is ICurveNumberController)
{
Console.Out.WriteLine(prefix + "\t\t" + ((ICurveNumberController)fanController).Value.ToString().Replace("}, {", "}\r\n" + prefix + "\t\t{"));
}
}
else
{
ISensor sensor = (ISensor)device;
Console.Out.WriteLine(prefix + "- " + sensor.Name + " = " + sensor.Value + " " + sensor.Unit.GetPostfix());
}
}
else
{
Console.Out.WriteLine(prefix + "+ " + device.Name);
foreach (BaseDevice subDevice in device.GetSubDevices())
{
PrintSensorsAndSubDevices(subDevice, prefix + "\t");
}
}
}