From 04b824d0527b173056cfc81543cf51a32513fa96 Mon Sep 17 00:00:00 2001
From: Stephan Philips <s.g.j.philips@tudelft.nl>
Date: Wed, 28 Oct 2020 23:07:01 +0100
Subject: [PATCH] fixes

---
 core_tools/GUI/virt_gate_matrix/hw.bak        |   2 +
 core_tools/GUI/virt_gate_matrix/hw.dat        | Bin 0 -> 1678 bytes
 core_tools/GUI/virt_gate_matrix/hw.dir        |   2 +
 core_tools/data/SQL/SQL_commands.py           |  10 +-
 core_tools/data/SQL/SQL_database_mgr.py       |   7 +-
 core_tools/data/SQL/SQL_measurment_queries.py |  40 +-
 core_tools/data/SQL/buffer_writer.py          |  16 +-
 core_tools/data/ds/data_set_core.py           |   8 +-
 core_tools/data/gui/data_browser.py           | 379 ++++++++++--------
 .../result_table_data_class.py                |   6 +-
 core_tools/data/gui/plot_mgr.py               |  34 +-
 core_tools/data/gui/plots/_2D_plotting.py     |   8 +-
 core_tools/data/measurement.py                |  20 +-
 setup.py                                      |   5 +-
 14 files changed, 294 insertions(+), 243 deletions(-)
 create mode 100644 core_tools/GUI/virt_gate_matrix/hw.bak
 create mode 100644 core_tools/GUI/virt_gate_matrix/hw.dat
 create mode 100644 core_tools/GUI/virt_gate_matrix/hw.dir

