@@ -77,6 +77,110 @@ class Motor(Device):
7777 SYSTEM_CLASS_NAME = 'tacho-motor'
7878 SYSTEM_DEVICE_NAME_CONVENTION = '*'
7979
80+ __slots__ = [
81+ '_address' ,
82+ '_command' ,
83+ '_commands' ,
84+ '_count_per_rot' ,
85+ '_count_per_m' ,
86+ '_driver_name' ,
87+ '_duty_cycle' ,
88+ '_duty_cycle_sp' ,
89+ '_full_travel_count' ,
90+ '_polarity' ,
91+ '_position' ,
92+ '_position_p' ,
93+ '_position_i' ,
94+ '_position_d' ,
95+ '_position_sp' ,
96+ '_max_speed' ,
97+ '_speed' ,
98+ '_speed_sp' ,
99+ '_ramp_up_sp' ,
100+ '_ramp_down_sp' ,
101+ '_speed_p' ,
102+ '_speed_i' ,
103+ '_speed_d' ,
104+ '_state' ,
105+ '_stop_action' ,
106+ '_stop_actions' ,
107+ '_time_sp' ,
108+ '_poll' ,
109+ ]
110+
111+ #: Run the motor until another command is sent.
112+ COMMAND_RUN_FOREVER = 'run-forever'
113+
114+ #: Run to an absolute position specified by `position_sp` and then
115+ #: stop using the action specified in `stop_action`.
116+ COMMAND_RUN_TO_ABS_POS = 'run-to-abs-pos'
117+
118+ #: Run to a position relative to the current `position` value.
119+ #: The new position will be current `position` + `position_sp`.
120+ #: When the new position is reached, the motor will stop using
121+ #: the action specified by `stop_action`.
122+ COMMAND_RUN_TO_REL_POS = 'run-to-rel-pos'
123+
124+ #: Run the motor for the amount of time specified in `time_sp`
125+ #: and then stop the motor using the action specified by `stop_action`.
126+ COMMAND_RUN_TIMED = 'run-timed'
127+
128+ #: Run the motor at the duty cycle specified by `duty_cycle_sp`.
129+ #: Unlike other run commands, changing `duty_cycle_sp` while running *will*
130+ #: take effect immediately.
131+ COMMAND_RUN_DIRECT = 'run-direct'
132+
133+ #: Stop any of the run commands before they are complete using the
134+ #: action specified by `stop_action`.
135+ COMMAND_STOP = 'stop'
136+
137+ #: Reset all of the motor parameter attributes to their default value.
138+ #: This will also have the effect of stopping the motor.
139+ COMMAND_RESET = 'reset'
140+
141+ #: Sets the normal polarity of the rotary encoder.
142+ ENCODER_POLARITY_NORMAL = 'normal'
143+
144+ #: Sets the inversed polarity of the rotary encoder.
145+ ENCODER_POLARITY_INVERSED = 'inversed'
146+
147+ #: With `normal` polarity, a positive duty cycle will
148+ #: cause the motor to rotate clockwise.
149+ POLARITY_NORMAL = 'normal'
150+
151+ #: With `inversed` polarity, a positive duty cycle will
152+ #: cause the motor to rotate counter-clockwise.
153+ POLARITY_INVERSED = 'inversed'
154+
155+ #: Power is being sent to the motor.
156+ STATE_RUNNING = 'running'
157+
158+ #: The motor is ramping up or down and has not yet reached a constant output level.
159+ STATE_RAMPING = 'ramping'
160+
161+ #: The motor is not turning, but rather attempting to hold a fixed position.
162+ STATE_HOLDING = 'holding'
163+
164+ #: The motor is turning, but cannot reach its `speed_sp`.
165+ STATE_OVERLOADED = 'overloaded'
166+
167+ #: The motor is not turning when it should be.
168+ STATE_STALLED = 'stalled'
169+
170+ #: Power will be removed from the motor and it will freely coast to a stop.
171+ STOP_ACTION_COAST = 'coast'
172+
173+ #: Power will be removed from the motor and a passive electrical load will
174+ #: be placed on the motor. This is usually done by shorting the motor terminals
175+ #: together. This load will absorb the energy from the rotation of the motors and
176+ #: cause the motor to stop more quickly than coasting.
177+ STOP_ACTION_BRAKE = 'brake'
178+
179+ #: Does not remove power from the motor. Instead it actively try to hold the motor
180+ #: at the current position. If an external force tries to turn the motor, the motor
181+ #: will `push back` to maintain its position.
182+ STOP_ACTION_HOLD = 'hold'
183+
80184 def __init__ (self , address = None , name_pattern = SYSTEM_DEVICE_NAME_CONVENTION , name_exact = False , ** kwargs ):
81185
82186 if address is not None :
@@ -112,37 +216,6 @@ def __init__(self, address=None, name_pattern=SYSTEM_DEVICE_NAME_CONVENTION, nam
112216 self ._time_sp = None
113217 self ._poll = None
114218
115- __slots__ = [
116- '_address' ,
117- '_command' ,
118- '_commands' ,
119- '_count_per_rot' ,
120- '_count_per_m' ,
121- '_driver_name' ,
122- '_duty_cycle' ,
123- '_duty_cycle_sp' ,
124- '_full_travel_count' ,
125- '_polarity' ,
126- '_position' ,
127- '_position_p' ,
128- '_position_i' ,
129- '_position_d' ,
130- '_position_sp' ,
131- '_max_speed' ,
132- '_speed' ,
133- '_speed_sp' ,
134- '_ramp_up_sp' ,
135- '_ramp_down_sp' ,
136- '_speed_p' ,
137- '_speed_i' ,
138- '_speed_d' ,
139- '_state' ,
140- '_stop_action' ,
141- '_stop_actions' ,
142- '_time_sp' ,
143- '_poll' ,
144- ]
145-
146219 @property
147220 def address (self ):
148221 """
@@ -491,79 +564,6 @@ def time_sp(self):
491564 def time_sp (self , value ):
492565 self ._time_sp = self .set_attr_int (self ._time_sp , 'time_sp' , value )
493566
494- #: Run the motor until another command is sent.
495- COMMAND_RUN_FOREVER = 'run-forever'
496-
497- #: Run to an absolute position specified by `position_sp` and then
498- #: stop using the action specified in `stop_action`.
499- COMMAND_RUN_TO_ABS_POS = 'run-to-abs-pos'
500-
501- #: Run to a position relative to the current `position` value.
502- #: The new position will be current `position` + `position_sp`.
503- #: When the new position is reached, the motor will stop using
504- #: the action specified by `stop_action`.
505- COMMAND_RUN_TO_REL_POS = 'run-to-rel-pos'
506-
507- #: Run the motor for the amount of time specified in `time_sp`
508- #: and then stop the motor using the action specified by `stop_action`.
509- COMMAND_RUN_TIMED = 'run-timed'
510-
511- #: Run the motor at the duty cycle specified by `duty_cycle_sp`.
512- #: Unlike other run commands, changing `duty_cycle_sp` while running *will*
513- #: take effect immediately.
514- COMMAND_RUN_DIRECT = 'run-direct'
515-
516- #: Stop any of the run commands before they are complete using the
517- #: action specified by `stop_action`.
518- COMMAND_STOP = 'stop'
519-
520- #: Reset all of the motor parameter attributes to their default value.
521- #: This will also have the effect of stopping the motor.
522- COMMAND_RESET = 'reset'
523-
524- #: Sets the normal polarity of the rotary encoder.
525- ENCODER_POLARITY_NORMAL = 'normal'
526-
527- #: Sets the inversed polarity of the rotary encoder.
528- ENCODER_POLARITY_INVERSED = 'inversed'
529-
530- #: With `normal` polarity, a positive duty cycle will
531- #: cause the motor to rotate clockwise.
532- POLARITY_NORMAL = 'normal'
533-
534- #: With `inversed` polarity, a positive duty cycle will
535- #: cause the motor to rotate counter-clockwise.
536- POLARITY_INVERSED = 'inversed'
537-
538- #: Power is being sent to the motor.
539- STATE_RUNNING = 'running'
540-
541- #: The motor is ramping up or down and has not yet reached a constant output level.
542- STATE_RAMPING = 'ramping'
543-
544- #: The motor is not turning, but rather attempting to hold a fixed position.
545- STATE_HOLDING = 'holding'
546-
547- #: The motor is turning, but cannot reach its `speed_sp`.
548- STATE_OVERLOADED = 'overloaded'
549-
550- #: The motor is not turning when it should be.
551- STATE_STALLED = 'stalled'
552-
553- #: Power will be removed from the motor and it will freely coast to a stop.
554- STOP_ACTION_COAST = 'coast'
555-
556- #: Power will be removed from the motor and a passive electrical load will
557- #: be placed on the motor. This is usually done by shorting the motor terminals
558- #: together. This load will absorb the energy from the rotation of the motors and
559- #: cause the motor to stop more quickly than coasting.
560- STOP_ACTION_BRAKE = 'brake'
561-
562- #: Does not remove power from the motor. Instead it actively try to hold the motor
563- #: at the current position. If an external force tries to turn the motor, the motor
564- #: will `push back` to maintain its position.
565- STOP_ACTION_HOLD = 'hold'
566-
567567 def run_forever (self , ** kwargs ):
568568 """Run the motor until another command is sent.
569569 """
0 commit comments