Removed analog and digital module numbers

AnalogModule and DigitalModule classes still exist, at least until they are
refactored into the classes that use them.

Change-Id: I5544d5418822f19d54ba0a5d651e64fad8b7b10d
This commit is contained in:
thomasclark
2014-06-13 17:45:10 -04:00
parent aa3b24092a
commit 58021f7397
90 changed files with 852 additions and 1988 deletions

View File

@@ -22,17 +22,17 @@ public class AnalogChannel extends SensorBase implements PIDSource,
/**
* Construct an analog channel on the default module.
*
*
* @param channel
* The channel number to represent.
*/
public AnalogChannel(final int channel) {
this(getDefaultAnalogModule(), channel);
this(1, channel);
}
/**
* Construct an analog channel on a specified module.
*
*
* @param moduleNumber
* The digital module to use (1 or 2).
* @param channel
@@ -58,7 +58,7 @@ public class AnalogChannel extends SensorBase implements PIDSource,
* Get a scaled sample straight from this channel on the module. The value
* is scaled to units of Volts using the calibrated scaling data from
* getLSBWeight() and getOffset().
*
*
* @return A scaled sample straight from this channel on the module.
*/
public double getVoltage() {
@@ -72,7 +72,7 @@ public class AnalogChannel extends SensorBase implements PIDSource,
* oversampling will cause this value to be higher resolution, but it will
* update more slowly. Using averaging will cause this value to be more
* stable, but it will update more slowly.
*
*
* @return A scaled sample from the output of the oversample and average
* engine for this channel.
*/
@@ -82,7 +82,7 @@ public class AnalogChannel extends SensorBase implements PIDSource,
/**
* Get the channel number.
*
*
* @return The channel number.
*/
public int getChannel() {
@@ -91,7 +91,7 @@ public class AnalogChannel extends SensorBase implements PIDSource,
/**
* Gets the number of the analog module this channel is on.
*
*
* @return The module number of the analog module this channel is on.
*/
public int getModuleNumber() {
@@ -100,7 +100,7 @@ public class AnalogChannel extends SensorBase implements PIDSource,
/*
* Get the average value for use with PIDController
*
*
* @return the average value
*/
public double pidGet() {

View File

@@ -11,13 +11,13 @@ package edu.wpi.first.wpilibj;
* Base class for all sensors.
* Stores most recent status information as well as containing utility functions for checking
* channels and error processing.
*
*
* XXX: Wait, there's no exception thrown if we try to allocate a non-existent module? It that behavior correct?
*/
public abstract class SensorBase { // TODO: Refactor
// TODO: Move this to the HAL
/**
* Ticks per microsecond
*/
@@ -26,25 +26,16 @@ public abstract class SensorBase { // TODO: Refactor
* Number of digital channels per digital sidecar
*/
public static final int kDigitalChannels = 14;
/**
* Number of digital modules
* XXX: This number is incorrect. We need to find the correct number.
*/
public static final int kDigitalModules = 2;
/**
* Number of analog channels per module
*/
public static final int kAnalogChannels = 8;
/**
* Number of analog modules
*/
public static final int kAnalogModules = 2;
/**
* Number of solenoid channels per module
*/
public static final int kSolenoidChannels = 8;
/**
* Number of analog modules
* Number of solenoid modules
*/
public static final int kSolenoidModules = 2;
/**
@@ -56,8 +47,6 @@ public abstract class SensorBase { // TODO: Refactor
*/
public static final int kRelayChannels = 8;
private static int m_defaultAnalogModule = 1;
private static int m_defaultDigitalModule = 1;
private static int m_defaultSolenoidModule = 1;
/**
@@ -66,32 +55,6 @@ public abstract class SensorBase { // TODO: Refactor
public SensorBase() {
}
/**
* Sets the default Digital Module.
* This sets the default digital module to use for objects that are created without
* specifying the digital module in the constructor. The default module is initialized
* to the first module in the chassis.
*
* @param moduleNumber The number of the digital module to use.
*/
public static void setDefaultDigitalModule(final int moduleNumber) {
checkDigitalModule(moduleNumber);
SensorBase.m_defaultDigitalModule = moduleNumber;
}
/**
* Sets the default Analog module.
* This sets the default analog module to use for objects that are created without
* specifying the analog module in the constructor. The default module is initialized
* to the first module in the chassis.
*
* @param moduleNumber The number of the analog module to use.
*/
public static void setDefaultAnalogModule(final int moduleNumber) {
checkAnalogModule(moduleNumber);
SensorBase.m_defaultAnalogModule = moduleNumber;
}
/**
* Set the default location for the Solenoid (9472) module.
*
@@ -102,51 +65,6 @@ public abstract class SensorBase { // TODO: Refactor
SensorBase.m_defaultSolenoidModule = moduleNumber;
}
/**
* Check that the digital module number is valid.
* Module numbers are 1 or 2 (they are no longer real cRIO slots).
*
* @param moduleNumber The digital module module number to check.
*/
protected static void checkDigitalModule(final int moduleNumber) {
// TODO: fix
if(moduleNumber == 1 || moduleNumber == 2)
System.err.println("Digital module " + moduleNumber + " is not present.");
}
/**
* Check that the digital module number is valid.
* Module numbers are 1 or 2 (they are no longer real cRIO slots).
*
* @param moduleNumber The digital module module number to check.
*/
protected static void checkRelayModule(final int moduleNumber) {
checkDigitalModule(moduleNumber);
}
/**
* Check that the digital module number is valid.
* Module numbers are 1 or 2 (they are no longer real cRIO slots).
*
* @param moduleNumber The digital module module number to check.
*/
protected static void checkPWMModule(final int moduleNumber) {
checkDigitalModule(moduleNumber);
}
/**
* Check that the analog module number is valid.
* Module numbers are 1 or 2 (they are no longer real cRIO slots).
*
* @param moduleNumber The analog module module number to check.
*/
protected static void checkAnalogModule(final int moduleNumber) {
// TODO: fix
if(moduleNumber == 1 || moduleNumber == 2) {
System.err.println("Analog module " + moduleNumber + " is not present.");
}
}
/**
* Verify that the solenoid module is correct.
* Module numbers are 1 or 2 (they are no longer real cRIO slots).
@@ -226,24 +144,6 @@ public abstract class SensorBase { // TODO: Refactor
}
}
/**
* Get the number of the default analog module.
*
* @return The number of the default analog module.
*/
public static int getDefaultAnalogModule() {
return SensorBase.m_defaultAnalogModule;
}
/**
* Get the number of the default analog module.
*
* @return The number of the default analog module.
*/
public static int getDefaultDigitalModule() {
return SensorBase.m_defaultDigitalModule;
}
/**
* Get the number of the default analog module.
*