de.jaetzold.art
Class Motor

java.lang.Object
  |
  +--de.jaetzold.art.RawSensor
        |
        +--de.jaetzold.art.RawActuator
              |
              +--de.jaetzold.art.Motor
All Implemented Interfaces:
Actuator, EventListener, PropertyChangeListener, Sensor, SensorPeer
Direct Known Subclasses:
StepperMotor

public class Motor
extends RawActuator

A class which represents a simple Motor. It can be switched on or off and the direction, as well as the level of the power supplied to the motor can be set. This particular implementation can just be used as some kind of Actuator-frontend, because it can give access to all of its abilities when only connected to a simple ActuatorPeer. This class provides some State and Methods which are more convenient to deal with, than with only a single value. However, an Interface can provide a special MotorPeer for this type of Motor, but a normal ActuatorPeer should be sufficient.

See Also:
ActuatorPeer, MotorPeer, Actuator

Inner classes inherited from class de.jaetzold.art.RawSensor
RawSensor.ValueSensorPort
 
Field Summary
protected  boolean backward
          Whether the output should reverse its polarity when supplying power to the motor.
protected  boolean on
          Whether the output should be supplied with any power at all.
protected  double power
          The power that the output should supply to the motor if it is on.
 
Fields inherited from class de.jaetzold.art.RawActuator
localReturn, vetos, waitForCompletion
 
Fields inherited from class de.jaetzold.art.RawSensor
changes, precision, precisionSet, propertyChangeEventDescriptor
 
Constructor Summary
Motor()
           
 
Method Summary
 void backward()
          Sets the direction of the motor to the opposite of its default-direction.
 void connectWith(ActuatorPort port)
          Connects this Object with the given Port.
 void disconnect()
          Disconnects this Sensor from it's Peer and it's Port.
 void forward()
          Sets the direction of the motor to its default-direction.
 boolean getBackward()
          Returns whether the polarity the output does or should supply to the motor will or should be reversed or not.
 double getPower()
          Returns the power the output does or should supply to the motor.
 boolean isOn()
          Returns whether the motor should be or is supplied with power.
 void off()
          Switches the Motor off.
 void on()
          Switches the Motor on.
 void reverse()
          Reverse the actual direction of the motor, whatever it is now.
 void setBackward(boolean backward)
          Controls whether the output should reverse its default polarity.
 void setOn(boolean on)
          Turns the motor on or of depending on the given value.
 void setPower(double power)
          Sets the power the output should supply to the motor to the given value.
 void setValue(double value)
          Computes the power, direction and the on/off state from the given value.
 
Methods inherited from class de.jaetzold.art.RawActuator
addVetoableChangeListener, connectWith, convertToActuatorIncoming, convertToActuatorOutgoing, getActuatorIncomingConversionDelegate, getActuatorOutgoingConversionDelegate, getLocalReturn, getValue, getWaitForCompletion, removeVetoableChangeListener, setActuatorIncomingConversionDelegate, setActuatorOutgoingConversionDelegate, setLocalReturn, setReversed, setValue, setWaitForCompletion
 
Methods inherited from class de.jaetzold.art.RawSensor
addPropertyChangeListener, addSensorListener, addSensorListener, connectWith, convertToIncoming, convertToOutgoing, disableEvent, enableEvent, getChangeEventsEnabled, getDeliversFloatingPoint, getIncomingConversionDelegate, getIntValue, getOutgoingConversionDelegate, getPeer, getPeerCacheEnabled, getPort, getPrecision, getSensorPort, isConnected, isIncomingConversionCacheable, isOutgoingConversionCacheable, isReversed, processEvent, propertyChange, removePropertyChangeListener, removeSensorListener, removeSensorListener, setChangeEventsEnabled, setIncomingConversionDelegate, setOutgoingConversionDelegate, setPeerCacheEnabled, setPrecision, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.jaetzold.art.Sensor
addPropertyChangeListener, addSensorListener, connectWith, getIntValue, getPort, getPrecision, getSensorPort, isConnected, processEvent, propertyChange, removePropertyChangeListener, removeSensorListener, update
 

Field Detail

power

protected double power
The power that the output should supply to the motor if it is on.

backward

protected boolean backward
Whether the output should reverse its polarity when supplying power to the motor.

on

protected boolean on
Whether the output should be supplied with any power at all.
Constructor Detail

Motor

public Motor()
Method Detail

setValue

public void setValue(double value)
Computes the power, direction and the on/off state from the given value. A positive value means forward, a negative backward, each with the power set to abs(value). If, and only if a value of zero is given the motor is switched off (retaining any previous value for power and backward), otherwise on. This Method calls setPower(double), setBackward(boolean) and setOn(boolean) with the extracted values in that order.
Overrides:
setValue in class RawActuator
See Also:
setPower(double), setBackward(boolean), setOn(boolean)

connectWith

public void connectWith(ActuatorPort port)
Connects this Object with the given Port. This sets the peer for this Object and is therefore required before it can be properly used.
Overrides:
connectWith in class RawActuator

disconnect

public void disconnect()
Description copied from interface: Sensor
Disconnects this Sensor from it's Peer and it's Port. This is implicitly called when the Sensor is already connected and asked to connect with another Port.
Overrides:
disconnect in class RawActuator
Following copied from interface: de.jaetzold.art.Sensor
See Also:
Sensor.connectWith(Port)

getPower

public double getPower()
Returns the power the output does or should supply to the motor. Which of these values is returned is influenced by localReturnMode.
See Also:
RawActuator.localReturn

setPower

public void setPower(double power)
Sets the power the output should supply to the motor to the given value. This usually has an effect to the speed of the motor, but it's real purpose is more to control the torque. Setting the power to 0 has the effect that the real Motor turns off, but it is still considered to be in the on-state. Dependig on the value of waitForCompletion this Method returns immediately after it has been registerd that this is now the state the motor should have, or it returns after the state has been set.
See Also:
RawActuator.waitForCompletion

getBackward

public boolean getBackward()
Returns whether the polarity the output does or should supply to the motor will or should be reversed or not. Which of these values is returned is influenced by localReturnMode.
See Also:
RawActuator.localReturn

setBackward

public void setBackward(boolean backward)
Controls whether the output should reverse its default polarity. Dependig on the value of waitMode this Method returns immediately after it has been registerd that this is now the state the motor should have, or it returns after the state has been set.
See Also:
RawActuator.waitForCompletion

isOn

public boolean isOn()
Returns whether the motor should be or is supplied with power. Which of these values is returned is influenced by localReturnMode.
See Also:
RawActuator.localReturn

setOn

public void setOn(boolean on)
Turns the motor on or of depending on the given value. Dependig on the value of waitMode this Method returns immediately after it has been registerd that this is now the state the motor should have, or it returns after the state has been set.
See Also:
RawActuator.waitForCompletion

backward

public void backward()
Sets the direction of the motor to the opposite of its default-direction.
See Also:
setBackward(boolean)

forward

public void forward()
Sets the direction of the motor to its default-direction.
See Also:
setBackward(boolean)

on

public void on()
Switches the Motor on.
See Also:
setOn(boolean)

off

public void off()
Switches the Motor off.
See Also:
setOn(boolean)

reverse

public void reverse()
Reverse the actual direction of the motor, whatever it is now. Because this Method depends on the actual state of the Motor it depends on the value of localReturnMode. If localReturnMode is set to false it is possible e.g. that two calls to reverse() have the same effect as one. This can happen if the value from the first call still hasn't been set in the hardware-interface when the second call arrives.