本文整理汇总了Java中edu.wpi.first.wpilibj.util.AllocationException类的典型用法代码示例。如果您正苦于以下问题:Java AllocationException类的具体用法?Java AllocationException怎么用?Java AllocationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AllocationException类属于edu.wpi.first.wpilibj.util包,在下文中一共展示了AllocationException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initDigitalPort
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
protected void initDigitalPort(int channel, boolean input) {
m_channel = channel;
checkDigitalChannel(m_channel);
try {
channels.allocate(m_channel);
} catch (CheckedAllocationException ex) {
throw new AllocationException("Digital input " + m_channel + " is already allocated");
}
long port_pointer = DIOJNI.getPort((byte) channel);
m_port = DIOJNI.initializeDigitalPort(port_pointer);
DIOJNI.allocateDIO(m_port, input);
}
开发者ID:trc492,项目名称:Frc2016FirstStronghold,代码行数:17,代码来源:DigitalSource.java
示例2: AnalogOutput
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
/**
* Construct an analog output on a specified MXP channel.
*
* @param channel The channel number to represent.
*/
public AnalogOutput(final int channel) {
m_channel = channel;
if (!AnalogJNI.checkAnalogOutputChannel(channel)) {
throw new AllocationException("Analog output channel " + m_channel
+ " cannot be allocated. Channel is not present.");
}
try {
channels.allocate(channel);
} catch (CheckedAllocationException e) {
throw new AllocationException("Analog output channel " + m_channel + " is already allocated");
}
long port_pointer = AnalogJNI.getPort((byte) channel);
m_port = AnalogJNI.initializeAnalogOutputPort(port_pointer);
LiveWindow.addSensor("AnalogOutput", channel, this);
UsageReporting.report(tResourceType.kResourceType_AnalogOutput, channel);
}
开发者ID:trc492,项目名称:Frc2016FirstStronghold,代码行数:25,代码来源:AnalogOutput.java
示例3: requestInterrupts
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
/**
* Request one of the 8 interrupts asynchronously on this digital input.
*
* @param handler The {@link InterruptHandlerFunction} that contains the
* method {@link InterruptHandlerFunction#interruptFired(int, Object)}
* that will be called whenever there is an interrupt on this device.
* Request interrupts in synchronous mode where the user program
* interrupt handler will be called when an interrupt occurs. The
* default is interrupt on rising edges only.
*/
public void requestInterrupts(InterruptHandlerFunction<?> handler) {
if (m_interrupt != 0) {
throw new AllocationException("The interrupt has already been allocated");
}
allocateInterrupts(false);
assert (m_interrupt != 0);
InterruptJNI.requestInterrupts(m_interrupt, getModuleForRouting(), getChannelForRouting(),
getAnalogTriggerForRouting());
setUpSourceEdge(true, false);
InterruptJNI.attachInterruptHandler(m_interrupt, handler.function,
handler.overridableParameter());
}
开发者ID:trc492,项目名称:Frc2016FirstStronghold,代码行数:26,代码来源:InterruptableSensorBase.java
示例4: initPWM
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
/**
* Initialize PWMs given a channel.
*
* This method is private and is the common path for all the constructors for
* creating PWM instances. Checks channel value ranges and allocates the
* appropriate channel. The allocation is only done to help users ensure that
* they don't double assign channels.
*$
* @param channel The PWM channel number. 0-9 are on-board, 10-19 are on the
* MXP port
*/
private void initPWM(final int channel) {
checkPWMChannel(channel);
m_channel = channel;
m_port = DIOJNI.initializeDigitalPort(DIOJNI.getPort((byte) m_channel));
if (!PWMJNI.allocatePWMChannel(m_port)) {
throw new AllocationException("PWM channel " + channel + " is already allocated");
}
PWMJNI.setPWM(m_port, (short) 0);
m_eliminateDeadband = false;
UsageReporting.report(tResourceType.kResourceType_PWM, channel);
}
开发者ID:trc492,项目名称:Frc2016FirstStronghold,代码行数:28,代码来源:PWM.java
示例5: initSolenoid
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
/**
* Common function to implement constructor behavior.
*/
private synchronized void initSolenoid() {
checkSolenoidModule(m_moduleNumber);
checkSolenoidChannel(m_channel);
try {
m_allocated.allocate(m_moduleNumber * kSolenoidChannels + m_channel);
} catch (CheckedAllocationException e) {
throw new AllocationException("Solenoid channel " + m_channel + " on module "
+ m_moduleNumber + " is already allocated");
}
long port = SolenoidJNI.getPortWithModule((byte) m_moduleNumber, (byte) m_channel);
m_solenoid_port = SolenoidJNI.initializeSolenoidPort(port);
LiveWindow.addActuator("Solenoid", m_moduleNumber, m_channel, this);
UsageReporting.report(tResourceType.kResourceType_Solenoid, m_channel, m_moduleNumber);
}
开发者ID:trc492,项目名称:Frc2016FirstStronghold,代码行数:21,代码来源:Solenoid.java
示例6: initRelay
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
/**
* Common relay initialization method. This code is common to all Relay
* constructors and initializes the relay and reserves all resources that need
* to be locked. Initially the relay is set to both lines at 0v.
*/
private void initRelay() {
SensorBase.checkRelayChannel(m_channel);
try {
if (m_direction == Direction.kBoth || m_direction == Direction.kForward) {
relayChannels.allocate(m_channel * 2);
UsageReporting.report(tResourceType.kResourceType_Relay, m_channel);
}
if (m_direction == Direction.kBoth || m_direction == Direction.kReverse) {
relayChannels.allocate(m_channel * 2 + 1);
UsageReporting.report(tResourceType.kResourceType_Relay, m_channel + 128);
}
} catch (CheckedAllocationException e) {
throw new AllocationException("Relay channel " + m_channel + " is already allocated");
}
m_port = DIOJNI.initializeDigitalPort(DIOJNI.getPort((byte) m_channel));
m_safetyHelper = new MotorSafetyHelper(this);
m_safetyHelper.setSafetyEnabled(false);
LiveWindow.addActuator("Relay", m_channel, this);
}
开发者ID:trc492,项目名称:Frc2016FirstStronghold,代码行数:28,代码来源:Relay.java
示例7: AnalogInput
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
/**
* Construct an analog channel.
*
* @param channel The channel number to represent. 0-3 are on-board 4-7 are on
* the MXP port.
*/
public AnalogInput(final int channel) {
m_channel = channel;
if (!AnalogJNI.checkAnalogInputChannel(channel)) {
throw new AllocationException("Analog input channel " + m_channel
+ " cannot be allocated. Channel is not present.");
}
try {
channels.allocate(channel);
} catch (CheckedAllocationException e) {
throw new AllocationException("Analog input channel " + m_channel + " is already allocated");
}
long port_pointer = AnalogJNI.getPort((byte) channel);
m_port = AnalogJNI.initializeAnalogInputPort(port_pointer);
LiveWindow.addSensor("AnalogInput", channel, this);
UsageReporting.report(tResourceType.kResourceType_AnalogChannel, channel);
}
开发者ID:trc492,项目名称:Frc2016FirstStronghold,代码行数:26,代码来源:AnalogInput.java
示例8: AnalogChannel
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
/**
* Construct an analog channel on a specified module.
*
* @param moduleNumber The digital module to use (1 or 2).
* @param channel The channel number to represent.
*/
public AnalogChannel(final int moduleNumber, final int channel) {
m_shouldUseVoltageForPID = false;
checkAnalogModule(moduleNumber);
checkAnalogChannel(channel);
m_channel = channel;
m_moduleNumber = moduleNumber;
m_module = AnalogModule.getInstance(moduleNumber);
try {
channels.allocate((moduleNumber - 1) * kAnalogChannels + m_channel - 1);
} catch (CheckedAllocationException e) {
throw new AllocationException(
"Analog channel " + m_channel + " on module " + m_moduleNumber + " is already allocated");
}
if (channel == 1 || channel == 2) {
m_accumulator = new tAccumulator((byte) (channel - 1));
m_accumulatorOffset = 0;
} else {
m_accumulator = null;
}
LiveWindow.addSensor("Analog", moduleNumber, channel, this);
UsageReporting.report(UsageReporting.kResourceType_AnalogChannel, channel, m_moduleNumber-1);
}
开发者ID:frc-team-342,项目名称:wpilibj,代码行数:30,代码来源:AnalogChannel.java
示例9: initCounter
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
private void initCounter(final Mode mode) {
m_allocatedUpSource = false;
m_allocatedDownSource = false;
try {
m_index = counters.allocate();
} catch (CheckedAllocationException e) {
throw new AllocationException("No counters left to be allocated");
}
m_counter = new tCounter(m_index);
m_counter.writeConfig_Mode(mode.value);
m_upSource = null;
m_downSource = null;
m_counter.writeTimerConfig_AverageSize(1);
UsageReporting.report(UsageReporting.kResourceType_Counter, m_index, mode.value);
}
开发者ID:frc-team-342,项目名称:wpilibj,代码行数:19,代码来源:Counter.java
示例10: initPWM
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
/**
* Initialize PWMs given an module and channel.
*
* This method is private and is the common path for all the constructors for creating PWM
* instances. Checks module and channel value ranges and allocates the appropriate channel.
* The allocation is only done to help users ensure that they don't double assign channels.
*/
private void initPWM(final int moduleNumber, final int channel) {
checkPWMModule(moduleNumber);
checkPWMChannel(channel);
try {
allocated.allocate((moduleNumber - 1) * kPwmChannels + channel - 1);
} catch (CheckedAllocationException e) {
throw new AllocationException(
"PWM channel " + channel + " on module " + moduleNumber + " is already allocated");
}
m_channel = channel;
m_module = DigitalModule.getInstance(moduleNumber);
m_module.setPWM(m_channel, kPwmDisabled);
m_eliminateDeadband = false;
UsageReporting.report(UsageReporting.kResourceType_PWM, channel, moduleNumber-1);
}
开发者ID:frc-team-342,项目名称:wpilibj,代码行数:24,代码来源:PWM.java
示例11: initRelay
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
/**
* Common relay initialization method.
* This code is common to all Relay constructors and initializes the relay and reserves
* all resources that need to be locked. Initially the relay is set to both lines at 0v.
* @param moduleNumber The number of the digital module to use.
*/
private void initRelay(final int moduleNumber) {
SensorBase.checkRelayModule(moduleNumber);
SensorBase.checkRelayChannel(m_channel);
try {
if (m_direction == Direction.kBoth || m_direction == Direction.kForward) {
relayChannels.allocate(((moduleNumber - 1) * kRelayChannels + m_channel - 1) * 2);
UsageReporting.report(UsageReporting.kResourceType_Relay, m_channel, moduleNumber-1);
}
if (m_direction == Direction.kBoth || m_direction == Direction.kReverse) {
relayChannels.allocate(((moduleNumber - 1) * kRelayChannels + m_channel - 1) * 2 + 1);
UsageReporting.report(UsageReporting.kResourceType_Relay, m_channel+128, moduleNumber-1);
}
} catch (CheckedAllocationException e) {
throw new AllocationException("Relay channel " + m_channel + " on module " + moduleNumber + " is already allocated");
}
m_module = DigitalModule.getInstance(moduleNumber);
m_module.setRelayForward(m_channel, false);
m_module.setRelayReverse(m_channel, false);
LiveWindow.addActuator("Relay", moduleNumber, m_channel, this);
}
开发者ID:frc-team-342,项目名称:wpilibj,代码行数:27,代码来源:Relay.java
示例12: allocateDIO
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
/**
* Allocate Digital I/O channels.
* Allocate channels so that they are not accidently reused. Also the direction is set at the
* time of the allocation.
*
* @param channel The channel to allocate.
* @param input Indicates whether the I/O pin is an input (true) or an output (false).
* @return True if the I/O pin was allocated, false otherwise.
*/
public boolean allocateDIO(final int channel, final boolean input) {
try {
DIOChannels.allocate((kDigitalChannels * (m_moduleNumber - 1) + channel - 1));
} catch (CheckedAllocationException e) {
throw new AllocationException(
"Digital channel " + channel + " on module " + m_moduleNumber + " is already allocated");
}
final int outputEnable = m_fpgaDIO.readOutputEnable();
final int bitToSet = 1 << (DigitalModule.remapDigitalChannel((channel - 1)));
short outputEnableValue;
if (input) {
outputEnableValue = (short) (outputEnable & (~bitToSet));
} else {
outputEnableValue = (short) (outputEnable | bitToSet);
}
m_fpgaDIO.writeOutputEnable(outputEnableValue);
return true;
}
开发者ID:frc-team-342,项目名称:wpilibj,代码行数:30,代码来源:DigitalModule.java
示例13: requestInterrupts
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
/**
* Request interrupts asynchronously on this digital input.
* @param handler The address of the interrupt handler function of type tInterruptHandler that
* will be called whenever there is an interrupt on the digitial input port.
* Request interrupts in synchronus mode where the user program interrupt handler will be
* called when an interrupt occurs.
* The default is interrupt on rising edges only.
* @param param argument to pass to the handler
*/
public void requestInterrupts(/*tInterruptHandler*/Object handler, Object param) {
//TODO: add interrupt support
try {
m_interruptIndex = interrupts.allocate();
} catch (CheckedAllocationException e) {
throw new AllocationException("No interrupts are left to be allocated");
}
allocateInterrupts(false);
m_interrupt.writeConfig_WaitForAck(false);
m_interrupt.writeConfig_Source_AnalogTrigger(getAnalogTriggerForRouting());
m_interrupt.writeConfig_Source_Channel((byte) getChannelForRouting());
m_interrupt.writeConfig_Source_Module((byte) getModuleForRouting());
setUpSourceEdge(true, false);
//TODO: m_manager.registerHandler(handler, param);
}
开发者ID:frc-team-342,项目名称:wpilibj,代码行数:29,代码来源:DigitalInput.java
示例14: initCounter
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
private void initCounter(final Mode mode)
{
m_allocatedUpSource = false;
m_allocatedDownSource = false;
try
{
m_index = counters.allocate();
}
catch (CheckedAllocationException e)
{
throw new AllocationException("No counters left to be allocated");
}
m_upSource = null;
m_downSource = null;
//UsageReporting.report(UsageReporting.kResourceType_Counter, m_index, mode.value);
}
开发者ID:wildstang111,项目名称:2013_drivebase_proto,代码行数:20,代码来源:Counter.java
示例15: AnalogChannel
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
/**
* Construct an analog channel on a specified module.
*
* @param moduleNumber The digital module to use (1 or 2).
* @param channel The channel number to represent.
*/
public AnalogChannel(final int moduleNumber, final int channel) {
checkAnalogModule(moduleNumber);
checkAnalogChannel(channel);
m_channel = channel;
m_moduleNumber = moduleNumber;
m_module = AnalogModule.getInstance(moduleNumber);
try {
channels.allocate((moduleNumber - 1) * kAnalogChannels + m_channel - 1);
} catch (CheckedAllocationException e) {
throw new AllocationException(
"Analog channel " + m_channel + " on module " + m_moduleNumber + " is already allocated");
}
if (channel == 1 || channel == 2) {
m_accumulator = new tAccumulator((byte) (channel - 1));
m_accumulatorOffset = 0;
} else {
m_accumulator = null;
}
LiveWindow.addSensor("Analog", moduleNumber, channel, this);
UsageReporting.report(UsageReporting.kResourceType_AnalogChannel, channel, m_moduleNumber-1);
}
开发者ID:eshsrobotics,项目名称:wpilib-java,代码行数:29,代码来源:AnalogChannel.java
示例16: setIndexSource
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
/**
* Set the index source for the encoder. When this source rises, the encoder count automatically
* resets.
*
* @param channel A DIO channel to set as the encoder index
* @param type The state that will cause the encoder to reset
*/
public void setIndexSource(int channel, IndexingType type) {
if (m_allocatedI) {
throw new AllocationException("Digital Input for Indexing already allocated");
}
m_indexSource = new DigitalInput(channel);
m_allocatedI = true;
setIndexSource(m_indexSource, type);
}
开发者ID:ArcticWarriors,项目名称:snobot-2017,代码行数:16,代码来源:Encoder.java
示例17: initAccumulator
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
/**
* Initialize the accumulator.
*/
public void initAccumulator() {
if (!isAccumulatorChannel()) {
throw new AllocationException("Accumulators are only available on slot " + kAccumulatorSlot
+ " on channels " + kAccumulatorChannels[0] + ", " + kAccumulatorChannels[1]);
}
m_accumulatorOffset = 0;
AnalogJNI.initAccumulator(m_port);
}
开发者ID:ArcticWarriors,项目名称:snobot-2017,代码行数:12,代码来源:AnalogInput.java
示例18: allocateInterrupts
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
/**
* Allocate the interrupt
*
* @param watcher true if the interrupt should be in synchronous mode where
* the user program will have to explicitly wait for the interrupt to
* occur.
*/
protected void allocateInterrupts(boolean watcher) {
try {
m_interruptIndex = interrupts.allocate();
} catch (CheckedAllocationException e) {
throw new AllocationException("No interrupts are left to be allocated");
}
m_isSynchronousInterrupt = watcher;
m_interrupt =
InterruptJNI.initializeInterrupts(m_interruptIndex, watcher);
}
开发者ID:trc492,项目名称:Frc2016FirstStronghold,代码行数:19,代码来源:InterruptableSensorBase.java
示例19: initAccumulator
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
/**
* Initialize the accumulator.
*/
public void initAccumulator() {
if (!isAccumulatorChannel()) {
throw new AllocationException(
"Accumulators are only available on slot " +
kAccumulatorSlot + " on channels " + kAccumulatorChannels[0] + "," + kAccumulatorChannels[1]);
}
m_accumulatorOffset = 0;
setAccumulatorCenter(0);
resetAccumulator();
}
开发者ID:frc-team-342,项目名称:wpilibj,代码行数:14,代码来源:AnalogChannel.java
示例20: initTrigger
import edu.wpi.first.wpilibj.util.AllocationException; //导入依赖的package包/类
/**
* Initialize an analog trigger from a module number and channel.
* This is the common code for the two constructors that use a module number and channel.
* @param moduleNumber The number of the analog module to create this trigger on.
* @param channel the port to use for the analog trigger
*/
protected void initTrigger(final int moduleNumber, final int channel) {
m_channel = channel;
m_analogModule = AnalogModule.getInstance(moduleNumber);
try {
m_index = triggers.allocate();
} catch (CheckedAllocationException e) {
throw new AllocationException("No analog triggers are available to allocate");
}
m_trigger = new tAnalogTrigger((byte) m_index);
m_trigger.writeSourceSelect_Channel((byte) (m_channel - 1));
m_trigger.writeSourceSelect_Module((byte) moduleNumber - 1);
UsageReporting.report(UsageReporting.kResourceType_AnalogTrigger, channel, moduleNumber-1);
}
开发者ID:frc-team-342,项目名称:wpilibj,代码行数:20,代码来源:AnalogTrigger.java
注:本文中的edu.wpi.first.wpilibj.util.AllocationException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论