View Single Post
  #6   Spotlight this post!  
Unread 13-02-2014, 01:10
seg9585's Avatar
seg9585 seg9585 is offline
Registered User
AKA: Eric
FRC #4276 (Surf City Vikings)
Team Role: Engineer
 
Join Date: Feb 2006
Rookie Year: 2001
Location: Boeing (Seal Beach, CA)
Posts: 520
seg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond repute
Re: Rookie Java FRC programming buttons

Quote:
Originally Posted by aweso_meme View Post
So what would be the code for creating a Thread class?
Do I need to create a new class inside my current package, and then in the main class call Loop xyz = new Loop();, or do i need a certain constructor? Also, with xyz.start(); I read on the internet that these threads have precedence. Does this mean I can have the main class running at the same time or no?

EDIT: Also, If I do need to make a new class, what methods do I need to define and how do I call them in the tele-op method?

Thanks again.
You need to create a new Java file, with the name the same as your new class (this is the case for any class -- which you can call by adding to your project and creating an object of your new Class name.

For a "Thread" example:

class YourNewClass extends Thread {

YourNewClass(int x) {
//This is the constructor
}

public void run() {
//Put a while() loop in here
. . .
}
}

from your teleop class:

YourNewClass triggeraction = new YourNewClass();
triggeraction.setPriority(1); //The lower the priority, the thread will be executed last in the computing cycles. teleOp is top priority
triggeraction.run();

while(isEnabled()){....
__________________
My FIRST legacy:

Team 204 Student 2001, 2002 (Voorhees, NJ)
Team 1493 College Mentor 2006 - 2008 (Troy, NY)
Team 2150 Intern/Professional Mentor 2007, 2009 (Palos Verdes)
Team 4123 Lead Engineering Mentor 2012 (Bellflower, CA)
Team 4276 Engineering Mentor 2012-2016 (Huntington Beach, CA)
Reply With Quote