Example #1
0
 def configuration_values_window(self):
     '''
     The function will create a QGroupBox for Configuration Values [it is called by the function device_child_window]
     '''
     self.ThirdGroupBox = QGroupBox("Configuration Values")
     labelvalue = [0 for i in np.arange(20)]  # 20 is just a hypothetical number
     self.confValueBox = [0 for i in np.arange(20)]
     ThirdGridLayout = QGridLayout()
     _dictionary = self.__dictionary_items
     _conf_indices = list(self.__conf_index)
     a = 0 
     for i in np.arange(len(_conf_indices)):
         _subIndexItems = list(AnalysisUtils().get_subindex_yaml(dictionary=_dictionary, index=_conf_indices[i], subindex="subindex_items"))
         for s in np.arange(len(_subIndexItems)):
             subindex_description_item = AnalysisUtils().get_subindex_description_yaml(dictionary=_dictionary, index=_conf_indices[i], subindex=_subIndexItems[s])
             labelvalue[a] = QLabel()
             labelvalue[a].setText(subindex_description_item + ":")
             self.confValueBox[a] = QLineEdit("")
             self.confValueBox[a].setStyleSheet("background-color: white; border: 1px inset black;")
             self.confValueBox[a].setReadOnly(True)
             self.confValueBox[a].setFixedWidth(80)
             labelvalue[a].setStatusTip('%s [index = %s & subIndex = %s]' % (subindex_description_item[9:-11], _conf_indices[i], _subIndexItems[s])) 
             ThirdGridLayout.addWidget(labelvalue[a], a, 0)
             ThirdGridLayout.addWidget(self.confValueBox[a], a, 1)
             a = a + 1
     self.ThirdGroupBox.setLayout(ThirdGridLayout)  
Example #2
0
    def adc_values_window(self):
        '''
        The function will create a QGroupBox for ADC Values [it is called by the function device_child_window]
        '''
        # info to read the ADC from the yaml file
        self.ADCGroupBox = QGroupBox("ADC Channels")
        FirstGridLayout = QGridLayout()
        _adc_channels_reg = self.__adc_channels_reg
        _dictionary = self.__dictionary_items
        _adc_indices = list(self.__adc_index)
        for i in np.arange(len(_adc_indices)):
            _subIndexItems = list(AnalysisUtils().get_subindex_yaml(dictionary=_dictionary, index=_adc_indices[i], subindex="subindex_items"))
            labelChannel = [_subIndexItems[k] for k in np.arange(len(_subIndexItems) * len(_adc_indices))]
            self.channelValueBox = [_subIndexItems[k] for k in np.arange(len(_subIndexItems) * len(_adc_indices))]
            self.trendingBox = [False for k in np.arange(len(_subIndexItems) * len(_adc_indices))]
            self.trendingBotton = [_subIndexItems[k] for k in np.arange(len(_subIndexItems) * len(_adc_indices))]
            _start_a = 3  # to start from channel 3
            for subindex in np.arange(_start_a, len(_subIndexItems) + _start_a - 1):
                s = subindex - _start_a
                s_correction = subindex - 2
                labelChannel[s] = QLabel()
                self.channelValueBox[s] = QLineEdit()
                self.channelValueBox[s].setStyleSheet("background-color: white; border: 1px inset black;")
                self.channelValueBox[s].setReadOnly(True)
                self.channelValueBox[s].setFixedWidth(80)
                subindex_description_item = AnalysisUtils().get_subindex_description_yaml(dictionary=_dictionary, index=_adc_indices[i], subindex=_subIndexItems[s_correction])
                labelChannel[s].setStatusTip('ADC channel %s [index = %s & subIndex = %s]' % (subindex_description_item[25:29],
                                                                                            _adc_indices[i],
                                                                                             _subIndexItems[s_correction]))  # show when move mouse to the icon
                labelChannel[s].setText(subindex_description_item[25:29] + ":")
                icon = QLabel(self)
                if _adc_channels_reg[str(subindex)] == "V": 
                    icon_dir = 'graphicsUtils/icons/icon_voltage.png'
                else: 
                    icon_dir = 'graphicsUtils/icons/icon_thermometer.png'
                pixmap = QPixmap(icon_dir)
                icon.setPixmap(pixmap.scaled(20, 20))
                self.trendingBotton[s] = QPushButton()
                self.trendingBotton[s].setObjectName(str(subindex))
                self.trendingBotton[s].setIcon(QIcon('graphicsUtils/icons/icon_trend.jpg'))
                self.trendingBotton[s].setStatusTip('Data Trending for %s' % subindex_description_item[25:29])
               # self.trendingBotton[s].clicked.connect(self.show_trendWindow)
#                 self.trendingBox[s] = QCheckBox("")
#                 self.trendingBox[s].setChecked(False)
                col_len = int(len(_subIndexItems) / 2)
                if s < col_len:
                    FirstGridLayout.addWidget(icon, s, 0)
                    # FirstGridLayout.addWidget(self.trendingBox[s], s, 1)
                    FirstGridLayout.addWidget(self.trendingBotton[s], s, 2)
                    FirstGridLayout.addWidget(labelChannel[s], s, 3)
                    FirstGridLayout.addWidget(self.channelValueBox[s], s, 4)
                else:
                    FirstGridLayout.addWidget(icon, s - col_len, 5)
                    # FirstGridLayout.addWidget(self.trendingBox[s], s-col_len, 6)
                    FirstGridLayout.addWidget(self.trendingBotton[s], s - col_len, 7)
                    FirstGridLayout.addWidget(labelChannel[s], s - col_len, 8)
                    FirstGridLayout.addWidget(self.channelValueBox[s], s - col_len , 9)         
        self.ADCGroupBox.setLayout(FirstGridLayout)
