basic programming question
adcantrell
Posts: 24
so I'm finding myself buiding this program and i used power assign to number all my channels,etc but i did it so picked up off the last number used but now things are getting screwie bc if i need to add a button the numbers will all be out of order,etc.
and i'm looking at the netlinx code going, "man this is getting messy".So my question is. can someone tell me what your basic outline is when starting a fresh system is? is it:
-get the gui perfect
-then channel numbering
-then coding,etc?
bc what im doing is ive got this system now where none of the channels are in any order and im dublicating the tps for other rooms so im thinking is it better to give each source its own 100 channels like dvd=channels 100 to 200 , dvr= 201 to 301, cable box 2, 302 to 402, etc that way you have at least know what source has what and you also have some room to add buttons without screwing the numbering schedule?
i hope that all makes sense.
and i'm looking at the netlinx code going, "man this is getting messy".So my question is. can someone tell me what your basic outline is when starting a fresh system is? is it:
-get the gui perfect
-then channel numbering
-then coding,etc?
bc what im doing is ive got this system now where none of the channels are in any order and im dublicating the tps for other rooms so im thinking is it better to give each source its own 100 channels like dvd=channels 100 to 200 , dvr= 201 to 301, cable box 2, 302 to 402, etc that way you have at least know what source has what and you also have some room to add buttons without screwing the numbering schedule?
i hope that all makes sense.
0
Comments
Often I write the code first and then make a gui to match but it can be easier the other way around.
I've covered this in some detail here on the forums before, so I'll spare everyone the reading material and jump to the meat. Essentially how it works is you've got several "maps" (they can be variables because controlling which device could change on the fly.) For IR devices, it's super simple In your routine in which you fire up your devices (I have a function named fnROOM_POWER), you assign which IR device you want to control for that zone. This is typically done with device arrays and using either the default assignment (the kitchen touch panel by default controls the kitchen cable box.) Usually using a short button event that selects the index of the device array of cable boxes (along with switching appropriate audio and video.) With the main button events I've defined a TRANSPORT_BTNS array of 1 though 99. (Can you think of any devices that use more than 100 commands?)
Essentially, in the BUTTON_EVENT for the TRANSPORT_BTNS, you control a specific device based off of the zone's current source. You can use the AMX SNAPI or come up with your own (which is what I did.) For example: 1 = play, 2 = stop, 3 = pause, 44 = menu, 50 = exit, 55 = jump, 56 = DVR; most devices share common controls (DVRs, DVDs, VCRs, CD players, etc.) all use Play-Stop-Pause-FFWD-FRWD-Skip+ and Skip - (buttons 1-7) so they all get used in those sources.
Here's a quick example of my button event that handles all sources, and controls for all devices. (If you wanted an EXTREMELY basic system - you'd have your "function" to turn things on and off, and a button event to select the source (and turn it off), and a button event to control the devices. So the way I do things, you coudl have 1 function, 3 button events and you'd be up and going. Here's what my device control BUTTON_EVENT looks like.
You could really do anything and still make it flexible. I would not recommend making things static.
I.e. Side note, I from time to time have to deal with this type of coding; imagine 10 touch panels, and 55 button events each - and inside a switch / case for each source. If you have to go back and change all ten panels' play command - you've got 10 changes. Imagine you need to swap out an IR controlled DVD with a serial controlled DVD. 10 x 55 . . . do the math. Or, you could deal with something that's dependent on source selection other maps, and string arrays and make only 1 or two changes.
This assumes though that you've modified any IR files to use a specific command template (1 - play, 2 - stop, etc.)
Anyway - enough about code. As far as the order of getting it done. I go with GUI first (this way, I have a plan as to what I need to do with code instead of coding aimlessly or on the fly - and thing try to think how to fit it on the page, where it will go on the page and if I need popups or pages, or whatever! And you shouldn't have to start out fresh every single time. Once you have a flexible coding scheme in place, and a GUI that's easily customizable, but structurally the same - you should be able to deploy your code quickly. (Unless of course someone comes along, and "designs" the hardware layout to how they want it - and doesn't involve you in the process, then throws you 8 masters to control what 2 could do and you WANNA RIP YOUR HAIR OUT BECAUSE IT'S TAKING TOO MUCH TIME AND ARRRRRGH . . . umm - sorry.)
So if there's anything you get out of this long post - do not make thing so dependent on each other that when you need to make a change that it messes everything else. Keep it flexible, but realize when you that things will "appear" to be more complicated. This takes time in getting used to (i.e. arrays within arrays pointing to other arrays.) Also, you could easily do this with structures as well, I just haven't gotten around to making a drastic change like that yet.
Anyway - good luck and happy programming!
Now, if I had an IR file - they'd be mapped that way for me. I don't like having an IR lookup table, it takes too much time to configure from job to job in my opinion. I just want to slap something in and go and not have to think about which device uses which command index.
Instead of however many categories you have (I'd guess 4 or 5), I think it's much easier to handle 1. If I have 10 sources, I manage only 10 switch/cases . . . as opposed to however many categories you have time 10.
As the catchphrase goes in our industry: There are many ways to skin a cat.