示例#1
0
 def createTemplateList(self, template):
     file_template = utility.readJsonFile(os.path.join(self.json_templates_path, template))
     list_measures = []
     for model in file_template["parameters"]["filter_tag"]:
         if(model["tag"] != "CommunicationCode"):
             list_measures.append(utility.getSubstring(model["tag"], start="."))           
     return(list_measures)
示例#2
0
 def createJson(self):
     if (self.name_hierarchy
             not in os.listdir(os.path.join(self.json_files_path))):
         os.mkdir(os.path.join(self.json_files_path, self.name_hierarchy))
     for meter_name, template in self.dict_meter_template.items():
         if (template != "Not Found"):
             file = utility.readJsonFile(
                 os.path.join(self.json_templates_path, template))
             file["gateway_id"] = self.gateway_id
             file["parameters"][
                 "environment_prefix"] = self.environment_prefix
             file["parameters"]["serial_number"] = self.serial_number
             file["parameters"]["model"] = template[:template.find(".")]
             file["parameters"]["user_name"] = self.username
             file["parameters"]["password"] = self.password
             key = file["parameters"]["file_name_filter"]
             key["match_group_value"] = self.match_group_value
             file["parameters"]["meter_name"] = meter_name
             file["parameters"]["maker"] = meter_name
             for measure_meter in file["parameters"]["filter_tag"]:
                 if (measure_meter["tag"] != "CommunicationCode"):
                     measure_meter["tag"] = measure_meter["tag"].replace(
                         measure_meter["tag"]
                         [:measure_meter["tag"].find(".")], meter_name)
             utility.saveJsonFile(
                 os.path.join(self.json_files_path, self.name_hierarchy,
                              meter_name + ".json"), file)
示例#3
0
def add_gateway_id(string):
    path = os.path.join(os.path.realpath(''), "configuration",
                        "gatewayIdConfiguration.json")
    list_gateway_id = utility.readJsonFile(path)
    if (string not in list_gateway_id and string != ''):
        list_gateway_id.append(string)
        utility.saveJsonFile(path, list_gateway_id)
        return True
    else:
        return False
示例#4
0
 def searchTemplate(self, list_meter_measures):
     dict_meters_config = utility.readJsonFile(os.path.join(os.path.realpath (''), "configuration", "meterMeasuresConfiguration.json"))
     list_model = []
     for model_meter, diz_value in dict_meters_config.items():
         for key, value in diz_value.items():
             if(key == "measuresSelected" and value==len(list_meter_measures)):
                 response = self.controlTemplate(model_meter+".json", list_meter_measures)               
                 if(response != False):
                     return response
     return False
示例#5
0
def add_environment_prefix(string):
    path = os.path.join(os.path.realpath(''), "configuration",
                        "environmentPrefixConfiguration.json")
    list_environment_prefix = utility.readJsonFile(path)
    if (string not in list_environment_prefix and string != ''):
        list_environment_prefix.append(string)
        utility.saveJsonFile(path, list_environment_prefix)
        return True
    else:
        return False
示例#6
0
    def __init__(self, parent=None):
        super(ChangeMeasuresSetInterface, self).__init__(parent)
        self.resize(700, 400)
        self.setWindowTitle("Change measures set")
        '''Font settings'''
        font = QtGui.QFont()
        font.setPointSize(13)
        self.setFont(font)
        '''Button settings'''
        self.button = QtWidgets.QPushButton("Save")
        self.button.setStyleSheet(
            "background-color: #8b0000; color: white; height:50; border-radius:10"
        )
        self.button.setFont(font)

        self.dict_measures_id = utility.readJsonFile(
            os.path.join(os.path.realpath(''), "configuration",
                         "trendIdConfiguration.json"))

        self.lista = []
        for measure_id in self.dict_measures_id.keys():
            self.lista.append(QtWidgets.QCheckBox(measure_id, self))
        '''Vertical layout'''
        vbox = QtWidgets.QVBoxLayout()
        vbox_check = QtWidgets.QVBoxLayout()

        for check_box in self.lista:
            if (self.dict_measures_id[check_box.text()]["active"] == True):
                vbox_check.addWidget(check_box)
                check_box.setChecked(True)
            else:
                vbox_check.addWidget(check_box)
                check_box.setChecked(False)

        widget = QtWidgets.QWidget()
        widget.setLayout(vbox_check)
        widget.setStyleSheet("width:500")
        widget.adjustSize()
        '''Scroll'''
        scroll = QtWidgets.QScrollArea()
        scroll.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        scroll.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        scroll.setWidgetResizable(False)
        scroll.setWidget(widget)

        vbox.addWidget(scroll)
        vbox.addWidget(self.button)

        layout = QtWidgets.QWidget()
        layout.setLayout(vbox)
        self.setCentralWidget(layout)

        self.button.clicked.connect(self.on_button_clicked)
