コード例 #1
0
    def sAdd(self):
        title = "Table "+self.name+" Add"                
        
        #get ID for default record
        #row = self.model.getDefaultTableRow()
        dbRow = self.model.getDefaultRow()    
        
        #print row                        
        dbRow['id'] = uiAccesories.showMessage(title,"ID: ", MSGTYPE.get_integer, dbRow['id'])                
        if dbRow['id'] == None:
            return

        #this ID exist?                
        res = db.getParId(self.name, dbRow['id'])            
        if(res):
            uiAccesories.showMessage(title,"Record with this ID already exist!")
            return
                     
                    
        #dstore.Set("user_actions", False)  
                                              
        if(dbRow != None):        
            db.insert_from_dict(self.name, dbRow)            
            uiAccesories.showMessage(title,"succesfully (id="+str(dbRow['id'])+")", MSGTYPE.statusbar)

        self.Update()                    
コード例 #2
0
 def sComboCellTask(self, index):                        
     '''získání a nastavení nové SET hodnoty'''
     cells_info = dstore.Get("cells_info", "GET")
     get_cell_info = cells_info[self.nr-1]
     set_cell_info = {}
     task = self.Idx2TaskNr(index)
     set_cell_info["task"] = task
     set_cell_info["trigger"] = get_cell_info["trigger"]                               
     set_cell_info["address"] = self.nr                               
     set_cell_info["fu1"] = 0x00                               
     set_cell_info["fu2"] = 0x00                               
     set_cell_info["fu3"] = 0x00
     
     cells_info = dstore.Get("cells_info", "GET")
     
     if task != 0:
         for info in cells_info:
             if info['task'] == task:         
                 self.comboCellTask.setCurrentIndex(self.TaskNr2Idx(get_cell_info["task"]))                                                                                                            
                 uiAccesories.showMessage("Cell Update error", "Cannot assign this task, probably already exist!")
                 return        
                            
     dstore.SetItem("cells_info", [self.nr-1], set_cell_info, "SET", changed = [self.nr-1])                               
     
     '''reset GET hodnoty'''
     dstore.ResetValue("cells_info", [self.nr-1, 'task'])
     self.timer_nochange = CellGroup.TIMER_NOCHANGE        
コード例 #3
0
ファイル: dfTableTimes.py プロジェクト: meloun/ew_aplikace
    def AutoUpdate(self):           
        
        ztime = time.clock()                   
        autorefresh = dstore.GetItem("times", ["auto_refresh"])
        if(autorefresh == 0):
            pass
        elif(self.auto_refresh_cnt == 0):
            self.auto_refresh_cnt = autorefresh                
        elif((self.auto_refresh_cnt-1) != 0):        
            self.auto_refresh_cnt = self.auto_refresh_cnt - 1                  
        else:
            #print "auto update", self.auto_refresh_cnt,  autorefresh, "s"
            self.auto_refresh_cnt = autorefresh
            ret = self.Update()
            if(ret == True):
                localtime = time.strftime("%H:%M:%S", time.localtime())
                updatetime = str(time.clock() - ztime)[0:5]+"s"
                calctime = str(mgr.GetInfo()["lastcalctime"])[0:5]+"s"                              
                uiAccesories.showMessage("Auto Refresh", localtime + " :: update: "+updatetime +" / calc: "+ str(calctime), MSGTYPE.statusbar)
                #uiAccesories.showMessage("Auto Refresh", time.strftime("%H:%M:%S", time.localtime())+" ("+str(time.clock() - ztime)[0:5]+"s)", MSGTYPE.statusbar)        ztime = time.clock()                   
            else:
                print "AutoUpdate: KO"

        autorefresh = dstore.GetItem("times", ["auto_www_refresh"])
        if(autorefresh == 0):
            pass
        elif(self.auto_www_refresh_cnt == 0):
            self.auto_www_refresh_cnt = autorefresh                
        elif((self.auto_www_refresh_cnt-1) != 0):        
            self.auto_www_refresh_cnt = self.auto_www_refresh_cnt - 1                  
        else:
            #print "auto update", self.auto_refresh_cnt,  autorefresh, "s"
            self.auto_www_refresh_cnt = autorefresh
            ret = self.sExportDirect(self.eHTM_EXPORT)
コード例 #4
0
 def sImportDialog(self, state):                            
     #title
     title = "Table '"+self.name + "' CSV Import"
     
     if(state['ko'] != 0) :
         uiAccesories.showMessage(title, "NOT Succesfully"+"\n\n" +str(state['ok'])+" record(s) imported.\n"+str(state['ko'])+" record(s) NOT imported.\n\n Wrong format or already exist.")                                                            
     else:
         uiAccesories.showMessage(title,"Succesfully"+"\n\n" +str(state['ok'])+" record(s) imported.", MSGTYPE.info)
