Go to Post I had a life before FIRST - I just can't remember what it was. - Tom Ore [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
  #3   Spotlight this post!  
Unread 06-03-2014, 07:55
kylelanman's Avatar
kylelanman kylelanman is offline
Programming Mentor
AKA: Kyle
FRC #2481 (Roboteers)
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Tremont Il
Posts: 186
kylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to all
Re: Grabbing subsystem data to use in another subsystem in Command Based

Keeping with the intent of the Command Based programming approach the only way to accomplish what you are asking is in commands. All commands inherit CommandBase and CommandBase contains static instances of each subsystem. In your command you could get the value of a sensor from your sensor subsystem and then based on it's value call different methods in your collector subsystem. This year we had a DistanceSensor subsystem. It essentially provided the distance we were from the goal in feet via a getDistance method. Our shooter had a setDistance method. In a command called AutoSetShooter we did the following. shooter->setDistance(distanceSensor->getDistance());

Depending on the application it might be better to restructure your subsystems so that the corresponding sensors for your collector are in your collector subsystem. The best example of this is limit switches and pots. They belong in the same subsystem that the actuator is in.

Kyle
__________________
"May the coms be with you"

Is this a "programming error" or a "programmer error"?

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

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