aboutsummaryrefslogtreecommitdiff
path: root/MotionControl/Service.py
blob: 241d1413dd920f5978b3dba2f979ffd6a976e557 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# -*- coding: utf-8 -*-

import rpyc

class Service(rpyc.Service):
	stage = None
	def on_connect(self):
		Service.stage.onPositionChanged.connect(self.onPosition)
		
		for i,p in enumerate(Service.stage.position):
			self.onPosition(None, i, p)
	
	def on_disconnect(self):
		Service.stage.onPositionChanged.disconnect(self.onPosition)
	
	def onPosition(self, sender, axis, position):
		rpyc.async(self._conn.root.onPosition)(axis, position)

	def exposed_set_destination(self, destination):
		Service.stage.set_destination(destination)
	def exposed_cycle_start(self):
		Service.stage.cycle_start()
	def exposed_abort(self):
		Service.stage.abort()

	def exposed_reference(self):
		Service.stage.reference()

	def exposed_getAxisLimits(self, axis):
		return Service.stage.axes[axis].limits