コード例 #5
0
    def sImport(self):
        """import"""                                         
                                           
        #gui dialog                        
        filename = uiAccesories.getOpenFileName("Import CSV to table "+self.name,"dir_import_csv","Csv Files (*.csv)", self.name+".csv")                
        
        #cancel or close window
        if(filename == ""):                        
            return        
                  
        #IMPORT CSV TO DATABASE         
            
        #load csv to df
        try:            
            df = pd.DataFrame.from_csv(str(filename), sep=";", encoding = "utf8")
            #df.drop([df.columns[-1]], axis=1, inplace=True)
            df.fillna("", inplace=True)                        
        except:
            uiAccesories.showMessage(self.name+" CSV Import", "NOT Succesfully imported\n empty file or wrong format")
            return
        
        df["id"] = df.index

        #callback
        try:
            df = self.importDf2dbDdf(df)
        except KeyError:
            title = "Table '"+self.name + "' CSV Import"
            uiAccesories.showMessage(title, "NOT Succesfully"+"\n\n" +"Wrong format or not existing data.")
            return
        
        #counters
        state = {'ko':0, 'ok':0}
        
        #adding rows to DB                        
        for i,row in df.iterrows():
            
            try:
                self.importRow2dbRow(row)
            except:
                state['ko'] += 1
                continue
                 
            #to dict because of CZ
            row = dict(row)       
                                                         
            #if(db.insert_from_lists(self.name, columns, row, commit_flag = False) != False):
            if(db.insert_from_dict(self.name, row, commit = False) != False):
                                                                      
                state['ok'] += 1
            else:            
                state['ko'] += 1 #increment errors for error message                

        db.commit()                        
        self.model.Update()
        self.sImportDialog(state)
コード例 #6
0
    def Update(self, mode = UPDATE_MODE.all):                                
                                                  
        #export        
        #exportgroups                
        changed = False        
        self.namesgroup.Update()             
        for i in range(0, NUMBER_OF.EXPORTS):
            self.headergroups[i].Update()
            self.wwwgroups[i].Update()
            self.filtersortgroups[i].Update()                        
            a = self.exportgroups[i].Update()            
            changed = changed or a            
            
#             column = dstore.GetItem("export_laps", ["column"])
#             if column == ExportLapsFormat.FORMAT_TIMES:
#                 Ui().radioExportLapsTimes.setChecked(True)            
#                 Ui().radioExportLapsLaptimes.setChecked(False)
#                 Ui().radioExportLapsPoints_1.setChecked(False)
#                 Ui().radioExportLapsPoints_2.setChecked(False)
#                 Ui().radioExportLapsPoints_3.setChecked(False)
#             elif column == ExportLapsFormat.FORMAT_LAPTIMES:            
#                 Ui().radioExportLapsTimes.setChecked(False)            
#                 Ui().radioExportLapsLaptimes.setChecked(True)
#                 Ui().radioExportLapsPoints_1.setChecked(False)
#                 Ui().radioExportLapsPoints_2.setChecked(False)
#                 Ui().radioExportLapsPoints_3.setChecked(False)
#             elif column == ExportLapsFormat.FORMAT_POINTS_1:            
#                 Ui().radioExportLapsTimes.setChecked(False)            
#                 Ui().radioExportLapsLaptimes.setChecked(False)
#                 Ui().radioExportLapsPoints_1.setChecked(True)                                
#                 Ui().radioExportLapsPoints_2.setChecked(False)
#                 Ui().radioExportLapsPoints_3.setChecked(False)
#             elif column == ExportLapsFormat.FORMAT_POINTS_2:            
#                 Ui().radioExportLapsTimes.setChecked(False)            
#                 Ui().radioExportLapsLaptimes.setChecked(False)
#                 Ui().radioExportLapsPoints_1.setChecked(False)                                
#                 Ui().radioExportLapsPoints_2.setChecked(True)
#                 Ui().radioExportLapsPoints_3.setChecked(False)
#             elif column == ExportLapsFormat.FORMAT_POINTS_3:            
#                 Ui().radioExportLapsTimes.setChecked(False)            
#                 Ui().radioExportLapsLaptimes.setChecked(False)
#                 Ui().radioExportLapsPoints_1.setChecked(False)                                
#                 Ui().radioExportLapsPoints_2.setChecked(False)
#                 Ui().radioExportLapsPoints_3.setChecked(True)
#             else:
#                 print "error: export laptimes"
                
        if(changed == True):            
            uiAccesories.showMessage("Additional info", "The column was disabled also for all exports.\n\n See the export tab. \n ", MSGTYPE.warning)
                
        #print dstore.Get("export")                                    
                                
        return True
