python-microscope / microscope

Python library for control of microscope devices, supporting hardware triggers and distribution of devices over the network for performance and flexibility.

Home Page:https://www.python-microscope.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stage aware simulated camera filter position issue.

iandobbie opened this issue · comments

It seems the stage aware camera simulation doesn't set the filter position at startup so generates this error.

Traceback (most recent call last):
File “/opt/homebrew/lib/python3.10/site-packages/wx/core.py”, line 3427, in
lambda event: event.callable(*event.args, **event.kw) )
File “/opt/homebrew/lib/python3.10/site-packages/cockpit/handlers/filterHandler.py”, line 113, in updateAfterMove
self.lastFilter = self.currentFilter()
File “/opt/homebrew/lib/python3.10/site-packages/cockpit/handlers/filterHandler.py”, line 103, in currentFilter
position = self.callbacks‘getPosition’
File “/opt/homebrew/lib/python3.10/site-packages/cockpit/devices/microscopeDevice.py”, line 404, in getPosition
return self._proxy.get_setting(‘position’)
File “/opt/homebrew/lib/python3.10/site-packages/Pyro4/core.py”, line 185, in call
return self.__send(self.__name, args, kwargs)
File “/opt/homebrew/lib/python3.10/site-packages/Pyro4/core.py”, line 476, in _pyroInvoke
raise data # if you see this in your traceback, you should probably inspect the remote traceback as well
KeyError: ‘position’

There seems to be a disjoint between cockpit and microscope filterwheel positions. Cockpit thinks it should be a setting, while microscope appears to have abc functions.

Cockpits microscopeDevice.py code:

def setPosition(self, position, callback=None):
    asproxy = Pyro4.Proxy(self._proxy._pyroUri)
    asproxy._pyroAsync()
    result = asproxy.set_setting('position', position).then(callback)

def getPosition(self):
    return self._proxy.get_setting('position')

Microscope abc.py code:

@property
def position(self) -> int:
    """Filter Wheel position (zero-based)."""
    return self._do_get_position()

@position.setter
def position(self, new_position: int) -> None:
    if 0 <= new_position < self.n_positions:
        return self._do_set_position(new_position)
    else:
        raise ValueError(
            "can't move to position %d, limits are [0 %d]"
            % (new_position, self.n_positions - 1)
        )

I think the microscopeDevice code should just call self._proxy.set_position and .get_position

Turns out David has already fixed this in the last few days I just hadn't updated to the very bleeding edge .