Fixed service registration for imjoy
This commit is contained in:
parent
4716dc8812
commit
9b75e8ec05
3 changed files with 62 additions and 15 deletions
|
|
@ -0,0 +1,43 @@
|
||||||
|
<docs>
|
||||||
|
[TODO: write documentation for this plugin.]
|
||||||
|
</docs>
|
||||||
|
|
||||||
|
<config lang="json">
|
||||||
|
{
|
||||||
|
"name": "List services",
|
||||||
|
"type": "web-worker",
|
||||||
|
"tags": [],
|
||||||
|
"ui": "",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"cover": "",
|
||||||
|
"description": "List the available ImJoy services in the console",
|
||||||
|
"icon": "extension",
|
||||||
|
"inputs": null,
|
||||||
|
"outputs": null,
|
||||||
|
"api_version": "0.1.8",
|
||||||
|
"env": "",
|
||||||
|
"permissions": [],
|
||||||
|
"requirements": [],
|
||||||
|
"dependencies": []
|
||||||
|
}
|
||||||
|
</config>
|
||||||
|
|
||||||
|
<script lang="javascript">
|
||||||
|
class ImJoyPlugin {
|
||||||
|
async setup() {
|
||||||
|
api.log('initialized')
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(ctx) {
|
||||||
|
// get a list of service
|
||||||
|
const services = await api.getServices({name: "OpenFlexure"});
|
||||||
|
console.log("OpenFlexure services:");
|
||||||
|
console.log(services);
|
||||||
|
const allservices = await api.getServices();
|
||||||
|
console.log("All services:");
|
||||||
|
console.log(allservices);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
api.export(new ImJoyPlugin())
|
||||||
|
</script>
|
||||||
|
|
@ -41,6 +41,8 @@ class ImJoyPlugin {
|
||||||
console.log(`Moved Z to ${await ofm.getPosition()}`);
|
console.log(`Moved Z to ${await ofm.getPosition()}`);
|
||||||
await ofm.setPosition(start[2]);
|
await ofm.setPosition(start[2]);
|
||||||
console.log(`Moved Z to ${await ofm.getPosition()}`);
|
console.log(`Moved Z to ${await ofm.getPosition()}`);
|
||||||
|
await ofm.fullFocus();
|
||||||
|
console.log("Ran a full autofocus");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -200,18 +200,16 @@ export default {
|
||||||
});
|
});
|
||||||
this.setupMicroscopeAPI();
|
this.setupMicroscopeAPI();
|
||||||
this.setupViewers();
|
this.setupViewers();
|
||||||
// load the script editor for openflexure
|
const origin = window.location.origin;
|
||||||
await this.loadPlugin(
|
const localPlugins = [
|
||||||
`${window.location.origin}/OpenFlexureScriptEditor.imjoy.html`
|
"OpenFlexureSnapImageTemplate",
|
||||||
);
|
"OpenFlexureScriptEditor",
|
||||||
// Load the snap image template
|
"OpenFlexureTestMoveStage",
|
||||||
await this.loadPlugin(
|
"ListServices"
|
||||||
`${window.location.origin}/OpenFlexureSnapImageTemplate.imjoy.html`
|
];
|
||||||
);
|
for(let fname of localPlugins){
|
||||||
// Load the move stage template
|
await this.loadPlugin(`${origin}/${fname}.imjoy.html`);
|
||||||
await this.loadPlugin(
|
}
|
||||||
`${window.location.origin}/OpenFlexureTestMoveStage.imjoy.html`
|
|
||||||
);
|
|
||||||
this.setupPluginEngine();
|
this.setupPluginEngine();
|
||||||
});
|
});
|
||||||
this.imjoy = imjoy;
|
this.imjoy = imjoy;
|
||||||
|
|
@ -259,7 +257,7 @@ export default {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
setupMicroscopeAPI() {
|
async setupMicroscopeAPI() {
|
||||||
// Here we register a set of API for controlling the microscope as a service
|
// Here we register a set of API for controlling the microscope as a service
|
||||||
// For interoperatability, it might be good to reuse a subset of the function names defined in MicroManager
|
// For interoperatability, it might be good to reuse a subset of the function names defined in MicroManager
|
||||||
// See here: https://valelab4.ucsf.edu/~MM/doc/MMCore/html/class_c_m_m_core.html
|
// See here: https://valelab4.ucsf.edu/~MM/doc/MMCore/html/class_c_m_m_core.html
|
||||||
|
|
@ -275,7 +273,7 @@ export default {
|
||||||
const service = {
|
const service = {
|
||||||
_rintf: true, // this will make sure the function can be called multiple times
|
_rintf: true, // this will make sure the function can be called multiple times
|
||||||
type: "#microscope-control",
|
type: "#microscope-control",
|
||||||
name: "#openflexure",
|
name: "OpenFlexure",
|
||||||
lastSnapResponse: null,
|
lastSnapResponse: null,
|
||||||
snapPreviewImage() {
|
snapPreviewImage() {
|
||||||
// The "proper" capture method is more involved - this one pulls a frame out of the preview stream
|
// The "proper" capture method is more involved - this one pulls a frame out of the preview stream
|
||||||
|
|
@ -376,8 +374,12 @@ export default {
|
||||||
return runAutofocus();
|
return runAutofocus();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.imjoy.pm.registerService({ name: "#openflexure" }, service);
|
const ref = await this.imjoy.pm.registerService(
|
||||||
|
{type: "#microscope-control", name: "OpenFlexure"},
|
||||||
|
service
|
||||||
|
);
|
||||||
console.log("registered service");
|
console.log("registered service");
|
||||||
|
console.log(ref);
|
||||||
},
|
},
|
||||||
closeWindow(w) {
|
closeWindow(w) {
|
||||||
if (w) {
|
if (w) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue