Home AMX User Forum NetLinx Studio
Options

Stuck on ReQuest Part of program

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
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 :)

Comments

  • Options
    ondrovicondrovic Posts: 217
    For the source function call under case 1 I have tried the following with no luck it tells me that the source function is running but its not doing anything
    CASE 1:
    {
    SWITCH(nIndex)
    {
    CASE 4:
    {
    DO_PUSH(arqTP1,32)
    BREAK
    }
    CASE 5:
    {
    DO_PUSH(arqTP2,32)
    BREAK
    }
    }
    Break
    }
    

    Any Suggestions or ideas of why it is not sending the commands?

    Thanks
  • Options
    ondrovicondrovic Posts: 217
    So I tried this and it works but just for Zone 4 none of the other
    CASE 1:		/// ReQuest
    	{
    	    /// Next Track ReQuest
    	    Switch(nIndex)
    	    {
    		CASE 4:	/// Exercise Rm
    		{
    		    DO_PUSH(arqTP1,32)
    		    strAudioFunc = 'Zone 1 -Exe Rm - ReQuest Next Track'
    		    
    		}
    		CASE 5:	/// Office
    		{
    		    DO_PUSH(arqTP2,32)
    		    strAudioFunc = 'Zone 2 - Office - ReQuest Next Track'
    		    
    		}
    		CASE 6:	/// Porch
    		{
    		    DO_PUSH(arqTp2,32)
    		    strAudioFunc = 'Zone 2 - Porch - ReQuest Next Track'
    		    
    		}
    		CASE 7:	/// Master Bed 1
    		{
    		    DO_PUSH(arqTP3,32)
    		    strAudioFunc = 'Zone 3 - Mst Bed 1 - ReQuest Next Track'
    		    
    		}
    		CASE 8:	/// Master Bed 2
    		{
    		    DO_PUSH(arqTP3,32)
    		    strAudioFunc = 'Zone 3 - Mst Bed 2 - ReQuest Next Track'
    		    
    		}
    	    }
    	    Break
    	}
    
  • Options
    jjamesjjames Posts: 2,908
    Anywhere in code are you selecting the zone to control? I believe zone selection starts at push 200 with the ARQ module; I normally do this in the source selection. Just an idea . . . probably an obvious one.
  • Options
    viningvining Posts: 4,368
    The first thing I wouold do is change all your select active's with = to ==:
    ACTIVE(!(strWhPwr[nIndex] = 'N') AND nButton < 5):
    To:
                ACTIVE(!(strWhPwr[nIndex] == 'N') AND nButton < 5):
    


    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:
    ACTIVE(!(strWhPwr[nIndex] = 'N') AND nButton < 5):
    To:
                ACTIVE((strWhPwr[nIndex] != 'N') AND nButton < 5):
    

    and the next line:
    ACTIVE(strWhPwr[nIndex] = 'N' AND nButton < 5 AND !(nButton = nZnSc[nIndex])):
     ACTIVE(strWhPwr[nIndex] == 'N' AND nButton < 5 AND (nButton != nZnSc[nIndex])):
    

    I could be reading this all wrong as I often do but I think this is the way you should be writing it.
  • Options
    vining wrote:
    The first thing I wouold do is change all your select active's with = to ==:

    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 <>.
  • Options
    viningvining Posts: 4,368
    NMarkRoberts wrote:
    Netlinx does not mind if you write comparisons with = or ==.

    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!
  • Options
    travtrav Posts: 188
    It still makes my brain hurt when I write things like

    [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.
  • Options
    DHawthorneDHawthorne Posts: 4,584
    Coming from a C++ background, I always use == for equivalence. Truth is, I don't trust the compiler to always make the correct determination. You have an ambiguity using a = for both equivalence and assignment; sometimes the context makes it clear, and sometimes not. Truth is, if you are writing it properly, you make it so there can't be any ambiguity, so it's all the programmer's fault if it screw up. Using the different operators is just my own way of being sure I've done it right.
  • Options
    ondrovicondrovic Posts: 217
    i will try replacing those '=' with '==' and see if it works
    thanks for the input

    EDIT : Tried it same result guess its back to the drawing board again LOL
  • Options
    mpullinmpullin Posts: 949
    trav wrote:
    [dvTP,3] = nBeer = nBeerstatus
    FYI. To resolve this, a C compiler would treat it like [dvTP,3] = (nBeer = nBeerstatus);

    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!
  • Options
    alexanboalexanbo Posts: 282
    Think the problem might have to do with scoping on the variable nIndex. How and where is that variable declared?

    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.
  • Options
    ondrovicondrovic Posts: 217
    alexanbo wrote:
    Think the problem might have to do with scoping on the variable nIndex. How and where is that variable declared?

    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
Sign In or Register to comment.