Commit ad864252 authored by Martin Drechsler's avatar Martin Drechsler

some log test and backend

parent 5af0befe
...@@ -12,22 +12,26 @@ from controlGui import ControlGui ...@@ -12,22 +12,26 @@ from controlGui import ControlGui
import logging import logging
from logging.handlers import SocketHandler from logging.handlers import SocketHandler
from lantz.core.log import DEBUG, log_to_socket, log_to_screen
if __name__ == "__main__": if __name__ == "__main__":
log = logging.getLogger('Main logger') # log = logging.getLogger('Main logger')
gui_log = log.getChild("GUI logger") # gui_log = log.getChild("GUI logger")
worker_log = log.getChild("Worker logger") # worker_log = log.getChild("Worker logger")
acq_log = log.getChild("Acquisition logger") # acq_log = log.getChild("Acquisition logger")
log.setLevel(1) # to send all records to cutelog # log.setLevel(1) # to send all records to cutelog
socket_handler = SocketHandler('127.0.0.1', 19996) # default listening address # socket_handler = SocketHandler('127.0.0.1', 19996) # default listening address
log.addHandler(socket_handler) # log.addHandler(socket_handler)
log.info('Hello world!') # log.info('Hello world!')
gui_log.info('hello') # gui_log.info('hello')
worker_log.info('hello') # worker_log.info('hello')
acq_log.info('hello') # acq_log.info('hello')
log_to_screen(DEBUG)
import sys import sys
app = QtGui.QApplication([]) app = QtGui.QApplication([])
......
...@@ -16,9 +16,9 @@ from MCDAQcontrolsignals import anal_control_signal ...@@ -16,9 +16,9 @@ from MCDAQcontrolsignals import anal_control_signal
from resources.messages import show_warning from resources.messages import show_warning
from resources.scanFunctions import create_measurement_array, yield_array from resources.scanFunctions import create_measurement_array, yield_array
from resources.storage import Storage from resources.storage import Storage
from lantz.qt.app import Backend
class CameraWorker(Backend):
class CameraWorker(QtCore.QObject):
imageReadySignal = QtCore.pyqtSignal(np.ndarray, int) imageReadySignal = QtCore.pyqtSignal(np.ndarray, int)
measurementStartingSignal = QtCore.pyqtSignal() measurementStartingSignal = QtCore.pyqtSignal()
measurementEndingSignal = QtCore.pyqtSignal() measurementEndingSignal = QtCore.pyqtSignal()
...@@ -31,11 +31,13 @@ class CameraWorker(QtCore.QObject): ...@@ -31,11 +31,13 @@ class CameraWorker(QtCore.QObject):
self.cam.SensorCooling.setValue(True) self.cam.SensorCooling.setValue(True)
print("camera worker initialized") print("camera worker initialized")
self.storage = Storage() self.storageTxtTxt = Storage()
self.ao_to_scan = None self.ao_to_scan = None
self.scan_array_gen = None self.scan_array_gen = None
self._lock = threading.Lock() self._lock = threading.Lock()
self.measure_params = dict() self.measure_params = dict()
self.log_debug('hola')
self.log_info('hola')
def make_connections(self, frontend): def make_connections(self, frontend):
# frontend connections # frontend connections
...@@ -140,9 +142,9 @@ class CameraWorker(QtCore.QObject): ...@@ -140,9 +142,9 @@ class CameraWorker(QtCore.QObject):
self.scan_array_gen = yield_array(create_measurement_array(start, end, step_num)) self.scan_array_gen = yield_array(create_measurement_array(start, end, step_num))
self.ao_to_scan.go_softly_to_value(start) self.ao_to_scan.go_softly_to_value(start)
self.storage.set_directory(measure_params['directory']) self.storageTxt.set_directory(measure_params['directory'])
self.storage.create_data_file('Time', measure_params['signal_to_scan'], 'Roi data') self.storageTxt.create_data_file('Time', measure_params['signal_to_scan'], 'Roi data')
self.storage.append_metadata_to_current_file(self.cam.GetMetaData(), self.measure_params) self.storageTxt.append_metadata_to_current_file(self.cam.GetMetaData(), self.measure_params)
self.cam.TriggerMode.setString('Software') self.cam.TriggerMode.setString('Software')
...@@ -185,7 +187,7 @@ class CameraWorker(QtCore.QObject): ...@@ -185,7 +187,7 @@ class CameraWorker(QtCore.QObject):
@QtCore.pyqtSlot(float) @QtCore.pyqtSlot(float)
def save_data_from_scan_step(self, roiData): def save_data_from_scan_step(self, roiData):
row = [time.time(), self.ao_to_scan.AO.current_value, roiData] row = [time.time(), self.ao_to_scan.AO.current_value, roiData]
self.storage.append_data_to_current_file(row) self.storageTxt.append_data_to_current_file(row)
self.simple_scan_measurement_step() self.simple_scan_measurement_step()
...@@ -196,8 +198,8 @@ class CameraWorker(QtCore.QObject): ...@@ -196,8 +198,8 @@ class CameraWorker(QtCore.QObject):
@QtCore.pyqtSlot(str) @QtCore.pyqtSlot(str)
def permanent_save_measurement(self, comment=''): def permanent_save_measurement(self, comment=''):
self.storage.append_metadata_to_current_file( self.storageTxt.append_metadata_to_current_file(
{'Final comment': comment} {'Final comment': comment}
) )
self.storage.permanent_save_current_data() self.storageTxt.permanent_save_current_data()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment