コード例 #1
0
ファイル: ZWaveManager.cs プロジェクト: davidov541/SAMI
 private static void ControllerStateChangedHandler(ZWControllerState state, ZWaveManager facade)
 {
     if (facade.OnNotification != null)
     {
         facade.OnControllerStateChanged(facade, new ControllerStateChangedEventArgs(facade, state));
     }
 }
コード例 #2
0
        public static void MyControllerStateChangedHandler(ZWControllerState state)
        {
            // Handle the controller state notifications here.
            bool complete = false;
            switch (state)
            {
                case ZWControllerState.Waiting:
                    {
                        logging.AddToLog("Waiting...", true);
                        break;
                    }
                case ZWControllerState.InProgress:
                    {
                        // Tell the user that the controller has been found and the adding process is in progress.
                        logging.AddToLog("Please wait...", true);
                        break;
                    }
                case ZWControllerState.Completed:
                    {
                        // Tell the user that the controller has been successfully added.
                        // The command is now complete
                        logging.AddToLog("Command Completed OK.", true);
                        complete = true;
                        break;
                    }
                case ZWControllerState.Failed:
                    {
                        // Tell the user that the controller addition process has failed.
                        // The command is now complete
                        logging.AddToLog("Command Failed.", true);
                        complete = true;
                        break;
                    }
                case ZWControllerState.NodeOK:
                    {
                        logging.AddToLog("Node has not failed.", true);
                        complete = true;
                        break;
                    }
                case ZWControllerState.NodeFailed:
                    {
                        logging.AddToLog("Node has failed.", true);
                        complete = true;
                        break;
                    }
            }

            if (complete)
            {
                logging.AddToLog("Removing event handler", true);
                // Remove the event handler
                m_manager.OnControllerStateChanged -= m_controllerStateChangedHandler;
            }
        }
コード例 #3
0
        private void ControllerStateHandle(ZWControllerState state)
        {
            bool?operationFailed = null;

            switch (state)
            {
            case ZWControllerState.Cancel:
            case ZWControllerState.Error:
            case ZWControllerState.Failed:
            case ZWControllerState.NodeFailed:
                operationFailed = true;
                break;

            case ZWControllerState.Completed:
            case ZWControllerState.NodeOK:
                operationFailed = false;
                break;
            }

            if (operationFailed != null)
            {
                _callbacksPool.Dequeue(!operationFailed.Value,
                                       nameof(AddNewDevice),
                                       nameof(AddNewSecureDevice),
                                       nameof(RemoveDevice),
                                       nameof(RemoveController),
                                       nameof(AddController),
                                       nameof(UpdateNetwork),
                                       nameof(EraseAll),
                                       nameof(ResetController),
                                       nameof(RecieveConfiguration),
                                       nameof(CheckNodeFailed),
                                       nameof(HealControllerNetwork),
                                       nameof(RemoveFailedNode),
                                       nameof(ReplaceFailedNode),
                                       nameof(TransferPrimaryRole),
                                       nameof(CreateNewPrimary),
                                       nameof(UpdateNodeNeighborList));
            }
        }
