/// <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(); }
public ControllerCommandDlg(ZWManager _manager, UInt32 homeId, ZWControllerCommand _op, Byte nodeId) { m_manager = _manager; _homeid = homeId; _zwcontrollercommand = _op; _nodeid = nodeId; _controllercommanddlg = this; InitializeComponent(); switch (_zwcontrollercommand) { case ZWControllerCommand.AddDevice: { Text = " - Add Device"; 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: { Text = " - Create New Primary Controller"; 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: { Text = " - Receive Configuration"; 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.RemoveDevice: { Text = " - Remove Device"; 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: { Text = " - Transfer Primary Role"; 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: { ButtonCancel.Enabled = false; Text = " - Has Node Failed"; label1.Text = "Testing whether the node has failed.\nThis command cannot be cancelled."; break; } case ZWControllerCommand.RemoveFailedNode: { ButtonCancel.Enabled = false; Text = " - Remove Failed Node"; label1.Text = "Removing the failed node from the controller's list.\nThis command cannot be cancelled."; break; } case ZWControllerCommand.ReplaceFailedNode: { ButtonCancel.Enabled = false; Text = " - Replacing Failed Node"; label1.Text = "Testing the failed node.\nThis command cannot be cancelled."; break; } } m_manager.OnControllerStateChanged += m_controllerStateChangedHandler; if (!m_manager.BeginControllerCommand(_homeid, _zwcontrollercommand, false, _nodeid)) { m_manager.OnControllerStateChanged -= m_controllerStateChangedHandler; } }
/// <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; } } }
private void Execute(ZWControllerCommand command, bool secure) { if (dataGrid.SelectedRows.Count > 0) _selectedNodeId = Convert.ToByte(dataGrid.SelectedRows[0].Cells["ID"].Value); ControllerCommandDlg dlg = new ControllerCommandDlg(_zwave.Manager, _zwave.HomeId.Value, command, _selectedNodeId, secure); DialogResult d = dlg.ShowDialog(this); dlg.Dispose(); RefreshData(); }
public ControllerCommandDlg(ZWManager _manager, uint _homeId, ZWControllerCommand _op, byte? nodeId, bool securityEnabled) { m_manager = _manager; homeId = _homeId; m_op = _op; m_nodeId = nodeId != null ? nodeId.Value : (byte)0; m_dlg = this; InitializeComponent(); m_manager.OnNotification += new ManagedNotificationsHandler(NotificationHandler); switch (m_op) { case ZWControllerCommand.RequestNodeNeighborUpdate: { this.Text = "Обновление списка соседних узлов"; this.label1.Text = "Узел обновляет список соседних узлов"; if (!m_manager.RequestNodeNeighborUpdate(homeId, m_nodeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.AddDevice: { this.Text = "Добавить устройство в ZWave сеть"; this.label1.Text = "Нажмите программную кнопку на Z-Wave устройстве для добавления его в сеть.\nДля безопасности, контроллер должен быть рядом с устройством ZWave (не более 2 метров)."; if (!m_manager.AddNode(homeId, securityEnabled)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.CreateNewPrimary: { this.Text = "Создать новый основной контроллер"; this.label1.Text = "Введите новый контроллер в режим передачи данных.\nТекущий контроллер должен быть рядом с целевым контроллером (не более 2 метров)."; if (!m_manager.CreateNewPrimary(homeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.ReceiveConfiguration: { this.Text = "Передача конфигурации"; this.label1.Text = "Передача сетевой конфигурации от другого устройства.\nПоместите другой контроллер в пределах 2 метров от текущего контроллера."; if (!m_manager.ReceiveConfiguration(homeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.RemoveDevice: { this.Text = "Удалит устройство из сети"; this.label1.Text = "Нажмите программную кнопку на устройстве ZWave для удаления его из сети.\nПо причинам безопасности, контроллер должен быть в радиусе 2-х метров от устройства."; if (!m_manager.RemoveNode(homeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.TransferPrimaryRole: { this.Text = "Передача роли основного контроллера другому контроллеру"; this.label1.Text = "Передача роли основного контроллера другому контроллеру.\n\nПо причинам безопасности, контроллер должен быть в радиусе 2-х метров от устройства."; if (!m_manager.TransferPrimaryRole(homeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.HasNodeFailed: { this.ButtonCancel.Enabled = false; this.Text = "Проверка узла на неисправность"; this.label1.Text = "Проверка узла.\nЭта команда не может быть отменена"; if (!m_manager.HasNodeFailed(homeId, m_nodeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.RemoveFailedNode: { this.ButtonCancel.Enabled = false; this.Text = "Удаление неисправного узла"; this.label1.Text = "Удаление неисправного узла.\nКоманда не может быть отменена."; if (!m_manager.RemoveFailedNode(homeId, m_nodeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.ReplaceFailedNode: { this.ButtonCancel.Enabled = false; this.Text = "Замена неисправного узла"; this.label1.Text = "Тестирование неисправного узла.\nКоманда не может быть отменена."; if (!m_manager.ReplaceFailedNode(homeId, m_nodeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } case ZWControllerCommand.RequestNetworkUpdate: { this.ButtonCancel.Enabled = false; this.Text = "Запрос обновления сети устройств"; this.label1.Text = "Запрос обновления сети устройств."; if (!m_manager.RequestNetworkUpdate(homeId, m_nodeId)) { MyControllerStateChangedHandler(ZWControllerState.Failed); } break; } default: { m_manager.OnNotification -= NotificationHandler; break; } } }
public bool BeginControllerCommand(uint homeId, ZWControllerCommand command, bool highPower, byte nodeId) { return(_manager.BeginControllerCommand(homeId, command, highPower, nodeId)); }
private void DoCommand(ZWControllerCommand command) { ControllerCommandDlg dlg = new ControllerCommandDlg(_zwave.Manager, _zwave.HomeId.Value, command, null, false); DialogResult d = dlg.ShowDialog(this); dlg.Dispose(); }