Example #3
0
 def __init__(self):
     super(OpcuaWindow, self).__init__(None)
     self.conf_cic = AnalysisUtils().open_yaml_file(file=config_dir +
                                                    "config.yaml",
                                                    directory=lib_dir)
     dev = AnalysisUtils().open_yaml_file(file=config_dir + "MOPS_cfg.yml",
                                          directory=lib_dir)
     self.__adc_channels_reg = dev["adc_channels_reg"]["adc_channels"]
     self.__dictionary_items = dev["Application"]["index_items"]
     self.__adc_index = dev["adc_channels_reg"]["adc_index"]
     pass
Example #4
0
 def update_opcua_config_box(self):
     self.conf_cic = AnalysisUtils().open_yaml_file(file=config_dir+ "config.yaml", directory=lib_dir)
     dev = AnalysisUtils().open_yaml_file(file=config_dir + "MOPS_cfg.yml", directory=lib_dir)
     self.__deviceName = dev["Application"]["device_name"] 
     self.__version = dev['Application']['device_version']
     self.__appIconDir = dev["Application"]["icon_dir"]
     self.__chipId = dev["Application"]["chipId"]
     self.__nodeIds = dev["Application"]["nodeIds"]
     self.__dictionary_items = dev["Application"]["index_items"]
     self.__index_items = list(self.__dictionary_items.keys())
     self.__adc_channels_reg = dev["adc_channels_reg"]["adc_channels"]
     self.__adc_index = dev["adc_channels_reg"]["adc_index"]
     self.__mon_index = dev["adc_channels_reg"]["mon_index"] 
     self.__conf_index = dev["adc_channels_reg"]["conf_index"] 
     self.__resistor_ratio = dev["Hardware"]["resistor_ratio"]
Example #5
0
    def _settingsMenu(self, menuBar, mainwindow):
        settingsMenu = menuBar.addMenu('&settings')
        self.MainWindow.update_device_box()
        self.__device = self.MainWindow.get_deviceName()
        conf = AnalysisUtils().open_yaml_file(file=config_dir + self.__device +
                                              "_cfg.yml",
                                              directory=lib_dir)
        self.__appIconDir = conf["Application"]["icon_dir"]

        def show_add_node():
            self.NodeWindow = QMainWindow()
            self.add_node(self.NodeWindow, conf)
            self.NodeWindow.show()

        def show_edit_adc():
            self.adcWindow = QMainWindow()
            self.edit_adc(self.adcWindow, conf)
            self.adcWindow.show()

        DeviceSettings = QAction(QIcon('graphics_Utils/icons/icon_nodes.png'),
                                 'Device settings', mainwindow)
        DeviceSettings.setStatusTip("Add Nodes to the Node menu")
        DeviceSettings.triggered.connect(show_add_node)

        ADCNodes = QAction(QIcon('graphics_Utils/icons/icon_nodes.png'),
                           'MOPS ADC settings', mainwindow)
        ADCNodes.setStatusTip("Edit ADC settings")
        ADCNodes.triggered.connect(show_edit_adc)

        settingsMenu.addAction(DeviceSettings)
        settingsMenu.addAction(ADCNodes)
Example #6
0
 def _save_items():
     if (nodeListBox.count() != 0):
         _nodes = [
             nodeListBox.item(x).text()
             for x in range(nodeListBox.count())
         ]
         _chipId = str(chipIdSpinBox.value())
         _resistorRatio = str(hardwareIdSpinBox.value())
         conf["Application"]["nodeIds"] = _nodes
         conf["Application"]["chipId"] = _chipId
         conf["Hardware"]["resistor_ratio"] = _resistorRatio
         file = config_dir + self.__device + "_cfg.yml"
         AnalysisUtils().dump_yaml_file(file=file,
                                        loaded=conf,
                                        directory=lib_dir)
         self.logger.info("Saving Information to the file %s" % file)
     else:
         self.logger.error("No data to be saved.....")
Example #7
0
 def _save_items():
     if (channelListBox.count() != 0 or parameterListBox.count() != 0):
         _adc_channels = [
             channelListBox.item(x).text()
             for x in range(channelListBox.count())
         ]
         _parameters = [
             parameterListBox.item(x).text()
             for x in range(parameterListBox.count())
         ]
         for i in range(len(_adc_channels)):
             conf["adc_channels_reg"]["adc_channels"][
                 _adc_channels[i]] = _parameters[i]
         file = config_dir + self.__device + "_cfg.yml"
         AnalysisUtils().dump_yaml_file(file=file,
                                        loaded=conf,
                                        directory=lib_dir)
         self.logger.info("Saving Information to the file %s" % file)
     else:
         self.logger.error("No data to be saved.....")