本文整理汇总了C#中Port.GetInfo方法的典型用法代码示例。如果您正苦于以下问题:C# Port.GetInfo方法的具体用法?C# Port.GetInfo怎么用?C# Port.GetInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Port
的用法示例。
在下文中一共展示了Port.GetInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnOperationInvoke
//.........这里部分代码省略.........
// int lockLevel = (int)args[1].Value();
// float fBrightness = ((float)((int)args[2].Value())) / 1000.0f;
// logger.Log("{0} Got {1} {2} {3}", this.ToString(), opName.ToLower(), bulbID.ToString(), lockLevel.ToString(), fBrightness.ToString());
// lightManager.SetLightBrightness(bulbID, fBrightness, lockLevel);
// List<VParamType> retVals = new List<VParamType>() { new ParamType(true) };
// return retVals;
// }
// case RoleHueBridge.OpBumpBulb:
// {
// int bulbID = (int)args[0].Value();
// logger.Log("{0} Got {1} {2}", this.ToString(), opName.ToLower(), bulbID.ToString());
// lightManager.BumpBulb(bulbID);
// List<VParamType> retVals = new List<VParamType>() { new ParamType(true) };
// return retVals;
// }
// default:
// logger.Log("Invalid operation: {0}", opName);
// return null;
// }
//}
/// <summary>
/// The demultiplexing routing for incoming operations
/// </summary>
/// <param name="message"></param>
public IList<VParamType> OnOperationInvoke(Port targetLightPort, string roleName, String opName, IList<VParamType> args)
{
logger.Log("{0} Got {1} {2}", this.ToString(), opName.ToLower(), targetLightPort.ToString());
//send back an error if we don't know of this port
if (!portToLightState.ContainsKey(targetLightPort))
{
logger.Log("Got request for unknown light!");
return new List<VParamType>() { new ParamType(ParamType.SimpleType.error, "unknown port " + targetLightPort.GetInfo().GetFriendlyName()) };
}
LightState lstate = portToLightState[targetLightPort];
switch (opName.ToLower())
{
case RoleSwitchMultiLevel.OpSetName:
{
double valToSetDbl = (double)args[0].Value();
if (valToSetDbl > 1) valToSetDbl = 1;
byte valToSet = (byte) (valToSetDbl * 255);
byte currVal = lstate.Brightness;
//if (currVal != valToSet)
//{
lightManager.SetLightBrightness(lstate, valToSet);
Notify(targetLightPort, RoleSwitchMultiLevel.Instance, RoleSwitchMultiLevel.OpGetName, new ParamType(valToSetDbl));
logger.Log("{0}: issued notification for light {1}, value {2}", ToString(), targetLightPort.ToString(), valToSetDbl.ToString());
//}
return new List<VParamType>();
}
case RoleSwitchMultiLevel.OpGetName:
{
byte value = lstate.Brightness;