diff options
author | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2011-12-02 18:30:50 +0100 |
---|---|---|
committer | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2011-12-02 18:30:50 +0100 |
commit | 68d1ddf0e3e781d4fe2f00317b06f3b501d2ad69 (patch) | |
tree | 3387b6cfc948597018ed18de147e77620e4ede2d | |
parent | cd5064f5b2a96514c4fd00d32b4c933e8eeebb10 (diff) | |
parent | e44a59d65e1556c96756f72235fc2f37a989bfe3 (diff) | |
download | PyMotionControl-68d1ddf0e3e781d4fe2f00317b06f3b501d2ad69.tar.gz PyMotionControl-68d1ddf0e3e781d4fe2f00317b06f3b501d2ad69.tar.bz2 |
scratchpad merged
-rw-r--r-- | MotionControl/Constraint.py | 0 | ||||
-rw-r--r-- | MotionControl/Motion.py | 0 | ||||
-rw-r--r-- | MotionControl/Planner.py | 0 | ||||
-rw-r--r-- | MotionControl/Stage.py | 0 | ||||
-rw-r--r-- | README | 27 | ||||
-rw-r--r-- | scratchpad.py | 107 |
6 files changed, 134 insertions, 0 deletions
diff --git a/MotionControl/Constraint.py b/MotionControl/Constraint.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/MotionControl/Constraint.py diff --git a/MotionControl/Motion.py b/MotionControl/Motion.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/MotionControl/Motion.py diff --git a/MotionControl/Planner.py b/MotionControl/Planner.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/MotionControl/Planner.py diff --git a/MotionControl/Stage.py b/MotionControl/Stage.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/MotionControl/Stage.py @@ -0,0 +1,27 @@ +PyMotionControl + +Classes and modules for building motion control +systems with Python. + +--- + +PyMotionControl itself does not interface with +actuator controllers. Instead the user of this +library is required to derive from +MotionControl.Axis.AxisBase and in the derived class +interface with actuator control packages of choice. + +Axes are assembled into a so called "Stage". The class +MotionControl.Stage.Stage provides general motion stage +functionality. However one may choose to derive from it +to form a application specific stage. + +--- + +NOTE scratchpad.py: + +scratchpad.py is the source file where new things are +tested and outlined, before they are moved into their +proper module file. So all contents of it are +work-in-progress, highly experimental and most likely +not working in the state you see them there. diff --git a/scratchpad.py b/scratchpad.py index 4154651..e5aac7b 100644 --- a/scratchpad.py +++ b/scratchpad.py @@ -83,3 +83,110 @@ class MotionControl(object): print self.name time.sleep(1) +import threading +import rpyc +import Phytron +from blinker import Signal + +class Constraint: + pass + +class Stage: + def __init__(self, axes): + self.axes = axes + + def setTarget(self, target): + self.target = target + + def startCycle(self): + for ax in self.axes: + pass + +class Axis(object): + def __init__(self, inverted = False, scale={}): + self.inverted = inverted + self.scale = scale + self.position = None + self.running = None + self.initializing = None + self.initialized = None + self.initiator_minus = None + self.initiator_plus = None + self.onPosition = Signal() + self.onStarted = Signal() + self.onStopped = Signal() + self.onInitializing = Signal() + self.onInitialized = Signal() + self.onInitiatorMinus = Signal() + self.onInitiatorPlus = Signal() + + def update(self): + last_position = self.position + last_running = self.running + last_initializing = self.initializing + last_initialized = self.initialized + last_initiator_minus = self.initiator_minus + last_initiator_plus = self.initiator_plus + + self.do_update() + + if last_position != self.position: + self.onPosition.send(position = self.position) + + if last_running != self.running: + if self.running: + self.onStarted.send() + else: + self.onStopped.send() + + if last_initializing != self.initializing: + self.onInitializing.send(initializing = self.initializing) + + if last_initialized != self.initialized: + self.onInitialized.send(initialized = self.initialized) + + if last_initiator_minus != self.initiator_minus: + self.onInitiatorMinus.send(active = self.initiator_minus) + + if last_initiator_plus != self.initiator_plus: + self.onInitiatorPlus.send(active = self.initiator_plus) + + def wait_for_stop(self): + self.update() + while self.running: + self.update() + + def initialize(self): + if self.running: + self.stop() + self.wait_for_stop() + self.do_initialize() + self.wait_for_stop() + +class PhytronAxis(Axis): + INITIATOR_MINUS = 1 + INITIATOR_PLUS = 2 + def __init__(self, ipcomm_axis, max_run_freq, initiator, scale, inverted = False): + super(PhytronAxis, self).__init__() + self.ipcomm_axis = ipcomm_axis + self.max_run_freq = max_run_freq + self.initiator = initiator + + def do_update(self): + if self.running: + self.pos = self.ipcomm_axis.getPosition() + + status = self.ipcomm_axis.getFullStatus() + self.running = status.running + self.initializing = status.initializing + self.initialized = status.initialized + self.initiator_minus = status.initiator_minus + self.initator_plus = status.initiator_plus + + def do_initialize(self): + self.ipcomm_axis.setRunFrequency(self.max_run_freq) + if self.initiator == PhytronAxis.INITIATOR_MINUS: + self.ipcomm_axis.initializeMinus() + if self.initiator == PhytronAxis.INITIATOR_PLUS: + self.ipcomm_axis.initializePlus() + |