Пример #1
0
 def set_cpri(self, cmd):
     #   Execute and send Info to Sim-Console
     self.parentWidget.deviceTranSignal.emit(cmd)
     res = TelRepository.telnet_instance.execute_command(cmd)
     res_display = RespFilter.trim(res)
     self.parentWidget.deviceRvdSignal.emit(res_display)
     # Emit Signal to Device Setting Tab as Response
     self.sigSetOK.emit(self.case, res)
Пример #2
0
 def get_frequency(self, cmd):
     #   Execute and send Info to Sim-Console
     self.parentWidget.deviceTranSignal.emit(cmd)
     res = TelRepository.telnet_instance.execute_command(cmd)
     res_display = RespFilter.trim(res)
     self.parentWidget.deviceRvdSignal.emit(res_display)
     #   Emit Signal to Trigger Value Refresh in Device Setting Tab
     self.sigGetRes.emit(self.case, res)
Пример #3
0
    def set_cpri(self, cmd):
        #   Execute and send Info to Sim-Console
        self.signals.consoleDisplay.emit(WorkerSignals.TRAN_SIGNAL, self.cmd)

        self.result = TelRepository.telnet_instance.execute_command(cmd)

        res_display = RespFilter.trim(self.result)
        self.signals.consoleDisplay.emit(WorkerSignals.RECV_SIGNAL, res_display)
Пример #4
0
 def get_ip_addr(self, cmd):
     """Used by LoginWidget to Get Ip Address of RRU Device
     """
     #   Execute and send Info to Sim-Console
     self.parentWidget.ipTranSignal.emit(cmd)
     res = TelRepository.telnet_instance.execute_command(cmd)
     res_display = RespFilter.trim(res)
     self.parentWidget.ipRecvSignal.emit(res_display)
     self.sigGetRes.emit(self.case, res)
