本文整理汇总了C#中ZWaveNode.OnNodeUpdated方法的典型用法代码示例。如果您正苦于以下问题:C# ZWaveNode.OnNodeUpdated方法的具体用法?C# ZWaveNode.OnNodeUpdated怎么用?C# ZWaveNode.OnNodeUpdated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZWaveNode
的用法示例。
在下文中一共展示了ZWaveNode.OnNodeUpdated方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResendOnWakeUp
public static void ResendOnWakeUp(ZWaveNode node, byte[] msg)
{
int minCommandLength = 8;
if (msg.Length >= minCommandLength)
{
byte[] command = new byte[minCommandLength];
Array.Copy(msg, 0, command, 0, minCommandLength);
// discard any message having same header and command (first 8 bytes = header + command class + command)
var wakeUpResendQueue = GetResendQueueData(node);
for (int i = wakeUpResendQueue.Count - 1; i >= 0; i--)
{
byte[] queuedCommand = new byte[minCommandLength];
Array.Copy(wakeUpResendQueue[i], 0, queuedCommand, 0, minCommandLength);
if (queuedCommand.SequenceEqual(command))
{
Utility.logger.Trace("Removing old message {0}", BitConverter.ToString(wakeUpResendQueue[i]));
wakeUpResendQueue.RemoveAt(i);
}
}
Utility.logger.Trace("Adding message {0}", BitConverter.ToString(msg));
wakeUpResendQueue.Add(msg);
var wakeUpStatus = (WakeUpStatus)node.GetData("WakeUpStatus", new WakeUpStatus()).Value;
if (!wakeUpStatus.IsSleeping)
{
wakeUpStatus.IsSleeping = true;
var nodeEvent = new NodeEvent(node, EventParameter.WakeUpSleepingStatus, 1 /* 1 = sleeping, 0 = awake */, 0);
node.OnNodeUpdated(nodeEvent);
}
}
}
示例2: WakeUpNode
public static void WakeUpNode(ZWaveNode node)
{
// If node was marked as sleeping, reset the flag
var wakeUpStatus = node.GetData("WakeUpStatus");
if (wakeUpStatus != null && wakeUpStatus.Value != null && ((WakeUpStatus)wakeUpStatus.Value).IsSleeping)
{
((WakeUpStatus)wakeUpStatus.Value).IsSleeping = false;
var wakeEvent = new NodeEvent(node, EventParameter.WakeUpSleepingStatus, 0 /* 1 = sleeping, 0 = awake */, 0);
node.OnNodeUpdated(wakeEvent);
// Resend queued messages while node was asleep
var wakeUpResendQueue = GetResendQueueData(node);
for (int m = 0; m < wakeUpResendQueue.Count; m++)
{
Utility.logger.Trace("Sending message {0} {1}", m, BitConverter.ToString(wakeUpResendQueue[m]));
node.SendMessage(wakeUpResendQueue[m]);
}
wakeUpResendQueue.Clear();
}
}
示例3: SendToSleep
public static ZWaveMessage SendToSleep(ZWaveNode node)
{
ZWaveMessage msg = null;
var wakeUpStatus = (WakeUpStatus)node.GetData("WakeUpStatus", new WakeUpStatus()).Value;
if (!wakeUpStatus.IsSleeping)
{
// 0x01, 0x09, 0x00, 0x13, 0x2b, 0x02, 0x84, 0x08, 0x25, 0xee, 0x8b
msg = node.SendDataRequest(new byte[] {
(byte)CommandClass.WakeUp,
(byte)Command.WakeUpNoMoreInfo,
0x25
}).Wait();
wakeUpStatus.IsSleeping = true;
var nodeEvent = new NodeEvent(node, EventParameter.WakeUpSleepingStatus, 1 /* 1 = sleeping, 0 = awake */, 0);
node.OnNodeUpdated(nodeEvent);
}
return msg;
}
示例4: GetEvent
public NodeEvent GetEvent(ZWaveNode node, byte[] message)
{
NodeEvent nodeEvent = null;
byte cmdType = message[1];
switch (cmdType)
{
case (byte)Command.WakeUpIntervalReport:
if (message.Length > 4)
{
uint interval = ((uint)message[2]) << 16;
interval |= (((uint)message[3]) << 8);
interval |= (uint)message[4];
nodeEvent = new NodeEvent(node, EventParameter.WakeUpInterval, interval, 0);
}
break;
case (byte)Command.WakeUpNotification:
// If node was marked as sleeping, reset the flag
var wakeUpStatus = node.GetData("WakeUpStatus");
if (wakeUpStatus != null && wakeUpStatus.Value != null && ((WakeUpStatus)wakeUpStatus.Value).IsSleeping)
{
((WakeUpStatus)wakeUpStatus.Value).IsSleeping = false;
var wakeEvent = new NodeEvent(node, EventParameter.WakeUpSleepingStatus, 0 /* 1 = sleeping, 0 = awake */, 0);
node.OnNodeUpdated(wakeEvent);
}
// Resend queued messages while node was asleep
var wakeUpResendQueue = GetResendQueueData(node);
for (int m = 0; m < wakeUpResendQueue.Count; m++)
{
Utility.logger.Trace("Sending message {0} {1}", m, BitConverter.ToString(wakeUpResendQueue[m]));
node.SendMessage(wakeUpResendQueue[m]);
}
wakeUpResendQueue.Clear();
nodeEvent = new NodeEvent(node, EventParameter.WakeUpNotify, 1, 0);
break;
}
return nodeEvent;
}