microscope-cockpit / cockpit

Cockpit is a microscope graphical user interface. It is a flexible and easy to extend platform aimed at life scientists using bespoke microscopes.
https://microscope-cockpit.org
GNU General Public License v3.0
37 stars 27 forks source link

Simple piezo struggling with decimal.Decimal #875

Closed iandobbie closed 1 year ago

iandobbie commented 1 year ago

Trying to run an experiment with a simplePiezo being run by the red pitaya as the executor running the stage.

Seems like the root cause is this error, trying to sleep a time defined by a decimal.Decimal

Traceback (most recent call last): File "C:\Users\idobbie1\src\cockpit\cockpit\gui\macroStage\macroStageZ.py", line 581, in OnMouse cockpit.interfaces.stageMover.goToZ(min(zHardMax, altitude)) File "C:\Users\idobbie1\src\cockpit\cockpit\interfaces\stageMover.py", line 419, in goToZ mover._goToAxes([(2, position)], shouldBlock) File "C:\Users\idobbie1\src\cockpit\cockpit\interfaces\stageMover.py", line 328, in _goToAxes handler.moveAbsolute(target - offset) File "C:\Users\idobbie1\src\cockpit\cockpit\handlers\stagePositioner.py", line 98, in moveAbsolute self.callbacks['moveAbsolute'](self.axis, pos) File "C:\Users\idobbie1\src\cockpit\cockpit\handlers\stagePositioner.py", line 166, in call time.sleep(sum(self.getMovementTime(0, arg))) TypeError: 'decimal.Decimal' object cannot be interpreted as an integer

iandobbie commented 1 year ago

Thinking about this further it seems like the system is dropping out of the red pitaya control for the piezo, like I havent properly added the analog definition for the device.

There is definitely a bug, I think we just need to cast the Decimal to a float, but I also think my analog control on the Red Pitaya isnt actually working properly. I will investigate.

iandobbie commented 1 year ago

Fixed in commit reference above