Home AMX User Forum NetLinx Studio

Dev Array In Call

xrmichaelxrmichael Junior MemberPosts: 79
Could someone help me out with the following.

I have an array of panels

DEV dvTP[]={dvTP1_1,dvTP2_1,dvTP3_1,dvTP4_1,dvTP5_1}

I can do this to send a command to all panels

SEND_COMMAND dvTP,"'@PPX'" //CLOSE ALL POPUPS

I have a call like this

DEFINE_CALL 'closepps' (DEV PANEL)
{
SEND_COMMAND PANEL,"'@PPX'" //CLOSE ALL POPUPS
}

But cannot do this - call 'closepps' (dvTP)

I have probably missed something as i normally do.

Michael

Comments

  • jjamesjjames Just another dude Posts: 2,904
    I've always felt it's a waste to have a call or a function do only one thing (one line of code). Why even call a function?

    But anyway - in your call parameter, it's set for only a single device. It should be:

    DEFINE_CALL 'closepps' (DEV PANEL[MAX_PANELS])

    Where MAX_PANELS would (obviously) be the maximum number of panels you have in the system. I don't know if defining the bounds of the array is necessary for a call / function, but it doesn't hurt I don't think.
  • xrmichaelxrmichael Junior Member Posts: 79
    Call

    There will be more than one line of code, that was just an example, i will give your suggestion a try now thanks for the quick response.
  • xrmichaelxrmichael Junior Member Posts: 79
    Call

    A few complier errors in the call now relation to a dimension mismatch. I will keep pluggin on.
  • DHawthorneDHawthorne Old Timer Posts: 4,584
    Actually, I think an empty set of brackets in the function will do it just fine. As you are doing it now, it thinks PANEL is a single device, not an array of devices, which is what you are actually sending. It can't hurt to put a dimension in there, but as I recall, it's ignored anyway. The dimension size of the array you send it is what determines the size when the function is called.
  • xrmichaelxrmichael Junior Member Posts: 79
    Call

    I have tried empty [] in the call

    DEFINE_CALL 'CLOSEPPS' (DEV PANEL[])

    But it throws these errors

    Dimension mismatch: [1] vs. [0]
    Type mismatch in call for parameter [PANEL]

    I will knock up a hack to get round it and pick it back up Monday it's friday and nearly home time.
  • mpullinmpullin Obvious Troll Account, Marked for Deletion Posts: 949
    You can't pass an array of DEVs into a call or function that takes a single DEV. That is a "bonus" behavior that is exclusive to SEND_STRING and SEND_COMMAND - giving an array will send to all elements of the array as you're obviously aware of. If you were just doing the command SEND_COMMAND dvTP,"'@PPX'" instead of making your CALL it would work!

    I would not use a function for this. But If I Did, Here's How It Happened:
    DEFINE_FUNCTION closePopups(INTEGER nTP){
         // passed 0, will close popups on all TP.  passed an index, it will close popups on just that tp
         if(nTP) SEND_COMMAND dvTP[nTP], '@PPX';
         else SEND_COMMAND dvTP, '@PPX';
    }
    
  • xrmichaelxrmichael Junior Member Posts: 79
    Call

    Thanks you have confirmed I was not going mad, ended up doing it with a for loop style thing.
  • Spire_JeffSpire_Jeff Formerly Caffeinated Programmer Posts: 1,917
    You could always just pass the index value to the function and pass a 0 if you want them all to get the message.
    DEFINE_CALL 'closepps' (integer nIndex)
    {
       if(nIndex) 
           SEND_COMMAND dvTp[nIndex],"'@PPX'" //CLOSE ALL POPUPS
       else
           SEND_COMMAND dvTp,"'@PPX'" //CLOSE ALL POPUPS
    }
    
    DEFINE_CALL 'closepps' (integer nIndex, dev dvDevs[]) ///Use this if the array of devs changes.
    {
       if(nIndex) 
           SEND_COMMAND dvDevs[nIndex],"'@PPX'" //CLOSE ALL POPUPS
       else
           SEND_COMMAND dvDevs,"'@PPX'" //CLOSE ALL POPUPS
    }
    
    .
    .
    .
    
    button_event[dvTp,1]{
      push:{
         call 'closepps' (get_last(dvTp));
      }
    }
    button_event[dvTp,2]{
      push:{
         call 'closepps' (0);
      }
    }
    
    

    Jeff
  • a_riot42a_riot42 AMX Wizard Posts: 1,619
    xrmichael wrote: »
    I have tried empty [] in the call

    DEFINE_CALL 'CLOSEPPS' (DEV PANEL[])

    But it throws these errors

    Dimension mismatch: [1] vs. [0]
    Type mismatch in call for parameter [PANEL]

    I will knock up a hack to get round it and pick it back up Monday it's friday and nearly home time.

    I have all kinds of functions that take an array of devices. Maybe you could post all the code as I have a feeling the problem may lie elsewhere.
    Paul
  • viningvining X Member Posts: 4,368
    Similar to what Jeff suggested this is what I do. Any index value of 1 or above the code will send to that index. If it gets passed a 0 it updates the entire UI array providing it's an appropriate type of UI:
    DEFINE_FUNCTION fnHWI_DoSend_VT(INTEGER iUI_Indx,INTEGER iVT_Chnl,CHAR iStrMSG[500]) 
         
         {
         STACK_VAR INTEGER n ;
         STACK_VAR INTEGER nTPCount ; 
         STACK_VAR INTEGER nLoopStart ; 
         
         if(iUI_Indx)
    	  {
    	  nTPCount = iUI_Indx ;
    	  nLoopStart = iUI_Indx ;
    	  }
         else
    	  {
    	  nTPCount = length_array(dvHWI_UIArry) ;
    	  nLoopStart = 1 ;
    	  }
    
         for(n = nLoopStart ; n <= nTPCount ; n++)
    	  {
    	  if(nUI_ActiveArry[n] == nDev_Instance)//means nothing here, only for module w/ instances
    	       {
    	       SWITCH(nUI_TypeArry[n])
    		    {
    		    CASE UI_TYPE_G4:
    		    CASE UI_TYPE_R4:
    		    CASE UI_TYPE_MIO_DMS:
    			 {
    			 STACK_VAR WIDECHAR cSTRING1[500] ;
    			 STACK_VAR CHAR cSTRING2[500] ;
    			 
    			 cSTRING1 = WC_DECODE(iStrMSG,WC_FORMAT_UTF8,1) ; 
    			 cSTRING2 = WC_ENCODE(cSTRING1,WC_FORMAT_TP,1) ;
    			 SEND_COMMAND dvHWI_UIArry[n], "'^UNI-',ITOA(iVT_Chnl),',0,',cSTRING2" ; 
    			 }
    		    CASE UI_TYPE_G3:
    			 {
    			 SEND_COMMAND dvHWI_UIArry[n], "'TEXT',ITOA(iVT_Chnl),'-',iStrMSG" ; 
    			 }
    		    CASE UI_TYPE_METKP:
    		    CASE UI_TYPE_VIRTUAL:
    		    CASE UI_TYPE_UNKNOWN:
    			 {
    			 //DO NOTHING
    			 }
    		    }
    	       }
    	  }
         
         RETURN ;
         }
    
    

    Here's a similar example I use for pop up control:
    DEFINE_FUNCTION fnFB_DoPop_Ups(INTEGER iUI_Indx,INTEGER iPOP_ON,INTEGER iPopUP_Indx)
         
         {
         STACK_VAR INTEGER n ;
         STACK_VAR INTEGER nSetOnce ;
         STACK_VAR INTEGER nTPCount ; 
         STACK_VAR INTEGER nLoopStart ; 
         
         if(iUI_Indx)
    	  {
    	  nTPCount = iUI_Indx ;
    	  nLoopStart = iUI_Indx ;
    	  }
         else
    	  {
    	  nTPCount = sSoundB.nNum_UIs ;
    	  nLoopStart = 1 ;
    	  }
         
         nSetOnce = 0 ;
         for(n = nLoopStart ; n <= nTPCount ; n++)
              {
    	  if(nUI_ActiveArry[n] == sSoundB.nDev_Instance)//means it on this SB & ACTIVE on page
    	       {
    	       SWITCH(nUI_TypeArry[n])
    		    {
    		    CASE UI_TYPE_G4:
    		    CASE UI_TYPE_G3:
    		    CASE UI_TYPE_R4:
    			 {
    			 if(iPOP_ON)
    			      {
    			      SEND_COMMAND dvUI_Arry[n],"'PPON-',POP_UP_ARRAY[iPopUP_Indx]" ;
    			      if(!nSetOnce)
    				   {
    				   nSetOnce = 1 ;
    				   if(iPopUP_Indx > POP_UP_MUSTCONNECT)//then side bar group
    					{
    					sSoundB.nSideBarPopUp = iPopUP_Indx ;
    					}
    				   else
    					{
    					sSoundB.nDisplayPopUp = iPopUP_Indx ;
    					}
    				   SWITCH(iPopUP_Indx)
    					{
    					CASE POP_UP_NONE:
    					CASE POP_UP_KEYBOARD:
    					CASE POP_UP_ADVSEARCH:
    					CASE POP_UP_CLEARQUEUE: 
    					     {
    					     }
    					CASE POP_UP_CURLISTDISPLAY:
    					     {
    					     fnFB_DoSend_CHNL(UI_UPDATE_ACTIVE,CH_VIEWINGQUEUE,CH_OFF) ;
    					     fnFB_DoSend_CHNL(UI_UPDATE_ACTIVE,CH_VIEWINGLIST,CH_ON) ;
    					     fnFB_DoSend_VT(UI_UPDATE_ACTIVE,VT_MAIN_LIST_COUNT,itoa(sSoundB.nListSize)) ;
    					     fnFB_DoSend_VT(UI_UPDATE_ACTIVE,VT_MAIN_INDX_RANGE,"itoa(sSoundB.nListIndxLow + 1),' - ',itoa(sSoundB.nListIndxHi + 1)") ;
    					     }
    					CASE POP_UP_DISCOSERVER:
    					CASE POP_UP_DISPLAYGROUP://THIS WON,T HAPPEN FOR POPON
    					CASE POP_UP_GETCURSONGINFO:    
    					CASE POP_UP_GETSONGINFO:
    					     {
    					     }
    					CASE POP_UP_QUEUEDISPLAY:
    					     {
    					     fnFB_DoSend_CHNL(UI_UPDATE_ACTIVE,CH_VIEWINGLIST,CH_OFF) ;
    					     fnFB_DoSend_CHNL(UI_UPDATE_ACTIVE,CH_VIEWINGQUEUE,CH_ON) ;
    					     fnFB_DoSend_VT(UI_UPDATE_ACTIVE,VT_MAIN_LIST_COUNT,itoa(sSoundB.nQueueSize)) ;
    					     fnFB_DoSend_VT(UI_UPDATE_ACTIVE,VT_MAIN_INDX_RANGE,"itoa(sSoundB.nQueueIndxLow + 1),' - ',itoa(sSoundB.nQueueIndxHi + 1)") ;
    					     }
    					CASE POP_UP_VERIFYDISCOSERV: 
    					CASE POP_UP_ADVSEARCH_iR: 
    					CASE POP_UP_MUSTCONNECT:               ///make sure this stays the last pop up of this group        
    					/////////// SIDE BAR GROUP //////////      
    					CASE POP_UP_DOWHAT:      
    					CASE POP_UP_LISTORSEARCH:  
    					CASE POP_UP_QUEUEWHAT:   
    					CASE POP_UP_SERVERS:
    					CASE POP_UP_SIDEBARGRP: //THIS WON,T HAPPEN FOR POPON   
    					CASE POP_UP_TEXTSEARCH:    
    					CASE POP_UP_VIEWLISTS:
    					CASE POP_UP_iRADIOLISTS:
    					     {
    					     }
    					}
    				   }
    			      }
    			 else
    			      {
    			      SEND_COMMAND dvUI_Arry[n],"'PPOF-',POP_UP_ARRAY[iPopUP_Indx]" ;
    			      if(!nSetOnce)
    				   {
    				   nSetOnce = 1 ;
    				   if(iPopUP_Indx > POP_UP_MUSTCONNECT)//then side bar group
    					{
    					sSoundB.nSideBarPopUp = iPopUP_Indx ;
    					}
    				   else
    					{
    					sSoundB.nDisplayPopUp = iPopUP_Indx ;
    					}
    				   SWITCH(iPopUP_Indx)
    					{
    					CASE POP_UP_NONE:
    					CASE POP_UP_KEYBOARD:
    					CASE POP_UP_ADVSEARCH:
    					CASE POP_UP_CLEARQUEUE: 
    					     {
    					     }
    					CASE POP_UP_CURLISTDISPLAY:
    					     {
    					     fnFB_DoSend_CHNL(UI_UPDATE_ACTIVE,CH_VIEWINGLIST,CH_OFF) ;
    					     }
    					CASE POP_UP_DISCOSERVER:
    					     {
    					     }
    					CASE POP_UP_DISPLAYGROUP:
    					     {
    					     fnFB_DoSend_CHNL(UI_UPDATE_ACTIVE,CH_VIEWINGLIST,CH_OFF) ;
    					     fnFB_DoSend_CHNL(UI_UPDATE_ACTIVE,CH_VIEWINGQUEUE,CH_OFF) ;
    					     }
    					CASE POP_UP_GETCURSONGINFO:    
    					CASE POP_UP_GETSONGINFO:
    					     {
    					     }
    					CASE POP_UP_QUEUEDISPLAY:
    					     {
    					     fnFB_DoSend_CHNL(UI_UPDATE_ACTIVE,CH_VIEWINGQUEUE,CH_OFF) ;
    					     }
    					CASE POP_UP_VERIFYDISCOSERV:
    					CASE POP_UP_ADVSEARCH_iR: 
    					CASE POP_UP_MUSTCONNECT:               ///make sure this stays the last pop up of this group        
    					/////////// SIDE BAR GROUP //////////      
    					CASE POP_UP_DOWHAT:      
    					CASE POP_UP_LISTORSEARCH:  
    					CASE POP_UP_QUEUEWHAT:   
    					CASE POP_UP_SERVERS:
    					CASE POP_UP_SIDEBARGRP:    
    					CASE POP_UP_TEXTSEARCH:    
    					CASE POP_UP_VIEWLISTS:
    					CASE POP_UP_iRADIOLISTS:
    					     {
    					     }
    					}
    				   }
    			      }
    			 }
    		    CASE UI_TYPE_MIO_DMS:
    		    CASE UI_TYPE_METKP:
    		    CASE UI_TYPE_UNKNOWN:
    			 {
    			 //DO NOTHING
    			 }
    		    }
    	       }
    	  }
    	  
         RETURN ;
         }
    
  • a_riot42a_riot42 AMX Wizard Posts: 1,619
    That seems like quite complicated code. What does it do?
    Paul
  • viningvining X Member Posts: 4,368
    The first example just handles VT feedback based on the type of UI being used and the second example just handle pop ups based on the type of UI.

    Some where else in the code during the UI arrays online event I run the DEVICE_ID command as UI's come online to determne there type and store that info in an array. Then in a particular module I can control feedback based on this type depending on that module's particular needs, also whether or not they are on the particular device page and on the particular instance of a module if that applies.

    I generally have something like this for all types of feedback, level, channel, VT, etc...

    I run this in my main code and pass it to modules as needed.
    DATA_EVENT   [dvUI_Arry]
         
         {
         ONLINE:
    	  {
    	  STACK_VAR INTEGER nUI_Indx ;
    	  STACK_VAR INTEGER nDeviceID ;
    	   
    	  nUI_Indx = GET_LAST(dvUI_Arry) ;
    	  if(nUI_TypeArry[nUI_Indx] < 2)//RUN IF VALUE IS 0 OR UNKOWN (1).
    	       {
    	       nDeviceID = DEVICE_ID(dvUI_Arry[nUI_Indx]) ;
    	       SELECT
    		    {
    		    ACTIVE(nDeviceID == 0)://?? No Number 
    			 {
    			 nDeviceID = UI_TYPE_UNKNOWN ; 
    			 }
    		    ACTIVE(nDeviceID >= DEV_ID_METKP_BEGIN && nDeviceID <= DEV_ID_METKP_END)://Metreau Keypads
    			 {
    			 nDeviceID = UI_TYPE_METKP ;
    			 }
    		    ACTIVE(nDeviceID >= DEV_ID_MIO_DMS_BEGIN && nDeviceID <= DEV_ID_MIO_DMS_END):
    			 {
    			 nDeviceID = UI_TYPE_MIO_DMS ;
    			 }
    		    ACTIVE(nDeviceID == DEV_ID_R4)://R4
    			 {
    			 nDeviceID = UI_TYPE_R4 ;
    			 }
    		    ACTIVE(nDeviceID == DEV_ID_VIRTUAL)://VIRTUAL DEVICE 
    			 {
    			 nDeviceID = UI_TYPE_VIRTUAL ;
    			 }
    		    ACTIVE(nDeviceID < 256)://G3 panel
    			 {
    			 nDeviceID = UI_TYPE_G3 ;
    			 }
    		    ACTIVE(1)://G4  //FIGURE OUT NUMBERS FOR THIS
    			 {
    			 nDeviceID = UI_TYPE_G4 ;
    			 }
    		    }
    	       nUI_TypeArry[nUI_Indx] = nDeviceID ;
    	       fnUI_DeBug("'UI Device: ',fnDEV_TO_STRING(dvUI_Arry[nUI_Indx]),' is a ',UI_TYPE[nDeviceID],
    					     '. ** UI Type #',itoa(nDeviceID),' **. >-Line-<',itoa(__LINE__),'>'") ;
    	       }
    	  }
         }
    DEFINE_CONSTANT //UI CONSTANTS & TYPES  
    
    #DEFINE UI_TYPE_CONSTANTS
    
    UI_OFF_PAGE		= 0 ;
    UI_ON_PAGE		= 1 ;
    
    UI_UPDATE_ACTIVE 	= 0 ;//OTHERWISE THE UI INDEX IS REQUIRED
    UI_TYPE_UNKNOWN         = 1 ;
    UI_TYPE_METKP		= 2 ;
    UI_TYPE_MIO_DMS		= 3 ;
    UI_TYPE_R4		= 4 ;
    UI_TYPE_G3		= 5 ;
    UI_TYPE_G4		= 6 ;
    UI_TYPE_VIRTUAL		= 7 ;
       
    CHAR UI_TYPE[][9] = 
    
         {
         'Unknown',			//1
         'Keypad',			//2
         'Mio_DMS',			//3
         'R4 Remote',		//4
         'G3 Panel',		//5
         'G4 Panel', 		//6
         'Virtual'                  //7
         } ;   
    
    

    Here's my current collection of device id's. Still need the newer panels.
    DEFINE_CONSTANT //DEVICE ID's 
    
    #DEFINE DEV_ID_CONSTANTS     
    
    /////////////////////////////////KEYPADS NO TEXT SUPPORT
    
    DEV_ID_METKP_BEGIN	= 169 ;
    DEV_ID_MET6N  		= 169 ;
    DEV_ID_MET7   		= 170 ;
    DEV_ID_MET13  		= 171 ;
    DEV_ID_METKP_END	= 171 ;
    
    /////////////////////////////////KEYPADS MIO DMS TEXT & UNI SUPPORT
    
    DEV_ID_MIO_DMS_BEGIN	= 304 ;
    DEV_ID_MIO_DMS1		= 304 ; //Mio-DMS Keypad (non-color, non-touch display with buttons)
    DEV_ID_MIO_DMS2		= 305 ; //Mio-DMS Keypad (non-color display with touch and slider)
    DEV_ID_MIO_DMS3		= 306 ; //Mio-DMS Keypad (color display with touch and slider)
    DEV_ID_MIO_DMS4		= 307 ; //Mio-DMS Keypad (color display with touch, slider, and intercom)
    DEV_ID_MIO_DMS_END	= 307 ;
    
    /////////////////////////////////G3 PANELS 
    
    DEV_ID_G3_END		= 256 ;
    
    /////////////////////////////////G4 PANELS 
    
    DEV_ID_CA15		= 281 ; //NXx-CA15
    DEV_ID_CV15		= 282 ; //NXx-CV15
    DEV_ID_CA17		= 283 ; //NXx-CA17
    DEV_ID_CV17		= 284 ; //NXx-CV17
    
    DEV_ID_7500 		= 288 ; //MVP-7500
    DEV_ID_8400 		= 289 ; //MVP-8400
    DEV_ID_CV7 		= 290 ; //NXx-CV7
    DEV_ID_CV10 		= 291 ; //NXx-CV10
         
    DEV_ID_1200 		= 294 ; //NXx-1200
    DEV_ID_12VG 		= 295 ; //NXx-1200VG
    DEV_ID_15VG 		= 296 ; //NXx-1500VG
    DEV_ID_17VG 		= 297 ; //NXx-1700VG
    
    DEV_ID_CV5		= 313 ; //NXD-CV5
    DEV_ID_7500TC		= 314 ; //MVP-7500 with Touch Controller
    DEV_ID_8400TC		= 315 ; //MVP-8400 with Touch Controller
    DEV_ID_CV7TC		= 316 ; //NXx-CV7 with Touch Controller
    DEV_ID_CV10TC		= 317 ; //NXx-CV10 with Touch Controller
    DEV_ID_12TC		= 318 ; //NXx-1200 with Touch Controller
    DEV_ID_12VGTC		= 319 ; //NXx-1200VG with Touch Controller
    DEV_ID_15VGTC		= 320 ; //NXx-1500VG with Touch Controller
    DEV_ID_17VGTC		= 321 ; //NXx-1700VG with Touch Controller
    
    /////////////////////////////////R4 
    
    DEV_ID_R4		= 322 ;
    
    /////////////////////////////////CONT G4 PANELS 
    
    DEV_ID_8400i		= 323 ; //MVP-8400i
    DEV_ID_CV7iTC		= 324 ; //NXx-CV7i with Touch Controller
    DEV_ID_CV10iTC		= 325 ; //NXx-CV10i with Touch Controller
    
    DEV_ID_5200i 		= 329 ;
    DEV_ID_5150 		= 329 ;
    DEV_ID_5100 		= 329 ;
    DEV_ID_500i 		= 331 ;
    
    /////////////////////////////////NI MASTERS
    
    DEV_ID_NI2_3_4000_M	= 285 ; //NI-2000/3000/4000 (Master)
    DEV_ID_NI2_3_4000_D	= 286 ; //NI-2000/3000/4000 (Device)
    
    
    DEV_ID_NI700		= 298 ; //NI-700                             
    DEV_ID_NI2_3_4000	= 299 ; //NI-2000/3000/4000 
    DEV_ID_NI900		= 312 ; //NI-900
    
                                    
    /////////////////////////////////ENT VST - C 
    
    DEV_ID_ENVVSTC 		= $E5 ;
    
    DEV_ID_VIRTUAL		= 65534 ;
    
Sign In or Register to comment.