Пример #5
0
class OffsetTab(QtWidgets.QWidget):
    deviceTranSignal = pyqtSignal(str)
    deviceRvdSignal = pyqtSignal(str)

    warningSignal = pyqtSignal(str)

    connectionOutSignal = pyqtSignal()

    def __init__(self, parent):
        super(OffsetTab, self).__init__()
        self.parentWidget = parent

        self._setup_ui()
        self._add_signal()

        self._init_bean()

    def _setup_ui(self):
        """OFFSET SETTING PANE"""
        offsetGroup = QtWidgets.QGroupBox("Frame Offset")

        self.getDlFrameOffsetLabel = QtWidgets.QLabel("Dl Frame Offset")
        self.dlOffsetValueLabel = ValueLabel("00000000", RRUCmd.GET_DL_OFFSET)
        self.dlOffsetValueLabel.refreshSig.connect(self.quick_refresh)
        self.dlOffsetValueLabel.setStyleSheet(NonQSSStyle.displayValueStyle)
        self.setDlFrameOffsetLabel = QtWidgets.QLabel("Set as")
        self.dlOffsetEdit = QtWidgets.QLineEdit()
        self.dlOffsetEdit.setStyleSheet(valueEditStyle)
        self.getUlFrameOffsetLabel = QtWidgets.QLabel("Ul Frame Offset")
        self.ulOffsetValueLabel = ValueLabel("00000000", RRUCmd.GET_UL_OFFSET)
        self.ulOffsetValueLabel.refreshSig.connect(self.quick_refresh)
        self.ulOffsetValueLabel.setStyleSheet(NonQSSStyle.displayValueStyle)
        self.setUlFrameOffsetLabel = QtWidgets.QLabel("Set as")
        self.ulOffsetEdit = QtWidgets.QLineEdit()
        self.ulOffsetEdit.setStyleSheet(valueEditStyle)

        self.getAxisOffsetLabel = QtWidgets.QLabel("Link Delay")
        self.axisOffsetValueLabel = ValueLabel("00000000", RRUCmd.GET_AXI_OFFSET)
        self.axisOffsetValueLabel.refreshSig.connect(self.quick_refresh)
        self.axisOffsetValueLabel.setStyleSheet(NonQSSStyle.displayValueStyle)
        self.axisOffsetEdit = QtWidgets.QLineEdit()
        self.axisOffsetEdit.setStyleSheet(valueEditStyle)

        frameOffsetLayout = QtWidgets.QGridLayout()
        frameOffsetLayout.addWidget(self.getDlFrameOffsetLabel, 0, 0)
        frameOffsetLayout.addWidget(self.dlOffsetValueLabel, 0, 1)
        frameOffsetLayout.addWidget(self.setDlFrameOffsetLabel, 0, 2)
        frameOffsetLayout.addWidget(self.dlOffsetEdit, 0, 3, 1, 3)
        frameOffsetLayout.addWidget(self.getUlFrameOffsetLabel, 1, 0)
        frameOffsetLayout.addWidget(self.ulOffsetValueLabel, 1, 1)
        frameOffsetLayout.addWidget(self.setUlFrameOffsetLabel, 1, 2)
        frameOffsetLayout.addWidget(self.ulOffsetEdit, 1, 3, 1, 3)
        frameOffsetLayout.addWidget(self.getAxisOffsetLabel, 2, 0)
        frameOffsetLayout.addWidget(self.axisOffsetValueLabel, 2, 1, 1, 2)
        frameOffsetLayout.addWidget(self.axisOffsetEdit, 2, 3, 1, 3)
        frameOffsetLayout.setSpacing(pubSpacing)

        vLineFrame = QtWidgets.QFrame()
        vLineFrame.setFrameStyle(QtWidgets.QFrame.VLine | QtWidgets.QFrame.Sunken)

        self.setUlOffsetButton = QtWidgets.QPushButton("Send")
        self.setUlOffsetButton.setStyleSheet(setButtonStyle)
        self.setUlOffsetButton.setMaximumWidth(buttonWidth)

        offsetLayout = QtWidgets.QGridLayout()
        offsetLayout.addLayout(frameOffsetLayout, 0, 0)
        offsetLayout.addWidget(vLineFrame, 0, 1)
        offsetLayout.addWidget(self.setUlOffsetButton, 0, 2)
        offsetGroup.setLayout(offsetLayout)
        """END OF OFFSET SETTING PANE"""

        """CPRI SETTING PANE"""
        cpriGroup = QtWidgets.QGroupBox("CPRI OFFSET")

        self.getCPRIStatusLabel = QtWidgets.QLabel("CPRI Status")
        self.cpriValueLabel = ValueLabel("---- ----", RRUCmd.GET_CPRI_STATUS)
        self.cpriValueLabel.refreshSig.connect(self.quick_refresh)
        self.cpriValueLabel.setStyleSheet(NonQSSStyle.displayValueStyle)
        self.getCPRIButton = QtWidgets.QPushButton("Refresh Status")
        self.getCPRIButton.setStyleSheet(valueEditStyle)
        self.configCPRIButton = QtWidgets.QPushButton("Set CPRI")
        self.configCPRIButton.setStyleSheet(valueEditStyle)

        self.getCPRILoopModeLabel = QtWidgets.QLabel("CPRI Loop Mode")
        self.cpriLoopModeLabel = ValueLabel("00000000", RRUCmd.GET_CPRI_LOOP_MODE)
        self.cpriLoopModeLabel.refreshSig.connect(self.quick_refresh)
        self.cpriLoopModeLabel.setStyleSheet(NonQSSStyle.displayValueStyle)
        self.setCPRILoopModeLabel = QtWidgets.QLabel("Set as")
        self.cpriLoopModeEdit = QtWidgets.QLineEdit()
        self.cpriLoopModeEdit.setStyleSheet(valueEditStyle)

        cpriLayout = QtWidgets.QGridLayout()
        cpriLayout.addWidget(self.getCPRIStatusLabel, 0, 0)
        cpriLayout.addWidget(self.cpriValueLabel, 0, 1, 1, 2)
        cpriLayout.addWidget(self.getCPRIButton, 0, 3)
        cpriLayout.addWidget(self.configCPRIButton, 0, 4)
        cpriLayout.addWidget(self.getCPRILoopModeLabel, 1, 0)
        cpriLayout.addWidget(self.cpriLoopModeLabel, 1, 1)
        cpriLayout.addWidget(self.setCPRILoopModeLabel, 1, 2)
        cpriLayout.addWidget(self.cpriLoopModeEdit, 1, 3, 1, 2)
        cpriLayout.setSpacing(pubSpacing)

        vLineFrame_2 = QtWidgets.QFrame()
        vLineFrame_2.setFrameStyle(QtWidgets.QFrame.VLine | QtWidgets.QFrame.Sunken)

        self.setCPRIButton = QtWidgets.QPushButton("Send")
        self.setCPRIButton.setStyleSheet(setButtonStyle)
        self.setCPRIButton.setMaximumWidth(buttonWidth)

        cpriSettingLayout = QtWidgets.QGridLayout()
        cpriSettingLayout.addLayout(cpriLayout, 0, 0)
        cpriSettingLayout.addWidget(vLineFrame_2, 0, 1)
        cpriSettingLayout.addWidget(self.setCPRIButton, 0, 2)
        cpriGroup.setLayout(cpriSettingLayout)
        """END OF DEVICE SETTING PANE"""

        mainLayout = QtWidgets.QVBoxLayout()
        mainLayout.addWidget(offsetGroup)
        mainLayout.addWidget(cpriGroup)
        mainLayout.addSpacing(mainSpacing)
        self.setLayout(mainLayout)

    def _add_signal(self):
        self.setUlOffsetButton.clicked.connect(self._send)
        self.getCPRIButton.clicked.connect(self._get_cpri_status)
        self.configCPRIButton.clicked.connect(self._set_cpri_status)
        self.setCPRIButton.clicked.connect(self._set_cpri_loop_mode)

        self.axisOffsetEdit.textChanged.connect(self._axi_offset_edit_back2normal)
        self.axisOffsetEdit.returnPressed.connect(self._set_axis_offset)
        self.ulOffsetEdit.textChanged.connect(self._ul_offset_edit_back2normal)
        self.dlOffsetEdit.textChanged.connect(self._dl_offset_edit_back2normal)
        self.cpriLoopModeEdit.textChanged.connect(self._cpri_loop_mode_edit_back2normal)
        self.cpriLoopModeEdit.returnPressed.connect(self._set_cpri_loop_mode)

    def _init_bean(self):
        self.antenna_bean_arr = []
        for i in range(max(RRUCmd.ant_num)):
            self.antenna_bean_arr.append(Antenna())
        self.antenna_index = 0

    def warning(self, info):
        self.warningSignal.emit(info)

    @staticmethod
    def info(info):
        msgBox = QtWidgets.QMessageBox()

        msgBox.setWindowTitle('Info')
        msgBox.setIcon(QtWidgets.QMessageBox.Information)
        msgBox.setText(info)

        msgBox.exec()

    def refresh_ant_num(self):
        if TelRepository.telnet_instance.isTelnetLogined:
            self.display()

    def display(self):
        """Refresh display of antenna-differed values
        """
        # Ul Frame Offset
        self.ulOffsetValueLabel.setText(self.antenna_bean_arr[self.antenna_index].ulFrameOffset)
        if self.antenna_bean_arr[self.antenna_index].ulFrameOffsetOutDated:
            self.ulOffsetValueLabel.setStyleSheet(NonQSSStyle.displayValueTempStyle)
        else:
            self.ulOffsetValueLabel.setStyleSheet(NonQSSStyle.displayValueStyle)
        self.ulOffsetEdit.setText(Antenna.not_none(self.antenna_bean_arr[self.antenna_index].ulFrameOffset))
        # Dl Frame Offset
        self.dlOffsetValueLabel.setText(self.antenna_bean_arr[self.antenna_index].dlFrameOffset)
        if self.antenna_bean_arr[self.antenna_index].dlFrameOffsetOutDated:
            self.dlOffsetValueLabel.setStyleSheet(NonQSSStyle.displayValueTempStyle)
        else:
            self.dlOffsetValueLabel.setStyleSheet(NonQSSStyle.displayValueStyle)
        self.dlOffsetEdit.setText(Antenna.not_none(self.antenna_bean_arr[self.antenna_index].dlFrameOffset))

    def slot_connection_out_signal(self):
        self.connectionOutSignal.emit()
            
    def _send(self):
        self._set_axis_offset()

        # TODO Valid Check not added yet
        ulOffset2set = self.ulOffsetEdit.text().strip()
        if len(ulOffset2set) != 0:
            self.ulOffsetValueLabel.setStyleSheet(NonQSSStyle.displayValueTempStyle)
            if ulOffset2set != self.ulOffsetValueLabel.text():
                cmd = RRUCmd.set_ul_frame_offset(self.parentWidget.get_option(), 
                                                 self.parentWidget.get_ant_num(), ulOffset2set)
                self.antenna_bean_arr[self.antenna_index].ulFrameOffsetOutDated = True

                thread_ul_offset_Set = WorkThread(self, RRUCmd.SET_UL_OFFSET, cmd)
                thread_ul_offset_Set.sigConnectionOut.connect(self.slot_connection_out_signal)
                thread_ul_offset_Set.sigSetOK.connect(self.set_resp_handler)
                thread_ul_offset_Set.start()
                thread_ul_offset_Set.exec()
        else:
            self.ulOffsetEdit.setStyleSheet(NonQSSStyle.warningStyle)

        # TODO Valid Check not added yet
        dlOffset2set = self.udlOffsetEdit.text().strip()
        if len(dlOffset2set) != 0:
            self.ulOffsetValueLabel.setStyleSheet(NonQSSStyle.displayValueTempStyle)
            if dlOffset2set != self.dlOffsetValueLabel.text():
                cmd = RRUCmd.set_dl_frame_offset(self.parentWidget.get_option(), 
                                                 self.parentWidget.get_ant_num(), dlOffset2set)
                self.antenna_bean_arr[self.antenna_index].dlFrameOffsetOutDated = True

                thread_dl_offset_Set = WorkThread(self, RRUCmd.SET_DL_OFFSET, cmd)
                thread_dl_offset_Set.sigConnectionOut.connect(self.slot_connection_out_signal)
                thread_dl_offset_Set.sigSetOK.connect(self.set_resp_handler)
                thread_dl_offset_Set.start()
                thread_dl_offset_Set.exec()
        else:
            self.dlOffsetEdit.setStyleSheet(NonQSSStyle.warningStyle)

    def _set_axis_offset(self):
        axiOffset2set = self.axisOffsetEdit.text().strip()
        if axiOffset2set != self.axisOffsetValueLabel.text():
            match = ValidCheck.filter(ValidCheck.HEX_RE, axiOffset2set)
            if match is not None:
                self.axisOffsetValueLabel.setStyleSheet(NonQSSStyle.displayValueTempStyle)
                cmd = RRUCmd.config_axis_offset(self.parentWidget.get_option(), str(match.group()))

                thread_axi_offset_set = WorkThread(self, RRUCmd.SET_AXI_OFFSET, cmd)
                thread_axi_offset_set.sigConnectionOut.connect(self.slot_connection_out_signal)
                thread_axi_offset_set.sigSetOK.connect(self.set_resp_handler)
                thread_axi_offset_set.start()
                thread_axi_offset_set.exec()
            else:
                self.axisOffsetEdit.setStyleSheet(NonQSSStyle.warningStyle)
        
    def _set_cpri_status(self):
        cmd = RRUCmd.get_cpri(self.parentWidget.get_option())

        thread_cpri_set = WorkThread(self, RRUCmd.SET_CPRI, cmd)
        thread_cpri_set.sigConnectionOut.connect(self.slot_connection_out_signal)
        thread_cpri_set.sigGetRes.connect(self.set_resp_handler)
        thread_cpri_set.start()
        thread_cpri_set.exec()
        
    def _set_cpri_loop_mode(self):
        # TODO Valid Check not added yet
        loopMode2set = self.cpriLoopModeEdit.text().strip()
        if loopMode2set != self.cpriValueLabel.text():
            if len(loopMode2set) != 0:
                self.cpriValueLabel.setStyleSheet(NonQSSStyle.displayValueTempStyle)
                cmd = RRUCmd.config_cpri_loop_mode(self.parentWidget.get_option(), loopMode2set)

                thread_cpri_loop_mode_set = WorkThread(self, RRUCmd.SET_CPRI_LOOP_MODE, cmd)
                thread_cpri_loop_mode_set.sigConnectionOut.connect(self.slot_connection_out_signal)
                thread_cpri_loop_mode_set.sigSetOK.connect(self.set_resp_handler)
                thread_cpri_loop_mode_set.start()
                thread_cpri_loop_mode_set.exec()
            else:
                self.cpriLoopModeEdit.setStyleSheet(NonQSSStyle.warningStyle)

    def _get_cpri_status(self):
        cmd = RRUCmd.get_cpri(self.parentWidget.get_option())

        thread_cpri_get = WorkThread(self, RRUCmd.GET_CPRI_STATUS, cmd)
        thread_cpri_get.sigConnectionOut.connect(self.slot_connection_out_signal)
        thread_cpri_get.sigGetRes.connect(self.get_resp_handler)
        thread_cpri_get.start()
        thread_cpri_get.exec()

    def _get_axi_offset(self):
        cmd = RRUCmd.get_axis_offset(self.parentWidget.get_option())

        thread_axi_offset_get = WorkThread(self, RRUCmd.GET_AXI_OFFSET, cmd)
        thread_axi_offset_get.sigConnectionOut.connect(self.slot_connection_out_signal)
        thread_axi_offset_get.sigGetRes.connect(self.get_resp_handler)
        thread_axi_offset_get.start()
        thread_axi_offset_get.exec()

    def _get_ul_frame_offset(self):
        cmd = RRUCmd.get_ul_frame_offset(self.parentWidget.get_option(), self.parentWidget.get_ant_num())

        thread_ul_frame_offset_get = WorkThread(self, RRUCmd.GET_UL_OFFSET, cmd)
        thread_ul_frame_offset_get.sigConnectionOut.connect(self.slot_connection_out_signal)
        thread_ul_frame_offset_get.sigGetRes.connect(self.get_resp_handler)
        thread_ul_frame_offset_get.start()
        thread_ul_frame_offset_get.exec()

    def _get_dl_frame_offset(self):
        cmd = RRUCmd.get_dl_frame_offset(self.parentWidget.get_option(), self.parentWidget.get_ant_num())

        thread_dl_frame_offset_get = WorkThread(self, RRUCmd.GET_DL_OFFSET, cmd)
        thread_dl_frame_offset_get.sigConnectionOut.connect(self.slot_connection_out_signal)
        thread_dl_frame_offset_get.sigGetRes.connect(self.get_resp_handler)
        thread_dl_frame_offset_get.start()
        thread_dl_frame_offset_get.exec()

    def _get_cpri_loop_mode(self):
        cmd = RRUCmd.get_cpri_loop_mode(self.parentWidget.get_option())

        thread_cpri_loop_mode_get = WorkThread(self, RRUCmd.GET_CPRI_LOOP_MODE, cmd)
        thread_cpri_loop_mode_get.sigConnectionOut.connect(self.slot_connection_out_signal)
        thread_cpri_loop_mode_get.sigGetRes.connect(self.get_resp_handler)
        thread_cpri_loop_mode_get.start()
        thread_cpri_loop_mode_get.exec()

    def get_resp_handler(self, case, res: str):
        """Work Thread Get the Value and Send to refresh_resp_handler for displaying
                update data mainly by rewriting antenna_bean and refresh display
                change dimension in the mean time
        """
        if case == RRUCmd.GET_CPRI_STATUS:
            value = RespFilter.word_value_filter(res, RespFilter.CPRI_STATUS_ASSERTION)
            if value is not None:
                self.cpriValueLabel.setText(str(value.group()))
                self.cpriValueLabel.setStyleSheet(NonQSSStyle.displayValueStyle)
            else:
                self.cpriValueLabel.setStyleSheet(NonQSSStyle.displayValueTempStyle)
                self.warning("CPRI Status cannot be refreshed properly")
