-
-
Notifications
You must be signed in to change notification settings - Fork 50
Give sensors information about their own variables #498
Description
Figure out a way to have a sensor figure out the metadata about its own variables. Currently that is stored in the variable objects, but it is also a property of the sensor's results passed to the variable via defines used in the specific variable constructors metadata. Right now there is no way for a sensor to know that the value in place 2 of its value array has the unit of meters. There's also no way to verify that someone doesn't try to create a variable erroneously linked to the value position of a sensor.
I'm not sure how to implement this. To store the information in the Sensor, each sensor would have to store a bunch of arrays of the metadata for each variable it can measure. And, because the same information is also a property of the variable itself - and variables need to store it since they could also be calculated and not linked to a sensor - storing the info in the Sensor object means it's stored twice.
Could the sensor initialization immediately create an instance of each possible variable and then place the pointers in the correct position in the variable pointer array store inside the sensor? Then, when a user wants to create a variable array, they could somehow get the pointer back out of the sensor object for the variables it created. Of course, that's a big change from how we've created the variable arrays and it means there are always a bunch of extra variable objects taking up space in memory even when the user has no use for them.