Help Compacting Code
remeolb
Posts: 79
There has to be a shorter way to do this. Any input?
I'm also worried that I will need to cancel waits for example if the doorbell button is pushed again before all of the waits under the release are finished.
BUTTON_EVENT[dvFRONT_DOOR_INTERCOM,1] // BUTTON ON MET-ECOM AT FRONT DOOR { PUSH: { SEND_STRING dvAUDIO_SWITCH, "'CL2I13O1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18T'" // SWITCH ALL AUDIO SWITCHER OUTPUTS TO INPUT FROM DOORBELL INTERFACE ON[dvRELAYS1,1] // TRIGGER CHIME ON DOORBELL INTERFACE } RELEASE: { OFF[dvRELAYS1,1] // RELEASE TRIGGER FOR CHIME ON DOORBELL INTERFACE WAIT 20 // WAIT 2 SECONDS TO ALLOW TIME FOR CHIME TO PLAY THEN SWITCH ALL OUTPUTS BACK TO THE PREVIOUS INPUT { SEND_STRING dvAUDIO_SWITCH, "'CL2I',ITOA(nAUDIO_KITCHEN),'O1T'" WAIT 3 { SEND_STRING dvAUDIO_SWITCH, "'CL2I',ITOA(nAUDIO_HEARTH),'O2T'" WAIT 3 { SEND_STRING dvAUDIO_SWITCH, "'CL2I',ITOA(nAUDIO_LIVING),'O3T'" WAIT 3 { SEND_STRING dvAUDIO_SWITCH, "'CL2I',ITOA(nAUDIO_DINING),'O4T'" WAIT 3 { SEND_STRING dvAUDIO_SWITCH, "'CL2I',ITOA(nAUDIO_PANTRY),'O5T'" WAIT 3 { SEND_STRING dvAUDIO_SWITCH, "'CL2I',ITOA(nAUDIO_LAUNDRY),'O6T'" WAIT 3 { SEND_STRING dvAUDIO_SWITCH, "'CL2I',ITOA(nAUDIO_GARAGE),'O7T'" WAIT 3 { SEND_STRING dvAUDIO_SWITCH, "'CL2I',ITOA(nAUDIO_DECK),'O8T'" WAIT 3 { SEND_STRING dvAUDIO_SWITCH, "'CL2I',ITOA(nAUDIO_STUDY),'O9T'" WAIT 3 { SEND_STRING dvAUDIO_SWITCH, "'CL2I',ITOA(nAUDIO_MASTER_BEDROOM),'O10T'" WAIT 3 { SEND_STRING dvAUDIO_SWITCH, "'CL2I',ITOA(nAUDIO_MASTER_BATHROOM),'O11T'" WAIT 3 { SEND_STRING dvAUDIO_SWITCH, "'CL2I',ITOA(nAUDIO_PATIO),'O12T'" WAIT 3 { SEND_STRING dvAUDIO_SWITCH, "'CL2I',ITOA(nAUDIO_BASEMENT),'O13T'" WAIT 3 { SEND_STRING dvAUDIO_SWITCH, "'CL2I',ITOA(nAUDIO_EXERCISE),'O14T'" } } } } } } } } } } } } } } } }
I'm also worried that I will need to cancel waits for example if the doorbell button is pushed again before all of the waits under the release are finished.
0
Comments
1) I don't think there are commas in the protocol to switch multiple outputs, so I believe it should be SEND_STRING dvAUDIO_SWITCH, "'CL2I13O1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18T'"
2) I use a for loop to switch things back to it's previous source like so:
FOR(nLOOP=1;nLOOP<=18;nLOOP++)
SEND_STRING dvAUDIO_SWITCH,"'CL2I',ITOA(nAV_ZONE_SOURCE[nLOOP]),'O',ITOA(nLOOP),'T'"
I've not run into a problem with the speed of the strings going out to the Autopatch, so the waits are not needed.
Source information would be stored in nAV_ZONE_SOURCE instead of individual variables for each zone. Shown is what I'd do:
If you use send_commands then you can do all the switching in one command without looping.
Paul
Does the protocol support something like so?
CL2I1O1I2O4I3O5 6 7T
I've not seen the module, but I know for one the typical reason not to use modules is because they're so bloated. Plus - the protocol is rather simple.
--D
Hi Dave! Thanks for the timely tip.
Good Call! Don't know why I didn't think of that. Thanks!
I have looked for this option in the past, but did not find it in the Autopatch Precis LT. Any chance this has been added, or that I missed it in my search? I know that some switchers allow 1 or more such presets and it would really make my life easier if Autopatch units supported this.
Jeff
RR#T, where # is the preset number.
To recall a preset:
R#T, where # is the preset number.
--D
Yes, the Preceis DSP units support several presets.
Kevin D.
You need to start thinking about using a pacing queue, there are alot of post in this forum that show you how to write and use a queue.
I will give it a try. I never tried it, because I found this in the manual:
If this actually works, it will be a HUGE time savings for me.
Jeff
P.S.
I was talking about the Precis DSP
Hmm.. Good thing I don't always read the manuals. This is controlling a DSP 18x18 and works fine:
Kevin D.
All of my switcher code is array driven. I make all of the changes I need to a 2 dim array then do a send_command 'TAKE' My module parses the array and makes any switches that did not exist before and assembles the switching strings in as few send_strings as possible. I just save the current array of values if I need to get back to them. The array is passed to the module. I do this for Autopatch, and any other switcher.