示例#7
0
 def getTemplateData(self, hierarchy_name):
     list_json_file = utility.createFileList(
         os.path.join(self.json_files_path, hierarchy_name), ".json")
     dict_measures = {}
     for file in list_json_file:
         file_json = utility.readJsonFile(
             os.path.join(self.json_files_path, hierarchy_name, file))
         for measure in file_json["parameters"]["filter_tag"]:
             if (measure["tag"] != "CommunicationCode"):
                 dict_measures[measure["tag"]] = [
                     measure["id"], measure["period"]
                 ]
     return (dict_measures)
示例#8
0
def add_trend_id(trend_id, channel, multipler):
    path = os.path.join(os.path.realpath(''), "configuration",
                        "trendIdConfiguration.json")
    dict_trend_id = utility.readJsonFile(path)
    if (trend_id not in dict_trend_id and trend_id != ''):
        dict_trend_id[trend_id] = {
            "channel": channel,
            "multipler": multipler,
            "active": False
        }
        utility.saveJsonFile(path, dict_trend_id)
        return True
    else:
        return False
示例#9
0
 def __init__(self, site_name, hierarchy_name, environment_prefix,
              dict_meters):
     '''Set path'''
     dict_configuration_path = utility.getConfigurationPath()
     self.json_templates_path = dict_configuration_path[
         "json_templates_path"]
     self.excel_templates_path = dict_configuration_path[
         "excel_templates_path"]
     self.json_files_path = dict_configuration_path["json_files_path"]
     self.excel_files_path = dict_configuration_path["excel_files_path"]
     self.hierarchy_file_path = dict_configuration_path["hierarchy_path"]
     '''Set Data'''
     self.site_name = site_name
     self.hierarchy_name = hierarchy_name
     self.environment_prefix = environment_prefix
     '''Dict'''
     self.dict_from_template = self.getTemplateData(hierarchy_name)
     self.dict_from_json_configuration = utility.readJsonFile(
         os.path.join(os.path.realpath(''), "configuration",
                      "trandIdConfiguration.json"))
     self.dict_meters = self.createDictMeterData(dict_meters)
     self.createExcelSheet()
