edu.nau.cs.scu
Class PMCentralInterface

java.lang.Object
  extended by edu.nau.cs.scu.PMCentralInterface

public class PMCentralInterface
extends java.lang.Object

This class provides an interface for the physics simulation of the gimbal device. This class contains appropriate instances of all classes necessary for modeling the position of the gimbal and provides an interface of methods for interacting with these objects.

Author:
Bernard Jzexoia Avery

Field Summary
(package private)  long powerUpStartTime
           
 
Method Summary
 void beginPowerUp()
          Instruct the servo controller to begin the power-up sequence.
 void beginPowerUpFromMEU()
          Instruct the servo controller to begin the power-up sequence in response to a command from the MEU.
 void cageMode()
          Enable "Cage Mode", which will return the gimbal to the home position.
 void disableTorquers()
          This method will disable both servo motors and cause the device to stop in its tracks.
 void enableTorquers()
          This method will enable both servo motors, allowing the device to move again.
 void failPowerUp()
          Instruct the servo controller to fail the power-up sequence.
static PMCentralInterface getInstance()
          Provides a static instance of this class.
 Status getStatus(int selectedSensor)
          This method gathers data about the state of the device from each component and returns a Status object describing that state.
 void passPowerUp()
          Instruct the servo controller to pass the power-up sequence.
 void positionMode(double e, double a)
          Enable "Position Mode", which will move the gimbal to a specified position at the default rate for the device.
 void rateMode(double e, double a)
          Enable "Rate Mode", which will move the gimbal at a specified rate until it either reaches a hard or soft stop or another movement command is received.
 void receiveInvalidCommand()
          Instruct the simulation to simulate receiving a single invalid command.
 void selectPortAntenna()
          Set the Port Antenna as selected.
 void selectStarboardAntenna()
          Set the Starboard Antenna as selected.
 void setErrors(boolean powerUpFail, boolean invalidCommand, boolean elevationRDError, boolean azimuthRDError, boolean elevationFoldBackError, boolean azimuthFoldBackError, boolean vendorError1, boolean vendorError0)
          Set all the custom error flags which this simulation is capable of accounting for:
 void setForcePowerUpFail(boolean forcePowerUpFail)
          Instruct this simulation whether or not to pass any power-up test sequences.
 void setNegativeSoftStop(double e, double a)
          Set up the negative soft stop positions for each servo.
 void setPositiveSoftStop(double e, double a)
          Set up the positive soft stop positions for each servo.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

powerUpStartTime

long powerUpStartTime
Method Detail

getInstance

public static PMCentralInterface getInstance()
Provides a static instance of this class. This allows us to use the PMCentralInterface as a singleton in our program which simplifies its interaction with other components a great deal


selectPortAntenna

public void selectPortAntenna()
Set the Port Antenna as selected. This method will simultaneously deselect the Starboard Antenna but will be ignored if the device is currently powering up or forcing commands to be treated as invalid.


selectStarboardAntenna

public void selectStarboardAntenna()
Set the Starboard Antenna as selected. This method will simultaneously deselect the Port Antenna but will be ignored if the device is currently powering up or forcing commands to be treated as invalid.


disableTorquers

public void disableTorquers()
This method will disable both servo motors and cause the device to stop in its tracks. This command will be ignored if the device is currently powering up or forcing commands to be treated as invalid.


enableTorquers

public void enableTorquers()
This method will enable both servo motors, allowing the device to move again. This command will be ignored if the device is currently powering up or forcing commands to be treated as invalid.


cageMode

public void cageMode()
Enable "Cage Mode", which will return the gimbal to the home position. Note that the device will not change its mode to "Cage Mode" until the home position has been reached, as per the specifications of the SCU device itself. This command will be ignored if the device is currently powering up or forcing commands to be treated as invalid.


positionMode

public void positionMode(double e,
                         double a)
Enable "Position Mode", which will move the gimbal to a specified position at the default rate for the device. If a position is specified which is beyond the upper or lower bounds for the servos, the servos will treat this as a command to move to their nearest valid location. Position vales should not exceed 360 degrees. This command will cause the device to enter "Position Mode." This command will be ignored if the device is currently powering up or forcing commands to be treated as invalid.

