From 233782803b5b73502a594dcfbd155782f99d4c23 Mon Sep 17 00:00:00 2001 From: "Wolfgang Draxinger (root@gar-ex-erdastep)" Date: Mon, 12 Dec 2011 19:59:22 +0100 Subject: Changed Axis signals onStarted, onStopped to single signal onRunning(bool) --- MotionControl/Axis.py | 11 +++-------- MotionControl/MotionStage.py | 35 +++++++++++++++++++++++++++++++++++ MotionControl/PhytronAxis.py | 4 ++-- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/MotionControl/Axis.py b/MotionControl/Axis.py index d137d54..42f6222 100644 --- a/MotionControl/Axis.py +++ b/MotionControl/Axis.py @@ -1,10 +1,9 @@ # -*- coding: utf8 -*- class Axis(object): - def __init__(self, limits=None, inverted = False, scale={}): + def __init__(self, limits=None, scale={}): from blinker import Signal self.limits = limits - self.inverted = inverted self.scale = scale self.position = None self.running = None @@ -15,8 +14,7 @@ class Axis(object): self.initiator_error = None self.temperature_warning = None self.onPosition = Signal() - self.onStarted = Signal() - self.onStopped = Signal() + self.onRunning = Signal() self.onInitializing = Signal() self.onInitialized = Signal() self.onInitiatorMinus = Signal() @@ -40,10 +38,7 @@ class Axis(object): self.onPosition.send(self, position = self.position) if last_running != self.running: - if self.running: - self.onStarted.send(self) - else: - self.onStopped.send(self) + self.onRunning.send(self, running = self.running) if last_initializing != self.initializing: self.onInitializing.send(self, initializing = self.initializing) diff --git a/MotionControl/MotionStage.py b/MotionControl/MotionStage.py index 90f811a..a25b1c7 100644 --- a/MotionControl/MotionStage.py +++ b/MotionControl/MotionStage.py @@ -21,8 +21,18 @@ class MotionStage(object): self.onDestinationChanged = Signal() + self.onRunning = Signal() + self.onInitializing = Signal() + self.onInitialized = Signal() + self.onInitiatorMinus = Signal() + self.onInitiatorPlus = Signal() self.onPositionChanged = Signal() for axis in self.axes: + axis.onInitializing.connect(self.onInitializing_repeat) + axis.onInitialized.connect(self.onInitialized_repeat) + axis.onInitiatorMinus.connect(self.onInitiatorMinus_repeat) + axis.onInitiatorPlus.connect(self.onInitiatorPlus_repeat) + axis.onRunning.connect(self.onRunning_repeat) axis.onPosition.connect(self.onPosition_repeat) self.worker_thread = None @@ -45,11 +55,36 @@ class MotionStage(object): self.action_queue.put(action) @property + def running(self): + return tuple([axis.running for axis in self.axes]) + @property + def initializing(self): + return tuple([axis.initializing for axis in self.axes]) + @property + def initialized(self): + return tuple([axis.initialized for axis in self.axes]) + @property + def initiator_minus(self): + return tuple([axis.initiator_minus for axis in self.axes]) + @property + def initiator_plus(self): + return tuple([axis.initiator_plus for axis in self.axes]) + @property def position(self): return tuple([axis.position for axis in self.axes]) + def onRunning_repeat(self, sender, running): + self.onRunning.send(self, axis=self.axes_idx[sender], running=running) def onPosition_repeat(self, sender, position): self.onPositionChanged.send(self, axis=self.axes_idx[sender], position=position) + def onInitializing_repeat(self, sender, initializing): + self.onInitializing.send(self, axis=self.axes_idx[sender], initializing=initializing) + def onInitialized_repeat(self, sender, initialized): + self.onInitialized.send(self, axis=self.axes_idx[sender], initialized=initialized) + def onInitiatorMinus_repeat(self, sender, active): + self.onInitiatorMinus.send(self, axis=self.axes_idx[sender], active=active) + def onInitiatorPlus_repeat(self, sender, active): + self.onInitiatorPlus.send(self, axis=self.axes_idx[sender], active=active) def update(self): old_position = self.position diff --git a/MotionControl/PhytronAxis.py b/MotionControl/PhytronAxis.py index 986dad7..0c27089 100644 --- a/MotionControl/PhytronAxis.py +++ b/MotionControl/PhytronAxis.py @@ -5,8 +5,8 @@ from Axis import Axis class PhytronAxis(Axis): INITIATOR_MINUS = 1 INITIATOR_PLUS = 2 - def __init__(self, ipcomm_axis, limits=None, max_run_freq=None, initiator=INITIATOR_MINUS, initiator_position = 0, inverted = False, limited = True, scale={}): - super(PhytronAxis, self).__init__(limits = limits, inverted = inverted, scale = scale) + def __init__(self, ipcomm_axis, limits=None, max_run_freq=None, initiator=INITIATOR_MINUS, initiator_position = 0, limited = True, scale={}): + super(PhytronAxis, self).__init__(limits = limits, scale = scale) self.ipcomm_axis = ipcomm_axis if not max_run_freq: -- cgit v1.2.3