View Single Post
  #1   Spotlight this post!  
Unread 19-02-2012, 18:09
joelg236 joelg236 is offline
4334 Retired Mentor & Alumni
AKA: Joel Gallant
no team
Team Role: Mentor
 
Join Date: Dec 2011
Rookie Year: 2012
Location: Calgary
Posts: 733
joelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond repute
Potentiometer and analogue channels

Hey guys, our code returns a NullPointerException because it was already allocated to that channel, but we are 100% sure that it was not. We have code specifically designed to prevent this here:

Code:
if(potentiometerOn) {
            if(potentiometer instanceof AnalogChannel) {
                potentiometerEnabled = true;
            }else {
                potentiometerEnabled = false;
                potentiometer = new AnalogChannel(potentiometerChannel);
                if(potentiometer instanceof AnalogChannel) {
                    potentiometerEnabled = true;
                }
            }
        }
Is it that the variable potentiometer is not registered as an instance of AnalogueChannel (A weird class or something?) Maybe if we used potentiometerEnabled as our qualifier to create the new instance it would work? We are a bit confused at this.
Reply With Quote