Home AMX User Forum AMXForums Archive Threads Residential Forum

Dealing with large data...

jisaacjisaac Junior MemberPosts: 34

i have the following scenario:
in controlling a lighting system the following pieces of data must be taken into account & are needed for control. Im trying to find a way to keep all this data together (prefer structure) but cant seem to avoid having to use a multi- dimensional array.. note--i like to avoid multi dimen arrays when possible plus i like that structures have that "." feature , i.e -- music[1].title or tracks[2].artist. heres what i need--

zones--several light zones lets use 10 as an example (ie kitchen, pool house, mas.bed, etc)
within each zone exist several light fixture(loads) i.e. kitchen cans, kitchen island lights, kitchen undercab
for each light fixture(loads) several pieces if data are needed-- load id, load value, load name etc.

is there any way to handle the above in structure? i cant see how--any thoughts on how you would deal with this?
Thanks in advance for any help!!


  • Dan ColegroveDan Colegrove Junior Member Posts: 39
    Try Multi Structure

    I like to use multiple layers of structures for this type of scenario. Like this
    STRUCTURE _Fixture
      CHAR sName[64]	//Name of fixture i.e. Kitchen Cans, Kitchen island pendant
      INTEGER nType		//Type of fixture i.e. Can, fluorescent
      INTEGER nDraw		//Current Draw
    STRUCTURE _LightingInfo
      CHAR sName[64]
      _Fixture Fixture[16]
    _LightingInfo stLightZone[10]
    stLightZone[1].sName = 'Kitchen'
    stLightZone[1].Fixture[1].sName = 'Kitchen Cans'
    stLightZone[1].Fixture[1].nType = 1
    stLightZone[1].Fixture[1].nDraw = 280
    stLightZone[1].Fixture[2].sName = 'Kitchen island Pendant'
    stLightZone[1].Fixture[2].nType = 2
    stLightZone[1].Fixture[2].nDraw = 120
    stLightZone[2].sName = 'Bedroom'
    stLightZone[2].Fixture[1].sName = 'Bedroom Downlights'
    stLightZone[2].Fixture[1].nType = 1
    stLightZone[2].Fixture[1].nDraw = 460

    You can add more elements to the structures and hold all sorts of data. Thats why I use structures all the time and hardly ever use multi-dim arrays.
  • ericmedleyericmedley Senior Member - 4000+ posts Posts: 4,177
    I know it's just a 'flavor' thing, but I'd just do an MultiDim array myself. There's no real memory advantage one way or another. So, it's just a matter of personal taste in how you like to do the code.
  • Dan ColegroveDan Colegrove Junior Member Posts: 39

    Except with multi-dim arrays you can't hold CHARs and INTEGERs and LONGs ect... all at the same time in a nice neat package.

    i.e. This does not work;
    SomeData[1][1] = 1 //input number
    SomeData[1][2] = 'Some Source Name' //source name

    But this does;
    SomeData[1].nInputNum = 1 //input number
    SomeData[1].sSourceName = 'Source Name' //source name

    For me by creating a structure I know and remember exactly what data should be in the second dim of the array.

    Like you said its a matter of taste. I prefer to work with data in this way.
  • viningvining X Member Posts: 4,368
    You can go pretty deep with structures and have different branches off shoot with other braches just by putting previous devined structures into another structure and then putting that into another structure so on and on ...like Dan did here:
    STRUCTURE _LightingInfo
      CHAR sName[64]
      _Fixture Fixture[16]
    Use short names though cuz the deeper you go the longer you line is:

    So you can easily do a room and then break it down by lighting, audio, hvac, shades, presets and then each sub category can have what ever you want in it.
Sign In or Register to comment.