Moved example extension and switched to includes

This commit is contained in:
jtc42 2020-01-22 15:17:31 +00:00
parent d2780f5541
commit 1115d00a18
12 changed files with 117 additions and 397 deletions

View file

@ -0,0 +1,36 @@
from labthings.server.extensions import BaseExtension
from labthings.server.find import find_component
def identify():
"""
Demonstrate access to Microscope.camera, and Microscope.stage
"""
microscope = find_component("org.openflexure.microscope")
response = (
f"My name is {microscope.name}. "
f"My parent camera is {microscope.camera}, "
f"and my parent stage is {microscope.stage}."
)
return response
def rename(new_name):
"""
Rename the microscope
"""
microscope = find_component("org.openflexure.microscope")
microscope.name = new_name
microscope.save_settings()
# Create your extension object
my_extension = BaseExtension("com.myname.myextension", version="0.0.0")
# Add methods to your extension
my_extension.add_method(identify, "identify")
my_extension.add_method(rename, "rename")