Use of arrays to control similar devices
stopuz
Posts: 15
Hi All,
I just finished the Programmer II class and started working on an AV project. I have been a programmer, but new to AV control world and NetLinx Programming Language. As part of the project I need to control 8 NEC E552 TVs. I found the duet module for it and used in my code. The TVs are located in different rooms and are connected using DXLink Receivers.
I have one TP screen to control all of them (volume +/-, mute on/off, power on/off) really simple stuff.
I ended up creating separate TP ports for each TV and used the same channel numbers, but could not figure out how to simplify my code. So, I wrote the below code block for each TV (only one of them is shown):
My question is, how can I simplify my code? My not directly related, but I also have an issue with volume ramp up event, in which somehow the TV does not go above Volume level 13. On the TP I only have volume ramp up and down buttons no bargraph for level event. Any ideas?
Thanks,
Sinan
I just finished the Programmer II class and started working on an AV project. I have been a programmer, but new to AV control world and NetLinx Programming Language. As part of the project I need to control 8 NEC E552 TVs. I found the duet module for it and used in my code. The TVs are located in different rooms and are connected using DXLink Receivers.
I have one TP screen to control all of them (volume +/-, mute on/off, power on/off) really simple stuff.
I ended up creating separate TP ports for each TV and used the same channel numbers, but could not figure out how to simplify my code. So, I wrote the below code block for each TV (only one of them is shown):
DEFINE_DEVICE dvNEC_BLDGENGRG22_1 = 6008:1:0; dvTP_NEC_BLDGENGRG22_1 = 10001:18:0; vdvNEC_BLDGENGRG22_1 = 41008:1:0; DEFINE_VARIABLE VOLATILE DEVCHAN dcTP_NEC_BLDGENGRG22_1[]= { {dvTP_NEC_BLDGENGRG22_1, 24}, {dvTP_NEC_BLDGENGRG22_1, 25}, {dvTP_NEC_BLDGENGRG22_1, 199}, {dvTP_NEC_BLDGENGRG22_1, 27}, {dvTP_NEC_BLDGENGRG22_1, 28} } DEFINE_START DEFINE_MODULE 'NEC_E552_Comm_dr1_0_0' tv8(vdvNEC_BLDGENGRG22_1, dvNEC_BLDGENGRG22_1); DEFINE_EVENT BUTTON_EVENT [dcTP_NEC_BLDGENGRG22_1] { PUSH: { if (button.input.channel != 199) { IF (BUTTON.INPUT.CHANNEL == VOL_UP OR BUTTON.INPUT.CHANNEL == VOL_DN) { ON [vdvNEC_BLDGENGRG22_1, BUTTON.INPUT.CHANNEL]; } ELSE { PULSE [vdvNEC_BLDGENGRG22_1, BUTTON.INPUT.CHANNEL]; } } else { [vdvNEC_BLDGENGRG22_1, VOL_MUTE_ON] = ![vdvNEC_BLDGENGRG22_1, VOL_MUTE_FB]; } } RELEASE: { IF (BUTTON.INPUT.CHANNEL == VOL_UP OR BUTTON.INPUT.CHANNEL == VOL_DN) { ON [vdvNEC_BLDGENGRG22_1, BUTTON.INPUT.CHANNEL]; } } }
My question is, how can I simplify my code? My not directly related, but I also have an issue with volume ramp up event, in which somehow the TV does not go above Volume level 13. On the TP I only have volume ramp up and down buttons no bargraph for level event. Any ideas?
Thanks,
Sinan
0
Comments
If I understand your example correctly, you have shown the DEVCHAN array and button event handler for only one TV and would replicate this for each TV you are controlling. You could instead gather the TP ports in to a DEV array, the devices being controlled in to a second dev array and the button channels in to an INTEGER array, then use a single button event handler for them all.
For example: The single button event handler then deals with the defined button channels across all touch panel ports and sends the comand to the appropriate TV. Of course, this relies on the touch panel array and the virtual device array having their contents in the same order.
Andy
Just create another array to track what AV system / TV that any given TP should be controlling. Make the TP's index position match the corresponding index position of virtual dev of the controlled system.
Thank you guys. I will give these a try.
Vining,
In your example, what is the difference between the system and the TV? Why is another layer needed? Could you explain a liitle?
Thanks,
Sinan
Your Dev and vDev arrays will usually be in a constant static order in most cases which is why I tend create them as constant arrays not variable arrays but your TP system control array could vary day to day.
http://www.amxforums.com/showthread.php?9546-Using-a-duet-module-sample-workspace-for-multiple-touch-panels
Thanks,
Sinan