Making it complicated... (programming-wise)
Jorde_V
Posts: 393
Trying to create a universal system for our touchpanels and systems. So I'll post what comes out of my head and hopefully someone push me in the right direction for what I'm trying to do.
I have rooms, touchpanels and devices. Aside from climate, light control etc.
I want to keep track of the device to control according to the room and the touchpanel controlling it. I then need to update the panels text (room text and device/page text).
So if I push the button 'tv' the following needs to happen:
- Open pop-up for TV
- Update panel's page-text
- Set the device to control
The issue is that text isn't a number nor are devices (well technically 3 numbers). So I need to keep track of all that using numbers and then if a number matches a device/text send that to the panel or use it to control a device.
So I would need to keep track of the device number and it's port. Because if it's in the 5001 range it's either IR or RS-232, but if it's in the 0 range I'm controlling an IP device. So there are exceptions, not to mention the possibility of multiple systems.
So I guess the way to go is structures, but if I look at the possibilities I'm probably making it way too complicated for it to be a useful system.
I would like to create a room according to a structure, but the structure would need to keep the rooms amount of lights, climate, security, devices, which touchpanels can control it, keep track of whether or not it's powered on fully or at least has powered on the necessary stuff, etc.
Most likely I'm just really looking at this in a very complicated manner and I hope you guys have different ways of figuring this all out.
So I hope I can some different views on this matter if you've been wanting/have done the same thing.
I have rooms, touchpanels and devices. Aside from climate, light control etc.
I want to keep track of the device to control according to the room and the touchpanel controlling it. I then need to update the panels text (room text and device/page text).
So if I push the button 'tv' the following needs to happen:
- Open pop-up for TV
- Update panel's page-text
- Set the device to control
The issue is that text isn't a number nor are devices (well technically 3 numbers). So I need to keep track of all that using numbers and then if a number matches a device/text send that to the panel or use it to control a device.
So I would need to keep track of the device number and it's port. Because if it's in the 5001 range it's either IR or RS-232, but if it's in the 0 range I'm controlling an IP device. So there are exceptions, not to mention the possibility of multiple systems.
So I guess the way to go is structures, but if I look at the possibilities I'm probably making it way too complicated for it to be a useful system.
I would like to create a room according to a structure, but the structure would need to keep the rooms amount of lights, climate, security, devices, which touchpanels can control it, keep track of whether or not it's powered on fully or at least has powered on the necessary stuff, etc.
Most likely I'm just really looking at this in a very complicated manner and I hope you guys have different ways of figuring this all out.
So I hope I can some different views on this matter if you've been wanting/have done the same thing.
0
Comments
examples:
My touch panels always have basically one page with a navigation bar/buttons. I call these buttons 'modes' They might be TV,House Music,HVAC,Ligthing, Security, etc... The buttonss themselves are blank and are filled in by the program from a big data array that holds all the values for these buttons and what kind of button they are going to be. This system also works with the smaller panels as you can scroll up and down the list of modes. So, there are typically 4-6 mode buttons on a panel. How the scroll behaves is also determined in the data table.
There's a big data table that manages the popups as well, which should be up, which go away, what they do. So, for example I have a standard Cablevision page. what box it controls is determined by the TV choice which is controlled by the mode section. Which audio zones are available on a given touch panle, which audio sources, what controls are available are, again controlled by the modes section.
TV control is done in a similar way. i don't have a section for Den TV, Living TV, etc.. They're just TVs and they have a numeric ID. The possibility to control any TV is there for any touch panel, but I limit it to whatever is considered local. (This also works with Man Caves as well - multiple TVs in one room)
I wrote a big TV control section on the same principle. I know when I select a TV source I mean to do the same thing each time: If TV power off, turn on. If TV not on source, get it there, If sound processor not on, turn on. If not on source, get it there. I also allow for 2 more aux source routers in the TVs because my designers seem to find the craziest ways to need to get some source where it's going.
Similarly, within the TV routine is a big section on just how the TV is controlled, IR and its channels, RS232 and it's commands, IP and its commands, AMX module and it's commands. You simply populate the data table and the correct flags for what kind of control is used.
Once you go through the heartache of getting all this setup, making a system is pretty much plug-n-play. I haven't written any actual code for TVs in quite some time.
That is how I approached it.
My first version of this program took me two solid weeks to create, and another to troubleshoot and iron out the kinks. I've been fine-tuning it as I run into different situations, but it's been a rock-solid approach so far.
I was an array kind of guy, but now have mostly (95+ %) structures. I use a lot of pre-compiler directives that dictate which structures get called. For example:
Inside EU_Structures, Rev 3 is:
In the main code, I have an init() function that again based on pre-compiler directives calls functions that fill in each structure's data. I set up how what the max number of TPs, max number of BDPs, max number of displays, etc. I also have a "Source" structure where the pop-up name is, whether it's a video source or an audio source only (this tells the display if it needs to turn on automatically or not - ex. satellite always turns on the TV - but these can be changed in the init() function as well.) I have allocated up to 40 different sources, but am at 30 at the current moment. You could even go as far as using #if_defined on the specific parts of the structure (which I'm starting to think about doing.) This way, you don't have an i_hdmiInput property if there is no HDMI switcher; or any receiver inputs if you don't have any receivers. This could (though I've not tried) cut down on the compile size.
Once all this information is filled in, the core code is nearly identical. My panel structure AND zone structures both have DEV vars in them - much like you are looking to do. It's a bit redundant in my opinion; the *only* time the panel's control device is different than the device in the zone it's controlling is when we are looking at what I call the "Whole House" page, which is a very quick glance at all of the sources available, and all of the rooms available (essentially a glorified matrix view of the system) and it allows the user to send and control specific sources to specific zones.
I have found that consistency is the key. I have a separate include file that lists all of the TP button numbers and that is what my TP must conform to. Otherwise, when I put in the code, it just doesn't work. While the panels are identical, customization is vital, if not for the client, out of necessity for the job; for example: Room A has 6 sources it can control / view, and Room B only has 4. What I do now (starting on this current job), is assign the source buttons the same variable text address as is their channel, and now I can move (using the BMF command), and hide (SHO command) source buttons on-the-fly dependent on what is needed. There's nothing more silly looking than buttons looking out of place and in my opinion, it's not necessary to have 5 different popups having all these different configurations based on the room. It got out of hand once when I had 18 panels (8400s, 5", 7", and 10" panels) with 50+ zones to control with all sorts of different configurations. I each popup had at least 5 different source configs so the popups were named "AV NAV 1", "AV NAV 2", etc. and I had to keep track of this in code. It was a disaster just because of the sheer size. I think I'd prefer one popup with the ability to move and remove buttons I need.
Anyway - sorry about the long (possibly useless) post. Good luck on the endeavor to become more organized; as Dave mentioned: it's a PITA to get it done, but once it is - it's a breeze there on out.
Who else is doing 2 port programming?
FYI, for those that don't know what the F' I'm talking about, all UI devices pretty much operate on the same TP port and you determine push function and feedback via code. The other port handles main page common features, etc.
That's what I've been doing for a while now, I can tell you that it can save you a lot of time especially when you have multiple touchpanels. Apart from that you centralize issues using this approach and you know it'll be in all your touchpanels if you make 1 error. (Aside from messing up the tp4 design). So yeah that's my approach, can be a pain to set up correctly, but a timesaver once done.
Not at all, I generally enjoy your long thorough explanations of how you're doing it. About the buttons thing, I was thinking of keeping that dynamic, so using the buttons numbers (say 6 sources on 1 page with possible expansion using an arrow).
101, 102, 103, 104, 105, 106 - change the icon and text according to what has to be loaded. Not using pop-ups at all. That way I can indefinitely expand it (theoretically) and have all the possible sources. So say if I have sources 1, 3, 4 and 6 available in a room I would allocate it to 101, 102, 103, 104 and leave out the last 2 buttons (105, 106) so that it still looks need from a UI/Design perspective. So using a check on the amount of sources and assign them accordingly.
I personally prefer structures as well as they allow me to hold any data_type.
Thanks for the info, I figured I'd start out small. But considering I've been using this system for a few projects now (a program as you go kind of approach, so it's been changed so much without a real set direction that it's not very usable or easy to expand or subtract stuff)
My designs are as identical as possible (obvious limitations left out (R4) or in case of bigger panels 12"+ a different approach).
The overlap is still great though.
Thanks for the info. I want to incorporate enough to keep make my systems ready for virtually anything. Much like you've made yours. As plug-n-pray as possible.
Frankly I'm quite amazed by the replies, I expected a few others to have thought of it and incorporated it, but not at this level. Thanks for the info guys, I'm going to work it out with my colleague this friday. I'll update this thread with my findings afterwards and
@alex
You should start worrying when you don't.