コード例 #4
0
        public static void MyControllerStateChangedHandler( ZWControllerState state )
        {
            // Handle the controller state notifications here.
            bool complete = false;
            String dlgText = "";
            bool buttonEnabled = true;

            switch (state)
            {
                case ZWControllerState.Waiting:
                {
                    // Display a message to tell the user to press the include button on the controller
                    if (m_op == ZWControllerCommand.ReplaceFailedNode)
                    {
                        dlgText = "Press the program button on the replacement 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.\nThis command cannot be cancelled.";
                    }
                    break;
                }
                case ZWControllerState.InProgress:
                {
                    // Tell the user that the controller has been found and the adding process is in progress.
                    dlgText = "Please wait...";
                    buttonEnabled = false;
                    break;
                }
                case ZWControllerState.Completed:
                {
                    // Tell the user that the controller has been successfully added.
                    // The command is now complete
                    dlgText = "Command Completed OK.";
                    complete = true;
                    result = DialogResult.OK;
                    break;
                }
                case ZWControllerState.Failed:
                {
                    // Tell the user that the controller addition process has failed.
                    // The command is now complete
                    dlgText = "Command Failed.";
                    complete = true;
                    result = DialogResult.Abort;
                    break;
                }
                case ZWControllerState.NodeOK:
                {
                    dlgText = "Node has not failed.";
                    complete = true;
                    result = DialogResult.No;
                    break;
                }
                case ZWControllerState.NodeFailed:
                {
                    dlgText = "Node has failed.";
                    complete = true;
                    result = DialogResult.Yes;
                    break;
                }
            }

            if (dlgText != "")
            {
                m_dlg.SetDialogText(dlgText);
            }

            m_dlg.SetButtonEnabled(buttonEnabled);

            if (complete)
            {
                m_dlg.SetButtonText( "OK" );

                // Remove the event handler
                m_manager.OnControllerStateChanged -= m_controllerStateChangedHandler;
            }
        }
コード例 #5
0
        public static void MyControllerStateChangedHandler(ZWControllerState state)
        {
            // Handle the controller state notifications here.
            bool   complete      = false;
            String dlgText       = "";
            bool   buttonEnabled = true;

            switch (state)
            {
            case ZWControllerState.Waiting:
            {
                // Display a message to tell the user to press the include button on the controller
                if (_zwcontrollercommand == ZWControllerCommand.ReplaceFailedNode)
                {
                    dlgText = "Press the program button on the replacement 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.\nThis command cannot be cancelled.";
                }
                break;
            }

            case ZWControllerState.InProgress:
            {
                // Tell the user that the controller has been found and the adding process is in progress.
                //Logger.log.Info(_zwcontrollercommand.ToString() + " in progress...", "OPENZWAVE");
                dlgText       = "Please wait...";
                buttonEnabled = false;
                break;
            }

            case ZWControllerState.Completed:
            {
                // Tell the user that the controller has been successfully added.
                // The command is now complete
                //Logger.log.Info(_zwcontrollercommand.ToString() + " command complete.", "OPENZWAVE");
                dlgText  = "Command Completed OK.";
                complete = true;
                break;
            }

            case ZWControllerState.Failed:
            {
                // Tell the user that the controller addition process has failed.
                // The command is now complete
                //Logger.log.Info(_zwcontrollercommand.ToString() + " command failed.", "OPENZWAVE");
                dlgText  = "Command Failed.";
                complete = true;
                break;
            }

            case ZWControllerState.NodeOK:
            {
                //Logger.log.Info(_zwcontrollercommand.ToString() + " node has not failed.", "OPENZWAVE");
                dlgText  = "Node has not failed.";
                complete = true;
                break;
            }

            case ZWControllerState.NodeFailed:
            {
                // Logger.log.Info(_zwcontrollercommand.ToString() + " node has failed.", "OPENZWAVE");
                dlgText  = "Node has failed.";
                complete = true;
                break;
            }
            }

            if (dlgText != "")
            {
                _controllercommanddlg.SetDialogText(dlgText);
            }

            _controllercommanddlg.SetButtonEnabled(buttonEnabled);

            if (complete)
            {
                _controllercommanddlg.SetButtonText("OK");

                // Remove the event handler
                m_manager.OnControllerStateChanged -= m_controllerStateChangedHandler;
            }
        }