Пример #6
0
    def get_resp_handler(self, case, res: str):
        """Work Thread Get the Value and Send to refresh_resp_handler for displaying
                update data mainly by rewriting antenna_bean and refresh display
                change dimension in the mean time
        """
        if case == RRUCmd.GET_CPRI_STATUS:
            value = RespFilter.word_value_filter(res, RespFilter.CPRI_STATUS_ASSERTION)
            if value is not None:
                self.cpriValueLabel.setText(str(value.group()))
                self.cpriValueLabel.setStyleSheet(NonQSSStyle.displayValueStyle)
            else:
                self.cpriValueLabel.setStyleSheet(NonQSSStyle.displayValueTempStyle)
                self.warning("CPRI Status cannot be refreshed properly")
        elif case == RRUCmd.GET_AXI_OFFSET:
            value = RespFilter.hex_value_filter(res, RespFilter.AXI_OFFSET_ASSERTION)
            if value is not None:
                self.axisOffsetValueLabel.setText(str(value.group()))
                self.axisOffsetValueLabel.setStyleSheet(NonQSSStyle.displayValueStyle)
                self.axisOffsetEdit.setText(str(value.group()))
            else:
                self.axisOffsetValueLabel.setStyleSheet(NonQSSStyle.displayValueTempStyle)
                self.warning("Axis Offset Address cannot be refreshed properly")
        elif case == RRUCmd.GET_UL_OFFSET:
            value = RespFilter.value_filter_with_ant(res, RespFilter.UL_OFFSET_ASSERTION, self.antenna_index)
            if value is not None:
                res = str(value.group())

                self.antenna_bean_arr[self.antenna_index].ulFrameOffset = res
                self.antenna_bean_arr[self.antenna_index].ulFrameOffset2Set = res
                self.antenna_bean_arr[self.antenna_index].ulFrameOffsetOutDated = False
