Home AMX User Forum NetLinx Studio

CONSTANT TROUBLES

viningvining Posts: 4,368
I'm re-working my HomeWorks module and I'm having a bit of an issue that's driving me batty.

I'me setting up for a max of 3 processors and I input values into the constants which then I use for a constant total for that processor. I then intend to use the constant for the individual processors to tally up the total for the entire system but I always get this error for the last line of the below code:

error:
ERROR: C:\file\: C10539: Identifier [HWI1_MAX_OUTPUTS] undefined  

DEFINE_CONSTANT//NUMBERS OF MIs, H48 AND RF LNIKS   <------------------------------------- CHANGE VALUES IN HERE!!!! FOR JOB ---------->

HWI_PROCESSOR_1			= 1 ;   //PROCESSOR 1 OR NUMBER OF PRCESSORS IN SYSTEM (MAX 3)
HWI_PROCESSOR_2			= 2 ;   //PROCESSOR 2 OR NUMBER OF PRCESSORS IN SYSTEM (MAX 3)
HWI_PROCESSOR_3			= 3 ;   //PROCESSOR 3 OR NUMBER OF PRCESSORS IN SYSTEM (MAX 3)
HWI_FIND_TOTAL			= 4 ;   //USE TO RETURN TOTALS FOR A PARTICULAR PROCESSOR OF MI's, H48's OR RF.

HWI_NUM_MI_DEVICES		= 32 ;  //MAX NUMBER OF OUTPUTS PER MI (PANEL) 8 MODULES X 4 OUTPUTS.
HWI_NUM_H48_DEVICES		= 48 ;  //NUMBER OF DEVICES PER H48 BOARD, SHADES OR MAESTRO DIMMERS.
HWI_NUM_RF_DEVICES		= 64 ;  //NUMBER ODF DEVICES PER RF LINKS, 1 RF LINK PER PROCESSOR.