コード例 #7
0
def sRefresh():
    title = "Manual Refresh"
    #myevent2.clear()
    
    #disable user actions
    ztime = time.clock()        
                                     
    ret = tabManager.GetCurrentTab().Update(UPDATE_MODE.all)        
    if(ret == True):
        localtime = time.strftime("%H:%M:%S", time.localtime())
        updatetime = str(time.clock() - ztime)[0:5]+"s"
        calctime = str(mgr.GetInfo()["lastcalctime"])[0:5]+"s"                              
        uiAccesories.showMessage(title, localtime + " :: update: "+updatetime +" / calc: "+ str(calctime), MSGTYPE.statusbar)            
コード例 #8
0
 def setDataFromDict(self, mydict):
     print "setDataFromDict()", mydict, self.name
     
     #category changed
     if "category" in mydict:                         
         category = tableCategories.model.getCategoryParName(unicode(mydict["category"]))
         if category.empty:
             uiAccesories.showMessage(self.name+" Update error", "No category with this name "+(mydict['category'])+"!")
             return                
         mydict["category_id"] = category['id']
         del mydict["category"]           
     
     #update db from mydict
     db.update_from_dict(self.name, mydict)
コード例 #9
0
 def sDeleteAll(self):
     
     #title
     title = "Table '"+self.name + "' Delete"
     
     #confirm dialog and delete
     if (uiAccesories.showMessage(title, "Are you sure you want to delete table '"+self.name+"' ?", msgtype = MSGTYPE.warning_dialog)):
         self.deleteAll()  
         return True
     return False                                                                    
コード例 #10
0
ファイル: MenusBars.py プロジェクト: meloun/ew_aplikace
    def sPortConnect(self):
        """
        connect/disconnect => create/kill communication thread
        """

        import ewitis.comm.manage_comm as manage_comm

        title = "Port connect"

        # comm runs?
        if dstore.Get("port")["opened"] == True:

            # KILL COMMUNICATION - thread, etc..
            dstore.SetItem("port", ["opened"], False)
            uiAccesories.showMessage(title, dstore.Get("port")["name"] + " disconnected", MSGTYPE.statusbar)
        else:
            uiAccesories.showMessage(title, dstore.Get("port")["name"] + " connected", MSGTYPE.statusbar)
            # CREATE COMMUNICATION - thread, etc..

            self.myManageComm = manage_comm.ManageComm(dstore)
            self.myManageComm.start()

            # wait to stable shared memory
            time.sleep(0.2)

            # already connected?
            # flag down => cant connect
            if dstore.Get("port")["opened"] == False:
                title = "Port connect"
                uiAccesories.showMessage(title, dstore.Get("port")["name"] + " cant connect")

        self.Update()
コード例 #11
0
ファイル: MenusBars.py プロジェクト: meloun/ew_aplikace
    def sPortSet(self):
        """
        set the port
        """

        import libs.comm.serial_utils as serial_utils

        # dostupne porty
        ports = []
        title = "Port Set"

        try:
            for p in serial_utils.enumerate_serial_ports():
                ports.append(p)
        except:
            uiAccesories.showMessage(title, "No serial port available.")
            return

        if ports == []:
            uiAccesories.showMessage(title, "No serial port available.")
            return

        ports = sorted(ports)

        item, ok = QtGui.QInputDialog.getItem(appWindow, "Serial Port", "Serial Port:", ports, 0, False)

        if ok and item:
            dstore.SetItem("port", ["name"], str(item))
            uiAccesories.showMessage(title, str(item), MSGTYPE.statusbar)

        self.Update()
コード例 #12
0
ファイル: dfTableTimes.py プロジェクト: meloun/ew_aplikace
 def sCivilsToZeroes(self):
     if (uiAccesories.showMessage("Civils to zeroes", "Are you sure you want to set civils numbers to zeroes?", MSGTYPE.warning_dialog) != True):            
         return
     print "A: Times: Civils to zeroes.. "
     query = \
             " UPDATE times" +\
                 " SET user_id=0, time1 = Null, lap1 = Null, time2 = Null, lap2 = Null, time3 = Null, lap3 = Null,  time4 = Null, lap4 = Null" +\
                 " WHERE (times.user_id > 100000)"                    
     res = db.query(query)                        
                     
     db.commit()
     eventCalcNow.set()
     print "A: Times: Civils to zeroes.. press F5 to finish"
     return res
コード例 #13
0
ファイル: dfTableTimes.py プロジェクト: meloun/ew_aplikace
    def sRecalculate(self):
        if (uiAccesories.showMessage("Recalculate", "Are you sure you want to recalculate times and laptimes?", MSGTYPE.warning_dialog) != True):            
            return

        query = \
                " UPDATE times" +\
                    " SET time1 = Null, lap1 = Null, time2 = Null, lap2 = Null, time3 = Null, lap3 = Null,  time4 = Null, lap4 = Null"

        res = db.query(query)

        #self.ResetStatus() 

        db.commit()
        eventCalcNow.set()
        print "A: Times: Recalculating.. press F5 to finish"
        return res                    
コード例 #14
0
 def sRecalculate(self, run_id):
     if (uiAccesories.showMessage("Recalculate", "Are you sure you want to recalculate times and laptimes? \n (only for the current run) ", MSGTYPE.warning_dialog) != True):            
         return
     print "A: Times: Recalculating.. run id:", run_id
     query = \
             " UPDATE times" +\
                 " SET time1 = Null, lap1 = Null, time2 = Null, lap2 = Null, time3 = Null, lap3 = Null,  time4 = Null, lap4 = Null" +\
                 " WHERE (times.run_id = \""+str(run_id)+"\")"
                     
     res = db.query(query)
             
     #self.ResetStatus() 
                     
     db.commit()
     eventCalcNow.set()
     print "A: Times: Recalculating.. press F5 to finish"
     return res                    
コード例 #15
0
ファイル: dfTableTimes.py プロジェクト: meloun/ew_aplikace
    def checkChangedNumber(self, tabRow):
        '''ZMĚNA ČÍSLA'''
        '''- kontrola uživatele, categorie, tagu                                
           - vrací user_id!!
        '''
        #print "checkChangedNumber", tabRow
                                                                                                                                                                                                                                                   
        if(tabRow["nr"] == 0):
            user_id = 0
        else:
                        
            #rigthts to change start cell?
            if(tabRow['cell'] == 1) and (dstore.GetItem("racesettings-app" ,["evaluation", "starttime"]) == StarttimeEvaluation.VIA_CATEGORY):                                                              
                uiAccesories.showMessage(self.name+" Update error", "Cannot assign user to start time!")
                return None
                                        
            #user exist?            
            user = tableUsers.model.getUserParNr(int(tabRow['nr']))            
            #user_id = tableUsers.model.getIdOrTagIdParNr(tabRow['nr'])                                                           
            if user == None:
                uiAccesories.showMessage(self.name+" Update error", "User nr. "+ str(tabRow['nr'])+" not found !")                
                QtCore.QTimer.singleShot(100, lambda: self.table.Edit())
                return None
            
            #category exist?                                                                                              
            category = tableCategories.model.getCategoryParName(user['category'])                        
            if category.empty:
                uiAccesories.showMessage(self.name+" Update error", "Category not found " + user['category'])
                return None 
            
            #user id exist?                                        
            user_id = tableUsers.model.getIdOrTagIdParNr(user['nr'])                                                                                                                 
            if user_id == None:
                uiAccesories.showMessage(self.name+": Update error", "No user or tag with number "+str(tabRow['nr'])+"!")                                                                         
                return None                                                                                                                                                                                                                                             

                                                                                                                                                                                                                                    
        return user_id
コード例 #16
0
 def sDelete(self, label=""):                
     
     #title
     title = "Table '"+self.name + "' Delete"
                     
     #get selected id
     try:                     
         rows = self.gui['view'].selectionModel().selectedRows()                        
         id = self.proxy_model.data(rows[0]).toInt()[0]
     except:
         uiAccesories.showMessage(title, "Nelze smazat")
         return
         
     #confirm dialog and delete
     if (label != ""):
         label="\n\n("+label+")"        
     if (uiAccesories.showMessage(title, "Are you sure you want to delete 1 record from table '"+self.name+"' ? \n (id="+str(id)+")"+label, MSGTYPE.warning_dialog)):
         if(self.sDeletePreCallback(id)):                        
             self.delete(id)
             uiAccesories.showMessage(title, "succesfully (id="+str(id)+")", MSGTYPE.statusbar)
         else:
             uiAccesories.showMessage(title, "Nelze smazat")                                                                                            