Пример #7
0
                                      self.set_cmd_pool.pop(0)[1])

            print("Generate CMD: " + cmd)

            thread = TelnetWorker(RRUCmd.SET_AXI_REG, cmd)
            thread.signals.connectionLost.connect(
                self.slot_connection_out_signal)
            thread.signals.result.connect(self.set_resp_handler)
            thread.signals.consoleDisplay.connect(self._console_slot)
            QThreadPool.globalInstance().start(thread)
        else:
            self.sendButton.setEnabled(False)

    def set_resp_handler(self, case, resp: str):
        if case == RRUCmd.SET_AXI_REG:
            if RespFilter.resp_check(resp):
                match = RespFilter.axi_read_filter(resp)
                if match is not None:
                    res = match.group().split(":")

                    addr = res[0]
                    reg = res[1]

                    n_addr = int(addr, 16)
                    n_reg = int(reg, 16)

                    found = False

                    if addr in self.regModel.addr_in_change:
                        self.regModel.addr_in_change.remove(addr)
Пример #8
0
        thread.signals.connectionLost.connect(self.slot_connection_out_signal)
        thread.signals.error.connect(self.log_error)

        if cmd_type == RRUCmd.CMD_TYPE_GET:
            thread.signals.result.connect(self.get_resp_handler)
        elif cmd_type == RRUCmd.CMD_TYPE_SET:
            thread.signals.result.connect(self.set_resp_handler)

        QThreadPool.globalInstance().start(thread)

    def get_resp_handler(self, case, resp: str):
        pass

    def set_resp_handler(self, case, resp: str):
        if case == RRUCmd.REBOOT:
            if not RespFilter.resp_check(resp):
                self.warning("Frequency cannot be set properly")
            else:
                if self.warning(
                        "Reboot Finished, Press YES to Refresh All Value"):
                    self.set_connected(True)

    def _console_slot(self, case, msg):
        if case == WorkerSignals.TRAN_SIGNAL:
            self.emit_trans_signal(msg)
        elif case == WorkerSignals.RECV_SIGNAL:
            self.emit_rvd_signal(msg)

    @staticmethod
    def log_error(t_error: tuple):
        s_error = ""
