Go to Post Where's the "drill enough weight holes so we're barely under 120lbs" option? ;-) - AlecMataloni [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 13-01-2011, 11:28
correnos correnos is offline
Registered User
FRC #2342
 
Join Date: Jan 2010
Location: Nashua, NH
Posts: 6
correnos is an unknown quantity at this point
Working with java classes

Hello,
I'm a programmer on an FRC team trying to work with Java. In previous years, we've programmed in C++, and we're making the switch this year. My question is on calling methods in the main class from other classes. Specifically, I'm trying to setup a separate thread for vacuum control, and would like to check whether the robot is enabled. Unfortunately, I cannot check RobotCode.isEnabled(), with the error "non-static method isEnabled() cannot be referenced from a static context". The same error pops up when attempting to access the Jaguar controlling the vacuum or the joystick's trigger. I understand why the error occurs, as these attempts access the class as opposed to its instance, however I do not know how I would work around this. Declaring the joystick and jaguar as static allow access to those, but I still cannot check isEnabled(). How would I check it? I could have a loop in RobotCode updating a static variable, but is there a better solution?

EDIT: I found that placing the vacuum class within the main class fixed the issue. It worked, but if anyone has a cleaner solution I would very much like to hear it.

Last edited by correnos : 13-01-2011 at 11:38.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:49.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi