本文整理汇总了C#中HomeOS.Hub.Platform.Views.VPort.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# VPort.Invoke方法的具体用法?C# VPort.Invoke怎么用?C# VPort.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HomeOS.Hub.Platform.Views.VPort
的用法示例。
在下文中一共展示了VPort.Invoke方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitSwitch
void InitSwitch(VPort switchPort, SwitchType switchType, bool isColored)
{
logger.Log("{0} adding switch {1} {2}", this.ToString(), switchType.ToString(), switchPort.ToString());
SwitchInfo switchInfo = new SwitchInfo();
switchInfo.Capability = GetCapability(switchPort, Constants.UserSystem);
switchInfo.Level = 0;
switchInfo.Type = switchType;
switchInfo.IsColored = isColored;
switchInfo.Color = Color.Black;
registeredSwitches.Add(switchPort, switchInfo);
string switchFriendlyName = switchPort.GetInfo().GetFriendlyName();
switchFriendlyNames.Add(switchFriendlyName, switchPort);
if (switchInfo.Capability != null)
{
IList<VParamType> retVals;
if (switchType == SwitchType.Multi)
{
retVals = switchPort.Invoke(RoleSwitchMultiLevel.RoleName, RoleSwitchMultiLevel.OpGetName, null,
ControlPort, switchInfo.Capability, ControlPortCapability);
switchPort.Subscribe(RoleSwitchMultiLevel.RoleName, RoleSwitchMultiLevel.OpGetName, ControlPort, switchInfo.Capability, ControlPortCapability);
if (retVals[0].Maintype() < 0)
{
logger.Log("SwitchController could not get current level for {0}", switchFriendlyName);
}
else
{
switchInfo.Level = (double)retVals[0].Value();
}
}
else
{
retVals = switchPort.Invoke(RoleSwitchBinary.RoleName, RoleSwitchBinary.OpGetName, null,
ControlPort, switchInfo.Capability, ControlPortCapability);
switchPort.Subscribe(RoleSwitchBinary.RoleName, RoleSwitchBinary.OpGetName, ControlPort, switchInfo.Capability, ControlPortCapability);
if (retVals[0].Maintype() < 0)
{
logger.Log("SwitchController could not get current level for {0}", switchFriendlyName);
}
else
{
bool boolLevel = (bool)retVals[0].Value();
switchInfo.Level = (boolLevel) ? 1 : 0;
}
}
//fix the color up now
if (isColored)
{
var retValsColor = switchPort.Invoke(RoleLightColor.RoleName, RoleLightColor.OpGetName, null,
ControlPort, switchInfo.Capability, ControlPortCapability);
switchPort.Subscribe(RoleLightColor.RoleName, RoleLightColor.OpGetName, ControlPort, switchInfo.Capability, ControlPortCapability);
if (retVals[0].Maintype() < 0)
{
logger.Log("SwitchController could not get color for {0}", switchFriendlyName);
}
else
{
byte red, green, blue;
red = Math.Min(Math.Max((byte)(int)retValsColor[0].Value(), (byte)0), (byte)255);
green = Math.Min(Math.Max((byte)(int)retValsColor[1].Value(), (byte)0), (byte)255);
blue = Math.Min(Math.Max((byte)(int)retValsColor[2].Value(), (byte)0), (byte)255);
switchInfo.Color = Color.FromArgb(red, green, blue);
}
}
}
}