Home AMX User Forum NetLinx Studio

Working on a tuner module

I'm working on a tuner module. There will be two tuners going in this job so i want the module to be the same for both of them. It was my impression that when you defined a module twice it created a second instance of the module. That way any variables in the module would be duplicated.

So this works with both tuners. All the variables in the main program manually duplicated for each tuner.
DEFINE_MODULE 'Onkyo_Tuner' TUNER_01
	(dvTUNER_01,
	vdvTUNER_01,
	arrTPTUNER_01,
	cCALLSIGN1,
	cSTATIONNAME1,
	cSTATIONINFO1,
	cARTISTNAME1,
	cFREQUENCY1,
	cBAND1,
	nHDRADIO1,
	nHDRADIO_CH1,
	nHDRADIO_CHs1
	)
	
DEFINE_MODULE 'Onkyo_Tuner' TUNER_02
	(dvTUNER_02,
	vdvTUNER_02,
	arrTPTUNER_02,
	cCALLSIGN2,
	cSTATIONNAME2,
	cSTATIONINFO2,
	cARTISTNAME2,
	cFREQUENCY2,
	cBAND2,
	nHDRADIO2,
	nHDRADIO_CH2,
	nHDRADIO_CHs2
	)

module defines
MODULE_NAME='Onkyo_Tuner'
	(
	DEV 		dvTUNER,
	DEV 		vdvTUNER,
	DEV		dvTP[],
	CHAR	cCALLSIGN[],		//HCN
	CHAR	cSTATIONNAME[],	//HDS
	CHAR	cSTATIONINFO[],	//HTI
	CHAR	cARTISTNAME[],	//HAT
	CHAR	cFREQUENCY[],		//TUN
	CHAR	cBAND[],			//SLI
	INTEGER	nHDRADIO,		//IS THE STATION HD? 1=TRUE 0=FALSE
	INTEGER	nHDRADIO_CH,		//ACTUAL CHANNEL THE HD RADIO IS ON
	INTEGER	nHDRADIO_CHs
	)



This is the way I would like to use it. How ever it doesn't work, well it works for one tuner the other doesn't seem to get a chance to write to its variables. when i go into the debug window and enter a variable it asks which one to point to i set it so i can see both of them and they both get the same information. Any Ideas what I'm doing wrong or tips that could make this work. In the verry least am I barking up the right tree?
DEFINE_MODULE 'Onkyo_Tuner' TUNER_01
	(dvTUNER_0,
	vdvTUNER_0,
	arrTPTUNER_0,)

The module file has all the variables defined in it, well i'll show that part too
MODULE_NAME='Onkyo_Tuner'
	(
	DEV 		dvTUNER,
	DEV 		vdvTUNER,
	DEV		dvTP[]
	)

DEFINE_VARIABLE

VOLATILE CHAR 	cTUNERBUFFER			[600]		//TUNER INPUT BUFFER
VOLATILE CHAR		cTUNERSENDBUFF		[100]		//TUNER SEND BUFFER
VOLATILE CHAR		cTUNERSENDBUFFPART	[20]		//TUNER SEND BUFFER SINGLE COMMAND

VOLATILE CHAR		cCALLSIGN				[7]		//HCN
VOLATILE CHAR		cSTATIONNAME			[64]		//HDS
VOLATILE CHAR		cSTATIONINFO			[64]		//HTI
VOLATILE CHAR		cARTISTNAME			[64]		//HAT
VOLATILE CHAR		cFREQUENCY			[10]		//TUN
VOLATILE CHAR		cBAND				[6]		//SLI
VOLATILE INTEGER	nHDRADIO						//IS THE STATION HD? 1=TRUE 0=FALSE
VOLATILE INTEGER	nHDRADIO_CH					//ACTUAL CHANNEL THE HD RADIO IS ON
VOLATILE INTEGER	nHDRADIO_CHs					



Thank you for any advice you have to offer, if I'm not being clear in what I'm trying to do here please let me know. Its tough to ask questions that make sense when you in over your head :) and I apologize for the wall of text.

Comments

  • Spire_JeffSpire_Jeff Posts: 1,917
    In just skimming what you have posted, it seems like it should do exactly what you want it to do. I know that the debugger has problems dealing with multiple instances of a module, so I wouldn't use that as a diagnostic tool. If you want to see that both modules are functioning properly, you could insert a couple of send_string 0 commands such as:
     send_string 0,"itoa(dvTuner.port),' is setting Station to ',cStationName"
    

    Put a line or two into the events that occur when the variable is changed, the watch the Diagnostics window for the strings to show up. If everything is showing up, but it is not updating properly on the touch panels, check the routine you are using to display the data and make sure that it is only displaying the correct device. You could also swap the serial cables and make sure it is not a hardware issue.

    Jeff

    Jeff
  • viningvining Posts: 4,368
    I've only been able to watch the variables of one instance at a time if you're dropping in the var declared in module itself so what ever the last instance dropped in is, is what you'll be seeing. All the same name vars even if other instances were 1st selected they'll all change to the instance of the last one dropped in. Usually the var instance is reverse of what you would think when you get to choose from the list which one to select. So if you have two instances of a mod declared and you want to see a var in the first instance when you get the pop up to select which instance you want to watch you need to choose the 2nd one listed to see the 1st module instance. It drives me batty especially when dealing with 4 or more instance of a module to figure out which one to select. I alway pass in a instance pointer just so I know which instance I'm dealing with cuz although lately it seems to be reverse order I swear it's been different in the past.

    Hoepfully you'll get what I'm trying to say cuz is doesn't sound like it makes any sense.
  • GWAHAHAHAHAHA!!!!! It works, yep you were both right about the debug window. I threw it on a touch panel and its all feeding back fine and it reports correctly if i only look at one instance at a time in the debug window. Thank you very much! I am so happy right now.
Sign In or Register to comment.