本文整理汇总了Java中edu.wpi.first.wpilibj.util.BoundaryException类的典型用法代码示例。如果您正苦于以下问题:Java BoundaryException类的具体用法?Java BoundaryException怎么用?Java BoundaryException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoundaryException类属于edu.wpi.first.wpilibj.util包,在下文中一共展示了BoundaryException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import edu.wpi.first.wpilibj.util.BoundaryException; //导入依赖的package包/类
/**
* Execute a read transaction with the device.
*
* <p>Read bytes from a device. Most I2C devices will auto-increment the register pointer
* internally allowing you to read consecutive registers on a device in a single transaction.
*
* @param registerAddress The register to read first in the transaction.
* @param count The number of bytes to read in the transaction.
* @param buffer A buffer to store the data read from the device. Must be created using
* ByteBuffer.allocateDirect().
* @return Transfer Aborted... false for success, true for aborted.
*/
public boolean read(int registerAddress, int count, ByteBuffer buffer) {
if (count < 1) {
throw new BoundaryException("Value must be at least 1, " + count + " given");
}
if (!buffer.isDirect()) {
throw new IllegalArgumentException("must be a direct buffer");
}
if (buffer.capacity() < count) {
throw new IllegalArgumentException("buffer is too small, must be at least " + count);
}
ByteBuffer dataToSendBuffer = ByteBuffer.allocateDirect(1);
dataToSendBuffer.put(0, (byte) registerAddress);
return transaction(dataToSendBuffer, 1, buffer, count);
}
示例2: readOnly
import edu.wpi.first.wpilibj.util.BoundaryException; //导入依赖的package包/类
/**
* Execute a read only transaction with the device.
*
* <p>Read bytes from a device. This method does not write any data to prompt the device.
*
* @param buffer A pointer to the array of bytes to store the data read from the device.
* @param count The number of bytes to read in the transaction.
* @return Transfer Aborted... false for success, true for aborted.
*/
public boolean readOnly(byte[] buffer, int count) {
if (count < 1) {
throw new BoundaryException("Value must be at least 1, " + count + " given");
}
if (buffer == null) {
throw new NullPointerException("Null return buffer was given");
}
ByteBuffer dataReceivedBuffer = ByteBuffer.allocateDirect(count);
int retVal = I2CJNI.i2CRead((byte) m_port.value, (byte) m_deviceAddress, dataReceivedBuffer,
(byte) count);
dataReceivedBuffer.get(buffer);
return retVal < count;
}
示例3: read
import edu.wpi.first.wpilibj.util.BoundaryException; //导入依赖的package包/类
/**
* Execute a read transaction with the device.
*
* Read bytes from a device. Most I2C devices will auto-increment the
* register pointer internally allowing you to read consecutive
* registers on a device in a single transaction.
*
* @param registerAddress The register to read first in the transaction.
* @param count The number of bytes to read in the transaction.
* @param buffer A buffer to store the data read from the device. Must be
* created using ByteBuffer.allocateDirect().
* @return Transfer Aborted... false for success, true for aborted.
*/
public boolean read(int registerAddress, int count, ByteBuffer buffer) {
if (count < 1) {
throw new BoundaryException("Value must be at least 1, " + count +
" given");
}
if (!buffer.isDirect())
throw new IllegalArgumentException("must be a direct buffer");
if (buffer.capacity() < count)
throw new IllegalArgumentException("buffer is too small, must be at least " + count);
ByteBuffer dataToSendBuffer = ByteBuffer.allocateDirect(1);
dataToSendBuffer.put(0, (byte) registerAddress);
return transaction(dataToSendBuffer, 1, buffer, count);
}
示例4: readOnly
import edu.wpi.first.wpilibj.util.BoundaryException; //导入依赖的package包/类
/**
* Execute a read only transaction with the device.
*
* Read bytes from a device. This method does not write any data to prompt
* the device.
*
* @param buffer A pointer to the array of bytes to store the data read from
* the device.
* @param count The number of bytes to read in the transaction.
* @return Transfer Aborted... false for success, true for aborted.
*/
public boolean readOnly(byte[] buffer, int count) {
if (count < 1) {
throw new BoundaryException("Value must be at least 1, " + count +
" given");
}
if (buffer == null) {
throw new NullPointerException("Null return buffer was given");
}
ByteBuffer dataReceivedBuffer = ByteBuffer.allocateDirect(count);
int retVal =
I2CJNI.i2CRead((byte) m_port.getValue(), (byte) m_deviceAddress, dataReceivedBuffer,
(byte) count);
dataReceivedBuffer.get(buffer);
return retVal < 0;
}
示例5: setAnalogOut
import edu.wpi.first.wpilibj.util.BoundaryException; //导入依赖的package包/类
/**
* Set the analog output voltage.
*
* AO1 is pin 11 on the top connector (P2).
* AO2 is pin 12 on the top connector (P2).
* AO1 is the reference voltage for the 2 analog comparators on DIO15 and DIO16.
*
* The output range is 0V to 4V, however due to the supply voltage don't expect more than about 3V.
* Current supply capability is only 100uA.
*
* @param channel The analog output channel on the DS IO. [1,2]
* @param value The voltage to output on the channel.
*/
public void setAnalogOut(int channel, double value) throws EnhancedIOException {
BoundaryException.assertWithinBounds(channel, 1, 2);
if (!m_outputValid) {
throw new EnhancedIOException("Enhanced IO Missing");
}
if (value < 0.0) {
value = 0.0;
}
if (value > kAnalogOutputReference) {
value = kAnalogOutputReference;
}
if (value > kAnalogOutputReference) {
value = kAnalogOutputReference;
}
synchronized (m_outputDataSemaphore) {
m_outputData.data.dac[channel - 1] = (byte) (value / kAnalogOutputReference * kAnalogOutputResolution);
}
}
示例6: setLED
import edu.wpi.first.wpilibj.util.BoundaryException; //导入依赖的package包/类
/**
* Set the state of an LED on the IO board.
*
* @param channel The LED channel to set. [1,8]
* @param value True to turn the LED on.
*/
public void setLED(int channel, boolean value) throws EnhancedIOException {
BoundaryException.assertWithinBounds(channel, 1, 8);
if (!m_outputValid) {
throw new EnhancedIOException("Enhanced IO Missing");
}
byte leds;
synchronized (m_outputDataSemaphore) {
leds = m_outputData.data.leds;
leds &= ~(1 << (channel - 1));
if (value) {
leds |= 1 << (channel - 1);
}
m_outputData.data.leds = leds;
}
}
示例7: setDigitalOutput
import edu.wpi.first.wpilibj.util.BoundaryException; //导入依赖的package包/类
/**
* Set the state of a DIO line that is configured for digital output.
*
* @param channel The DIO channel to set. [1,16]
* @param value The state to set the selected channel to.
*/
public void setDigitalOutput(int channel, boolean value) throws EnhancedIOException {
BoundaryException.assertWithinBounds(channel, 1, 16);
if (!m_outputValid) {
throw new EnhancedIOException("Enhanced IO Missing");
}
short digital;
synchronized (m_outputDataSemaphore) {
if ((m_outputData.data.digital_oe & (1 << (channel - 1))) != 0) {
digital = m_outputData.data.digital;
digital &= ~(1 << (channel - 1));
if (value) {
digital |= 1 << (channel - 1);
}
m_outputData.data.digital = digital;
} else {
System.err.println("Line not configured for output");
}
}
}
示例8: setFixedDigitalOutput
import edu.wpi.first.wpilibj.util.BoundaryException; //导入依赖的package包/类
/**
* Set the state to output on a Fixed High Current Digital Output line.
*
* FixedDO1 is pin 5 on the top connector (P2).
* FixedDO2 is pin 3 on the top connector (P2).
*
* The FixedDO lines always output 0V and 3.3V regardless of J1 and J4.
* They can source 4mA and can sink 25mA. Because of this, they are expected to be used
* in an active low configuration, such as connecting to the cathode of a bright LED.
* Because they are expected to be active low, they default to true.
*
* @param channel The FixedDO channel to set.
* @param value The state to set the FixedDO.
*/
public void setFixedDigitalOutput(int channel, boolean value) throws EnhancedIOException {
BoundaryException.assertWithinBounds(channel, 1, 2);
if (!m_outputValid) {
throw new EnhancedIOException("Enhanced IO Missing");
}
byte digital;
synchronized (m_outputDataSemaphore) {
digital = m_outputData.data.fixed_digital_out;
digital &= ~(1 << (channel - 1));
if (value) {
digital |= 1 << (channel - 1);
}
m_outputData.data.fixed_digital_out = digital;
}
}
示例9: setInputRange
import edu.wpi.first.wpilibj.util.BoundaryException; //导入依赖的package包/类
/**
* Sets the maximum and minimum values expected from the input.
*
* @param minimumInput the minimum value expected from the input
* @param maximumInput the maximum value expected from the output
*/
public void setInputRange(double minimumInput, double maximumInput) {
if (minimumInput > maximumInput) {
throw new BoundaryException("Lower bound is greater than upper bound");
}
m_minimumInput = minimumInput;
m_maximumInput = maximumInput;
setSetpoint(m_setpoint);
}
示例10: setOutputRange
import edu.wpi.first.wpilibj.util.BoundaryException; //导入依赖的package包/类
/**
* Sets the minimum and maximum values to write.
*
* @param minimumOutput the minimum value to write to the output
* @param maximumOutput the maximum value to write to the output
*/
public void setOutputRange(double minimumOutput, double maximumOutput) {
if (minimumOutput > maximumOutput) {
throw new BoundaryException("Lower bound is greater than upper bound");
}
m_minimumOutput = minimumOutput;
m_maximumOutput = maximumOutput;
}
示例11: setInputRange
import edu.wpi.first.wpilibj.util.BoundaryException; //导入依赖的package包/类
/**
* Sets the maximum and minimum values expected from the input and setpoint.
*
* @param minimumInput the minimum value expected from the input
* @param maximumInput the maximum value expected from the input
*/
public synchronized void setInputRange(double minimumInput, double maximumInput) {
if (minimumInput > maximumInput) {
throw new BoundaryException("Lower bound is greater than upper bound");
}
m_minimumInput = minimumInput;
m_maximumInput = maximumInput;
setSetpoint(m_setpoint);
}
示例12: setOutputRange
import edu.wpi.first.wpilibj.util.BoundaryException; //导入依赖的package包/类
/**
* Sets the minimum and maximum values to write.
*
* @param minimumOutput the minimum percentage to write to the output
* @param maximumOutput the maximum percentage to write to the output
*/
public synchronized void setOutputRange(double minimumOutput, double maximumOutput) {
if (minimumOutput > maximumOutput) {
throw new BoundaryException("Lower bound is greater than upper bound");
}
m_minimumOutput = minimumOutput;
m_maximumOutput = maximumOutput;
}
示例13: setPIDSourceType
import edu.wpi.first.wpilibj.util.BoundaryException; //导入依赖的package包/类
/**
* Set which parameter of the encoder you are using as a process control variable. The counter
* class supports the rate and distance parameters.
*
* @param pidSource An enum to select the parameter.
*/
public void setPIDSourceType(PIDSourceType pidSource) {
if (pidSource == null) {
throw new NullPointerException("PID Source Parameter given was null");
}
BoundaryException.assertWithinBounds(pidSource.value, 0, 1);
m_pidSource = pidSource;
}
示例14: setPIDSourceType
import edu.wpi.first.wpilibj.util.BoundaryException; //导入依赖的package包/类
/**
* Set which parameter of the encoder you are using as a process control
* variable. The counter class supports the rate and distance parameters.
*
* @param pidSource An enum to select the parameter.
*/
public void setPIDSourceType(PIDSourceType pidSource) {
if (pidSource == null) {
throw new NullPointerException("PID Source Parameter given was null");
}
BoundaryException.assertWithinBounds(pidSource.value, 0, 1);
m_pidSource = pidSource;
}
示例15: readOnly
import edu.wpi.first.wpilibj.util.BoundaryException; //导入依赖的package包/类
/**
* Execute a read only transaction with the device.
* <p/>
* Read 1 to 7 bytes from a device. This method does not write any data to prompt
* the device.
*
* @param buffer A pointer to the array of bytes to store the data read from
* the device.
* @param count The number of bytes to read in the transaction. [1..7]
* @return Transfer Aborted... false for success, true for aborted.
*/
public boolean readOnly(byte[] buffer, int count) {
BoundaryException.assertWithinBounds(count, 1, 7);
if (buffer == null) {
throw new NullPointerException("Null return buffer was given");
}
ByteBuffer dataReceivedBuffer = ByteBuffer.allocateDirect(count);
int retVal = 0;
dataReceivedBuffer.get(buffer);
return retVal < 0;
}