Help Compacting Code
remeolb
Junior Member
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.
Comments
-
If you really want the commands spaced that far apart, look up timelines in the NetLinx help file to send them at nice regular intervals. If you want them sent as fast as the device can process them, look up command queueing on this forum to see some ideas for keeping a list of commands and sending the next one as soon as the device responds to the previous one.
-
Couple of things I noticed (we do the same thing with our doorbells).
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:DEFINE_FUNCTION fnDOORBELL2() { SEND_STRING dvAUDIO_SWITCH,"'CL2I12O1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18T'"; WAIT 20 { FOR(nLOOP=1;nLOOP<=18;nLOOP++) { SEND_STRING dvAUDIO_SWITCH,"'CL2I',ITOA(nAV_ZONE_SOURCE[nLOOP]),'O',ITOA(nLOOP),'T'"; } } } -
That worked great. Thanks for the help!
-
Why are you sending raw strings to the switch? Are you not using a module? One of the advantages of sending commands rather than strings is that you don't need to worry so much about queueing since the controller has its own queue for send_commands.
If you use send_commands then you can do all the switching in one command without looping.
Paul -
Only if all the zones needed to return to the same source, however if the bathroom was listening to the radio input, and the kitchen was listening to the AudioRequest, you can't send a single-line command to switch them can you?If you use send_commands then you can do all the switching in one command without looping.
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. -
Another possibility would be for you to record a router preset before switching all of the output to the doorbell. Then after the doorbell has complete recall the preset to restore the router to it's previous config.
--D -
Nice TipAnother possibility would be for you to record a router preset before switching all of the output to the doorbell. Then after the doorbell has complete recall the preset to restore the router to it's previous config.
--D
Hi Dave! Thanks for the timely tip. -
Another possibility would be for you to record a router preset before switching all of the output to the doorbell. Then after the doorbell has complete recall the preset to restore the router to it's previous config.
--D
Good Call! Don't know why I didn't think of that. Thanks! -
Another possibility would be for you to record a router preset before switching all of the output to the doorbell. Then after the doorbell has complete recall the preset to restore the router to it's previous config.
--D
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 -
I haven't used the Precis, but the standard Autopatch command to record a preset is:
RR#T, where # is the preset number.
To recall a preset:
R#T, where # is the preset number.
--D -
Spire_Jeff wrote: »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
Yes, the Preceis DSP units support several presets.
Kevin D. -
There has to be a shorter way to do this. Any input?
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. -
shr00m-dew wrote: »Yes, the Preceis DSP units support several presets.
Kevin D.
I will give it a try. I never tried it, because I found this in the manual:Precis DSP
General Commands and Conditions
If the Level “ L” designation is omitted, the command is executed on the audio level. When entering BCS commands, either omit the Level designation or use Level 0 or Level 2 (Level 0 indicates all levels and the Stereo with DSP models only have one level).
Does not support global or local preset commands
Does not support auxiliary commands
Supports using a colon ( : ) to designate a range of destination numbers in multiple number entries.
Audio Commands
Full DSP functionality (page19)
Digital output volume control – absolute, relative and increment/decrement methods (page13)
Verifying volume status (page15)
Muting and un-muting outputs (page14)
Digital input gain control – absolute, relative and increment/decrement methods (page16)
Verifying digital input gain status (page18)
If this actually works, it will be a HUGE time savings for me.
Jeff
P.S.
I was talking about the Precis DSP
-
Spire_Jeff wrote: »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
Hmm.. Good thing I don't always read the manuals. This is controlling a DSP 18x18 and works fine:SEND_COMMAND AUDIO, "'PASS=RR1'" SEND_COMMAND AUDIO, "'PASS=CL2I',ITOA(IA_DOORBELL),'O1:18'" SEND_COMMAND AUDIO, "'PASS=CL0O1:18VA-300'" WAIT 100 { SEND_COMMAND AUDIO, "'PASS=R1'" }
Kevin D. -
Array Driven
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.
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums