Merge branch 'master' of https://gitlab.com/openflexure/openflexure-microscope-server into master
This commit is contained in:
commit
1c7b27a29f
3 changed files with 41 additions and 46 deletions
|
|
@ -315,7 +315,7 @@ class PiCameraStreamer(BaseCamera):
|
||||||
|
|
||||||
def start_preview(self, fullscreen=True, window=None):
|
def start_preview(self, fullscreen=True, window=None):
|
||||||
"""Start the on board GPU camera preview."""
|
"""Start the on board GPU camera preview."""
|
||||||
with self.lock():
|
with self.lock(timeout=1):
|
||||||
try:
|
try:
|
||||||
if not self.camera.preview:
|
if not self.camera.preview:
|
||||||
logging.debug("Starting preview")
|
logging.debug("Starting preview")
|
||||||
|
|
@ -340,7 +340,7 @@ class PiCameraStreamer(BaseCamera):
|
||||||
|
|
||||||
def stop_preview(self):
|
def stop_preview(self):
|
||||||
"""Stop the on board GPU camera preview."""
|
"""Stop the on board GPU camera preview."""
|
||||||
with self.lock():
|
with self.lock(timeout=1):
|
||||||
if self.camera.preview:
|
if self.camera.preview:
|
||||||
self.camera.stop_preview()
|
self.camera.stop_preview()
|
||||||
self.preview_active = False
|
self.preview_active = False
|
||||||
|
|
@ -359,7 +359,7 @@ class PiCameraStreamer(BaseCamera):
|
||||||
output_object (str/BytesIO): Target object.
|
output_object (str/BytesIO): Target object.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
with self.lock:
|
with self.lock(timeout=5):
|
||||||
# Start recording method only if a current recording is not running
|
# Start recording method only if a current recording is not running
|
||||||
if not self.record_active:
|
if not self.record_active:
|
||||||
|
|
||||||
|
|
@ -388,7 +388,7 @@ class PiCameraStreamer(BaseCamera):
|
||||||
|
|
||||||
def stop_recording(self):
|
def stop_recording(self):
|
||||||
"""Stop the last started video recording on splitter port 2."""
|
"""Stop the last started video recording on splitter port 2."""
|
||||||
with self.lock:
|
with self.lock(timeout=5):
|
||||||
# Stop the camera video recording on port 2
|
# Stop the camera video recording on port 2
|
||||||
logging.info("Stopping recording")
|
logging.info("Stopping recording")
|
||||||
self.camera.stop_recording(splitter_port=2)
|
self.camera.stop_recording(splitter_port=2)
|
||||||
|
|
|
||||||
|
|
@ -189,9 +189,7 @@ class Microscope:
|
||||||
Return:
|
Return:
|
||||||
dict: Dictionary containing complete microscope state
|
dict: Dictionary containing complete microscope state
|
||||||
"""
|
"""
|
||||||
with self.lock:
|
return {"camera": self.camera.state, "stage": self.stage.state}
|
||||||
state = {"camera": self.camera.state, "stage": self.stage.state}
|
|
||||||
return state
|
|
||||||
|
|
||||||
def update_settings(self, settings: dict):
|
def update_settings(self, settings: dict):
|
||||||
"""
|
"""
|
||||||
|
|
@ -242,27 +240,26 @@ class Microscope:
|
||||||
"extensions": self.extension_settings,
|
"extensions": self.extension_settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
with self.lock:
|
# If attached to a camera
|
||||||
# If attached to a camera
|
if self.camera:
|
||||||
if self.camera:
|
settings_current_camera = self.camera.read_settings()
|
||||||
settings_current_camera = self.camera.read_settings()
|
settings_current["camera"] = settings_current_camera
|
||||||
settings_current["camera"] = settings_current_camera
|
|
||||||
|
|
||||||
# If attached to a stage
|
# If attached to a stage
|
||||||
if self.stage:
|
if self.stage:
|
||||||
settings_current_stage = self.stage.read_settings()
|
settings_current_stage = self.stage.read_settings()
|
||||||
settings_current["stage"] = settings_current_stage
|
settings_current["stage"] = settings_current_stage
|
||||||
|
|
||||||
# Capture manager
|
# Capture manager
|
||||||
settings_current_captures = self.captures.read_settings()
|
settings_current_captures = self.captures.read_settings()
|
||||||
settings_current["captures"] = settings_current_captures
|
settings_current["captures"] = settings_current_captures
|
||||||
|
|
||||||
settings_full = self.settings_file.merge(settings_current)
|
settings_full = self.settings_file.merge(settings_current)
|
||||||
|
|
||||||
if full:
|
if full:
|
||||||
return settings_full
|
return settings_full
|
||||||
else:
|
else:
|
||||||
return settings_current
|
return settings_current
|
||||||
|
|
||||||
def save_settings(self):
|
def save_settings(self):
|
||||||
"""
|
"""
|
||||||
|
|
@ -274,28 +271,27 @@ class Microscope:
|
||||||
self.settings_file.save(current_config, backup=True)
|
self.settings_file.save(current_config, backup=True)
|
||||||
|
|
||||||
def force_get_configuration(self):
|
def force_get_configuration(self):
|
||||||
with self.lock:
|
initial_configuration = self.configuration_file.load()
|
||||||
initial_configuration = self.configuration_file.load()
|
|
||||||
|
|
||||||
current_configuration = {
|
current_configuration = {
|
||||||
"application": {
|
"application": {
|
||||||
"name": "openflexure-microscope-server",
|
"name": "openflexure-microscope-server",
|
||||||
"version": pkg_resources.get_distribution(
|
"version": pkg_resources.get_distribution(
|
||||||
"openflexure-microscope-server"
|
"openflexure-microscope-server"
|
||||||
).version,
|
).version,
|
||||||
},
|
},
|
||||||
"stage": {
|
"stage": {
|
||||||
"type": self.stage.__class__.__name__,
|
"type": self.stage.__class__.__name__,
|
||||||
**self.stage.configuration,
|
**self.stage.configuration,
|
||||||
},
|
},
|
||||||
"camera": {
|
"camera": {
|
||||||
"type": self.camera.__class__.__name__,
|
"type": self.camera.__class__.__name__,
|
||||||
**self.camera.configuration,
|
**self.camera.configuration,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
initial_configuration.update(current_configuration)
|
initial_configuration.update(current_configuration)
|
||||||
return initial_configuration
|
return initial_configuration
|
||||||
|
|
||||||
def get_configuration(self, cache_key=None):
|
def get_configuration(self, cache_key=None):
|
||||||
if cache_key:
|
if cache_key:
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,7 @@ class SangaStage(BaseStage):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def position(self):
|
def position(self):
|
||||||
with self.lock(timeout=None):
|
return self.board.position
|
||||||
return self.board.position
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def backlash(self):
|
def backlash(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue