• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CheckedAllocationException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中edu.wpi.first.wpilibj.util.CheckedAllocationException的典型用法代码示例。如果您正苦于以下问题:Java CheckedAllocationException类的具体用法?Java CheckedAllocationException怎么用?Java CheckedAllocationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CheckedAllocationException类属于edu.wpi.first.wpilibj.util包,在下文中一共展示了CheckedAllocationException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initDigitalPort

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的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.CheckedAllocationException; //导入依赖的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: initSolenoid

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的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


示例4: initRelay

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的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


示例5: AnalogInput

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的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


示例6: AnalogChannel

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的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


示例7: initCounter

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的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


示例8: initPWM

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的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


示例9: initRelay

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的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


示例10: allocateDIO

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的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


示例11: requestInterrupts

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的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


示例12: initCounter

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的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


示例13: AnalogChannel

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的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


示例14: allocate

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的package包/类
/**
 * Allocate a resource. When a resource is requested, mark it allocated. In this case, a free
 * resource value within the range is located and returned after it is marked allocated.
 *
 * @return The index of the allocated block.
 * @throws CheckedAllocationException If there are no resources available to be allocated.
 */
public int allocate() throws CheckedAllocationException {
  for (int i = 0; i < m_size; i++) {
    if (m_numAllocated[i] == false) {
      m_numAllocated[i] = true;
      return i;
    }
  }
  throw new CheckedAllocationException("No available resources");
}
 
开发者ID:ArcticWarriors,项目名称:snobot-2017,代码行数:17,代码来源:Resource.java


示例15: allocateInterrupts

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的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


示例16: allocate

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的package包/类
/**
 * Allocate a resource. When a resource is requested, mark it allocated. In
 * this case, a free resource value within the range is located and returned
 * after it is marked allocated.
 *
 * @return The index of the allocated block.
 * @throws CheckedAllocationException If there are no resources available to
 *         be allocated.
 */
public int allocate() throws CheckedAllocationException {
  for (int i = 0; i < m_size; i++) {
    if (m_numAllocated[i] == false) {
      m_numAllocated[i] = true;
      return i;
    }
  }
  throw new CheckedAllocationException("No available resources");
}
 
开发者ID:trc492,项目名称:Frc2016FirstStronghold,代码行数:19,代码来源:Resource.java


示例17: initTrigger

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的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


示例18: initEncoder

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的package包/类
/**
 * Common initialization code for Encoders.
 * This code allocates resources for Encoders and is common to all constructors.
 * @param reverseDirection If true, counts down instead of up (this is all relative)
 * @param encodingType either k1X, k2X, or k4X to indicate 1X, 2X or 4X decoding. If 4X is
 * selected, then an encoder FPGA object is used and the returned counts will be 4x the encoder
 * spec'd value since all rising and falling edges are counted. If 1X or 2X are selected then
 * a counter object will be used and the returned value will either exactly match the spec'd count
 * or be double (2x) the spec'd count.
 */
private void initEncoder(boolean reverseDirection) {
    switch (m_encodingType.value) {
        case EncodingType.k4X_val:
            try {
                m_index = quadEncoders.allocate();
            } catch (CheckedAllocationException e) {
                throw new AllocationException("There are no encoders left to allocate");
            }
            m_encoder = new tEncoder(m_index);
            m_encoder.writeConfig_ASource_Module(m_aSource.getModuleForRouting());
            m_encoder.writeConfig_ASource_Channel(m_aSource.getChannelForRouting());
            m_encoder.writeConfig_ASource_AnalogTrigger(m_aSource.getAnalogTriggerForRouting());
            m_encoder.writeConfig_BSource_Module(m_bSource.getModuleForRouting());
            m_encoder.writeConfig_BSource_Channel(m_bSource.getChannelForRouting());
            m_encoder.writeConfig_BSource_AnalogTrigger(m_bSource.getAnalogTriggerForRouting());
            m_encoder.strobeReset();
            m_encoder.writeConfig_Reverse(reverseDirection);
            m_encoder.writeTimerConfig_AverageSize(1);
            if (m_indexSource != null) {
                m_encoder.writeConfig_IndexSource_Module(m_indexSource.getModuleForRouting());
                m_encoder.writeConfig_IndexSource_Channel(m_indexSource.getChannelForRouting());
                m_encoder.writeConfig_IndexSource_AnalogTrigger(m_indexSource.getAnalogTriggerForRouting());
                m_encoder.writeConfig_IndexActiveHigh(true);
            }
            m_counter = null;
            break;
        case EncodingType.k2X_val:
        case EncodingType.k1X_val:
            m_counter = new Counter(m_encodingType, m_aSource, m_bSource, reverseDirection);
            break;
    }
    m_distancePerPulse = 1.0;

    UsageReporting.report(UsageReporting.kResourceType_Encoder, m_index, m_encodingType.value);
    LiveWindow.addSensor("Encoder", m_aSource.getModuleForRouting(), m_aSource.getChannelForRouting(), this);
}
 
开发者ID:frc-team-342,项目名称:wpilibj,代码行数:47,代码来源:Encoder.java


示例19: initSolenoid

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的package包/类
/**
 * Common function to implement constructor behavior.
 */
private synchronized void initSolenoid() {
    checkSolenoidModule(m_moduleNumber);
    checkSolenoidChannel(m_channel);

    try {
        m_allocated.allocate((m_moduleNumber - 1) * kSolenoidChannels + m_channel - 1);
    } catch (CheckedAllocationException e) {
        throw new AllocationException(
                "Solenoid channel " + m_channel + " on module " + m_moduleNumber + " is already allocated");
    }

    LiveWindow.addActuator("Solenoid", m_moduleNumber, m_channel, this);
    UsageReporting.report(UsageReporting.kResourceType_Solenoid, m_channel, m_moduleNumber - 1);
}
 
开发者ID:frc-team-342,项目名称:wpilibj,代码行数:18,代码来源:Solenoid.java


示例20: allocateDO_PWM

import edu.wpi.first.wpilibj.util.CheckedAllocationException; //导入依赖的package包/类
/**
 * Allocate a DO PWM Generator.
 * Allocate PWM generators so that they are not accidently reused.
 */
public int allocateDO_PWM() {
    try {
        return DO_PWMGenerators[m_moduleNumber - 1].allocate();
    } catch (CheckedAllocationException e) {
        throw new AllocationException(
            "No Digital Output PWM Generators on module " + m_moduleNumber + " remaining");
    }
}
 
开发者ID:frc-team-342,项目名称:wpilibj,代码行数:13,代码来源:DigitalModule.java



注:本文中的edu.wpi.first.wpilibj.util.CheckedAllocationException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FlowSession类代码示例发布时间:2022-05-23
下一篇:
Java StatisticSet类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap