Skip to content

Commit

Permalink
Disable DB queries in GUI when a window is hidden. Partially addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
abalijepalli committed Aug 23, 2016
1 parent 57be122 commit 55a781a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 21 deletions.
1 change: 1 addition & 0 deletions mosaic/process/metaEventProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def __init__(self, icurr, Fs, **kwargs):
# Setup function timing
self.timingObj=mosaicTiming.mosaicTiming()

self.mdEventProcessTime=0.0
# print self.settingsDict
# Call sub-class initialization
self._init(**kwargs)
Expand Down
29 changes: 16 additions & 13 deletions mosaicgui/blockdepthview/blockdepthview.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
import gc
import csv
import time
# import time
import sqlite3
from scipy import signal

Expand All @@ -16,6 +16,7 @@
import mosaicgui.autocompleteedit as autocomplete
import mosaicgui.sqlQueryWorker as sqlworker
from mosaic.utilities.resource_path import resource_path, last_file_in_directory
import mosaic.utilities.mosaicTiming as mosaicTiming
import matplotlib.ticker as ticker

css = """QLabel {
Expand All @@ -33,11 +34,13 @@ def __init__(self, parent = None):

self._positionWindow()

self.queryInterval=15
self.lastQueryTime=round(time.time())
self.time=mosaicTiming.mosaicTiming()

self.queryInterval=5
self.lastQueryTime=round(self.time.time())

self.idleTimer=QtCore.QTimer()
self.idleTimer.start(5000)
self.idleTimer.start(3000)

self.queryString="select BlockDepth from metadata where ProcessingStatus='normal'and ResTime > 0.025"
self.queryData=[]
Expand Down Expand Up @@ -189,7 +192,7 @@ def update_graph(self):

# Once the canvas is updated flag the query as complete
self.queryRunning=False
self.lastQueryTime=round(time.time())
self.lastQueryTime=round(self.time.time())
self._updateButtonEnabled(True)
except ValueError:
pass
Expand Down Expand Up @@ -239,14 +242,13 @@ def _ticks(self, nticks):
axes.yaxis.set_major_formatter(ticker.FormatStrFormatter('%d'))

def _updatequery(self):
# if self.queryRunning:
# return
print self.isHidden()
if self.isHidden():
return

self.qThread.start()
# print "update query: ", self.queryString
QtCore.QMetaObject.invokeMethod(self.qWorker, 'queryDB', Qt.QueuedConnection, QtCore.Q_ARG(str, self.queryString) )

# print "_updatequery"
self.queryRunning=True
self._updateButtonEnabled(False)

Expand All @@ -260,7 +262,6 @@ def _updateButtonEnabled(self, value):

def _decode(self, queryres):
try:
print queryres
return [ base64.b64decode(q) for q in queryres ]
except:
return queryres
Expand Down Expand Up @@ -333,22 +334,24 @@ def OnAppIdle(self):
if not self.updateDataOnIdle:
return

t1=round(time.time())
t1=round(self.time.time())
if not self.queryRunning and t1-self.lastQueryTime >= self.queryInterval:
# self.lastQueryTime=t1
# print "update", t1, self.lastQueryTime, t1-self.lastQueryTime
self._updatequery()

def OnProcessEvents(self):
pass
# QtGui.QApplication.sendPostedEvents()

if __name__ == '__main__':
dbfile=resource_path('eventMD-PEG29-Reference.sqlite')
# dbfile=resource_path('eventMD-PEG28-ADEPT2State.sqlite')
dbfile="/Users/arvind/Desktop/test/testdb.sqlite"
# dbfile=resource_path('tempMSA.sqlite')

app = QtGui.QApplication(sys.argv)
dmw = BlockDepthWindow()
dmw.openDBFile(dbfile)
dmw.openDBFile(dbfile, True)

dmw.show()
dmw.raise_()
Expand Down
10 changes: 3 additions & 7 deletions mosaicgui/fiteventsview/fiteventsview.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
import matplotlib.ticker as ticker
# from mosaicgui.trajview.trajviewui import Ui_Dialog

css = """QLabel {
color: FireBrick;
}"""
css_warning = """QLabel {
color: OrangeRed;
}"""

class FitEventWindow(QtGui.QDialog):
def __init__(self, parent = None):
self.v=[]
Expand Down Expand Up @@ -287,6 +280,9 @@ def _ticks(self, nticks):
axes.yaxis.set_major_formatter(ticker.FormatStrFormatter('%d'))

def _updatequery(self):
if self.isHidden() and self.updateDataOnIdle:
return

try:
if not self.EndOfData:
self.queryData=self.queryDatabase.queryDB(self.queryString)
Expand Down
2 changes: 1 addition & 1 deletion mosaicgui/sqlQueryWorker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, dbfile, **kwargs):
@QtCore.pyqtSlot(bool)
def dbColumnNames(self, filterRealList):
self.queryDatabase=sqlite.sqlite3MDIO()
self.queryDatabase.openDB(self.dbFile)
self.queryDatabase.openDB(self.dbFile, timeout=3.0)
if filterRealList:
self.dbColumnsReady.emit( [ col[0] for col in zip( self.queryDatabase.mdColumnNames, self.queryDatabase.mdColumnTypes ) if col[1] != 'REAL_LIST' ] )
else:
Expand Down
7 changes: 7 additions & 0 deletions mosaicgui/statisticsview/statisticsview.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def __init__(self, parent = None):
self.qWorker=None
self.qThread=QtCore.QThread()

self.queryRunning=False

# Set QLabel properties
self.neventsLabel.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
self.errorrateLabel.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
Expand Down Expand Up @@ -127,6 +129,9 @@ def _createDBIndex(self, dbfile):
db.close()

def _updatequery(self):
if self.isHidden() and self.updateDataOnIdle:
return

self.qThread.start()
QtCore.QMetaObject.invokeMethod(self.qWorker, 'queryDB2', Qt.QueuedConnection,
QtCore.Q_ARG(str, self.queryString),
Expand Down Expand Up @@ -251,6 +256,8 @@ def _parseanalysislog(self):
def OnAppIdle(self):
if not self.updateDataOnIdle:
return
if self.isHidden():
return

if not self.queryRunning:
self._updatequery()
Expand Down

0 comments on commit 55a781a

Please sign in to comment.