diff --git a/core_tools/GUI/virt_gate_matrix/hw.bak b/core_tools/GUI/virt_gate_matrix/hw.bak
new file mode 100644
index 00000000..5351f0bf
--- /dev/null
+++ b/core_tools/GUI/virt_gate_matrix/hw.bak
@@ -0,0 +1,2 @@
+'general', (0, 647)
+'eps matrix', (1024, 654)
diff --git a/core_tools/GUI/virt_gate_matrix/hw.dat b/core_tools/GUI/virt_gate_matrix/hw.dat
new file mode 100644
index 0000000000000000000000000000000000000000..c388a999d5baa512e55df22dc5e32cb7e113878b
GIT binary patch
literal 1678
zcmeH{yH3L}6o!*tD1=Laa=#X)utYRvU_e5m8<8r+fU=;-P2CcyN&7nv&;h9ofOs<=
zhc^JXb`eMn9YA8hgYzfnPvUcq{q@rRh3&=d2EQSUT6Gp&Qx;p-0pkg2c}>D;Yz0xw
zSrXESdqcw&Vf`13&qf2<-aYg?q)a!XX<9@=inN;(vPmP#NDCP^FYXvspZ5Be7}-mV
znQlr%PWF+LqJ(iNY)nW|h9SiPCaGHx?$1B>Lc&>aizz=!!cN!n+ajGXY4LzCM!JT_
zsNWvs;d2Ai(q%+-8O4mFJs@AvYnXk)+&Sh=M|ZML_7MeTt@Cb&8dw;tp>c>sM|1Qi
zES+Q7bkeRa)^miFYPEX$CdOcLG>+BUbLB<E#CScH*HP!c=f@hydd-~|8GNa|Y~#iy
zHcdC(4~jl+DOJL@QZ|Z8m9eAL0d{Fpvqmk+zwd`D(EI)KZ-^z+PFz$6bYujaeITHu
s5O8J>5n%r#;M<Mx`^Xp-0o*SM1Y~9Jy&(j+--p2PsjV=;{j$WsJ522!A^-pY

literal 0
HcmV?d00001

diff --git a/core_tools/GUI/virt_gate_matrix/hw.dir b/core_tools/GUI/virt_gate_matrix/hw.dir
new file mode 100644
index 00000000..5351f0bf
--- /dev/null
+++ b/core_tools/GUI/virt_gate_matrix/hw.dir
@@ -0,0 +1,2 @@
+'general', (0, 647)
+'eps matrix', (1024, 654)
diff --git a/core_tools/data/SQL/SQL_commands.py b/core_tools/data/SQL/SQL_commands.py
index d8f8bc7a..f61c5025 100644
--- a/core_tools/data/SQL/SQL_commands.py
+++ b/core_tools/data/SQL/SQL_commands.py
@@ -102,6 +102,10 @@ class write_query_generator:
 	def get_last_meas_id_in_measurement_table(table_name="global_measurement_overview"):
 		return "SELECT id, uuid FROM {} ORDER BY uuid DESC LIMIT 1;".format(table_name)
 
+	@staticmethod
+	def check_completed_measurement_table(uuid, table_name="global_measurement_overview"):
+		return "SELECT completed FROM {} where uuid = {};".format(table_name, uuid)
+
 	def fill_meas_info_in_measurement_table(meas_uuid, measurement_table_name=None, start_time=None, stop_time=None, metadata=None, snapshot=None, tags= None, completed=None):
 		'''
 		fill in the addional data in a record of the measurements overview table.
@@ -276,7 +280,11 @@ class data_fetch_queries:
 					)
 		cursor = conn.cursor()
 		cursor.execute(statement)
-		data = cursor.fetchone()
+		data = list(cursor.fetchone())
+
+		# dirty fix
+		if data[7] is None:
+			data[7] = data[6]
 
 		ds = data_set_raw(exp_id=data[0], exp_uuid=data[1], exp_name=data[2], 
 			set_up = data[3], project = data[4], sample = data[5], 
diff --git a/core_tools/data/SQL/SQL_database_mgr.py b/core_tools/data/SQL/SQL_database_mgr.py
index ecd93731..38053e0b 100644
--- a/core_tools/data/SQL/SQL_database_mgr.py
+++ b/core_tools/data/SQL/SQL_database_mgr.py
@@ -90,7 +90,7 @@ class SQL_database_manager(SQL_database_init):
 		cur.execute(write_query_generator.update_cursors_in_meas_tab(ds.SQL_datatable, ds.measurement_parameters_raw))
 		self.conn_local.commit()
 
-	def is_running(self, exp_uuid):
+	def is_completed(self, exp_uuid):
 		'''
 		checks if the current measurement is still running
 
@@ -98,6 +98,11 @@ class SQL_database_manager(SQL_database_init):
 			exp_uuid (int) : uuid of the experiment to check
 		'''
 		cur = self.conn_local.cursor()
+		cur.execute(write_query_generator.check_completed_measurement_table(exp_uuid))
+		completed = cur.fetchone()[0]
+		cur.close()
+		
+		return completed
 
 	def finish_measurement(self, ds):
 		'''
diff --git a/core_tools/data/SQL/SQL_measurment_queries.py b/core_tools/data/SQL/SQL_measurment_queries.py
index d864ec8e..4f687764 100644
--- a/core_tools/data/SQL/SQL_measurment_queries.py
+++ b/core_tools/data/SQL/SQL_measurment_queries.py
@@ -125,7 +125,6 @@ class query_for_measurement_results:
 		if words != "":
 			statement += " and exp_name like '%{}%' ".format(words)
 		statement += " ;"
-		print(statement)
 
 		
 		cur = SQL_database_manager().conn_local.cursor()
@@ -135,6 +134,20 @@ class query_for_measurement_results:
 
 		return m_result_overview(res)
 
+	def detect_new_meaurements(n_records=0):
+		statement = "SELECT count(*) from global_measurement_overview;"
+		cur = SQL_database_manager().conn_local.cursor()
+		cur.execute(statement)
+		res = cur.fetchall()
+		cur.close()
+
+		update = False
+		if res[0][0] != n_records:
+			update =True
+			n_records = res[0][0]
+
+		return update, n_records
+
 if __name__ == '__main__':
 	
 	from core_tools.data.SQL.connector import SQL_conn_info_local, SQL_conn_info_remote, sample_info, set_up_local_storage
@@ -148,14 +161,14 @@ if __name__ == '__main__':
 	# print(s)
 	# s = query_for_samples.get_samples(set_up='6dot', project=None)
 	# print(s)
-	import datetime
-	from datetime import date
-	my_date = date.fromisoformat('2020-10-05')
-	print()
-	current_date = datetime.datetime.now()
-	print(current_date - datetime.timedelta(hours=current_date.hour, minutes=current_date.minute,
-    seconds=current_date.second, microseconds=current_date.microsecond) )
-	test_date = datetime.datetime.now()- datetime.timedelta(20)
+	# import datetime
+	# from datetime import date
+	# my_date = date.fromisoformat('2020-10-05')
+	# print()
+	# current_date = datetime.datetime.now()
+	# print(current_date - datetime.timedelta(hours=current_date.hour, minutes=current_date.minute,
+ #    seconds=current_date.second, microseconds=current_date.microsecond) )
+	# test_date = datetime.datetime.now()- datetime.timedelta(20)
 	# a = query_for_measurement_results.get_results_for_date(test_date, sample=None, set_up=None, project='Intel Project', limit=1000)
 	# print(a[0])
 	# print(len(a))
@@ -163,6 +176,9 @@ if __name__ == '__main__':
 	# a = query_for_measurement_results.get_all_dates_with_meaurements(sample=None, set_up=None, project='Intel Project')
 	# print(a)
 
-	a = query_for_measurement_results.search_query(None, None, 'a', None, None, 'Intel Project', None, None)
-	print(a)
-	print(len(a))
\ No newline at end of file
+	# a = query_for_measurement_results.search_query(None, None, 'a', None, None, 'Intel Project', None, None)
+	# print(a)
+	# print(len(a))
+
+	a = query_for_measurement_results.detect_new_meaurements()
+	print(a)
\ No newline at end of file
diff --git a/core_tools/data/SQL/buffer_writer.py b/core_tools/data/SQL/buffer_writer.py
index a2b515f6..79bdb13d 100644
--- a/core_tools/data/SQL/buffer_writer.py
+++ b/core_tools/data/SQL/buffer_writer.py
@@ -115,16 +115,14 @@ class buffer_reader(buffer_reference):
 		'''
 		update the buffer (for datasets that are still being written)
 		'''
-		try:
-			self.lobject.seek(self.cursor*8)
-			binary_data = self.lobject.read()
-			data = np.frombuffer(binary_data)
+		self.lobject = self.conn.lobject(self.oid, 'rb')
+		self.lobject.seek(self.cursor*8)
+		binary_data = self.lobject.read()
+		data = np.frombuffer(binary_data)
+
+		self.buffer[self.cursor:self.cursor+data.size] = data
+		self.cursor = self.cursor+data.size
 
-			self.buffer[self.cursor:self.cursor+data.size] = data
-			self.cursor = self.cursor+data.size
-		except:
-			self.lobject = self.conn.lobject(self.oid, 'rb')
-			self.sync(self.cursor, stop)
 
 
 if __name__ == '__main__':
diff --git a/core_tools/data/ds/data_set_core.py b/core_tools/data/ds/data_set_core.py
index a25c0a49..ce2c638a 100644
--- a/core_tools/data/ds/data_set_core.py
+++ b/core_tools/data/ds/data_set_core.py
@@ -21,7 +21,7 @@ class data_set_desciptor(object):
         return getattr(getattr(obj,"_data_set__data_set_raw"), self.var)
 
 class data_set:
-    running = data_set_desciptor('uploaded_complete')
+    completed = data_set_desciptor('completed')
     
     dbname = data_set_desciptor('dbname')
     table_name = data_set_desciptor('SQL_table_name')
@@ -114,10 +114,10 @@ class data_set:
         '''
         Updates dataset in case only part of the points were downloaded.
         '''
-        if self.running == True:
+        if self.completed == False:
             SQL_mgr = SQL_database_manager()
-            self.running = SQL_mgr.is_running(self.exp_uuid)
-            self.__data_set_raw.sync_buffers(writer_pointers)
+            self.completed = SQL_mgr.is_completed(self.exp_uuid)
+            self.__data_set_raw.sync_buffers()
 
     def __write_to_db(self, force = False):
         '''
diff --git a/core_tools/data/gui/data_browser.py b/core_tools/data/gui/data_browser.py
index 44422b27..ea5e328b 100644
--- a/core_tools/data/gui/data_browser.py
+++ b/core_tools/data/gui/data_browser.py
@@ -1,5 +1,7 @@
 import core_tools.data.gui.ui_files.data_browser_autogen as data_browser_autogen
+from core_tools.data.ds.data_set import load_by_uuid, load_by_id
 
+from core_tools.data.gui.plot_mgr import data_plotter
 from core_tools.data.gui.data_browser_models.result_table_gui import result_table_model
 from core_tools.data.gui.data_browser_models.date_list_GUI import data_list_model
 
@@ -13,186 +15,209 @@ import sys
 import datetime
 
 def if_any_to_none(arg):
-	if arg == "any":
-		return None
-	return arg
+    if arg == "any":
+        return None
+    return arg
 
 class data_browser(data_browser_autogen.Ui_MainWindow):
-	def __init__(self):
-		self.app = QtWidgets.QApplication(sys.argv)
-		MainWindow = QtWidgets.QMainWindow()
-		self.setupUi(MainWindow)
-		MainWindow.show()
-
-		##################
-		# overiew window #
-		##################
-		self.sample_info = dict()
-		self.sample_info['project'] = sample_info.project
-		self.sample_info['sample'] = sample_info.set_up
-		self.sample_info['set_up'] = sample_info.sample
-
-		self.dates_overview_model = data_list_model()
-		self.dates_overview.setModel(self.dates_overview_model)
-		self.dates_overview.clicked.connect(self.load_meas_data)
-		
-		self.data_table_model = result_table_model()
-		self.data_table.setSortingEnabled(True);
-		self.data_table.sortByColumn(3, QtCore.Qt.DescendingOrder)
-		self.data_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows);
-		self.data_table.doubleClicked.connect(self.load_measurement)
-		self.data_table.setModel(self.data_table_model)
-
-		self.init_index(self.set_up_scroll_box, ['any', sample_info.set_up])
-		self.init_index(self.Sample_scroll_box, ['any', sample_info.sample])
-		self.init_index(self.Project_scroll_box, ['any', sample_info.project])
-		self.update_index(('set_up',self.set_up_scroll_box),
-			('project', self.Project_scroll_box), ('sample', self.Sample_scroll_box))
-		self.update_index(('sample', self.Sample_scroll_box),
-			('set_up',self.set_up_scroll_box), ('project', self.Project_scroll_box))
-		self.update_index(('project', self.Project_scroll_box),
-			('set_up',self.set_up_scroll_box), ('sample', self.Sample_scroll_box), True)
-
-		self.set_up_scroll_box.activated.connect(partial(self.update_index, ('set_up',self.set_up_scroll_box),
-			('project', self.Project_scroll_box), ('sample', self.Sample_scroll_box), True))
-		self.Sample_scroll_box.activated.connect(partial(self.update_index, ('sample', self.Sample_scroll_box),
-			('set_up',self.set_up_scroll_box), ('project', self.Project_scroll_box), True))
-		self.Project_scroll_box.activated.connect(
-			partial(self.update_index, 
-						('project', self.Project_scroll_box),
-						('set_up',self.set_up_scroll_box),
-						('sample', self.Sample_scroll_box),
-						True))
-
-		##############
-		# search tab #
-		##############
-
-		self.enable_min_date.stateChanged.connect(partial(self.enable_date, self.min_date_field))
-		self.enable_max_date.stateChanged.connect(partial(self.enable_date, self.max_date_field))
-
-		self.set_up_search.activated.connect(partial(self.update_index, ('set_up',self.set_up_search),
-			('project', self.project_search), ('sample', self.sample_search)))
-		self.sample_search.activated.connect(partial(self.update_index, ('sample', self.sample_search),
-			('set_up',self.set_up_search), ('project', self.project_search)))
-		self.project_search.activated.connect(partial(self.update_index, 
-			('project', self.project_search), ('set_up',self.set_up_search),('sample', self.sample_search)))
-
-		self.reset_search_box()
-
-		self.reset_search.clicked.connect(self.reset_search_box)
-
-		self.search_table_data_model = result_table_model()
-		self.search_table_data.setSortingEnabled(True);
-		self.search_table_data.sortByColumn(3, QtCore.Qt.DescendingOrder)
-		self.search_table_data.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows);
-		self.search_table_data.doubleClicked.connect(self.load_measurement_search)
-		self.search_table_data.setModel(self.search_table_data_model)
-
-		self.search_bottom.clicked.connect(self.search_data)
-
-		self.app.exec_()
-
-
-	def enable_date(self, item, state):
-		item.setVisible(state)
-
-	def init_index(self, index, values, idx = 1):
-		index.clear()
-		index.addItems(values)
-		index.setCurrentIndex(idx)
-
-	def update_index(self, current, other_1, other_2, update_date=False, *args):
-		current_val = current[1].currentText()
-		other_1_val = other_1[1].currentText()
-		other_2_val = other_2[1].currentText()
-
-		vals_1 = ['any'] + query_for_samples.get_x_given_yz(other_1[0], (other_2[0],if_any_to_none(other_2_val)), 
-									(current[0], if_any_to_none(current_val)))
-		vals_2 = ['any'] + query_for_samples.get_x_given_yz(other_2[0], (other_1[0],if_any_to_none(other_1_val)), 
-									(current[0], if_any_to_none(current_val)))
-
-		self.init_index(other_1[1], vals_1, vals_1.index(other_1_val))
-		self.init_index(other_2[1], vals_2, vals_2.index(other_2_val))
-
-		if update_date == True:
-			self.sample_info[current[0]] = if_any_to_none(current[1].currentText())
-			self.sample_info[other_1[0]] = if_any_to_none(other_1[1].currentText())
-			self.sample_info[other_2[0]] = if_any_to_none(other_2[1].currentText())
-			data = query_for_measurement_results.get_all_dates_with_meaurements(self.sample_info['project'],
-				self.sample_info['set_up'], self.sample_info['sample'])
-
-			self.dates_overview_model.update_content(data)
-			
-			if len(self.dates_overview_model.data_list) > 0:
-				self.load_data_table(self.dates_overview_model.data_list[0])
-
-	def load_meas_data(self, idx):
-		self.load_data_table(self.dates_overview_model.data_list[idx.row()])
-	
-	def load_data_table(self, date):
-		data = query_for_measurement_results.get_results_for_date(date, **self.sample_info)
-		self.data_table_model.overwrite_data(data)
-
-	def load_measurement(self, index):
-		print('loading measurment window for uuid {}'.format(self.data_table_model._data[index.row()].uuid))
-
-	def load_measurement_search(self, index):
-		print('loading measurment window for uuid {}'.format(self.search_table_data_model._data[index.row()].uuid))
-
-
-	def reset_search_box(self):
-		self.min_date_field.hide()
-		self.max_date_field.hide()
-
-		self.enable_min_date.setCheckState(0)
-		self.enable_max_date.setCheckState(0)
-
-		max_date = datetime.datetime.now()
-		min_date = max_date - datetime.timedelta(days=7)
-
-		self.min_date_field.setDate(min_date.date())
-		self.max_date_field.setDate(max_date.date())
-
-		self.description_search.clear()
-		self.id_uuid_search.clear()
-
-		self.init_index(self.project_search, ['any', sample_info.project])
-		self.init_index(self.set_up_search, ['any', sample_info.set_up])
-		self.init_index(self.sample_search, ['any', sample_info.sample])
-
-		self.update_index(('set_up',self.set_up_search), ('project', self.project_search), ('sample', self.sample_search))
-		self.update_index(('sample', self.sample_search), ('set_up',self.set_up_search), ('project', self.project_search))
-		self.update_index(('project', self.project_search), ('set_up',self.set_up_search), ('sample', self.sample_search))
-
-	def search_data(self):
-		exp_id = None
-		exp_uuid = None
-		id_uuid = self.id_uuid_search.text()
-		seach_type_id_uuid = self.id_uuid_search_type.currentText()
-		if seach_type_id_uuid == 'id' and id_uuid!="":
-			exp_id = id_uuid
-		elif seach_type_id_uuid == 'uuid' and id_uuid!="":
-			exp_uuid = id_uuid
-		
-		project = if_any_to_none(self.project_search.currentText())
-		set_up = if_any_to_none(self.set_up_search.currentText())
-		sample = if_any_to_none(self.sample_search.currentText())
-		words = self.description_search.text()
-
-		start_date = None
-		stop_date = None
-		if self.enable_min_date.checkState() == 2:
-			start_date = self.min_date_field.date()
-		if self.enable_max_date.checkState() == 2:
-			stop_date = self.max_date_field.date()
-
-		data = query_for_measurement_results.search_query(exp_id, exp_uuid, words, start_date, stop_date, project, set_up, sample)
-
-		self.search_table_data_model.overwrite_data(data)
+    def __init__(self):
+        self.app = QtWidgets.QApplication(sys.argv)
+        MainWindow = QtWidgets.QMainWindow()
+        self.setupUi(MainWindow)
+        MainWindow.show()
+
+        ##################
+        # overiew window #
+        ##################
+        self.sample_info = dict()
+        self.sample_info['project'] = sample_info.project
+        self.sample_info['sample'] = sample_info.set_up
+        self.sample_info['set_up'] = sample_info.sample
+
+        self.dates_overview_model = data_list_model()
+        self.dates_overview.setModel(self.dates_overview_model)
+        self.dates_overview.clicked.connect(self.load_meas_data)
+        
+        self.data_table_model = result_table_model()
+        self.data_table.setSortingEnabled(True);
+        self.data_table.sortByColumn(3, QtCore.Qt.DescendingOrder)
+        self.data_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows);
+        self.data_table.doubleClicked.connect(self.load_measurement)
+        self.data_table.setModel(self.data_table_model)
+
+        self.selected_date = None
+        self.init_index(self.set_up_scroll_box, ['any', sample_info.set_up])
+        self.init_index(self.Sample_scroll_box, ['any', sample_info.sample])
+        self.init_index(self.Project_scroll_box, ['any', sample_info.project])
+        self.update_index(('set_up',self.set_up_scroll_box),
+            ('project', self.Project_scroll_box), ('sample', self.Sample_scroll_box))
+        self.update_index(('sample', self.Sample_scroll_box),
+            ('set_up',self.set_up_scroll_box), ('project', self.Project_scroll_box))
+        self.update_index(('project', self.Project_scroll_box),
+            ('set_up',self.set_up_scroll_box), ('sample', self.Sample_scroll_box), True)
+
+        self.set_up_scroll_box.activated.connect(partial(self.update_index, ('set_up',self.set_up_scroll_box),
+            ('project', self.Project_scroll_box), ('sample', self.Sample_scroll_box), True))
+        self.Sample_scroll_box.activated.connect(partial(self.update_index, ('sample', self.Sample_scroll_box),
+            ('set_up',self.set_up_scroll_box), ('project', self.Project_scroll_box), True))
+        self.Project_scroll_box.activated.connect(
+            partial(self.update_index, 
+                        ('project', self.Project_scroll_box),
+                        ('set_up',self.set_up_scroll_box),
+                        ('sample', self.Sample_scroll_box),
+                        True))
+
+        ##############
+        # search tab #
+        ##############
+
+        self.enable_min_date.stateChanged.connect(partial(self.enable_date, self.min_date_field))
+        self.enable_max_date.stateChanged.connect(partial(self.enable_date, self.max_date_field))
+
+        self.set_up_search.activated.connect(partial(self.update_index, ('set_up',self.set_up_search),
+            ('project', self.project_search), ('sample', self.sample_search)))
+        self.sample_search.activated.connect(partial(self.update_index, ('sample', self.sample_search),
+            ('set_up',self.set_up_search), ('project', self.project_search)))
+        self.project_search.activated.connect(partial(self.update_index, 
+            ('project', self.project_search), ('set_up',self.set_up_search),('sample', self.sample_search)))
+
+        self.reset_search_box()
+
+        self.reset_search.clicked.connect(self.reset_search_box)
+
+        self.search_table_data_model = result_table_model()
+        self.search_table_data.setSortingEnabled(True);
+        self.search_table_data.sortByColumn(3, QtCore.Qt.DescendingOrder)
+        self.search_table_data.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows);
+        self.search_table_data.doubleClicked.connect(self.load_measurement_search)
+        self.search_table_data.setModel(self.search_table_data_model)
+
+        self.search_bottom.clicked.connect(self.search_data)
+
+        self.plots = []
+
+        self.count_measurements = 0
+        self.check_for_updates()
+        self.timer = QtCore.QTimer()
+        self.timer.timeout.connect(self.check_for_updates)
+        self.timer.start(200)
+        
+        
+        self.app.exec_()
+
+    def enable_date(self, item, state):
+        item.setVisible(state)
+
+    def init_index(self, index, values, idx = 1):
+        index.clear()
+        index.addItems(values)
+        index.setCurrentIndex(idx)
+
+    def update_index(self, current, other_1, other_2, update_date=False, *args):
+        current_val = current[1].currentText()
+        other_1_val = other_1[1].currentText()
+        other_2_val = other_2[1].currentText()
+
+        vals_1 = ['any'] + query_for_samples.get_x_given_yz(other_1[0], (other_2[0],if_any_to_none(other_2_val)), 
+                                    (current[0], if_any_to_none(current_val)))
+        vals_2 = ['any'] + query_for_samples.get_x_given_yz(other_2[0], (other_1[0],if_any_to_none(other_1_val)), 
+                                    (current[0], if_any_to_none(current_val)))
+
+        self.init_index(other_1[1], vals_1, vals_1.index(other_1_val))
+        self.init_index(other_2[1], vals_2, vals_2.index(other_2_val))
+
+        if update_date == True:
+            self.sample_info[current[0]] = if_any_to_none(current[1].currentText())
+            self.sample_info[other_1[0]] = if_any_to_none(other_1[1].currentText())
+            self.sample_info[other_2[0]] = if_any_to_none(other_2[1].currentText())
+            data = query_for_measurement_results.get_all_dates_with_meaurements(self.sample_info['project'],
+                self.sample_info['set_up'], self.sample_info['sample'])
+
+            self.dates_overview_model.update_content(data)
+            
+            if len(self.dates_overview_model.data_list) > 0:
+                self.selected_date = self.dates_overview_model.data_list[0]
+                self.load_data_table(self.selected_date)
+
+    def load_meas_data(self, idx):
+        self.selected_date = self.dates_overview_model.data_list[idx.row()]
+        self.load_data_table(self.selected_date)
+    
+    def load_data_table(self, date):
+        data = query_for_measurement_results.get_results_for_date(date, **self.sample_info)
+        self.data_table_model.overwrite_data(data)
+
+    def load_measurement(self, index):
+        self.plot_ds(self.data_table_model._data[index.row()].uuid)
+    
+    def load_measurement_search(self, index):
+        self.plot_ds(self.search_table_data_model._data[index.row()].uuid)
+        
+    def plot_ds(self, uuid):
+        ds = load_by_uuid(uuid)
+        p = data_plotter(ds)
+        self.plots.append(p)
+
+    def check_for_updates(self):
+        update, self.count_measurements = query_for_measurement_results.detect_new_meaurements(self.count_measurements)
+        if update==True:
+            self.load_data_table(self.selected_date)
+
+            if self.action_autoplot_new.isChecked() == True:
+                self.plot_ds(self.data_table_model._data[0].uuid)
+
+    def reset_search_box(self):
+        self.min_date_field.hide()
+        self.max_date_field.hide()
+
+        self.enable_min_date.setCheckState(0)
+        self.enable_max_date.setCheckState(0)
+
+        max_date = datetime.datetime.now()
+        min_date = max_date - datetime.timedelta(days=7)
+
+        self.min_date_field.setDate(min_date.date())
+        self.max_date_field.setDate(max_date.date())
+
+        self.description_search.clear()
+        self.id_uuid_search.clear()
+
+        self.init_index(self.project_search, ['any', sample_info.project])
+        self.init_index(self.set_up_search, ['any', sample_info.set_up])
+        self.init_index(self.sample_search, ['any', sample_info.sample])
+
+        self.update_index(('set_up',self.set_up_search), ('project', self.project_search), ('sample', self.sample_search))
+        self.update_index(('sample', self.sample_search), ('set_up',self.set_up_search), ('project', self.project_search))
+        self.update_index(('project', self.project_search), ('set_up',self.set_up_search), ('sample', self.sample_search))
+
+    def search_data(self):
+        exp_id = None
+        exp_uuid = None
+        id_uuid = self.id_uuid_search.text()
+        seach_type_id_uuid = self.id_uuid_search_type.currentText()
+        if seach_type_id_uuid == 'id' and id_uuid!="":
+            exp_id = id_uuid
+        elif seach_type_id_uuid == 'uuid' and id_uuid!="":
+            exp_uuid = id_uuid
+        
+        project = if_any_to_none(self.project_search.currentText())
+        set_up = if_any_to_none(self.set_up_search.currentText())
+        sample = if_any_to_none(self.sample_search.currentText())
+        words = self.description_search.text()
+
+        start_date = None
+        stop_date = None
+        if self.enable_min_date.checkState() == 2:
+            start_date = self.min_date_field.date()
+        if self.enable_max_date.checkState() == 2:
+            stop_date = self.max_date_field.date()
+
+        data = query_for_measurement_results.search_query(exp_id, exp_uuid, words, start_date, stop_date, project, set_up, sample)
+
+        self.search_table_data_model.overwrite_data(data)
 
 if __name__ == '__main__':
 
-	set_up_local_storage('stephan', 'magicc', 'test', 'Intel Project', 'F006', 'SQ38328342')
+    set_up_local_storage('stephan', 'magicc', 'test', 'Intel Project', 'F006', 'SQ38328342')
 
-	db = data_browser()
+    db = data_browser()
diff --git a/core_tools/data/gui/data_browser_models/result_table_data_class.py b/core_tools/data/gui/data_browser_models/result_table_data_class.py
index 42b1f3aa..a9f9e0f3 100644
--- a/core_tools/data/gui/data_browser_models/result_table_data_class.py
+++ b/core_tools/data/gui/data_browser_models/result_table_data_class.py
@@ -19,8 +19,8 @@ class m_result_item():
     @property
     def location(self):
         if self._location == '0':
-            return 'local'
-        return 'remote'
+            return 'remote'
+        return 'local'
 
     @property
     def keywords(self):
@@ -32,7 +32,7 @@ class m_result_item():
     
     @property
     def date(self):
-        return self._date.strftime("%d/%m/%Y %H:%M")
+        return self._date.strftime("%d/%m/%Y %H:%M:%S")
     
     def set_sort_idx(self, i):
         self.__search_key_idx = i
diff --git a/core_tools/data/gui/plot_mgr.py b/core_tools/data/gui/plot_mgr.py
index f5cf870a..8ccc27ac 100644
--- a/core_tools/data/gui/plot_mgr.py
+++ b/core_tools/data/gui/plot_mgr.py
@@ -1,7 +1,6 @@
 import core_tools.data.gui.ui_files.plotter_basic_autgen as plotter_basic_autgen
 from core_tools.data.gui.generate_mparam_ui_box import single_m_param_m_descriptor
 from PyQt5 import QtCore, QtGui, QtWidgets
-
 import sys
 
 from core_tools.data.gui.plots._1D_plotting import _1D_plot
@@ -10,18 +9,18 @@ from core_tools.data.gui.plots._2D_plotting import _2D_plot
 
 class data_plotter(QtWidgets.QMainWindow, plotter_basic_autgen.Ui_MainWindow):
     def __init__(self, ds):
+        self.ds = ds
+
         self.app = QtCore.QCoreApplication.instance()
-        instance_ready = True
+        self.instance_ready = True
         if self.app is None:
-            instance_ready = False
+            self.instance_ready = False
             self.app = QtWidgets.QApplication([])
         super(QtWidgets.QMainWindow, self).__init__()
         self.setupUi(self)
-
-        self.ui_box_mgr = ui_box_mgr(self.app, ds, self.data_plot_layout)
-
+        self.ui_box_mgr = ui_box_mgr(self.app, self.ds, self.data_plot_layout)
         # add gui for dataset selection
-        for m_param_set in ds:
+        for m_param_set in self.ds:
             for m_param in m_param_set:
                 m_param = m_param[1]
                 layout = single_m_param_m_descriptor(m_param, self.scrollAreaWidgetContents_4)
@@ -33,12 +32,11 @@ class data_plotter(QtWidgets.QMainWindow, plotter_basic_autgen.Ui_MainWindow):
         
         # render plots
         self.ui_box_mgr.draw_plots()
-        print('bef')
+
         self.show()
-        print('aftrer')
-        if instance_ready == False:
+
+        if self.instance_ready == False:
             self.app.exec()
-        print('aft')
 
 class ui_box_mgr():
     def __init__(self, app, ds, plot_layout):
@@ -90,24 +88,24 @@ class ui_box_mgr():
 
 
     def update_plots(self):
+        if self.ds.completed==True:
+            self.timer.stop()
+        self.ds.sync()
+
         for plot in self.plot_widgets:
             plot.update()
-        self.app.processEvents()
-
-
+        print('updating plot')
 
 
 if __name__ == '__main__':
     from core_tools.data.SQL.connector import SQL_conn_info_local, SQL_conn_info_remote, sample_info, set_up_local_storage
     from core_tools.data.SQL.SQL_measurment_queries import query_for_measurement_results
-    from core_tools.data.ds.data_set import load_by_uuid
+    from core_tools.data.ds.data_set import load_by_uuid, load_by_id
     import sys
     import datetime
     set_up_local_storage('stephan', 'magicc', 'test', 'Intel Project', 'F006', 'SQ38328342')
     
 
-    ds = load_by_uuid(1603910814933642671)
+    ds = load_by_id(14)
     p = data_plotter(ds)
     print('pass')
-
-    p.app.exec_()
diff --git a/core_tools/data/gui/plots/_2D_plotting.py b/core_tools/data/gui/plots/_2D_plotting.py
index 9745f0f4..bccb3c30 100644
--- a/core_tools/data/gui/plots/_2D_plotting.py
+++ b/core_tools/data/gui/plots/_2D_plotting.py
@@ -169,7 +169,7 @@ if __name__ == '__main__':
     from core_tools.data.ds.data_set import load_by_uuid
     import time
     set_up_local_storage('stephan', 'magicc', 'test', 'Intel Project', 'F006', 'SQ38328342')
-    ds = load_by_uuid(1603792891275642671)
+    ds = load_by_uuid(1603912517622618611)
 
     app = QtGui.QApplication([])
 
@@ -181,6 +181,6 @@ if __name__ == '__main__':
     win.setCentralWidget(plot.widget)
     win.show()
 
-    import sys
-    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
-        QtGui.QApplication.instance().exec_()
\ No newline at end of file
+    # import sys
+    # if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
+    #     QtGui.QApplication.instance().exec_()
\ No newline at end of file
diff --git a/core_tools/data/measurement.py b/core_tools/data/measurement.py
index d2a75e06..2f25fa56 100644
--- a/core_tools/data/measurement.py
+++ b/core_tools/data/measurement.py
@@ -22,7 +22,6 @@ general structure:
     The synchronization process starts in a separate thread in parallel to the measurement.
     When the last result is added, the final sync to the db is performed and you are done.
 '''
-from core_tools.data.gui.plot_mgr import data_plotter
 from core_tools.data.lib.data_class import setpoint_dataclass, m_param_dataclass
 from core_tools.data.ds.data_set import create_new_data_set
 import qcodes as qc
@@ -32,7 +31,6 @@ class Measurement:
     '''
     class used to describe a measurement.
     '''
-    ENABLE_LIVEPLOT = True
     def __init__(self, name):
         self.setpoints = dict()
         self.m_param = dict()
@@ -129,8 +127,7 @@ class Measurement:
     def __enter__(self):
         # generate dataset
         self.dataset = create_new_data_set(self.name, *self.m_param.values())
-        if self.ENABLE_LIVEPLOT == True:
-            data_plotter(self.dataset)
+
         return self
 
     def  __exit__(self, exc_type, exc_value, exc_traceback):
@@ -191,24 +188,24 @@ if __name__ == '__main__':
     dig = fake_digitizer("test")
 
 
-    a1 = MyCounter('name1')
+    a1 = MyCounter('name11')
 
     a2 = MyCounter('name2')
-    # d = dummy_multi_parameter_2dawg("name2")
+    d = dummy_multi_parameter_2dawg("name2")
     m1 = MyCounter('name3')
     m2 = dummy_multi_parameter_2dawg("name4")
     m3 = construct_2D_scan_fast('P2', 10, 10, 'P5', 10, 10,50000, True, None, dig)
     m4 = construct_1D_scan_fast("P2", 10,10,5000, True, None, dig)
 
-    x = 10
-    y = 10
+    x = 100
+    y = 100
 
     m_param = m2
     meas = Measurement('dataset test experiment')
     meas.register_set_parameter(a1, x)
     meas.register_set_parameter(a2, y)
 
-    meas.register_get_parameter(m_param, a1, a2)
+    meas.register_get_parameter(m_param, a1,a2)
 
     m_param_1 = list(meas.m_param.values())[0]
     # print(m1.name)
@@ -226,15 +223,14 @@ if __name__ == '__main__':
     # print("loading_meas")
 
     import time
-
+    j = 0
     t0  =time.time()
     with meas as ds:
         for i in range(x):
             for j in range(y):
-                print(i,j)
                 z = m_param.get()
+                # ds.add_result((a1, i), (m_param, z))
                 ds.add_result((a1, i), (a2, j), (m_param, z))
-                time.sleep(0.01)
 
     t1  =time.time()
     print(meas.dataset)
diff --git a/setup.py b/setup.py
index ea2f04fb..fda47b22 100644
--- a/setup.py
+++ b/setup.py
@@ -1,12 +1,13 @@
 from setuptools import setup, find_packages
 from setuptools.extension import Extension
 
-
-
 packages = ['core_tools', 'sample_specific', 'keysightSD1']
 print('packages: {}'.format(packages))
 
 setup(name="core_tools",
 	version="1.0",
 	packages = find_packages(),
+	install_requires=[
+          'pyqtgraph','si-prefix', 'matplotlib', 'psycopg2 '
+      ],
 	)
-- 
GitLab