Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Can isTimedOut() be used in a command group? (http://www.chiefdelphi.com/forums/showthread.php?t=127594)

Tedi 07-03-2014 20:50

Can isTimedOut() be used in a command group?
 
Hey guys,
So I was wondering if in the constructor of a command group (where addParallel and addSequential are added), can I also add setTimeout(x); and then check within the same command group if it has timed out? I am asking because I am unsure if setting a timeout inside a command group actually works or if it's only for commands.

Example:

Code:

public class cmdg extends CommandGroup {
    boolean A = false;
    public cmdg() {
        setTimeout(x);
        addSequential(command_here, x);
        if (isTimedOut()) {
            A = false;
        } else {
            A = true;
        }
        if (A) {
            //stuff here
        } else {
            //stuff here
        }
       
       
       
    }
}

Thanks,
Tedi

Joe Ross 07-03-2014 22:20

Since CommandGroup extends Command, you can override isFinished. However CommandGroup isFinished implements a few checks, so you should make your isFinished be super.isFinished() || isTimedout() or you'll break the CommandGroup.

Arhowk 09-03-2014 15:27

Re: Can isTimedOut() be used in a command group?
 
No. The constructor only runs once at robot initialization, so none of the commands should be timed out.

NotInControl 14-03-2014 15:51

Re: Can isTimedOut() be used in a command group?
 
Quote:

Originally Posted by Arhowk (Post 1355890)
No. The constructor only runs once at robot initialization, so none of the commands should be timed out.

To reiterate this....

The only way to use isTimedOut is to first use seTimeOut within the command, or command group.

If you use the 2 paramter constructor to set the timeout value, this is never seen by the command, instead I believe it is passed to the scheduler to be killed.

So isTimedOut will always return false, unless you exlicitly set the timeout within the command itself.

Is that clear?

Hope this helps,
Kevin


All times are GMT -5. The time now is 22:38.

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