Go to Post No need to apologize, you didn't do anything wrong. your just learning. thats what the forums are for. please keep them coming. - Tytus Gerrish [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 27-01-2015, 13:04
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Command Based Programming (Threads?)

Quote:
Originally Posted by notmattlythgoe View Post
I haven't looked at the wait command under the hood, but this is how I believe it works. I can look under the hood tonight at the source code and see if I'm correct.

Code:
public class WaitCommand extends Command {

     private double waitTime;

     public WaitCommand(double waitTime) {
          this.waitTime = waitTime;
     }

     public boolean isFinished() {
          return timeSinceInitialized >= waitTme;
     }
}
I don't read much Java code. Is this the correct interpretation of what that code is supposed to do?
- the first time it is executed it notes the system time so that it can compute the value of "timeSinceInitialized" each time it is executed.

- it gets executed every 20ms as long as it returns "isFinished()" as false

- it returns "isFinished()" as false as long as "timeSinceInitialized" is less than the desired "waitTime" that was passed as a parameter

- as long as it is returning "isFinished()" as false, any commands that are waiting for it to finish will not execute.

- when "timeSinceInitialized" is greater than or equal to the desired "waitTime", it returns "isFinished()" as true, which results in it being removed from the list of commands to be executed every 20ms. Any commands that were waiting for it to finish will now execute.

Reply With Quote
  #2   Spotlight this post!  
Unread 27-01-2015, 13:13
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,715
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Command Based Programming (Threads?)

Quote:
Originally Posted by Ether View Post
I don't read much Java code. Is this the correct interpretation of what that code is supposed to do?
- the first time it is executed it notes the system time so that it can compute the value of "timeSinceInitialized" each time it is executed.

- it gets executed every 20ms as long as it returns "isFinished()" as false

- it returns "isFinished()" as false as long as "timeSinceInitialized" is less than the desired "waitTime" that was passed as a parameter

- as long as it is returning "isFinished()" as false, any commands that are waiting for it to finish will not execute.

- when "timeSinceInitialized" is greater than or equal to the desired "waitTime", it returns "isFinished()" as true, which results in it being removed from the list of commands to be executed every 20ms. Any commands that were waiting for it to finish will now execute.

Yes, that would be the correct process from my interpretation.
Reply With Quote
Reply


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 11:10.

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