コード例 #6
0
        /// <summary>
        /// Handles controller state changes.
        /// </summary>
        /// <param name="state">The state.</param>
        private static void MyControllerStateChangedHandler(ZWControllerState state)
        {
            // Handle the controller state notifications here.
            bool   complete      = false;
            String dlgText       = "";
            bool   buttonEnabled = true;

            switch (state)
            {
            case ZWControllerState.Waiting:
            {
                // Display a message to tell the user to press the include button on the controller
                if (m_op == ZWControllerCommand.ReplaceFailedNode)
                {
                    dlgText =
                        "Press the program button on the replacement 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.\nThis command cannot be cancelled.";
                }
                break;
            }

            case ZWControllerState.InProgress:
            {
                // Tell the user that the controller has been found and the adding process is in progress.
                dlgText       = "Please wait...";
                buttonEnabled = false;
                break;
            }

            case ZWControllerState.Completed:
            {
                // Tell the user that the controller has been successfully added.
                // The command is now complete
                dlgText  = "Command Completed OK.";
                complete = true;
                result   = DialogResult.OK;
                break;
            }

            case ZWControllerState.Failed:
            {
                // Tell the user that the controller addition process has failed.
                // The command is now complete
                dlgText  = "Command Failed.";
                complete = true;
                result   = DialogResult.Abort;
                break;
            }

            case ZWControllerState.NodeOK:
            {
                dlgText  = "Node has not failed.";
                complete = true;
                result   = DialogResult.No;
                break;
            }

            case ZWControllerState.NodeFailed:
            {
                dlgText  = "Node has failed.";
                complete = true;
                result   = DialogResult.Yes;
                break;
            }

            case ZWControllerState.Cancel:
            {
                dlgText  = "Command was cancelled.";
                complete = true;
                result   = DialogResult.Cancel;
                break;
            }

            case ZWControllerState.Error:
            {
                dlgText  = "An error occurred while processing the controller command.";
                complete = true;
                result   = DialogResult.Cancel;
                break;
            }
            }

            if (dlgText != "")
            {
                m_dlg.SetDialogText(dlgText);
            }

            m_dlg.SetButtonEnabled(buttonEnabled);

            if (complete)
            {
                m_dlg.SetButtonText("OK");

                // Remove the event handler
                m_manager.NotificationReceived -= NotificationHandler;
            }
        }
コード例 #7
0
ファイル: ControllerCommandDlg.cs プロジェクト: noant/Pyrite
        public static void MyControllerStateChangedHandler(ZWControllerState state)
        {
            bool complete = false;
            String dlgText = "";
            bool buttonEnabled = true;

            switch (state)
            {
                case ZWControllerState.Waiting:
                    {
                        if (m_op == ZWControllerCommand.ReplaceFailedNode)
                        {
                            dlgText =
                                "Нажмите програмную кнопку на узле для замены.\nПо причинам безопасности, контроллер должен быть в радиусе 2-х метров от устройства.";
                        }
                        break;
                    }
                case ZWControllerState.InProgress:
                    {
                        dlgText = "Подождите...";
                        buttonEnabled = false;
                        break;
                    }
                case ZWControllerState.Completed:
                    {
                        dlgText = "Команда выполнена.";
                        complete = true;
                        result = DialogResult.OK;
                        break;
                    }
                case ZWControllerState.Failed:
                    {
                        dlgText = "Не удалось выполнить команду.";
                        complete = true;
                        result = DialogResult.Abort;
                        break;
                    }
                case ZWControllerState.NodeOK:
                    {
                        dlgText = "Узел исправен.";
                        complete = true;
                        result = DialogResult.No;
                        break;
                    }
                case ZWControllerState.NodeFailed:
                    {
                        dlgText = "Узел неисправен.";
                        complete = true;
                        result = DialogResult.Yes;
                        break;
                    }
                case ZWControllerState.Cancel:
                    {
                        dlgText = "Команда была отменена.";
                        complete = true;
                        result = DialogResult.Cancel;
                        break;
                    }
                case ZWControllerState.Error:
                    {
                        dlgText = "Ошибка во время выполнения команды контроллера.";
                        complete = true;
                        result = DialogResult.Cancel;
                        break;
                    }
            }

            if (dlgText != "")
            {
                m_dlg.SetDialogText(dlgText);
            }

            m_dlg.SetButtonEnabled(buttonEnabled);

            if (complete)
            {
                m_dlg.SetButtonText("OK");

                m_manager.OnNotification -= NotificationHandler;
            }
        }
コード例 #8
0
 public ControllerStateChangedEventArgs(IZWaveManager manager, ZWControllerState controllerState)
 {
     Manager         = manager;
     ControllerState = controllerState;
 }