Parameters:
e - The desired position for the elevation servo, in radians.
a - The desired position for the azimuth servo, in radians.

rateMode

public void rateMode(double e,
                     double a)
Enable "Rate Mode", which will move the gimbal at a specified rate until it either reaches a hard or soft stop or another movement command is received. This command will be ignored if the device is currently powering up or forcing commands to be treated as invalid. Rates should not exceed +/-30 degrees/second. This command will cause the device to enter "Rate Mode."

Parameters:
e - The desired rate for the elevation servo, in radians per second.
a - The desired rate for the azimuth servo, in radians per second.

setPositiveSoftStop

public void setPositiveSoftStop(double e,
                                double a)
Set up the positive soft stop positions for each servo. Note that setting the positive soft stop for a servo to a value lower than that of its negative soft stop will prevent that servo from moving at all. This command will cause the device to enter "Positive Soft Stop Mode." This command will be ignored if the device is currently powering up or forcing commands to be treated as invalid. Note that setting the positive soft stop for a servo to a value lower than that of its negative soft stop will prevent that servo from moving at all.

Parameters:
e - The desired soft stop for the elevation servo, in radians.
a - The desired soft stop for the azimuth servo, in radians.

setNegativeSoftStop

public void setNegativeSoftStop(double e,
                                double a)
Set up the negative soft stop positions for each servo. Note that setting the negative soft stop for a servo to a value higher than that of its positive soft stop will prevent that servo from moving at all. This command will cause the device to enter "Negative Soft Stop Mode." This command will be ignored if the device is currently powering up or forcing commands to be treated as invalid.

Parameters:
e - The desired soft stop for the elevation servo, in radians.
a - The desired soft stop for the azimuth servo, in radians.

getStatus

public Status getStatus(int selectedSensor)
This method gathers data about the state of the device from each component and returns a Status object describing that state. This method should be called at least 50 times per second for accurate simulation. Note that this method simply returns a Status object and not a valid serial message, so there is no need to send a response to the MEU every time this method is called.

Parameters:
selectedSensor - the index of the sensor to be recorded in this status message.
Returns:
a status object describing the state of the gimbal

setErrors

public void setErrors(boolean powerUpFail,
                      boolean invalidCommand,
                      boolean elevationRDError,
                      boolean azimuthRDError,
                      boolean elevationFoldBackError,
                      boolean azimuthFoldBackError,
                      boolean vendorError1,
                      boolean vendorError0)
Set all the custom error flags which this simulation is capable of accounting for:

Parameters:
powerUpFail - This error will cause any power-up sequence to fail.
invalidCommand - This error will cause the simulation to treat all incoming commands as invalid.
elevationRDError - Indicate an Elevation RD Error.
azimuthRDError - Indicate an Azimuth RD Error.
elevationFoldBackError - Indicate an Elevation Current Fold-Back Error.
azimuthFoldBackError - Indicate an Azimuth Current Fold-Back Error.
vendorError1 - Indicate vendor-defined error #1
vendorError0 - Indicate vendor-defined error #0

beginPowerUp

public void beginPowerUp()
Instruct the servo controller to begin the power-up sequence. This will change the mode to Powering Up and begin a 5-second countdown to the end of the power-up sequence.


beginPowerUpFromMEU

public void beginPowerUpFromMEU()
Instruct the servo controller to begin the power-up sequence in response to a command from the MEU. This differs from beginPowerUp() in that this command will be ignored if the device is already starting up or is treating inomging commands as invalid.


passPowerUp

public void passPowerUp()
Instruct the servo controller to pass the power-up sequence. This may be called at the end of a power-up sequence.


failPowerUp

public void failPowerUp()
Instruct the servo controller to fail the power-up sequence. This may be called at the end of a power-up sequence.


setForcePowerUpFail

public void setForcePowerUpFail(boolean forcePowerUpFail)
Instruct this simulation whether or not to pass any power-up test sequences.

Parameters:
forcePowerUpFail - If true, the simulation will fail any power-up test sequences. If false, it will pass any power-up test sequences.

receiveInvalidCommand

public void receiveInvalidCommand()
Instruct the simulation to simulate receiving a single invalid command.