Skip to content

Commit 1622f6b

Browse files
authored
Merge pull request #116 from openUC2/mergemaster
fixing issue with current position
2 parents 9e96afa + e96890d commit 1622f6b

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

uc2rest/motor.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,9 +654,9 @@ def get_position(self, axis=None, timeout=1):
654654
_physicalOffsets = np.array((self.offsetA, self.offsetX, self.offsetY, self.offsetZ))
655655

656656
# this may be an asynchronous call.. #FIXME!
657-
r = self._parent.post_json(path, payload, getReturn = True, nResponses=1, timeout=timeout)
657+
r = self._parent.post_json(path, payload, getReturn = True, nResponses=1, timeout=timeout)[0]
658658
# returns {"motor": }
659-
if "motor" in r:
659+
if "motor" in r :
660660
for index, istepper in enumerate(r["motor"]["steppers"]):
661661
if index >3: break # TODO: We would need to handle other values too soon
662662
_position[istepper["stepperid"]]=istepper["position"]*_physicalStepSizes[self.motorAxisOrder[index]]-_physicalOffsets[self.motorAxisOrder[index]]
@@ -775,6 +775,32 @@ def start_stage_scanning(self, xstart=0, xstep=1000, nx=20, ystart=0, ystep=1000
775775
r = self._parent.post_json(path, payload)
776776
return r
777777

778+
def start_stage_scanning_by_coordinates(self, coordinates, tPre=50, tPost=50, led=100, illumination=[50, 75, 100, 125], stopped=0):
779+
'''
780+
Example: {"task": "/motor_act", "stagescan": {"coordinates": [{"x": 100, "y": 200}, {"x": 300, "y": 400}, {"x": 500, "y": 600}], "tPre": 50, "tPost": 50, "led": 100, "illumination": [50, 75, 100, 125], "stopped": 0}}
781+
782+
coordinates: list of dictionaries with x and y coordinates
783+
tPre: time before exposure in ms
784+
tPost: exposure time - time after action
785+
led: led value for illumination
786+
illumination: list of values for each channel of the illumination
787+
stopped: 0 for start, 1 for stop
788+
'''
789+
path = "/motor_act"
790+
payload = {
791+
"task": path,
792+
"stagescan": {
793+
"coordinates": coordinates,
794+
"tPre": tPre,
795+
"tPost": tPost,
796+
"led": led,
797+
"illumination": illumination,
798+
"stopped": stopped
799+
}
800+
}
801+
r = self._parent.post_json(path, payload)
802+
return r
803+
778804
def set_tmc_parameters(self, axis=0, msteps=None, rms_current=None, stall_value=None, sgthrs=None, semin=None, semax=None, blank_time=None, toff=None, timeout=1):
779805
''' set the TMC parameters for a specific axis
780806
msteps: microsteps

uc2rest/mserial.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,10 @@ def _process_commands(self):
387387
except: pass
388388

389389
with self.lock:
390-
try:
390+
try: # TODO: THis looks fishy an
391391
self.responses[currentIdentifier].append(json_response.copy())
392-
except:
392+
except Exception as e:
393+
#self._logger.error("Failed to append the response: "+str(e))
393394
self.responses[currentIdentifier] = list()
394395
self.responses[currentIdentifier].append(json_response.copy())
395396
buffer = "" # reset buffer

0 commit comments

Comments
 (0)