Go to Post This is not an engineering design challenge, this is a project management and common sense challenge with engineering elements. Don't go out of your way to screw yourself. - PayneTrain [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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
  #16   Spotlight this post!  
Unread 03-12-2015, 09:07 PM
JefferMC JefferMC is offline
Registered User
AKA: Jeff Corbett
FRC #1319 (Flash)
Team Role: Mentor
 
Join Date: Nov 2012
Rookie Year: 2005
Location: United States
Posts: 44
JefferMC will become famous soon enough
Re: COmmand based software Interrupts

Quote:
Originally Posted by otherguy View Post

Here's why using the joy1button4->WhileHeld(new DropElevator()); as an example:
  1. Joy 1 Button 4 is pressed.
  2. A new command is created and added into the scheduler (DropElevator)
A small nit. The DropElevator() will be constructed by the new operator when this line of code in OI.CPP is executed. A pointer to that object will be passed to the WhileHeld method of the CommandButton class for the joy1button4 object. It will retain this pointer for use later when the button is held, thus, the correct order is:
  1. OI's constructor is called.
  2. The DropElevator command is created and its constructor called
    ...
  3. The button is pushed, triggering the WhileHeld
  4. The DropElevator's Initialize method is called
  5. The DropElevator's Execute method is called for the first time and will be called for every iteration until the button is released. To be honest, if Interupted() is called, or IsFinished() returns true, I'm not sure what the command based system might do with the fact that the button is still held.

The fact there is only one object created at Robot init (vs. one created every time the button is held) is only important if your command has member variables that might make a difference to you how many objects there are.
Reply With Quote
 


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 10:47 AM.

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