HWI_TOTAL_NUM_PROCs		= 1 ;   //TOTAL NUMBER OF PROCESSORS IN THE SYSTEM.
//PROCESSOR 1 GROUP
HWI1_NUM_MIs			= 3 ;  	//0 OR NUMBER OF MI's (PANELS) ON PROCESSOR 1.  (MAX 16)
HWI1_NUM_H48s			= 1 ;  	//0 OR NUMBER OF H48 BOARDS OR Q96 DEVICES ON PROCESSOR 1.  (MAX 4)
HWI1_NUM_RF_LINKS		= 0 ;  	//0 OR 1 IF USING RF. ONLY 1 PER PROCESSOR. IF USING MULTIPLE RF PROCESSORS, ADD ANOTHER PROCESSOR GROUP.  (MAX 1) 
HWI1_MAX_OUTPUTS		= ((HWI1_NUM_MIs * HWI_NUM_MI_DEVICES) + (HWI1_NUM_H48s * HWI_NUM_H48_DEVICES) + (HWI1_NUM_RF_LINKS * HWI_NUM_RF_DEVICES)) ;
//PROCESSOR 2 GROUP
HWI2_NUM_MIs			= 0 ;  	//0 OR NUMBER OF MI's (PANELS) ON PROCESSOR 2.  (MAX 16)
HWI2_NUM_H48s			= 0 ;  	//0 OR NUMBER OF H48 BOARDS OR Q96 DEVICES ON PROCESSOR 2.  (MAX 4)
HWI2_NUM_RF_LINKS	`	= 0 ;  	//0 OR 1 IF USING RF. ONLY 1 PER PROCESSOR. IF USING MULTIPLE RF PROCESSORS, ADD ANOTHER PROCESSOR GROUP.  (MAX 1) 
HWI2_MAX_OUTPUTS   		= ((HWI2_NUM_MIs * HWI_NUM_MI_DEVICES) + (HWI2_NUM_H48s * HWI_NUM_H48_DEVICES) + (HWI2_NUM_RF_LINKS * HWI_NUM_RF_DEVICES)) ;
//PROCESSOR 3 GROUP
HWI3_NUM_MIs			= 0 ;  	//0 OR NUMBER OF MI's (PANELS) ON PROCESSOR 3.  (MAX 16)
HWI3_NUM_H48s			= 0 ;  	//0 OR NUMBER OF H48 BOARDS OR Q96 DEVICES ON PROCESSOR 3.  (MAX 4)
HWI3_NUM_RF_LINKS		= 0 ;  	//0 OR 1 IF USING RF. ONLY 1 PER PROCESSOR. IF USING MULTIPLE RF PROCESSORS.  (MAX 1) 
HWI3_MAX_OUTPUTS		= ((HWI3_NUM_MIs * HWI_NUM_MI_DEVICES) + (HWI3_NUM_H48s * HWI_NUM_H48_DEVICES) + (HWI3_NUM_RF_LINKS * HWI_NUM_RF_DEVICES)) ;

//TOTAL SYSTEM ALL PROCESSORS
HWI_TOTAL_OUTPUTS		= (HWI1_MAX_OUTPUTS + HWI2_MAX_OUTPUTS + HWI3_MAX_OUTPUTS) ;

HWI1_MAX_OUTPUTS in the watch bar indicates it exists and holds the correct value but the last line where I try to get the overall total doesn't work. Why? I've tried everything possible with the parethesis and this is no differant than what I'm doing above for the individual processor totals which work.

What am I missing?

Comments

  • glr-ftiglr-fti Posts: 286
    I wasn't aware you could use a constant while defining a constant in DEFINE_CONSTANT. Don't you have to move the issuance of using the constant down to DEFINE_VARIABLE?
  • John GonzalesJohn Gonzales Posts: 609
    Did you try removing the semicolon from the line prior to the HWI1_MAX_OUTPUTS declaration?

    --John
  • viningvining Posts: 4,368
    glr-fti wrote:
    I wasn't aware you could use a constant while defining a constant in DEFINE_CONSTANT.
    I've been doing this for years but normally not so invovled. A simple:
    DEFINE_CONSTANT
    
    NUM_ZONES	= 10 ;
    FILE_SIZE	= NUM_ZONES * 1024 ;
    
    As long as the constant being used in the other constants initialization is declared prior it seems to work fine. May not be right but I've never had an issue that I've been aware of. I also need it in my constant section so that constant array delcared later can be initialized with this value.

    if I chnage this line:
    HWI_TOTAL_OUTPUTS		= 192 //(HWI1_MAX_OUTPUTS + HWI2_MAX_OUTPUTS + HWI3_MAX_OUTPUTS) ;
    
    and compile I can watch the constant HWI1_MAX_OUTPUTS has beed correctly initialized to 144.
    HWI1_MAX_OUTPUTS		= ((HWI1_NUM_MIs * HWI_NUM_MI_DEVICES) + (HWI1_NUM_H48s * HWI_NUM_H48_DEVICES) + (HWI1_NUM_RF_LINKS * HWI_NUM_RF_DEVICES)) ;
    
    So it works

    John Gonzales wrote:
    Did you try removing the semicolon from the line prior to the HWI1_MAX_OUTPUTS declaration?
    That shouldn't and doesn't help. Although I have screwed myself many time with semi-colons. Usually after a while(xxx) ; or if(xxx); or define_function fnSomeFunctio() ; these will ruin you day and they're almost invisable when you're looking for the problem. Usually the result of a copy & paste.

    I could easily just put the numbers in manually but I'd like to make this so I have to do as little as possible on every new job. After all isn't that the point, suffer today so tomorrow is easier.
  • Joe HebertJoe Hebert Posts: 2,159
    vining wrote: »
    I always get this error for the last line of the below code:

    error:
    ERROR: C:\file\: C10539: Identifier [HWI1_MAX_OUTPUTS] undefined  
    

    DEFINE_CONSTANT//NUMBERS OF MIs, H48 AND RF LNIKS   <------------------------------------- CHANGE VALUES IN HERE!!!! FOR JOB ---------->
    
    HWI_PROCESSOR_1			= 1 ;   //PROCESSOR 1 OR NUMBER OF PRCESSORS IN SYSTEM (MAX 3)
    HWI_PROCESSOR_2			= 2 ;   //PROCESSOR 2 OR NUMBER OF PRCESSORS IN SYSTEM (MAX 3)
    HWI_PROCESSOR_3			= 3 ;   //PROCESSOR 3 OR NUMBER OF PRCESSORS IN SYSTEM (MAX 3)
    HWI_FIND_TOTAL			= 4 ;   //USE TO RETURN TOTALS FOR A PARTICULAR PROCESSOR OF MI's, H48's OR RF.
    
    HWI_NUM_MI_DEVICES		= 32 ;  //MAX NUMBER OF OUTPUTS PER MI (PANEL) 8 MODULES X 4 OUTPUTS.
    HWI_NUM_H48_DEVICES		= 48 ;  //NUMBER OF DEVICES PER H48 BOARD, SHADES OR MAESTRO DIMMERS.
    HWI_NUM_RF_DEVICES		= 64 ;  //NUMBER ODF DEVICES PER RF LINKS, 1 RF LINK PER PROCESSOR.
    
    HWI_TOTAL_NUM_PROCs		= 1 ;   //TOTAL NUMBER OF PROCESSORS IN THE SYSTEM.
    //PROCESSOR 1 GROUP
    HWI1_NUM_MIs			= 3 ;  	//0 OR NUMBER OF MI's (PANELS) ON PROCESSOR 1.  (MAX 16)
    HWI1_NUM_H48s			= 1 ;  	//0 OR NUMBER OF H48 BOARDS OR Q96 DEVICES ON PROCESSOR 1.  (MAX 4)
    HWI1_NUM_RF_LINKS		= 0 ;  	//0 OR 1 IF USING RF. ONLY 1 PER PROCESSOR. IF USING MULTIPLE RF PROCESSORS, ADD ANOTHER PROCESSOR GROUP.  (MAX 1) 
    HWI1_MAX_OUTPUTS		= ((HWI1_NUM_MIs * HWI_NUM_MI_DEVICES) + (HWI1_NUM_H48s * HWI_NUM_H48_DEVICES) + (HWI1_NUM_RF_LINKS * HWI_NUM_RF_DEVICES)) ;
    //PROCESSOR 2 GROUP
    HWI2_NUM_MIs			= 0 ;  	//0 OR NUMBER OF MI's (PANELS) ON PROCESSOR 2.  (MAX 16)
    HWI2_NUM_H48s			= 0 ;  	//0 OR NUMBER OF H48 BOARDS OR Q96 DEVICES ON PROCESSOR 2.  (MAX 4)
    HWI2_NUM_RF_LINKS	`	= 0 ;  	//0 OR 1 IF USING RF. ONLY 1 PER PROCESSOR. IF USING MULTIPLE RF PROCESSORS, ADD ANOTHER PROCESSOR GROUP.  (MAX 1) 
    HWI2_MAX_OUTPUTS   		= ((HWI2_NUM_MIs * HWI_NUM_MI_DEVICES) + (HWI2_NUM_H48s * HWI_NUM_H48_DEVICES) + (HWI2_NUM_RF_LINKS * HWI_NUM_RF_DEVICES)) ;
    //PROCESSOR 3 GROUP
    HWI3_NUM_MIs			= 0 ;  	//0 OR NUMBER OF MI's (PANELS) ON PROCESSOR 3.  (MAX 16)
    HWI3_NUM_H48s			= 0 ;  	//0 OR NUMBER OF H48 BOARDS OR Q96 DEVICES ON PROCESSOR 3.  (MAX 4)
    HWI3_NUM_RF_LINKS		= 0 ;  	//0 OR 1 IF USING RF. ONLY 1 PER PROCESSOR. IF USING MULTIPLE RF PROCESSORS.  (MAX 1) 
    HWI3_MAX_OUTPUTS		= ((HWI3_NUM_MIs * HWI_NUM_MI_DEVICES) + (HWI3_NUM_H48s * HWI_NUM_H48_DEVICES) + (HWI3_NUM_RF_LINKS * HWI_NUM_RF_DEVICES)) ;
    
    //TOTAL SYSTEM ALL PROCESSORS
    HWI_TOTAL_OUTPUTS		= (HWI1_MAX_OUTPUTS + HWI2_MAX_OUTPUTS + HWI3_MAX_OUTPUTS) ;
    

    I don't get a error compiling what you posted.
  • viningvining Posts: 4,368
    Now what really boggles my mind is that if I change this:
    HWI_TOTAL_OUTPUTS		= 192 //(HWI1_MAX_OUTPUTS + HWI2_MAX_OUTPUTS + HWI3_MAX_OUTPUTS) ;
    
    Which works with just the number 192 to this:
    HWI_TOTAL_OUTPUTS		= ((HWI1_NUM_MIs * HWI_NUM_MI_DEVICES) + (HWI1_NUM_H48s * HWI_NUM_H48_DEVICES) + (HWI1_NUM_RF_LINKS * HWI_NUM_RF_DEVICES)) ;
    
    which is the same as what I did previously a few lines earlier.
    HWI1_MAX_OUTPUTS		= ((HWI1_NUM_MIs * HWI_NUM_MI_DEVICES) + (HWI1_NUM_H48s * HWI_NUM_H48_DEVICES) + (HWI1_NUM_RF_LINKS * HWI_NUM_RF_DEVICES)) ;
    
    which doesn't cause a problem I then get this error but no error where for where it was used before:
    ERROR: C:\file\ (82): C10539: Identifier [HWI1_NUM_MIS] undefined  
    
    Which completely blows my mind! Why does it work earlier and not now? Maybe I'm not supposed to do this and the compiler is saying enough is enough. I let you slide the first couple of time but no more. But compilers don't behave like that, you either can or can't for the most part.
  • viningvining Posts: 4,368
    Joe Hebert wrote:
    I don't get a error compiling what you posted
    That's good, I think? But now I have to figure out why I'm getting this and you're not. Every fibre of my being was telling me it should work but it just won't no matter what I try.

    What firmware and processor are you using? I'm using an NI-4000 running v3.50.430.
  • Joe HebertJoe Hebert Posts: 2,159
    vining wrote: »
    What firmware and processor are you using? I'm using an NI-4000 running v3.50.430.
    I didn?t load the code. I just compiled the code you posted error free.

    You get an error (with no line number) when you only compile the constants?
  • viningvining Posts: 4,368
    Joe Hebert wrote:
    I just compiled the code you posted error free.
    I should have realized that since it's a compiling problem at this point. My brain is a little fuzzy.

    I get line numbers. I just deleted that portion of the error line with the file path but the error consistantly points to that line and moves when it moves and I moved it several times.

    My compiler is build 2.5.2.20 but me thinks I have to delete NS3 and do a reload. Maybe I'm not even current, although that wouldn't be the cause.
  • Joe HebertJoe Hebert Posts: 2,159
    You get the error when you only compile the constants with no other code?
  • viningvining Posts: 4,368
    No, just the constants compile fine.
  • Joe HebertJoe Hebert Posts: 2,159
    vining wrote: »
    No, just the constants compile fine.
    You?re not giving us a whole lot to go on then.

    Can you post the code that doesn?t compile?
  • viningvining Posts: 4,368
    For the moment this is an .axi file so after moving things around and adding compiler directives so I can compile this include file with out all kinds of other error from missing parts and pieces that live in the main code I can now compile the entire HWI.axi and isolate areas.

    If I leave this line in:
    HWI_TOTAL_OUTPUTS		= (HWI_TOTAL_MI_OUTPUTS + HWI_TOTAL_H48_OUTPUTS + HWI_TOTAL_RF_OUTPUTS) ;
    
    and leave this constant in the 2 constant array delcared further down the line and the 1 structure that uses this constant I get the error. If I use a different constant in these array and structure it works and leave the above line in it compiles fine.

    I just adding the constant to the 1st constant array that uses it, it compiled ok. Same with the second constant array but adding it back to the structure causes the error again.
    ERROR: C:\filepath\VAV_HWI.axi(83): C10539: Identifier [HWI_TOTAL_MI_OUTPUTS] undefined  
    
    which is this line:
    HWI_TOTAL_OUTPUTS		= (HWI_TOTAL_MI_OUTPUTS + HWI_TOTAL_H48_OUTPUTS + HWI_TOTAL_RF_OUTPUTS) ;
    
    HWI_TOTAL_MI_OUTPUTS is defined here 3 lines prior (code has changed from original)
    HWI_TOTAL_MI_OUTPUTS		= ((HWI1_NUM_MIs * HWI_NUM_MI_DEVICES) + (HWI2_NUM_MIs * HWI_NUM_MI_DEVICES) + (HWI3_NUM_MIs * HWI_NUM_MI_DEVICES)) ;
    HWI_TOTAL_H48_OUTPUTS		= ((HWI1_NUM_H48s * HWI_NUM_H48_DEVICES) + (HWI2_NUM_H48s * HWI_NUM_H48_DEVICES) + (HWI3_NUM_H48s * HWI_NUM_H48_DEVICES)) ;
    HWI_TOTAL_RF_OUTPUTS		= ((HWI1_NUM_RF_LINKS * HWI_NUM_RF_DEVICES) + (HWI2_NUM_RF_LINKS * HWI_NUM_RF_DEVICES) + (HWI3_NUM_RF_LINKS * HWI_NUM_RF_DEVICES)) ;
    
    HWI_TOTAL_OUTPUTS		= (HWI_TOTAL_MI_OUTPUTS + HWI_TOTAL_H48_OUTPUTS + HWI_TOTAL_RF_OUTPUTS) ;
    

    The structure and arrays that use it, although the 2nd array will be deleted at some point:
    DEFINE_CONSTANT //DIMMER NAMES                                                   
    
    CHAR cOutputName[HWI_TOTAL_OUTPUTS][18]=
         
              {//DIMMERS
    /////////////////////////////BEGIN 1ST H48/SHADES
              //123456789012345678
    /////////////////////////////LINK 1  
    (* 1*)	   'E. Back Step Lts',           
    (* 2*)	   'E. Front Step Lts',           
    (* 3*)	   'Service Stairs',            
    (* 4*)	   '2nd & 3rd FL Steps',          
    (* 5*)	   '',       
    (* 6*)	   '',         
    (* 7*)	   '',           
    (* 8*)     ''
             //and on and on.....
    	  }
    
    DEFINE_CONSTANT //cHWI_SysDimmers  (dimmers suffix array)                        HWI_TEMPTOTAL_OUTPUTS
    
    CHAR cHWI_SysDimmers [HWI_TOTAL_OUTPUTS][6]=
        
       
        {
        '01:01]',//1 
        '01:02]',//2 
        '01:03]' //3 
        //and on and on
        }
    
    DEFINE_TYPE     //_sHWI
    
    STRUCTURE _sHWI
    
         {
         _sHWI_Status sStatus ;
         _sHWI_Outputs sOutput[HWI_TOTAL_OUTPUTS] ;
         }
    
    If I make this change it works:
    DEFINE_CONSTANT
    
    HWI_TEMPTOTAL_OUTPUTS		= 192 ;
    
    
    DEFINE_TYPE     //_sHWI
    
    STRUCTURE _sHWI
    
         {
         _sHWI_Status sStatus ;
         _sHWI_Outputs sOutput[HWI_TEMPTOTAL_OUTPUTS] ;
         }
    

    The constant arrays are still using HWI_TOTAL_OUTPUTS and it compiles fine. I swear at certian times the constant arrays wouldn't work either.

    Very flaky!
  • DHawthorneDHawthorne Posts: 4,584
    I have not been able to nail down the exact pattern, or when it happens and when it doesn't, but I have had problems many times with declarations using a semicolon to terminate the line. I gave up trying to figure it out. By default, I use semicolons, and if I get a weird error at the beginning of the actual code, I take the semicolons out of the declaration. It works a scary amount of the time. No idea if it has any bearing on what you are seeing, but I thought I'd throw it out there.
  • viningvining Posts: 4,368
    The weird thing is, that if I leave the TEMP constant in the structure declaration, compile and upload my constants and the one in particular that I want too use for the structure intialization shows that they indeed initialize to the correct values in the debug watch window.

    Almost like the error is thrown on an initial pass of the compiler where it hasn't yet been truely initialized but in the end when it matters it is. So it works fine if I don't use it?

    Maybe I'll play with semi colons cuz I ain't got much else to try at this point. I did the one prior in response to John's post, maybe I need to do more.
  • Joe HebertJoe Hebert Posts: 2,159
    I?m not sure if I compiled the correct chunks of code but aside from the undefined errors I?m also getting a: C10589: Cannot perform math operations on type [STRUCTURE]

    It sounds like that?s more likely your real problem. You're not getting the math error?
  • viningvining Posts: 4,368
    No, I only get the "constant not defined" thing. Sounds like the constant isn't initalizing prior to the structure and the structure ends up trying doing the math of that constant initialization is supposed when that that particular constant was defined. Cuz I don't get the constant that I use inside the structure as not being defined, I get the constant that I use x others to define the constant that I use to define the structure.

    Definitely something wierd going on.
Sign In or Register to comment.