View Single Post
  #4   Spotlight this post!  
Unread 16-02-2013, 21:27
Cel Skeggs Cel Skeggs is offline
Robot Software Manager Alumnus
AKA: Previously known as Colby
FRC #1540 (The Flaming Chickens)
Team Role: Alumni
 
Join Date: Feb 2013
Rookie Year: 2009
Location: Portland, Oregon, USA
Posts: 107
Cel Skeggs is a glorious beacon of lightCel Skeggs is a glorious beacon of lightCel Skeggs is a glorious beacon of lightCel Skeggs is a glorious beacon of lightCel Skeggs is a glorious beacon of lightCel Skeggs is a glorious beacon of light
Re: AnalogChannel Already Allocated???

The problem here is that you are creating one instance of CurrentDetector for every instance of CommandBase.
Code:
// Create a single static instance of all of your subsystems
public static ExampleSubsystem exampleSubsystem = new ExampleSubsystem();
CurrentDetector currentDetector = new CurrentDetector();
SpikeLoad spikeLoad = new SpikeLoad();
Since you have multiple classes that extend CommandBase, you have multiple instances of CurrentDetector and SpikeLoad.
Each time you create a new instance of CurrentDetector, it tries to allocate Analog Channel 2. The error you are getting is that the channel is being allocated multiple times.

To fix this problem, you should make the instances of CurrentDetector and SpikeLoad static:
Code:
// Create a single static instance of all of your subsystems
public static ExampleSubsystem exampleSubsystem = new ExampleSubsystem();
public static CurrentDetector currentDetector = new CurrentDetector();
public static SpikeLoad spikeLoad = new SpikeLoad();
Reply With Quote