コード例 #17
0
ファイル: dfTable.py プロジェクト: meloun/ew_aplikace
    def sExport(self, mode, dialog):
        
        print "I: ", self.name, ": export"

        if (mode == self.eTABLE):                
            format = "Csv"            
        elif mode == self.eWWW:
            format = "Htm"  
        elif mode == self.eDB:
            format = "Db"          
        else:
            print "sExport: ERROR"
            
                
        '''get filename, gui dialog, save path to datastore'''                        
        if dialog:
            print "as", "dir_export_"+format.lower()         
            filename = uiAccesories.getSaveFileName("Export table "+self.name+" to "+format.upper(),"dir_export_"+format.lower(), format.upper()+" Files (*."+format.lower()+")", self.name+"."+format.lower())
        else:
            filename = utils.get_filename("export/"+format.lower()+"/"+self.name+"_"+dstore.GetItem("racesettings-app",['race_name'])+"."+format.lower())
                     
        if(filename == ""):
            return                
                
        title = "Table '"+self.name + "'"+format.upper()+" Export"                        
                
        '''Write to the file'''
        if format == "Csv":
            
            #export times (with collumn's names)            
            try:
                self.model.df.to_csv(filename, ";", mode="w", index = False, encoding = "utf8", float_format = "%g")                
            except IOError:
                uiAccesories.showMessage(self.name+" Export warning", "File "+filename+"\nPermission denied!")                                                                                
        elif format == "Htm":                    
            '''Write to HTML file'''            
            try:                                                                
                html_page = ew_html.Page_table(filename, title = dstore.GetItem("racesettings-app", ['race_name']), styles= ["css/results.css",], lists = exportRows, keys = exportHeader)
                html_page.save()                             
                uiAccesories.showMessage(title, "Succesfully ("+filename+") : "+ time.strftime("%H:%M:%S", time.localtime()), msgtype = MSGTYPE.statusbar)            
            except IOError:            
                uiAccesories.showMessage(title, "NOT succesfully \n\nCannot write into the file ("+filename+")")                                           
コード例 #18
0
ファイル: dfTableTimes.py プロジェクト: meloun/ew_aplikace
 def sExportDirect(self, export_type = eCSV_EXPORT):             
     
     #ret = uiAccesories.showMessage("Results Export", "Choose format of results", MSGTYPE.question_dialog, "NOT finally results", "Finally results")                        
     #if ret == False: #cancel button
     #    return 
 
     #take last calculated data
     #self.Update()
     
     # 3DFs for 3 exports
     exportDf = [pd.DataFrame()] * NUMBER_OF.EXPORTS        
     exported = {}
     ttDf = self.model.GetDataframe() #self.model.df      
     utDf = pd.DataFrame()
     if len(ttDf) != 0:                       
         #merge table users and times
         cols_to_use = tableUsers.model.df.columns.difference(self.model.df.columns)        
         cols_to_use = list(cols_to_use) + ["nr"]
         #print "cols_to_use",cols_to_use       
         utDf = pd.merge(ttDf, tableUsers.model.df[cols_to_use], how = "left", on="nr")
         #print "cols_to_use",utDf.columns            
     
     if (len(ttDf) != 0) or (export_type == ttExport.eHTM_EXPORT_LOGO):   
         #call export function
         try:            
             exported = ttExport.Export(utDf, export_type)
         except IOError:                            
             uiAccesories.showMessage("Export", time.strftime("%H:%M:%S", time.localtime())+" :: NOT succesfully, cannot write into the file.", MSGTYPE.statusbar)
             return
     
     exported_string = ""        
     for key in sorted(exported.keys()):
         exported_string += key + " : " + str(exported[key])+" times\n"
            
     if export_type == ttExport.eHTM_EXPORT or export_type == ttExport.eHTM_EXPORT_LOGO:                        
         uiAccesories.showMessage("WWW Export", time.strftime("%H:%M:%S", time.localtime())+" :: exported "+exported_string, MSGTYPE.statusbar)
     else:
         uiAccesories.showMessage("Table Times Exported", exported_string, MSGTYPE.info)
              
     return                      
