Stuck on ReQuest Part of program
ondrovic
Posts: 217
Hello all,
Let me start by telling you about the problem I am having :
We put in a 4 Zone Audio ReQuest at a clients house. Each Zone Controls a different floor ( Zone 1 : Floor 1; Zone 2 : Floor 2 etc ). There are 3 CP4/A's ( 1st Floor, 2nd Floor & 4th Floor ), 1 VPT-CP ( theater ) and 5 MSP8's ( 1 - 1st Floor, 2 - 2nd Floor & 2 - 3rd Floor ). All the zones are being controlled correctly for each of the locations but none of the functions I have setup to work with the keypads are working correctly.
Here is the source function call ( the one that isn't working correctly although strDebug is telling me its working
Going to continue with new post to save scroll time
Let me start by telling you about the problem I am having :
We put in a 4 Zone Audio ReQuest at a clients house. Each Zone Controls a different floor ( Zone 1 : Floor 1; Zone 2 : Floor 2 etc ). There are 3 CP4/A's ( 1st Floor, 2nd Floor & 4th Floor ), 1 VPT-CP ( theater ) and 5 MSP8's ( 1 - 1st Floor, 2 - 2nd Floor & 2 - 3rd Floor ). All the zones are being controlled correctly for each of the locations but none of the functions I have setup to work with the keypads are working correctly.
Here is the source function call ( the one that isn't working correctly although strDebug is telling me its working
Source Function
DEFINE_CALL 'Source Function' { SWITCH(nZnSC[nIndex]) { CASE 1: /// ReQuest { /// Next Track ReQuest Break } CASE 2: /// Radio { /// Next Preset nTuner_Preset = nTuner_Preset + 1 Break } CASE 3: /// Sat Music { /// Next Preset nTemp = nCur_Music_Preset + 1 Break } CASE 4: /// Tv Out { /// Do Nothing Break } } Off[nAddress,nZnSc[nIndex]] Wait 5 ON[nAddress,nZnSc[nIndex]] strDebug = 'Source Function Call Running' WAIT 15 strDebug = '' }
Button Event
BUTTON_EVENT[dvMSP,nAud_Source_Buttons] { PUSH: { nButton = Get_Last(nAud_Source_Buttons) nIndex = Get_Last(dvMSP) + 3 nAddress = (nIndex + 33017) Select { ACTIVE(!(strWhPwr[nIndex] = 'N') AND nButton < 5): { nZnSC[nIndex] = nButton CALL 'Zone On' } ACTIVE(strWhPwr[nIndex] = 'N' AND nButton < 5 AND nButton = nZnSc[nIndex]): { CALL 'Source Function' } ACTIVE(strWhPwr[nIndex] = 'N' AND nButton < 5 AND !(nButton = nZnSc[nIndex])): { nZnSc[nIndex] = nButton CALL 'Zone Source' } ACTIVE(nButton = 5): { CALL 'Zone Off' } ACTIVE(nButton = 6): { SWITCH(nZnSC[nIndex]) { CASE 1: /// ReQuest - Next Album { Break } CASE 2: /// Radio - Next Preset { nTuner_Preset = 1 BREAK } CASE 3: /// Sat Music - Next Preset { nTemp = nCur_Music_Preset + 1 BREAK } CASE 4: /// Tv Output - { /// Do Nothing BREAK } } PULSE[nAddress,8] } } } HOLD[20]: { SWITCH(nZnSC[nIndex]) { CASE 1: /// ReQuest - Next Genre { BREAK } CASE 2: /// Radio - Previous Preset { nTuner_Preset = nTuner_Preset - 2 BREAK } CASE 3: /// Sat Music -Previous Preset { nTemp = nCur_Music_Preset - 1 BREAK } CASE 4: /// Tv Output - { /// Do Nothing BREAK } CASE 5: /// Turn Off All Zones { CALL 'Zone Off' BREAK } } } Release: { nCur_Music_Preset = nTemp } }
Going to continue with new post to save scroll time
0
Comments
Any Suggestions or ideas of why it is not sending the commands?
Thanks
I don't recall whether Netlinxs allows this but typically a single = is an assignment and double == is a comparison which is what your "active" statement should be doing.
actually for the same line above I would do, I just saw that ! and the beginning:
To:
and the next line:
I could be reading this all wrong as I often do but I think this is the way you should be writing it.
If your background is writing C or some similar language, this is an entirely reasonable suggestion. If your background is writing some of many other languages, this is anathema.
Netlinx does not mind if you write comparisons with = or ==. I only use = and it works fine. I have a colleague who can't cope with it and always writes ==. It works fine.
The same BTW applies to != and <>.
I thought I remembered that from Pro II class but I wasn't sure. It seems to me that I've had issues with that before in Netlinx but that may have been related soemthing entirely different.
So basically any = or == in a "statement" is cosidered and assignment and any = or == in a "condition" is a comparison or does that just apply to conditions?
Now I have to look up the word "anathema" cuz I don't have a freakin clue!
[dvTP,3] = nBeer = nBeerstatus
Sure i usually put brackets around it, and put in a == but I'm just highlighting the ability of Netlinx to allow us to write some really obfuscated code.
thanks for the input
EDIT : Tried it same result guess its back to the drawing board again LOL
Think of operators in C as functions, only the parameters are the terms before and after the operator. The operator= would set nBeer to the value of nBeerstatus, and return the value nBeerstatus. Then it would set [dvTP,3] to be equal to the returned value which is nBeerstatus. As a result, [dvTP,3], nBeer, and nBeerstatus would all hold the same value, the value of nBeerstatus.
Definitely not what you intended!
Your button event in the first post sets nIndex to a minimum of 4 while your source function is looking for values of 1,2,3,4
I think you might want to consider passing values to the source function as opposed to using global type variables.
Thanks for the suggestion. All the indexs are being defined right and passing correctly. I will take your suggestion and give it a try thanks again