Home AMX User Forum AMX General Discussion

SET_VIRTUAL_LEVEL

I created a virtual device array of virtuals with the same device number and different ports:
vdvTP_DCM_1             = 33021:1:1 ;
vdvTP_DCM_2             = 33021:2:1 ; 

VOLATILE DEV vdvTP_DCMArry[DCM_NUM_DCMs]= {vdvTP_DCM_1,vdvTP_DCM_2} ;
Then in define start:
SET_VIRTUAL_PORT_COUNT(vdvTP_DCMArry[1],DCM_NUM_vdTP_DCMs) ;
to allow multiple ports on a virtual device number.

I then needed 48 levels for each virtual so in the online event for vdvTP_DCMArry I put:
DATA_EVENT[dvDCM_TPArry]

     {
     ONLINE://
	  {
	  STACK_VAR INTEGER nTPIndx ;
	  
	  nTPIndx = GET_LAST(dvDCM_TPArry) ;
	  SET_VIRTUAL_LEVEL_COUNT(dvDCM_TPArry[nTPIndx],DCM_NUM_STRUCT_n_LVLs) ;//
	  fnDCM_DeBug("fnDEV_TO_STRING(dvDCM_TPArry[nTPIndx]),', ONLINE! >-Line-<',ITOA(__LINE__),'>',CRLF") ;
	  }

unfortunately unless I'm missing something only virtual port 1 will generate an online event and trigger the set_virtual_level function. This had me going nuts for a good hour until I started watching diagnostics with the debug send strings in place.

So I decided to run a loop in define start:
DEFINE_START    //SET VIRTUAL PORT COUNTS & LEVEL COUNTS

     {
     STACK_VAR INTEGER i ;
     
     nDCM_DeBug = 1 ; #WARN 'debug set to 1 line 910 DefineStart' ;
     
     SET_VIRTUAL_PORT_COUNT(vdvTP_DCMArry[1],DCM_NUM_vdTP_DCMs) ;
     REBUILD_EVENT() ;
     fnDCM_DeBug("fnDEV_TO_STRING(vdvTP_DCMArry[1]),', SET PORT COUNT-',itoa(DCM_NUM_vdTP_DCMs),'! >-Line-<',ITOA(__LINE__),'>',CRLF") ;
     for(i = 1 ; i <= DCM_NUM_vdTP_DCMs ; i ++)
	  {
	  SET_VIRTUAL_LEVEL_COUNT(vdvTP_DCMArry[i],DCM_NUM_STRUCT_n_LVLs) ;
	  REBUILD_EVENT() ;
	  
	  fnDCM_DeBug("fnDEV_TO_STRING(vdvTP_DCMArry[i]),', SET LEVEL COUNT TO ',ITOA(DCM_NUM_STRUCT_n_LVLs),'. >-Line-<',ITOA(__LINE__),'>',CRLF") ;
	  fnDCM_DeBug("fnDEV_TO_STRING(vdvTP_DCMArry[i]),', REBUILT EVENT. >-Line-<',ITOA(__LINE__),'>',CRLF") ;
	  }
     }

I guess I could also do this since every one says set_level/channel counts should be in an online event:
DATA_EVENT[dvDCM_TPArry]

     {
     ONLINE://Main TP Online_Event defaults to Main Page
	  {
	  STACK_VAR INTEGER nTPIndx ;
	  
	  nTPIndx = GET_LAST(dvDCM_TPArry) ;
	  
	  if(nTPIndx == 1)
	       {
	       for(i = 1 ; i <= DCM_NUM_vdTP_DCMs ; i ++)
		    {
		    SET_VIRTUAL_LEVEL_COUNT(vdvTP_DCMArry[i],DCM_NUM_STRUCT_n_LVLs) ;
		    REBUILD_EVENT() ;
		    fnDCM_DeBug("fnDEV_TO_STRING(vdvTP_DCMArry[i]),', SET LEVEL COUNT TO ',ITOA(DCM_NUM_STRUCT_n_LVLs),'. >-Line-<',ITOA(__LINE__),'>',CRLF") ;
		    fnDCM_DeBug("fnDEV_TO_STRING(vdvTP_DCMArry[i]),', REBUILT EVENT. >-Line-<',ITOA(__LINE__),'>',CRLF") ;
		    }
	       }
	  fnDCM_DeBug("fnDEV_TO_STRING(dvDCM_TPArry[nTPIndx]),', ONLINE! >-Line-<',ITOA(__LINE__),'>',CRLF") ;
	  }

Any thoughts or alternatives other than not using mutliple port virtuals? Should I be using Rebuild_Event in the code where I have them? Obviously I'm thinking I should since they do affect the event tables but do I?
Sign In or Register to comment.