Пример #9
0
class LoginWidget(QWidget):
    sinOption = pyqtSignal(int)
    loginSignal = pyqtSignal(bool)
    loginWarningSignal = pyqtSignal(str)

    ipTranSignal = pyqtSignal(str)
    ipRecvSignal = pyqtSignal(str)

    def __init__(self, parent):
        self.isTelnetLogined = False

        super(LoginWidget, self).__init__()
        self.parentWindow = parent

        with open('../Qss/OperatorQSS.qss', 'r') as f:
            self.list_style = f.read()

        self.setStyleSheet(self.list_style)

        self._setup_ui()
        self._add_signal()

        self._check_json()

        self._set_logger()

        # self.ip_config_widget.setDisabled(True)

    def _setup_ui(self):
        self.hostnameLabel = QtWidgets.QLabel("Hostname")
        self.hostEdit = QtWidgets.QLineEdit()
        self.hostEdit.setStyleSheet(valueEditStyle)
        self.saveCheckBox = QtWidgets.QCheckBox("Save   ")
        self.saveCheckBox.setChecked(True)

        device_manage_layout = QtWidgets.QGridLayout()

        device_manage_layout.addWidget(self.hostnameLabel, 0, 0)
        device_manage_layout.addWidget(self.hostEdit, 0, 1)
        device_manage_layout.addWidget(self.saveCheckBox, 0, 3)
        device_manage_layout.setSpacing(pubSpacing)

        userPwGroup = QtWidgets.QGroupBox()

        self.loginButton = QtWidgets.QPushButton("Login")
        self.loginButton.setStyleSheet(setButtonStyle)

        self.getTxGainLabel = QtWidgets.QLabel("Username")
        self.userEdit = QtWidgets.QLineEdit()
        self.userEdit.setStyleSheet(valueEditStyle)

        self.optionComboBox = QtWidgets.QComboBox()
        for i in range(len(RRUCmd.cmd_type_str)):
            self.optionComboBox.addItem(RRUCmd.cmd_type_str[i])

        self.getRxGainLabel = QtWidgets.QLabel("Password")
        self.passwordEdit = QtWidgets.QLineEdit()
        self.passwordEdit.setStyleSheet(valueEditStyle)
        self.passwordEdit.setEchoMode(QtWidgets.QLineEdit.Password)

        self.user_pw_layout = QtWidgets.QGridLayout()
        self.user_pw_layout.addWidget(self.getTxGainLabel, 0, 0)
        self.user_pw_layout.addWidget(self.userEdit, 0, 1)
        self.user_pw_layout.addWidget(self.optionComboBox, 0, 3)
        self.user_pw_layout.addWidget(self.getRxGainLabel, 1, 0)
        self.user_pw_layout.addWidget(self.passwordEdit, 1, 1, 1, 3)
        self.user_pw_layout.setSpacing(pubSpacing)

        self.vLineFrame = QtWidgets.QFrame()
        self.vLineFrame.setFrameStyle(QtWidgets.QFrame.VLine
                                      | QtWidgets.QFrame.Sunken)

        deviceLayout = QtWidgets.QGridLayout()
        deviceLayout.addLayout(self.user_pw_layout, 0, 0)
        deviceLayout.addWidget(self.vLineFrame, 0, 1)
        deviceLayout.addWidget(self.loginButton, 0, 2)
        userPwGroup.setLayout(deviceLayout)
        '''Ip Address Config Pane'''
        self.ipaddrLabel = QtWidgets.QLabel("IP Address Config")
        self.ipaddrEdit = QtWidgets.QLineEdit()
        self.ipaddrEdit.setStyleSheet(valueEditStyle)
        self.ipAddrRefreshButton = QtWidgets.QPushButton("Refresh")
        self.ipAddrConfigButton = QtWidgets.QPushButton("Config")

        ip_config_layout = QtWidgets.QGridLayout()
        ip_config_layout.addWidget(self.ipaddrLabel, 0, 0)
        ip_config_layout.addWidget(self.ipaddrEdit, 0, 1, 1, 3)
        ip_config_layout.addWidget(self.ipAddrRefreshButton, 0, 4)
        ip_config_layout.addWidget(self.ipAddrConfigButton, 0, 5)
        ip_config_layout.setSpacing(pubSpacing)

        self.ip_config_widget = QtWidgets.QWidget()
        self.ip_config_widget.setLayout(ip_config_layout)
        '''End of ip Address Config Pane'''

        mainLayout = QtWidgets.QVBoxLayout()
        mainLayout.addLayout(device_manage_layout)
        mainLayout.addWidget(userPwGroup)
        mainLayout.addWidget(self.ip_config_widget)
        mainLayout.setContentsMargins(10, 20, 10, 20)
        mainLayout.setSpacing(mainSpacing)

        v_layout = QtWidgets.QVBoxLayout()
        v_layout.addLayout(mainLayout)
        v_layout.setContentsMargins(5, 70, 5, 70)

        self.setLayout(v_layout)

    def _add_signal(self):
        self.loginButton.clicked.connect(self.login_onclick)
        self.optionComboBox.currentIndexChanged.connect(self._send_option)
        self.ipAddrRefreshButton.clicked.connect(self.refresh_ip_addr)
        self.ipAddrConfigButton.clicked.connect(self.set_ip_addr)

        self.passwordEdit.textChanged.connect(self.back_normal)
        self.passwordEdit.returnPressed.connect(self.login_onclick)
        self.userEdit.textChanged.connect(self.back_normal)
        self.hostEdit.textChanged.connect(self.back_normal)

        self.setTabOrder(self.hostEdit, self.userEdit)
        self.setTabOrder(self.userEdit, self.passwordEdit)

    def _check_json(self):
        if os.access('../JSON/' + Telnet.json_filename + '.json', os.F_OK):
            data_in_json = JsonRep.read_json(Telnet.json_filename)
            self.hostEdit.setText(data_in_json[0][Telnet.json_dict[0]])
            self.userEdit.setText(data_in_json[0][Telnet.json_dict[1]])
            self.passwordEdit.setText(data_in_json[0][Telnet.json_dict[2]])
            return True
        else:
            return False

    @staticmethod
    def _set_logger():
        logging.basicConfig(
            filename='../log/' + __name__ + '.log',
            format=
            '[%(asctime)s-%(filename)s-%(funcName)s-%(levelname)s:%(message)s]',
            level=logging.DEBUG,
            filemode='a',
            datefmt='%Y-%m-%d %I:%M:%S %p')

    def login(self):
        self.back_normal()

        host = self.hostEdit.text().strip()
        user = self.userEdit.text().strip()
        password = self.passwordEdit.text()

        self.isTelnetLogined = TelRepository.telnet_instance.login(
            host, user, password)
        if self.isTelnetLogined:
            self.loginButton.setStyleSheet(
                "background-color: green; height: 90px")
            self.loginButton.setText('Logout')

            # self.ip_config_widget.setDisabled(False)

            # Save
            if self.saveCheckBox.isChecked():
                data = [{
                    Telnet.json_dict[0]: host,
                    Telnet.json_dict[1]: user,
                    Telnet.json_dict[2]: password
                }]
                JsonRep.save_by_json(data)

            self.loginSignal.emit(True)

            monitor_thread = ConnectionMonitor()
            monitor_thread.signals.connectionLost.connect(self.health_failure)
            QThreadPool.globalInstance().start(monitor_thread)
        else:
            self.loginButton.setStyleSheet(
                "background-color: red; height: 90px")
            self.loginButton.setText('Failed')

            self.loginSignal.emit(False)
            self.loginWarningSignal.emit(
                str(TelRepository.telnet_instance.get_warning()))

    def back_normal(self):
        if TelRepository.telnet_instance.isTelnetLogined:
            self.loginButton.setStyleSheet(
                "background-color: green; height: 90px")
        else:
            self.loginButton.setStyleSheet(setButtonStyle)
        self.loginButton.setText("Login")

    def test_login(self):
        self.back_normal()

        host = self.hostEdit.text().strip()
        user = self.userEdit.text().strip()
        password = self.passwordEdit.text().strip()

        self.isTelnetLogined = TelRepository.telnet_instance.login(
            host, user, password)
        if self.isTelnetLogined:
            self.loginButton.setStyleSheet(
                "background-color: green; height: 90px")
            self.loginButton.setText('Logout')

            # Save
            if self.saveCheckBox.isChecked():
                data = [{
                    Telnet.json_dict[0]: host,
                    Telnet.json_dict[1]: user,
                    Telnet.json_dict[2]: password
                }]
                JsonRep.save_by_json(data)

            self.monitorT.start()
        else:
            self.loginButton.setStyleSheet(
                "background-color: red; height: 90px")
            self.loginButton.setText('Failed')

    @staticmethod
    def warning(title: str, icon, info):
        msgBox = QtWidgets.QMessageBox()

        msgBox.setWindowTitle(title)
        msgBox.setIcon(icon)
        msgBox.setText('Info')
        msgBox.setInformativeText(info)
        msgBox.addButton('Yes', QtWidgets.QMessageBox.AcceptRole)
        no = msgBox.addButton('No', QtWidgets.QMessageBox.RejectRole)
        msgBox.setDefaultButton(no)

        reply = msgBox.exec()
        if reply == QtWidgets.QMessageBox.AcceptRole:
            return True
        else:
            return False

    def login_onclick(self):
        if self.isTelnetLogined:
            info = "Press Yes to log out"
            if self.userEdit.text().strip(
            ) != TelRepository.telnet_instance.loginedUserName:
                info = "Press Yes to log out first"
            if self.warning("Warning", QtWidgets.QMessageBox.Information,
                            info):
                if TelRepository.connection_check():
                    TelRepository.telnet_instance.logout()
                    self._loose_login()
                else:
                    self._loose_login()
        else:
            self.login()  # TODO Use self.login() if not for DEBUG

    def _send_option(self):
        self.sinOption.emit(self.optionComboBox.currentIndex())

    def health_failure(self):
        """Shut down all panes and send warning when connection lost
            Connection lost may either be reported by monitor thread or passive touch before sending message
        """
        self._loose_login()

        msgBox = QtWidgets.QMessageBox()

        msgBox.setWindowTitle('Warning')
        msgBox.setIcon(QtWidgets.QMessageBox.Warning)
        msgBox.setText('Connection Lost!')

        msgBox.exec()

    def _loose_login(self):
        self.loginSignal.emit(False)
        # self.ip_config_widget.setDisabled(True)
        self.isTelnetLogined = False
        self.back_normal()

    def refresh_ip_addr(self):
        if self.isTelnetLogined:
            cmd = RRUCmd.get_ipaddr("ipaddr")

            thread = TelnetWorker(RRUCmd.GET_IP_ADDR, cmd)
            thread.signals.connectionLost.connect(self.health_failure)
            thread.signals.consoleDisplay.connect(self._console_slot)
            thread.signals.result.connect(self.refresh_resp_handler)
            QThreadPool.globalInstance().start(thread)
        else:
            msgBox = QtWidgets.QMessageBox()

            msgBox.setWindowTitle('Warning')
            msgBox.setIcon(QtWidgets.QMessageBox.Warning)
            msgBox.setText('Login before Refreshing the IP Address')

            msgBox.exec()

    def refresh_resp_handler(self, case, res):
        if case == RRUCmd.GET_IP_ADDR:
            value = RespFilter.ipaddr_read_filter(res)
            if value is not None:
                self.ipaddrEdit.setText(str(value.group()))
            else:
                msgBox = QtWidgets.QMessageBox()

                msgBox.setWindowTitle('Warning')
                msgBox.setIcon(QtWidgets.QMessageBox.Warning)
                msgBox.setText('Cannot get IP Address!')

                msgBox.exec()