View Single Post
  #4   Spotlight this post!  
Unread 21-01-2015, 10:46
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Using Global Variables Instead of Get Refnum

Quote:
Originally Posted by Doug Norman View Post
One way some teams do this is by creating a typedef enum updated with a list of all their RefNum names. Then they simply drop that enum followed by the Format Into String function any place they need a RefNum name. It's a bit of extra code, but makes it so they don't have to remember the names or correct spellings - they simply pick it from the enum list.
We've done that, and actually took the concept a bit farther a couple of years ago. Along with the typedefs (.ctl files in LabVIEW), we had a Global Variable vi full of cluster constant arrays that defined everything that goes into the Open functions. In Begin, we looped through those arrays for Drive, Digital Input, Motor, Encoder, etc. to open everything. In Finish, we did the same thing to close everything. We made copies of each Refnum Get vi and modified them to take the enum directly. The rest of the robot code looked almost the same as the "normal" way of doing things, except that the enums are blue where strings are pink.
Reply With Quote