コード例 #19
0
    def Update(self):  
        #self.lineCellSynchronizedOnce.setStyleSheet("background:"+COLORS.green)
        
        css_string = ""      
        
        #enable/disable items in cell toolbar 
        if(dstore.GetItem("racesettings-app", ['rfid']) == 2):
            '''RFID RACE'''
            
            #enable 'generate celltime' for START and FINISH
            for i, cell_actions in enumerate(self.cells_actions):
                for key, action in cell_actions.items():                    
                    if (i==0 or i==5) and (key == 'generate_celltime') and dstore.Get("port")["opened"]:                    
                        action.setEnabled(True)
                    else:
                        action.setEnabled(False)                    
        else:
            '''IR'''                                     
            for i, cell_actions in enumerate(self.cells_actions):
                                            
                #convert index to task nr
                i = self.Collumn2TaskNr(i)
                
                cell = tabCells.GetCellParTask(i)            
                if cell != None and dstore.Get("port")["opened"]:
                   
                    #get info
                    info = cell.GetInfo()
                                         
                    # PING, set bold if cell active
                    if info['active']:                    
                        font = cell_actions['ping_cell'].font()
                        font.setBold(True)
                        font.setUnderline(True)
                        cell_actions['ping_cell'].setFont(font)                        
                        css_string = css_string + "QToolButton#w_ping_cell"+str(i)+"{ background:"+COLORS.green+"; }"
                                            
                    else:
                        font = cell_actions['ping_cell'].font()
                        font.setBold(False)
                        font.setUnderline(False)
                        cell_actions['ping_cell'].setFont(font)
                        css_string = css_string + "QToolButton#w_ping_cell"+str(i)+"{ background:"+COLORS.red+"; }"                        
                                                                                                
                        
                    
                    # enable/disable all actions
                    if(info['trigger'] == 3): #MANUAL
                        cell_actions['ping_cell'].setEnabled(False)
                        cell_actions['enable_cell'].setEnabled(False)
                        cell_actions['disable_cell'].setEnabled(False)
                        cell_actions['generate_celltime'].setEnabled(True)
                    else:
                        for key, action in cell_actions.items():                                                                
                            action.setEnabled(True)
                        
                else:
                    #DISABLE all actions, cell not configured or no connection with device
                    for key, action in cell_actions.items(): 
                        action.setEnabled(False)
                                    
                         
            #background to the toolbars
            hw_status = self.GetHwStatus()   
            app_status = self.GetAppStatus()                      
            self.toolbar_ping.setStyleSheet(css_string) #cell enabled => green, bold
            #self.toolbar_enable.setStyleSheet("QToolButton#w_check_hw{ background:"+BarCellActions.STATUS_COLOR[hw_status]+"; }")
            #self.toolbar_generate.setStyleSheet("QToolButton#w_check_app{ background:"+BarCellActions.STATUS_COLOR[app_status]+"; }")
            
           
            self.toggle_status = self.toggle_status + 1                            
            if self.toggle_status == 2:
                if app_status != STATUS.ok:
                    app_status = STATUS.none
                if hw_status != STATUS.ok:
                    hw_status = STATUS.none                
                self.toggle_status = 0
                            
            self.toolbar_generate.setStyleSheet("QToolButton#w_check_app{ background:"+BarCellActions.STATUS_COLOR[app_status]+"; }")
            self.toolbar_enable.setStyleSheet("QToolButton#w_check_hw{ background:"+BarCellActions.STATUS_COLOR[hw_status]+"; }")

            
#             font = self.check_app.font()
#             font.setItalic(not font.italic())
#             self.check_app.setFont(font)               
            
        #enabled only when blackbox is connected
        if dstore.Get("port")["opened"]:            
            Ui().aClearDatabase.setEnabled(True)
            Ui().aQuitTiming.setEnabled(True)
        else:
            Ui().aQuitTiming.setEnabled(False)
            Ui().aClearDatabase.setEnabled(False)
            
        #asynchron messages
        if self.clear_database_changed:
            if(dstore.IsChanged("clear_database") == False):
                uiAccesories.showMessage("Clear Database", "Database is empty now", msgtype = MSGTYPE.statusbar)
                self.clear_database_changed = False
コード例 #20
0
 def sClearDatabase(self):
     if (uiAccesories.showMessage("Clear Database", "Are you sure you want to clear all database?\n It will take 20 seconds.\n ", msgtype = MSGTYPE.warning_dialog) != True):            
         return        
     uiAccesories.showMessage("Clear Database", "clearing database, please wait.. it will take 20 seconds.", msgtype = MSGTYPE.statusbar)                                                                                                                                                                                            
     dstore.Set("clear_database", 0x00, "SET")
     self.clear_database_changed = True
