File update interval switched to NumericProperty; changed do_update on PlotWidget to run a scheduled clock interval, default to every 5 seconds
This commit is contained in:
parent
974a189e52
commit
babac7ae2e
18
main.py
18
main.py
|
@ -376,6 +376,9 @@ class PlotWidget(Image):
|
|||
show_protease = BooleanProperty(True)
|
||||
show_betaamylase = BooleanProperty(True)
|
||||
show_alphaamylase = BooleanProperty(True)
|
||||
file_write_interval = NumericProperty(15)
|
||||
image_update_interval = NumericProperty(5)
|
||||
|
||||
|
||||
# Common data that we should only instantiate once
|
||||
# Source : http://www.howtobrew.com/section3/chapter14-1.html
|
||||
|
@ -402,9 +405,16 @@ class PlotWidget(Image):
|
|||
self.image_data = None
|
||||
self._image_raw_data = None
|
||||
self.reference_profile = None
|
||||
Clock.schedule_interval(self.do_update, self.image_update_interval)
|
||||
self.do_update()
|
||||
|
||||
|
||||
def on_image_update_interval(self, *args):
|
||||
# Reschedule the update function.
|
||||
Clock.unschedule(self.do_update, True)
|
||||
Clock.schedule_interval(self.do_update, self.image_update_interval)
|
||||
|
||||
|
||||
def update_patches(self, tmax = None):
|
||||
items = [
|
||||
(self.show_betaglucan, self.betaglucan_vertices),
|
||||
|
@ -444,7 +454,7 @@ class PlotWidget(Image):
|
|||
self.do_update()
|
||||
|
||||
|
||||
def do_update(self):
|
||||
def do_update(self, *args):
|
||||
image_data = self.to_image_data()
|
||||
# We can't use ImageLoaders since they assume it's a file on disk.
|
||||
# This replicates code from ImageLoaderPygame.load() and ImageLoaderBase.populate()
|
||||
|
@ -466,6 +476,7 @@ class PlotWidget(Image):
|
|||
# @TODO Add in an update interval so the disk isn't hammered on every single update
|
||||
self.update_output_files()
|
||||
|
||||
|
||||
def to_image_data(self):
|
||||
# Add in polygons for hilightning particular temperature ranges of interest.
|
||||
plot_args = []
|
||||
|
@ -515,7 +526,7 @@ class PlotWidget(Image):
|
|||
def update_output_files(self, force = False):
|
||||
# Do this only once every 15 seconds to avoid hitting the disk frequently
|
||||
Logger.debug('update_output_files called')
|
||||
if force or time.time() - self.lastSave > 15:
|
||||
if force or time.time() - self.lastSave > self.file_write_interval:
|
||||
Logger.debug('update_output_files going ahead')
|
||||
self.update_raw_data_output_file()
|
||||
self.update_image_output_file()
|
||||
|
@ -559,13 +570,12 @@ class PlotWidget(Image):
|
|||
#Logger.debug('self.data: ' + str(self.data))
|
||||
#Logger.debug('newpoint: ' + str(newpoint))
|
||||
self.data = numpy.vstack((self.data, newpoint))
|
||||
self.do_update()
|
||||
|
||||
|
||||
def on_reference_profile_file(self, *args, **kwargs):
|
||||
Logger.debug('PlotWidget: on_reference_profile_file ' + str(self.reference_profile_file))
|
||||
self.load_reference_profile()
|
||||
self.do_update()
|
||||
Clock.schedule_once(self.do_update)
|
||||
|
||||
|
||||
def load_reference_profile(self):
|
||||
|
|
Loading…
Reference in New Issue