Quote:
Originally Posted by Greg McKaskle
The get/set refnum is what we refer to as a functional global. It stores data as a side-effect of its execution. It implements a name -> value lookup for some number of refnums of a given type.
Regular globals will work, but it will be more work to add one more sensor, one more motor, etc. With changes being made to the framework this year, it won't be as necessary to use either of these ... but that is for another day.
Greg McKaskle
|
This could actually be really nice. I have had to help so many teams debug their code because they accidentally put an extra space or changed a capitol in a refnum name. We have actually not used refnums at all since 2010, and instead implement our own functional globals for each subsystem with a Begin, Run and End enum, because of all the troubles refnums caused, plus the speed hit involved with a string lookup table. It will be interesting to see if the new changes do anything like this, even though this season is probably our last using LabVIEW.
As for the original question, the refnums are/were good because you could access the state of any IO object from anywhere in your code. The other solutions are like you said storing all these in globals, implementing your own storage, or running wires between every VI with the object state. For FRC, refnums were the easiest way to do this it seemed, but without compiler checking for the string, it caused a lot of headache.
__________________
All statements made are my own and not the feelings of any of my affiliated teams.
Teams 1510 and 2898 - Student 2010-2012
Team 4488 - Mentor 2013-2016
Co-developer of
RobotDotNet, a .NET port of the WPILib.