コード例 #21
0
    def Update(self):
        
        #get cell info from datastore                                      
        get_info = self.GetInfo()
        set_info = self.SetInfo()
        port_open = dstore.Get("port")["opened"]
        
        #wait for establish new values after connect
        if port_open:
            if self.timer_nodialog != 0:
                self.timer_nodialog = self.timer_nodialog -1                
        else:
            self.timer_nodialog = CellGroup.TIMER_NODIALOG_INIT

        #set enabled        
        if(port_open ==False) or (get_info['task'] == None) or (get_info['task'] == 0):
            self.SetEnabled(False, port_open)
        else: 
            self.SetEnabled(True, port_open)                    
        
        #task
        index = self.TaskNr2Idx(get_info["task"])        
        if(get_info['task'] != None):
            self.lineCellTask.setText(self.comboCellTask.itemText(index))
        else:
            self.lineCellTask.setText(" - - - ")                                    
        colors_enabled =  get_info['task']
        self.lineCellTask.setStyleSheet("background:"+COLORS.GetColor(self.lineCellTask.text(), get_info['task']))        
                    
            
        #trigger                            
        if(get_info['trigger'] != None):
            self.lineCellTrigger.setText(self.comboCellTrigger.itemText(get_info['trigger']))
        else:
            self.lineCellTrigger.setText(" - - - ")
        self.lineCellTrigger.setStyleSheet("background:"+COLORS.GetColor(self.lineCellTrigger.text(), get_info['task']))                    
                               
        #synchronize comboboxes with GET value (after timeout)
        if self.timer_nochange == 0:                 
            
            task_index = self.TaskNr2Idx(get_info["task"])
            if task_index:
                if(task_index != self.comboCellTask.currentIndex()) and port_open and (self.timer_nodialog==0):
                    uiAccesories.showMessage("Cell Update error", "Cannot assign this task!")           
                self.comboCellTask.setCurrentIndex(task_index)
            else:
                self.comboCellTask.setCurrentIndex(0) #get value None <= "- - -"
            
            if get_info["trigger"] != None:
                if(get_info["trigger"] != self.comboCellTrigger.currentIndex()) and port_open and (self.timer_nodialog==0):                 
                    uiAccesories.showMessage("Cell Update error", "Cannot assign this trigger!")  
                self.comboCellTrigger.setCurrentIndex(get_info["trigger"])
            else:                
                self.comboCellTrigger.setCurrentIndex(0)  #get value None <= "- - -"
        else:
            self.timer_nochange = self.timer_nochange - 1            
        
        
                                    
        
        #battery
        if(get_info['battery'] != None):
            self.lineCellBattery.setText(str(get_info['battery']))                        
        else:
            self.lineCellBattery.setText("0")
        self.lineCellBattery.setStyleSheet("background:"+self.GetColorParBattery(get_info["battery"], colors_enabled))
                                                                                          
        
        #ir signal                
        if get_info["ir_signal"] == True:
            self.lineCellIrSinal.setText("IR SIGNAL")
        elif get_info["ir_signal"] == False:
            self.lineCellIrSinal.setText("NO IR SIGNAL")
        else:
            self.lineCellIrSinal.setText(" - - ")        
        self.lineCellIrSinal.setStyleSheet("background:"+COLORS.GetColor(get_info["ir_signal"], colors_enabled))

        #active/blocked            
        if get_info["active"] == True:
            self.lineCellActive.setText("ACTIVE")
        elif get_info["active"] == False:
            self.lineCellActive.setText("BLOCKED")
        else:
            self.lineCellActive.setText(" - - ")
        self.lineCellActive.setStyleSheet("background:"+COLORS.GetColor(get_info["active"], colors_enabled))
            
        #synchronized once
        if get_info["synchronized_once"] == True:
            self.lineCellSynchronizedOnce.setText("ONCE")
            self.lineCellSynchronizedOnce.setStyleSheet("background:"+COLORS.green)
        elif get_info["synchronized_once"] == False:
            self.lineCellSynchronizedOnce.setText("ONCE")
            self.lineCellSynchronizedOnce.setStyleSheet("background:grey"+COLORS.red)
        else:
            self.lineCellSynchronizedOnce.setText(" - - ")
            self.lineCellSynchronizedOnce.setStyleSheet("")
        self.lineCellSynchronizedOnce.setStyleSheet("background:"+COLORS.GetColor(get_info["synchronized_once"], colors_enabled))
        
        #synchronized 10min
        if get_info["synchronized"] == True:
            self.lineCellSynchronized.setText("10MIN")            
        elif get_info["synchronized"] == False:
            self.lineCellSynchronized.setText("10MIN")            
        else:
            self.lineCellSynchronized.setText(" - - ")                    
        self.lineCellSynchronized.setStyleSheet("background:"+COLORS.GetColor(get_info["synchronized"], colors_enabled))                       
        
        #diagnostic shork ok
        if(get_info['diagnostic_short_ok'] != None):                                    
            self.lineCellDiagShortOk.setText(str(get_info['diagnostic_short_ok']))
        else:
            self.lineCellDiagShortOk.setText("- -")
                                          
        #diagnostic short ko
        if(get_info['diagnostic_short_ko'] != None):                                    
            self.lineCellDiagShortKo.setText(str(get_info['diagnostic_short_ko']))
        else:
            self.lineCellDiagShortKo.setText("- -")            
        #diagnostic %
        sum_ko_ok = get_info['diagnostic_short_ko']+get_info['diagnostic_short_ok']
        if(get_info['diagnostic_short_ok'] != None) and (get_info['diagnostic_short_ko'] != None) and (sum_ko_ok != 0):                                    
            self.lineCellDiagShortRatio.setText(str((100*get_info['diagnostic_short_ok'])/sum_ko_ok))
        else:
            self.lineCellDiagShortRatio.setText("- -")
            
        #diagnostic shork ok
        if(get_info['diagnostic_long_ok'] != None):                                    
            self.lineCellDiagLongOk.setText(str(get_info['diagnostic_long_ok']))
        else:
            self.lineCellDiagLongOk.setText("- -")
                                          
        #diagnostic long ko
        if(get_info['diagnostic_long_ko'] != None):                                    
            self.lineCellDiagLongKo.setText(str(get_info['diagnostic_long_ko']))
        else:
            self.lineCellDiagLongKo.setText("- -")            
        #diagnostic %
        sum_ko_ok = get_info['diagnostic_long_ko']+get_info['diagnostic_long_ok']
        if(get_info['diagnostic_long_ok'] != None) and (get_info['diagnostic_long_ko'] != None) and (sum_ko_ok != 0):                                    
            self.lineCellDiagLongRatio.setText(str((100*get_info['diagnostic_long_ok'])/sum_ko_ok))
        else:
            self.lineCellDiagLongRatio.setText("- -")
