Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   DefaultCommand won't restart? (http://www.chiefdelphi.com/forums/showthread.php?t=112552)

Fifthparallel 01-02-2013 20:45

DefaultCommand won't restart?
 
Hey, I run SetDefaultCommand(new [insert default command]()); but whenever I run a command that interrupts it (cancels default command), the default command will not restart. I have tried calling InitDefaultCommand inside of End() of the interrupting command, but this will not start the default command.

Can anybody tell me how to restart the default command after another command interrupts it?

William Kunkel 03-02-2013 21:14

Re: DefaultCommand won't restart?
 
Can you post some code? Also, are you sure the interrupting command ends when you think it does?

Fifthparallel 04-02-2013 01:39

Re: DefaultCommand won't restart?
 
Sorry for not posting the solution I found!
Long story short, I needed to call SetExpiration(double X.Y) and SetSafetyEnabled(false) for the RobotDrive object.

The example I was trying to play with/test was basic ArcadeDrive, and a command that would drive the motors forward for 5 seconds. SetSafetyEnabled(true) with no SetExpiration(double X.Y) was called for the RobotDrive object initialization for the subsystem. The command would set the RobotDrive object (which I'll just call *drive) to drive->Drive(0.7) and SetTimeout(5) in the Initialize method of the command. Then, IsFinished would return IsTimedOut().

At runtime, whenever the button that spawned this command was called, the diagnostics tab would spit out errors about motors exceeding a timeout at line 117 of MotorSafetyHelper.cpp. And so on.

Essentially, this was a problem I could have solved by looking at the Simple Robot Template, a beginner's mistake.


All times are GMT -5. The time now is 12:56.

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