/// <summary> /// Does the command. /// </summary> /// <param name="command">The command.</param> private void DoCommand(ZWControllerCommand command) { ControllerCommandDlg dlg = new ControllerCommandDlg(this, m_manager, m_homeId, command, m_rightClickNode); DialogResult d = dlg.ShowDialog(this); dlg.Dispose(); }
public ControllerCommandDlg(MainForm _mainDlg, ZWManager _manager, UInt32 homeId, ZWControllerCommand _op, Byte nodeId) { m_mainDlg = _mainDlg; m_manager = _manager; m_homeId = homeId; m_op = _op; m_nodeId = nodeId; m_dlg = this; InitializeComponent(); switch (m_op) { case ZWControllerCommand.RequestNodeNeighborUpdate: { this.Text = "Node Neighbor Update"; this.label1.Text = "Request that a node update its list of neighbors."; break; } case ZWControllerCommand.AddController: { this.Text = "Add Controller"; this.label1.Text = "Put the target controller into receive configuration mode.\nThe PC Z-Wave Controller must be within 2m of the controller being added."; break; } case ZWControllerCommand.AddDevice: { this.Text = "Add Device"; this.label1.Text = "Press the program button on the Z-Wave device to add it to the network.\nFor security reasons, the PC Z-Wave Controller must be close to the device being added."; break; } case ZWControllerCommand.CreateNewPrimary: { this.Text = "Create New Primary Controller"; this.label1.Text = "Put the target controller into receive configuration mode.\nThe PC Z-Wave Controller must be within 2m of the controller that is being made the primary."; break; } case ZWControllerCommand.ReceiveConfiguration: { this.Text = "Receive Configuration"; this.label1.Text = "Transfering the network configuration\nfrom another controller.\n\nPlease bring the other controller within 2m of the PC controller and set it to send its network configuration."; break; } case ZWControllerCommand.RemoveController: { this.Text = "RemoveController"; this.label1.Text = "Put the target controller into receive configuration mode.\nThe PC Z-Wave Controller must be within 2m of the controller being added."; break; } case ZWControllerCommand.RemoveDevice: { this.Text = "Remove Device"; this.label1.Text = "Press the program button on the Z-Wave device to remove it from the network.\nFor security reasons, the PC Z-Wave Controller must be close to the device being removed."; break; } case ZWControllerCommand.TransferPrimaryRole: { this.Text = "Transfer Primary Role"; this.label1.Text = "Transfering the primary role\nto another controller.\n\nPlease bring the new controller within 2m of the PC controller and set it to receive the network configuration."; break; } case ZWControllerCommand.HasNodeFailed: { this.ButtonCancel.Enabled = false; this.Text = "Has Node Failed"; this.label1.Text = "Testing whether the node has failed.\nThis command cannot be cancelled."; break; } case ZWControllerCommand.RemoveFailedNode: { this.ButtonCancel.Enabled = false; this.Text = "Remove Failed Node"; this.label1.Text = "Removing the failed node from the controller's list.\nThis command cannot be cancelled."; break; } case ZWControllerCommand.ReplaceFailedNode: { this.ButtonCancel.Enabled = false; this.Text = "Replacing Failed Node"; this.label1.Text = "Testing the failed node.\nThis command cannot be cancelled."; break; } } m_manager.OnControllerStateChanged += m_controllerStateChangedHandler; if (!m_manager.BeginControllerCommand(m_homeId, m_op, false, m_nodeId)) { m_manager.OnControllerStateChanged -= m_controllerStateChangedHandler; } }
private void DoCommand(ZWControllerCommand command) { ControllerCommandDlg dlg = new ControllerCommandDlg(this, m_manager, m_homeId, command, m_rightClickNode); DialogResult d = dlg.ShowDialog(this); dlg.Dispose(); }
/// <summary> /// Initializes a new instance of the <see cref="ControllerCommandDlg"/> class. /// </summary> /// <param name="_mainDlg">The main form.</param> /// <param name="_manager">The manager.</param> /// <param name="homeId">The home identifier.</param> /// <param name="_op">The Controller Command.</param> /// <param name="nodeId">The node identifier.</param> public ControllerCommandDlg(MainForm _mainDlg, ZWManager _manager, UInt32 homeId, Func <bool> _op, Byte nodeId, ZWControllerCommand cmd) { m_mainDlg = _mainDlg; m_manager = _manager; m_homeId = homeId; m_op = cmd; m_nodeId = nodeId; m_dlg = this; InitializeComponent(); m_manager.NotificationReceived += new NotificationReceivedEventHandler(NotificationHandler); switch (m_op) { case ZWControllerCommand.RequestNodeNeighborUpdate: { this.Text = "Node Neighbor Update"; this.label1.Text = "Request that a node update its list of neighbors."; if (!m_manager.RequestNodeNeighborUpdate(m_homeId, m_nodeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.AddDevice: { this.Text = "Add Device"; this.label1.Text = "Press the program button on the Z-Wave device to add it to the network.\nFor security reasons, the PC Z-Wave Controller must be close to the device being added."; if (!m_manager.AddNode(m_homeId, m_mainDlg.SecurityEnabled)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.CreateNewPrimary: { this.Text = "Create New Primary Controller"; this.label1.Text = "Put the target controller into receive configuration mode.\nThe PC Z-Wave Controller must be within 2m of the controller that is being made the primary."; if (!m_manager.CreateNewPrimary(m_homeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.ReceiveConfiguration: { this.Text = "Receive Configuration"; this.label1.Text = "Transfering the network configuration\nfrom another controller.\n\nPlease bring the other controller within 2m of the PC controller and set it to send its network configuration."; if (!m_manager.ReceiveConfiguration(m_homeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.RemoveDevice: { this.Text = "Remove Device"; this.label1.Text = "Press the program button on the Z-Wave device to remove it from the network.\nFor security reasons, the PC Z-Wave Controller must be close to the device being removed."; if (!m_manager.RemoveNode(m_homeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.TransferPrimaryRole: { this.Text = "Transfer Primary Role"; this.label1.Text = "Transfering the primary role\nto another controller.\n\nPlease bring the new controller within 2m of the PC controller and set it to receive the network configuration."; if (!m_manager.TransferPrimaryRole(m_homeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.HasNodeFailed: { this.ButtonCancel.Enabled = false; this.Text = "Has Node Failed"; this.label1.Text = "Testing whether the node has failed.\nThis command cannot be cancelled."; if (!m_manager.HasNodeFailed(m_homeId, m_nodeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.RemoveFailedNode: { this.ButtonCancel.Enabled = false; this.Text = "Remove Failed Node"; this.label1.Text = "Removing the failed node from the controller's list.\nThis command cannot be cancelled."; if (!m_manager.RemoveFailedNode(m_homeId, m_nodeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.ReplaceFailedNode: { this.ButtonCancel.Enabled = false; this.Text = "Replacing Failed Node"; this.label1.Text = "Testing the failed node.\nThis command cannot be cancelled."; if (!m_manager.ReplaceFailedNode(m_homeId, m_nodeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.RefreshNodeInfo: { this.ButtonCancel.Enabled = false; this.Text = "Refreshing Node Info"; this.label1.Text = "Refreshing the node info\nThis command cannot be cancelled."; if (!m_manager.RefreshNodeInfo(m_homeId, m_nodeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.RequestNetworkUpdate: { this.ButtonCancel.Enabled = false; this.Text = "Requesting Network Update"; this.label1.Text = "Requesting the Network Update."; if (!m_manager.RequestNetworkUpdate(m_homeId, m_nodeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } default: { m_manager.NotificationReceived -= NotificationHandler; break; } } }
public ControllerCommandDlg(MainForm _mainDlg, ZWManager _manager, UInt32 homeId, ZWControllerCommand _op, Byte nodeId) { m_mainDlg = _mainDlg; m_manager = _manager; m_homeId = homeId; m_op = _op; m_nodeId = nodeId; m_dlg = this; InitializeComponent(); switch (m_op) { case ZWControllerCommand.AddController: { this.Text = "Add Controller"; this.label1.Text = "Put the target controller into receive configuration mode.\nThe PC Z-Wave Controller must be within 2m of the controller being added."; break; } case ZWControllerCommand.AddDevice: { this.Text = "Add Device"; this.label1.Text = "Press the program button on the Z-Wave device to add it to the network.\nFor security reasons, the PC Z-Wave Controller must be close to the device being added."; break; } case ZWControllerCommand.CreateNewPrimary: { this.Text = "Create New Primary Controller"; this.label1.Text = "Put the target controller into receive configuration mode.\nThe PC Z-Wave Controller must be within 2m of the controller that is being made the primary."; break; } case ZWControllerCommand.ReceiveConfiguration: { this.Text = "Receive Configuration"; this.label1.Text = "Transfering the network configuration\nfrom another controller.\n\nPlease bring the other controller within 2m of the PC controller and set it to send its network configuration."; break; } case ZWControllerCommand.RemoveController: { this.Text = "RemoveController"; this.label1.Text = "Put the target controller into receive configuration mode.\nThe PC Z-Wave Controller must be within 2m of the controller being added."; break; } case ZWControllerCommand.RemoveDevice: { this.Text = "Remove Device"; this.label1.Text = "Press the program button on the Z-Wave device to remove it from the network.\nFor security reasons, the PC Z-Wave Controller must be close to the device being removed."; break; } case ZWControllerCommand.TransferPrimaryRole: { this.Text = "Transfer Primary Role"; this.label1.Text = "Transfering the primary role\nto another controller.\n\nPlease bring the new controller within 2m of the PC controller and set it to receive the network configuration."; break; } case ZWControllerCommand.HasNodeFailed: { this.ButtonCancel.Enabled = false; this.Text = "Has Node Failed"; this.label1.Text = "Testing whether the node has failed.\nThis command cannot be cancelled."; break; } case ZWControllerCommand.RemoveFailedNode: { this.ButtonCancel.Enabled = false; this.Text = "Remove Failed Node"; this.label1.Text = "Removing the failed node from the controller's list.\nThis command cannot be cancelled."; break; } case ZWControllerCommand.ReplaceFailedNode: { this.ButtonCancel.Enabled = false; this.Text = "Replacing Failed Node"; this.label1.Text = "Testing the failed node.\nThis command cannot be cancelled."; break; } } m_manager.OnControllerStateChanged += m_controllerStateChangedHandler; if (!m_manager.BeginControllerCommand(m_homeId, m_op, false, m_nodeId)) { m_manager.OnControllerStateChanged -= m_controllerStateChangedHandler; } }