コード例 #22
0
 def sQuitTiming(self):
     if (uiAccesories.showMessage("Quit Timing", "Are you sure you want to quit timing? \n ", msgtype = MSGTYPE.warning_dialog) != True):            
         return
     print "A: Generate quit time"                                                                                                                                                                                            
     dstore.Set("quit_timing", 0x00, "SET")
コード例 #23
0
ファイル: dfTableTimes.py プロジェクト: meloun/ew_aplikace
    def setDataFromDict(self, mydict):
        print "setDataFromDict()", mydict, self.name
                        
        #dict => df
        dfChange = pd.DataFrame([mydict])
        dfChange.set_index(dfChange.id, inplace=True)                   
                       
        #take row before change (from global df)
        dfChangedRow = self.df.loc[dfChange.id]
        #take user before change                                                        
        old_user = tableUsers.model.getUserParNr(int(dfChangedRow['nr']))
               
        #update row before change with change                 
        dfChangedRow.update(dfChange)        
        
        #category changed        
        if "nr" in mydict:            
                                                                        
            user_id = self.checkChangedNumber(dfChangedRow.iloc[0])                                                                                            
            if user_id == None: #dialog inside checkChangedNumber()
                return False
            
            #adjust dict for writing to db
            mydict["user_id"] = user_id
            if mydict["nr"] < 0:                       
                mydict["us1"] = "Civil #"+str(abs(mydict["nr"]))
            del mydict["nr"]                            
                                         
        elif "cell" in mydict:                                                                      
            pass
                      
        # TIMERAW column
        elif "timeraw" in mydict:   
                              
            try:
                dbTimeraw = TimesUtils.TimesUtils.timestring2time(mydict['timeraw'])
            except TimesUtils.TimeFormat_Error:
                uiAccesories.showMessage(self.name+" Update error", "Wrong Time format!")
                return False
            
            #adjust dict for writing to db
            mydict["time_raw"] = dbTimeraw
            del mydict["timeraw"]            

            #change the state (C -> manually Changed)            
            state = str(dfChangedRow.iloc[0]['state'])         
            mydict["state"] = "C" + state[1] + state[2]            
            

        elif "un1" in mydict:
            pass 
        elif "un2" in mydict:
            pass 
        elif "un3" in mydict:
            pass 
        elif "us1" in mydict:
            pass 
        else:
            uiAccesories.showMessage(self.name+" Update error", "Unexpecting change!")
            return False                                                                                         
                                    
        # add changed row to "changed_rows"
        # keep as dataframe otherwise float issues for "nr" and "cell"
        cleared = self.ClearCalculated(dfChangedRow.iloc[0].copy())                                                                                
        self.changed_rows = self.changed_rows.append(cleared)
        try:
            self.changed_rows["nr"] = int(self.changed_rows["nr"])                           
            self.changed_rows["cell"] = int(self.changed_rows["cell"])                           
        except:
            pass        
        eventCalcReady.clear() #s                                 
                                                                                            
        #update db from mydict            
        db.update_from_dict(self.name, mydict)
        
        #user changed => reset all times for new user
        if mydict and ("user_id" in mydict):
            #print "mazu vsechny1", mydict["user_id"]
            self.ResetCalculatedValuesForUser(mydict["user_id"])        

        #reset 1 time
        elif mydict and ("id" in mydict):
            #print "mazu neco", mydict["id"]
            self.ResetCalculatedValues(mydict["id"])
        
        if old_user and ("id" in old_user):
            print "mazu vsechny2", old_user["id"]
            self.ResetCalculatedValuesForUser(old_user["id"])
                
        #self.ResetNrOfLaps()  
        eventCalcNow.set()
        return True