示例#10
0
    def __init__(self, parent=None):
        super(MainInterface, self).__init__(parent)
        '''Configuration path'''
        dict_configuration_path = utility.getConfigurationPath()
        self.json_templates_path = dict_configuration_path[
            "json_templates_path"]
        self.excel_templates_path = dict_configuration_path[
            "excel_templates_path"]
        self.json_files_path = dict_configuration_path["json_files_path"]
        self.excel_files_path = dict_configuration_path["excel_files_path"]
        self.hierarchy_path = dict_configuration_path["hierarchy_path"]
        '''Window settings'''
        self.setWindowTitle("JaSONx")
        self.setFixedSize(1050, 600)
        self.setWindowIcon(
            QtGui.QIcon(os.path.join(os.path.realpath(''), "image",
                                     "logo.png")))
        '''Font settings'''
        font = QtGui.QFont()
        font.setPointSize(13)
        fontToolbar = QtGui.QFont()
        fontToolbar.setPointSize(10)
        self.setFont(font)
        '''Label settings'''
        self.title_label = QtWidgets.QLabel()
        self.user_name_label = QtWidgets.QLabel()
        self.password_label = QtWidgets.QLabel()
        self.match_group_value_label = QtWidgets.QLabel()
        self.combo_box_hierarchy_label = QtWidgets.QLabel()
        self.gateway_id_label = QtWidgets.QLabel()
        self.combo_box_environment_prefix_label = QtWidgets.QLabel()
        self.title_label.setAlignment(QtCore.Qt.AlignCenter)
        '''Label text'''
        self.title_label.setPixmap(
            QtGui.QPixmap(
                os.path.join(os.path.realpath(''), "image", "title.png")))
        self.user_name_label.setText("Username: "******"Password: "******"Hierarchy: ")
        self.gateway_id_label.setText("Gateway id: ")
        self.combo_box_environment_prefix_label.setText("Environment prefix: ")
        '''Textbox settings'''
        self.user_name_text = QtWidgets.QLineEdit(self)
        self.password_text = QtWidgets.QLineEdit(self)
        '''Combobox settings'''
        self.combo_box_hierarchy = QtWidgets.QComboBox()
        self.combo_box_hierarchy.addItems(
            utility.createFileList(self.hierarchy_path, ".xml"))

        self.combo_box_environment_prefix = QtWidgets.QComboBox()
        self.combo_box_environment_prefix.addItems(
            utility.readJsonFile(
                os.path.join(os.path.realpath(''), "configuration",
                             "environmentPrefixConfiguration.json")))

        self.combo_box_gateway_id = QtWidgets.QComboBox()
        self.combo_box_gateway_id.addItems(
            utility.readJsonFile(
                os.path.join(os.path.realpath(''), "configuration",
                             "gatewayIdConfiguration.json")))
        '''Button settings'''
        self.button = QtWidgets.QPushButton("Send data")
        self.button.setStyleSheet(
            "background-color: #8b0000; color: white; height:50; border-radius:10"
        )
        self.button.setFont(font)
        self.button.clicked.connect(self.on_pushButton_clicked)
        '''Grid layout'''
        grid = QtWidgets.QGridLayout()
        grid.addWidget(self.user_name_label, 0, 0)
        grid.addWidget(self.user_name_text, 0, 1)
        grid.addWidget(self.password_label, 1, 0)
        grid.addWidget(self.password_text, 1, 1)
        grid.addWidget(self.gateway_id_label, 2, 0)
        grid.addWidget(self.combo_box_gateway_id, 2, 1)
        grid.addWidget(self.combo_box_environment_prefix_label, 3, 0)
        grid.addWidget(self.combo_box_environment_prefix, 3, 1)
        grid.addWidget(self.combo_box_hierarchy_label, 4, 0)
        grid.addWidget(self.combo_box_hierarchy, 4, 1)
        '''Vertical layout'''
        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(self.title_label)
        vbox.addLayout(grid)
        vbox.addWidget(self.button)
        '''Layout QWidget'''
        layout = QtWidgets.QWidget()
        layout.setLayout(vbox)
        '''Layout QMainWindow'''
        self.setCentralWidget(layout)
        '''TOOLBAR'''
        toolbar = self.addToolBar('Toolbar')
        toolbar.setMovable(False)
        toolbar.setIconSize(QtCore.QSize(40, 40))
        toolbar.setFont(fontToolbar)
        toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
        '''Icon toolbar'''
        '''Exit application'''
        exit_act = QtWidgets.QAction(
            QtGui.QIcon(
                os.path.join(os.path.realpath(''), "image", "icon",
                             "exiticon.png")), '', self)
        exit_act.setShortcut('Ctrl+Q')
        exit_act.setStatusTip('Close application')
        '''Add Hierarchy xml'''
        add_xml_hierarchy_act = QtWidgets.QAction(
            QtGui.QIcon(
                os.path.join(os.path.realpath(''), "image", "icon",
                             "xmlicon.png")), 'Hierarchy', self)
        add_xml_hierarchy_act.setShortcut('Ctrl+H')
        add_xml_hierarchy_act.setStatusTip('Add Hierarchy XML')
        '''Add template json'''
        add_json_template_act = QtWidgets.QAction(
            QtGui.QIcon(
                os.path.join(os.path.realpath(''), "image", "icon",
                             "jsonicon.png")), 'Template', self)
        add_json_template_act.setShortcut('Ctrl+T')
        add_json_template_act.setStatusTip('Add JSON Template')
        '''Refresh application'''
        refresh_act = QtWidgets.QAction(
            QtGui.QIcon(
                os.path.join(os.path.realpath(''), "image", "icon",
                             "refreshicon.png")), '', self)
        refresh_act.setShortcut('Ctrl+R')
        refresh_act.setStatusTip('Refresh application')
        '''Add evironment prefix'''
        add_environment_prefix_act = QtWidgets.QAction(
            QtGui.QIcon(
                os.path.join(os.path.realpath(''), "image", "icon",
                             "addlisticon.png")), 'Environment prefix', self)
        add_environment_prefix_act.setShortcut('Ctrl+P')
        add_environment_prefix_act.setStatusTip('Add environment prefix')
        '''Add gateway id'''
        add_gateway_id_act = QtWidgets.QAction(
            QtGui.QIcon(
                os.path.join(os.path.realpath(''), "image", "icon",
                             "addlisticon.png")), 'Gateway id', self)
        add_gateway_id_act.setShortcut('Ctrl+Y')
        add_gateway_id_act.setStatusTip('Add gateway id')
        '''acThing'''
        acThing_act = QtWidgets.QAction(
            QtGui.QIcon(
                os.path.join(os.path.realpath(''), "image", "acthing.png")),
            'acThing', self)
        acThing_act.setShortcut('Ctrl+I')
        acThing_act.setStatusTip('Open acThing Interface')
        '''Excel Append'''
        excel_append_act = QtWidgets.QAction(
            QtGui.QIcon(
                os.path.join(os.path.realpath(''), "image", "icon",
                             "excelicon.png")), 'Append', self)
        excel_append_act.setShortcut('Ctrl+Z')
        excel_append_act.setStatusTip('Open Excel Append Interface')
        '''ACTION TOOLBAR'''
        toolbar.addAction(exit_act)
        toolbar.addSeparator()
        toolbar.addSeparator()
        toolbar.addSeparator()
        toolbar.addAction(add_xml_hierarchy_act)
        toolbar.addAction(add_json_template_act)
        toolbar.addAction(add_environment_prefix_act)
        toolbar.addAction(add_gateway_id_act)
        toolbar.addSeparator()
        toolbar.addSeparator()
        toolbar.addSeparator()
        toolbar.addAction(acThing_act)
        toolbar.addAction(excel_append_act)
        toolbar.addSeparator()
        toolbar.addSeparator()
        toolbar.addSeparator()
        toolbar.addAction(refresh_act)
        '''TOOOLBAR TRIGGERED'''
        exit_act.triggered.connect(self.closeFunction)
        add_xml_hierarchy_act.triggered.connect(self.addHierarchy)
        add_json_template_act.triggered.connect(self.addJsonTemplate)
        refresh_act.triggered.connect(self.refreshWindow)
        add_environment_prefix_act.triggered.connect(self.addEnvironmentPrefix)
        add_gateway_id_act.triggered.connect(self.addGatewayId)
        acThing_act.triggered.connect(self.openActThingInterface)
        excel_append_act.triggered.connect(self.openExcelAppendInterface)
        '''MENU SETTINGS'''
        '''Configuration Json path'''
        configJsonPathAct = QtWidgets.QAction(
            QtGui.QIcon(
                os.path.join(os.path.realpath(''), "image", "menu",
                             "json.png")), 'Json output', self)
        configJsonPathAct.setShortcut('Ctrl+J')
        configJsonPathAct.setStatusTip('')
        configJsonPathAct.triggered.connect(self.changePathJsonFile)
        '''Configuration Hierarchy path'''
        configHierarchyPathAct = QtWidgets.QAction(
            QtGui.QIcon(
                os.path.join(os.path.realpath(''), "image", "menu",
                             "xml.png")), 'Hierarchy', self)
        configHierarchyPathAct.setShortcut('Ctrl+X')
        configHierarchyPathAct.setStatusTip('')
        configHierarchyPathAct.triggered.connect(self.changePathHierarchy)
        '''Configuration Template path'''
        configTemplatePathAct = QtWidgets.QAction(
            QtGui.QIcon(
                os.path.join(os.path.realpath(''), "image", "menu",
                             "json.png")), 'Template', self)
        configTemplatePathAct.setShortcut('Ctrl+L')
        configTemplatePathAct.setStatusTip('')
        configTemplatePathAct.triggered.connect(self.changePathTemplate)
        '''Configuration Excel path'''
        configExcelPathAct = QtWidgets.QAction(
            QtGui.QIcon(
                os.path.join(os.path.realpath(''), "image", "menu",
                             "excel.png")), 'Excel output', self)
        configExcelPathAct.setShortcut('Ctrl+E')
        configExcelPathAct.setStatusTip('')
        configExcelPathAct.triggered.connect(self.changePathExcel)
        '''Configuration Excel Final path'''
        configExcelFinalPathAct = QtWidgets.QAction(
            QtGui.QIcon(
                os.path.join(os.path.realpath(''), "image", "menu",
                             "excel.png")), 'Excel Final output', self)
        configExcelFinalPathAct.setShortcut('Ctrl+S')
        configExcelFinalPathAct.setStatusTip('')
        configExcelFinalPathAct.triggered.connect(self.changePathExcelFinal)
        '''Reset paths default'''
        resetPathAct = QtWidgets.QAction(
            QtGui.QIcon(
                os.path.join(os.path.realpath(''), "image", "menu",
                             "reset.png")), 'Reset Path to Default', self)
        resetPathAct.setShortcut('Ctrl+D')
        resetPathAct.setStatusTip('')
        resetPathAct.triggered.connect(self.resetDefaultPath)
        '''User Guide'''
        UserGuideAct = QtWidgets.QAction(
            QtGui.QIcon(
                os.path.join(os.path.realpath(''), "image", "menu",
                             "guide.png")), 'Open User Guide', self)
        UserGuideAct.setShortcut('Ctrl+G')
        UserGuideAct.setStatusTip('')
        UserGuideAct.triggered.connect(self.openUserGuide)
        '''Add bar menu'''
        menubar = self.menuBar()
        '''Menu path population'''
        fileMenu = menubar.addMenu('&Change Path')
        fileMenu.addAction(configJsonPathAct)
        fileMenu.addAction(configHierarchyPathAct)
        fileMenu.addAction(configTemplatePathAct)
        fileMenu.addAction(configExcelPathAct)
        fileMenu.addAction(configExcelFinalPathAct)
        fileMenu.addAction(resetPathAct)
        '''Menu Info - User Guide'''
        fileMenu2 = menubar.addMenu('&Info')
        fileMenu2.addAction(UserGuideAct)
    def __init__(self, obj, parent=None):
        super(ActThingMainInterface, self).__init__(parent)
        self.obj = obj
        '''Window settings'''
        self.setWindowTitle("actTHING")
        self.setFixedSize(1050, 600)
        self.setWindowIcon(
            QtGui.QIcon(
                os.path.join(os.path.realpath(''), "image", "acthing.png")))
        '''Font settings'''
        font = QtGui.QFont()
        font.setPointSize(13)
        fontToolbar = QtGui.QFont()
        fontToolbar.setPointSize(10)
        self.setFont(font)
        '''Label settings'''
        self.account_label = QtWidgets.QLabel()
        self.api_id_label = QtWidgets.QLabel()

        self.account_label.setText("Account ")
        self.api_id_label.setText("API Id: ")
        '''Combo box settings'''
        self.combo_box_account = QtWidgets.QComboBox()
        self.combo_box_account.addItems(
            utility.readJsonFile(
                os.path.join(os.path.realpath(''), "configuration",
                             "accountConfiguration.json")))

        self.combo_box_api_id = QtWidgets.QComboBox()
        self.combo_box_api_id.addItems(
            utility.readJsonFile(
                os.path.join(os.path.realpath(''), "configuration",
                             "apiIdConfiguration.json")))
        '''Button settings'''
        self.button = QtWidgets.QPushButton("Activate Things")
        self.button.setStyleSheet(
            "background-color: orange; color: white; height:50; border-radius:10"
        )
        self.button.setFont(font)

        if (type(obj) != list):
            '''Create list file .json'''
            self.list_file_json = utility.createFileList(
                os.path.join(self.obj.json_files_path,
                             self.obj.name_hierarchy), ".json")
        else:
            self.list_file_json = obj

        vbox = QtWidgets.QVBoxLayout()
        '''Layout settings'''
        grid = QtWidgets.QGridLayout()
        self.table = QtWidgets.QTableWidget()
        self.table.setFont(font)
        self.table.setRowCount(len(self.list_file_json))
        self.table.setColumnCount(1)
        self.table.setHorizontalHeaderLabels(["File JSON"])
        self.table.setColumnWidth(0, 1000)
        '''Grid Layout'''
        grid.addWidget(self.table, 0, 0)

        vbox.addLayout(grid)
        vbox.addWidget(self.account_label)
        vbox.addWidget(self.combo_box_account)
        vbox.addWidget(self.api_id_label)
        vbox.addWidget(self.combo_box_api_id)
        vbox.addWidget(self.button)
        '''Layout QWidget'''
        layout = QtWidgets.QWidget()
        layout.setLayout(vbox)
        '''Layout QMainWindow'''
        self.setCentralWidget(layout)
        '''Table settings'''
        count = 0
        for file in self.list_file_json:
            self.table.setItem(count, 0, QtWidgets.QTableWidgetItem(file))
            count += 1
        '''Button clicked'''
        self.button.clicked.connect(self.on_pushButton_clicked)