Main Site Documentation

Need a little direction with respect to global classes


#1

I’m hoping that someone can help me out with a point in the right direction, on how to dynamically declare a global class after startup.

The specific problem is dealing with large sensor networks. I’ve two scenario’s, where I’ve a large number of for example “houses” with say for example a single sensor, and the scenario where I’ve a single “house” with a large number of sensors.
I don’t want to create global classes for both house and sensor, because the multiplied memory usage gets to be to large.

(Ie, A museum that has 32 doors to monitor, windows, temperature ect to monitor, (so create arrays of 32 long) but it is a single location. VS a landlord that has 40 houses, with a single door, window, temperature ect, so using that 32 byte array multiplied by # of houses)… That’s simplified, but is the root of the issue. To complicate matters, the museum might have 32 Cerberus boards, each controlling each room, where as the houses each have one, its the permutations of all the combinations that have me struggling for an answer. My background is way more in electronic engineering vs programming, but slowly gaining proficiency. The light bulb keeps going off the more examples I go thru.

I can create the class at runtime, by reading in a setup file, but then it isn’t accessible outside of the instance, (which makes sense, given what classes are). Fundamentally if I could go back, and specify the array size after runtime, to a global class, it would solve all my issues.

Not looking for a tutorial here, but hoping somebody can either point me towards an example where this is done, or at least give me the right terms to google search.


#2

singleton design pattern


#3

Instead of modeling each sensor as an instance of a class, have one class that keeps a list of sensors.