//Untested public void SetDeviceName(string newName) { name = newName; byte[] namePart = GetNamePart(newName, 1); if (namePart == null) { return; } CANInterface.SendMessage(this, Commands.CmdSysPName1, namePart); namePart = GetNamePart(newName, 2); if (namePart == null) { return; } CANInterface.SendMessage(this, Commands.CmdSysPName2, namePart); namePart = GetNamePart(newName, 3); if (namePart == null) { return; } CANInterface.SendMessage(this, Commands.CmdSysPName3, namePart); }
/// <summary> /// Polls the network with the given command, then fires the PollRecieved event with the results. /// </summary> /// <param name="sendCommand">The command to send.</param> /// <param name="nodes">The Nodes to poll. Leave null for all.</param> /// <param name="devices">The Devices to poll on each Node. Leave null for all, set to 0 to poll only Nodes.</param> public NewPing(Commands sendCommand, Dictionary <byte, List <byte> > nodeDevices) { expectedResult = responseCommands[sendCommand]; //If given an empty list, ping just the nodes //Probably better to just throw an exception, actually if (nodeDevices.Count == 0) { for (byte i = 1; i < 127; i++) { nodeDevices.Add(i, new List <byte>()); } } foreach (byte node in nodeDevices.Keys) { lastMessage = CANInterface.SendMessage(node, 0, sendCommand); foreach (byte device in nodeDevices[node]) { lastMessage = CANInterface.SendMessage(node, device, sendCommand); } } CANInterface.MessageSent += CANInterface_MessageSent; CANInterface.MessageReceived += CANInterface_MessageReceived; waitForResponse.Interval = 100; waitForResponse.Tick += WaitForResponse_Tick; }
/// <summary> /// Sets the brightness of the light as a percent. /// </summary> /// <param name="brightness">The brightness, as a value from 0-100.</param> private void SetBrightness(byte brightness) { if (brightness > 100) { throw new Exception("Cannot set light brightness higher than 100%."); } CANInterface.SendMessage(this, Commands.CmdConValue, new byte[] { brightness }); }
/// <summary> /// Sends the given command to the given device, then fires the PollRecieved event with the result. /// </summary> /// <param name="sendCommand">The command to send.</param> /// <param name="nodeId">The Node to poll.</param> /// <param name="deviceId">The Device to poll on that Node.</param> public CANPing(Commands sendCommand, byte nodeId, byte deviceId) { expectedResult = responseCommands[sendCommand]; lastMessage = CANInterface.SendMessage(nodeId, deviceId, sendCommand); CANInterface.MessageSent += CANInterface_MessageSent; CANInterface.MessageReceived += CANInterface_MessageReceived; waitForResponse.Interval = 100; waitForResponse.Tick += WaitForResponse_Tick; }
/// <summary> /// Set brightness value over time. /// </summary> /// <param name="brightness">The brightness, as a value from 0-100.</param> /// <param name="time">The time in seconds to reach the brightness value, as a value between 0 - 65535.</param> public void SetFade(byte brightness, int time) { if (time < 0 || time > 65535) { throw new Exception("Time value for SetFade must be a value between 0 - 65535."); } byte time1 = BitConverter.GetBytes(time)[1]; byte time2 = BitConverter.GetBytes(time)[0]; CANInterface.SendMessage(this, Commands.CmdConSetFade, new byte[] { brightness, time1, time2 }); }
/// <summary> /// Polls the network with the given command, then fires the PollRecieved event with the results. /// </summary> /// <param name="sendCommand">The command to send.</param> /// <param name="nodes">The Nodes to poll.</param> /// <param name="devices">The Devices to poll on each Node.</param> public CANPing(Commands sendCommand, Dictionary <byte, List <byte> > nodeDevices) { if (nodeDevices.Count == 0) { throw new Exception("Cannot ping 0 nodes."); } expectedResult = responseCommands[sendCommand]; foreach (byte node in nodeDevices.Keys) { lastMessage = CANInterface.SendMessage(node, 0, sendCommand); foreach (byte device in nodeDevices[node]) { lastMessage = CANInterface.SendMessage(node, device, sendCommand); } } CANInterface.MessageSent += CANInterface_MessageSent; CANInterface.MessageReceived += CANInterface_MessageReceived; waitForResponse.Interval = 100; waitForResponse.Tick += WaitForResponse_Tick; }
/// <summary> /// Sets the last “On” value to the current value. Used when a switch is /// dimming the output and is then released. /// </summary> public void Release() { CANInterface.SendMessage(this, Commands.CmdConRelease); }
public void FullOn() { CANInterface.SendMessage(this, Commands.CmdConDClk); }
/// <summary> /// Sets whether the light is on (at a preset brightness), or off. /// </summary> /// <param name="on">if set to <c>true</c>, the light is [on].</param> public void SetOnOff(bool on) { CANInterface.SendMessage(this, on ? Commands.CmdConOn : Commands.CmdConOff); }
/// <summary> /// Toggles the light on and off. /// </summary> public void ToggleOnOff() { CANInterface.SendMessage(this, Commands.CmdConOnOff); }
public void OnDeserializingMethod() { CANInterface.MessageReceived += CANInterface_MessageReceived; CANInterface.SendMessage(this, Commands.CmdSysEStateZZ); }
/// <summary> /// Fade one step up or down and reverse direction when 0 or 100% is reached. /// </summary> public void FadeContinuous() { CANInterface.SendMessage(this, Commands.CmdConFadeCont); }
/// <summary> /// Fade down one step and stop when 0% is reached. /// </summary> public void FadeDown() { CANInterface.SendMessage(this, Commands.CmdConFadeDwn); }
/// <summary> /// Fade up one step and stop when 100% is reached. /// </summary> public void FadeUp() { CANInterface.SendMessage(this, Commands.CmdConFadeUp); }