Dynamically change D:P:S

criss87criss87 Junior MemberPosts: 32
Hi there!
I currently set up some classes in an university, because all the room are almost the same and are coupled together like one master room with it's slave one, i try to make just one file that autoset all matrix inputs and outputs based on the system number of all the ni3100 we got.
In the same manner, i try to change some virtual device, i tryed this in the define_start session where i set a dev variable to 33001:1:102 on system 101, 33001:1:101 on system 102 and so on.
Of course this compile correctly but is not working because i didn't specify that device in the define_device section.

Is there a way to add/modify a device d:p:s dinamically in code ?

Any help will be appreciated!

Criss

Comments

  • DHawthorneDHawthorne Junior Member Posts: 4,584
    The short answer is no. It's a constant, and too much is done with it at compile time. That said, there is a workaround. Make all your references in the program to a virtual device. Then define all the possible real device numbers you may have to switch around. At run time, use COMBINE_DEVICE to match the virtual to the real device number you are using.

    Personally, I find it easier to make the project-specific things like device assignments an INCLUDE, and just change that and recompile.
  • PhreaKPhreaK Senior Member Posts: 966
    How are you setting the matrix in's and out's? You can use SYSTEM_NUMBER to grab the masters system number at runtime and set up your routing tables from there.
  • viningvining X Member Posts: 4,348
    AMXJeff posted something to this affect in another thread a few weeks ago so I figured I'd try it out to amuse myself. It seems to work as advertised but on my office system it takes about 35 seconds to complete rebuilding the event tables assiciated with dvDynamic_DPS, the var I used to hold my dev. During the 35 seconds it takes to rebuild the tables button pushes on the TP didn't work either which makes me think that when the master is busy rebuilding it isn't capable of doing anything else.

    This makes using the DEFINE_COMBINE method that Dave talked about a much faster change and much less likely to negatively affect a users ability to use the system during a switch.

    It's kind of cool but I can't think of anything I'd use it for but maybe it could work for what you're trying to do.
    PROGRAM_NAME='Dynamic_DPS'
    
    DEFINE_VARIABLE
    
    DEV dvDynamic_DPS	= 0:1:0 ;
    CHAR nDynamicDPS_DeBug	= 1 ;
    
    DEFINE_FUNCTION fnDynamicDPS_DeBug(CHAR iStr[])
    
         {
         if(nDynamicDPS_DeBug)
    	  {
    	  STACK_VAR CHAR cCopyStr[1024] ;
    	  STACK_VAR INTEGER nLineCount ;
    	  
    	  cCopyStr = iStr ;
    	  
    	  nLineCount ++ ;
    	  WHILE(length_string(cCopyStr) > 100)
    	       {
    	       SEND_STRING 0,"'Dynamic_DPS.axi-(',itoa(nLineCount),') ',get_buffer_string(cCopyStr,100)" ; 
    	       nLineCount ++
    	       }
    	  if(length_string(cCopyStr))
    	       {
    	       SEND_STRING 0,"'Dynamic_DPS.axi-(',itoa(nLineCount),') ',cCopyStr" ;// DEBUG: 
    	       }
    	  }
         
         RETURN ;
         } 
         
    DEFINE_EVENT   //BUTTON_EVENT [vDynamic_DPS,0]
    
    BUTTON_EVENT [vDynamic_DPS,0]//33029:1:0 virtual used to push button in emulate device in order to run this code
    
         {
         PUSH:
    	  {
    	  STACK_VAR INTEGER nBtn ;
    	   
    	  nBtn = BUTTON.INPUT.CHANNEL ;
    	  fnDynamicDPS_DeBug("'PUSH_CHNL-[ ',itoa(nBtn),' ] :DEBUG<',ITOA(__LINE__),'>'") ;
    	  SWITCH(nBtn)
    	       {
    	       CASE 1:
    		    {
    		    fnDynamicDPS_DeBug("'SWITCH DEV TO HWI :DEBUG<',ITOA(__LINE__),'>'") ;
    		    dvDynamic_DPS = dvHWI ;//5001:2:0
    		    REBUILD_EVENT() ;
    		    fnDynamicDPS_DeBug("'REBUILT EVENT TABLE :DEBUG<',ITOA(__LINE__),'>'") ;
    		    }
    	       CASE 2:
    		    {
    		    fnDynamicDPS_DeBug("'SWITCH DEV TO Bnk :DEBUG<',ITOA(__LINE__),'>'") ;
    		    dvDynamic_DPS = dvBnKDistAudio ;//5001:3:0
    		    REBUILD_EVENT() ;
    		    fnDynamicDPS_DeBug("'REBUILT EVENT TABLE :DEBUG<',ITOA(__LINE__),'>'") ;
    		    }
    	       CASE 3:
    		    {
    		    fnDynamicDPS_DeBug("'SWITCH DEV TO VIEWSTATS :DEBUG<',ITOA(__LINE__),'>'") ;
    		    dvDynamic_DPS = dvViewStats ;//5001:7:0
    		    REBUILD_EVENT() ;
    		    fnDynamicDPS_DeBug("'REBUILT EVENT TABLE :DEBUG<',ITOA(__LINE__),'>'") ;
    		    }
    	       CASE 4:
    		    {
    		    fnDynamicDPS_DeBug("'SWITCH DEV TO SQZ SERVER :DEBUG<',ITOA(__LINE__),'>'") ;
    		    dvDynamic_DPS = dvSqzServer_1 ;//0:12:0
    		    REBUILD_EVENT() ;
    		    fnDynamicDPS_DeBug("'REBUILT EVENT TABLE :DEBUG<',ITOA(__LINE__),'>'") ;
    		    }
    	       CASE 5:
    		    {
    		    fnDynamicDPS_DeBug("'SWITCH DEV TO MASTER :DEBUG<',ITOA(__LINE__),'>'") ;
    		    dvDynamic_DPS = dvMaster ;//0:1:0
    		    REBUILD_EVENT() ;
    		    fnDynamicDPS_DeBug("'REBUILT EVENT TABLE :DEBUG<',ITOA(__LINE__),'>'") ;
    		    }
    	       }
    	  }
         RELEASE:
    	  {
    	  
    	  }
         }
         
    DEFINE_EVENT   //DATA_EVENT[dvDynamic_DPS]
    
    DATA_EVENT[dvDynamic_DPS]
         
         {
         ONLINE:
    	  {
    	  fnDynamicDPS_DeBug("'Online :DEBUG<',ITOA(__LINE__),'>'") ;
    	  }
         OFFLINE:
    	  {
    	  fnDynamicDPS_DeBug("'Offline :DEBUG<',ITOA(__LINE__),'>'") ;
    	  }
         STRING:
    	  {
    	  fnDynamicDPS_DeBug("'DEV-[ ',fnDEV_TO_STRING(dvDynamic_DPS),' ], DATA.TEXT-[ ',DATA.TEXT,' ] :DEBUG<',ITOA(__LINE__),'>'") ;
    	  }
         }
    

    Diagnostic print out and strings received from devices after dvDynamic_DPS changed to a different dev:
    Line      1 (20:07:21)::  Dynamic_DPS.axi-(1) PUSH_CHNL-[ 1 ] :DEBUG<43>
    Line      2 (20:07:21)::  Dynamic_DPS.axi-(1) SWITCH DEV TO HWI :DEBUG<48>
    Line      3 (20:07:56)::  Dynamic_DPS.axi-(1) REBUILT EVENT TABLE :DEBUG<51>
    Line      4 (20:07:57)::  Dynamic_DPS.axi-(1) DEV-[ 5001:2:0 ], DATA.TEXT-[ $0D$0DKeypad not in database$0D$0DL232>  ] :DEBUG<104>
    Line      5 (20:07:58)::  Dynamic_DPS.axi-(1) DEV-[ 5001:2:0 ], DATA.TEXT-[ $0D$0DKLS, [01:08:02:01], 000100000000000000000000$0D$0DL232>  ] :DEBUG<104>
    Line      6 (20:07:59)::  Dynamic_DPS.axi-(1) DEV-[ 5001:2:0 ], DATA.TEXT-[ $0D$0DKLS, [01:08:02:02], 000000000000000000000000$0D$0DL232>  ] :DEBUG<104>
    Line      7 (20:08:00)::  Dynamic_DPS.axi-(1) DEV-[ 5001:2:0 ], DATA.TEXT-[ $0D$0DKeypad not in database$0D$0DL232>  ] :DEBUG<104>
    Line      8 (20:08:00)::  Dynamic_DPS.axi-(1) DEV-[ 5001:2:0 ], DATA.TEXT-[ $0D ] :DEBUG<104>
    Line      9 (20:08:01)::  Dynamic_DPS.axi-(1) DEV-[ 5001:2:0 ], DATA.TEXT-[ $0DKLS, [01:08:02:01], 000100000000000000000000$0D$0DL232>  ] :DEBUG<104>
    Line     10 (20:08:02)::  Dynamic_DPS.axi-(1) DEV-[ 5001:2:0 ], DATA.TEXT-[ $0D$0DKLS, [01:08:02:02], 000000000000000000000000$0D$0DL232>  ] :DEBUG<104>
    Line     11 (20:08:03)::  Dynamic_DPS.axi-(1) DEV-[ 5001:2:0 ], DATA.TEXT-[ $0D$0DKeypad not in database$0D$0DL232>  ] :DEBUG<104>
    Line     12 (20:08:04)::  Dynamic_DPS.axi-(1) DEV-[ 5001:2:0 ], DATA.TEXT-[ $0D$0DKLS, [01:08:02:01], 000100000000000000000000$0D$0DL232>  ] :DEBUG<104>
    Line     13 (20:08:05)::  Dynamic_DPS.axi-(1) DEV-[ 5001:2:0 ], DATA.TEXT-[ $0D$0DKLS, [01:08:02:02], 000000000000000000000000$0D$0DL232>  ] :DEBUG<104>
    Line     14 (20:08:05)::  Dynamic_DPS.axi-(1) PUSH_CHNL-[ 2 ] :DEBUG<43>
    Line     15 (20:08:05)::  Dynamic_DPS.axi-(1) SWITCH DEV TO Bnk :DEBUG<55>
    Line     16 (20:08:40)::  Dynamic_DPS.axi-(1) REBUILT EVENT TABLE :DEBUG<58>
    Line     17 (20:08:45)::  Dynamic_DPS.axi-(1) DEV-[ 5001:3:0 ], DATA.TEXT-[ (00,U,I,0D=40;02D2) ] :DEBUG<104>
    Line     18 (20:08:45)::  Dynamic_DPS.axi-(1) DEV-[ 5001:3:0 ], DATA.TEXT-[ (00,R,Z0D,24=01;0343)(00,R,P0D=FF,01=1B,02=05,03=0
    Line     19 (20:08:45)::  Dynamic_DPS.axi-(2) 5,04=03,05=05, ] :DEBUG<104>
    Line     20 (20:08:45)::  Dynamic_DPS.axi-(1) DEV-[ 5001:3:0 ], DATA.TEXT-[ 06=09,07=00,08=21,09=37,0A=01,0B=00;1021) ] :DEBUG<104>
    Line     21 (20:08:47)::  Dynamic_DPS.axi-(1) DEV-[ 5001:3:0 ], DATA.TEXT-[ (00,U,I,0C=40;02D1) ] :DEBUG<104>
    Line     22 (20:08:48)::  Dynamic_DPS.axi-(1) DEV-[ 5001:3:0 ], DATA.TEXT-[ (00,R,Z0C,24=01;0342)(00,R,P0C=FF,01=1E,02=05,03=0
    Line     23 (20:08:48)::  Dynamic_DPS.axi-(2) 5,04=03,05=07, ] :DEBUG<104>
    Line     24 (20:08:48)::  Dynamic_DPS.axi-(1) DEV-[ 5001:3:0 ], DATA.TEXT-[ 06=07,07=01,08=61,09=27,0A=01,0B=00;1027) ] :DEBUG<104>
    Line     25 (20:08:52)::  Dynamic_DPS.axi-(1) PUSH_CHNL-[ 3 ] :DEBUG<43>
    Line     26 (20:08:52)::  Dynamic_DPS.axi-(1) SWITCH DEV TO VIEWSTATS :DEBUG<62>
    Line     27 (20:09:27)::  Dynamic_DPS.axi-(1) REBUILT EVENT TABLE :DEBUG<65>
    Line     28 (20:09:27)::  Dynamic_DPS.axi-(1) DEV-[ 5001:7:0 ], DATA.TEXT-[ SN2 C8=ON$0D ] :DEBUG<104>
    Line     29 (20:09:28)::  Dynamic_DPS.axi-(1) DEV-[ 5001:7:0 ], DATA.TEXT-[ SN1FAM ROOM$FF  T=79F$0D ] :DEBUG<104>
    Line     30 (20:09:41)::  Dynamic_DPS.axi-(1) PUSH_CHNL-[ 4 ] :DEBUG<43>
    Line     31 (20:09:41)::  Dynamic_DPS.axi-(1) SWITCH DEV TO SQZ SERVER :DEBUG<69>
    Line     32 (20:10:16)::  Dynamic_DPS.axi-(1) REBUILT EVENT TABLE :DEBUG<72>
    Line     33 (20:10:18)::  UI DEBUG (1): UI Device: 10004:1:0 SEND_COMMAND: PAGE-Source SlimServer :DEBUG <71>
    Line     34 (20:10:18)::  Connected Successfully
    Line     35 (20:10:19)::  CIpEvent::OnLine 0:12:1
    Line     36 (20:10:19)::  Dynamic_DPS.axi-(1) Online :DEBUG<96>
    Line     37 (20:10:19)::  Dynamic_DPS.axi-(1) DEV-[ 0:12:0 ], DATA.TEXT-[ 00%3A04%3A20%3A00%3A00%3A01 power 1 $0A ] :DEBUG<104>
    Line     38 (20:10:19)::  Dynamic_DPS.axi-(1) DEV-[ 0:12:0 ], DATA.TEXT-[ 00%3A04%3A20%3A00%3A00%3A01 listen 1$0A ] :DEBUG<104>
    Line     39 (20:10:19)::  Dynamic_DPS.axi-(1) DEV-[ 0:12:0 ], DATA.TEXT-[ 00%3A04%3A20%3A00%3A00%3A01 playlist tracks 9$0A ] :DEBUG<104>
    Line     40 (20:10:19)::  Dynamic_DPS.axi-(1) DEV-[ 0:12:0 ], DATA.TEXT-[ 00%3A04%3A20%3A00%3A00%3A01 playlist index 3$0A ] :DEBUG<104>
    Line     41 (20:10:19)::  Dynamic_DPS.axi-(1) DEV-[ 0:12:0 ], DATA.TEXT-[ 00%3A04%3A20%3A00%3A00%3A01 status 3 2 tags%3Agal pl
    Line     42 (20:10:19)::  Dynamic_DPS.axi-(2) ayer_name%3AVortexBox%20Player player_connected%3A1 player_ip%3A127.0.0.1%3A4067
    Line     43 (20:10:19)::  Dynamic_DPS.axi-(3) 4 power%3A1 signalstrength%3A0 mode%3Apause time%3A324.277 rate%3A1 duration%3A4
    Line     44 (20:10:19)::  Dynamic_DPS.axi-(4) 67.8 can_seek%3A1 mixer%20volume%3A100 playlist%20repeat%3A0 playlist%20shuffle%
    Line     45 (20:10:19)::  Dynamic_DPS.axi-(5) 3A0 playlist%20mode%3Aoff seq_no%3A0 playlist_cur_index%3A3 playlist_timestamp%3
    Line     46 (20:10:19)::  Dynamic_DPS.axi-(6) A1315259239.25552 playlist_tracks%3A9 playlist%20index%3A3 id%3A9261 title%3ASou
    Line     47 (20:10:19)::  Dynamic_DPS.axi-(7) lshine genre%3ARock artist%3AGov't%20Mule album%3AThe%20Deep%20End%2C%20Vol.%201
    Line     48 (20:10:19)::  Dynamic_DPS.axi-(8)  playlist%20index%3A4 id%3A10084 title%3AEl%20Farol genre%3ARock artist%3ASantan
    Line     49 (20:10:19)::  Dynamic_DPS.axi-(9) a album%3ASupernatural$0A ] :DEBUG<104>
    Line     50 (20:10:19)::  Dynamic_DPS.axi-(1) DEV-[ 0:12:0 ], DATA.TEXT-[ 00%3A04%3A20%3A00%3A00%3A01 playlist path 3 file%3A%
    Line     51 (20:10:19)::  Dynamic_DPS.axi-(2) 2F%2F%2Fstorage%2Fmusic%2Fflac%2FGov%2527t%2520Mule%2FThe%2520Deep%2520End%2C%25
    Line     52 (20:10:19)::  Dynamic_DPS.axi-(3) 20Vol.%25201%2F08%2520Gov%2527t%2520Mule%2520-%2520Soulshine.flac$0A ] :DEBUG<104>
    Line     53 (20:10:19)::  Dynamic_DPS.axi-(1) DEV-[ 0:12:0 ], DATA.TEXT-[ 00%3A04%3A20%3A00%3A00%3A01 songinfo 0 100 url%3Afil
    Line     54 (20:10:19)::  Dynamic_DPS.axi-(2) e%3A%2F%2F%2Fstorage%2Fmusic%2Fflac%2FGov%2527t%2520Mule%2FThe%2520Deep%2520End%
    Line     55 (20:10:19)::  Dynamic_DPS.axi-(3) 2C%2520Vol.%25201%2F08%2520Gov%2527t%2520Mule%2520-%2520Soulshine.flac id%3A9261
    Line     56 (20:10:19)::  Dynamic_DPS.axi-(4)  title%3ASoulshine artist%3AGov't%20Mule duration%3A467.8 album_id%3A659 filesiz
    Line     57 (20:10:19)::  Dynamic_DPS.axi-(5) e%3A51053148 genre%3ARock disc%3A1 coverart%3A1 artwork_track_id%3A9254 album%3A
    Line     58 (20:10:19)::  Dynamic_DPS.axi-(6) The%20Deep%20End%2C%20Vol.%201 modificationTime%3AWednesday%2C%20November%2024%2
    Line     59 (20:10:19)::  Dynamic_DPS.axi-(7) C%202010%2C%207%3A53%20PM type%3Aflc genre_id%3A88 disccount%3A1 bitrate%3A872kb
    Line     60 (20:10:19)::  Dynamic_DPS.axi-(8) ps%20VBR artist_id%3A759 tracknum%3A8 year%3A2001 compilation%3A1 samplesize%3A1
    Line     61 (20:10:19)::  Dynamic_DPS.axi-(9) 6 rating%3A4 samplerate%3A44100$0A ] :DEBUG<104>
    Line     62 (20:10:34)::  Dynamic_DPS.axi-(1) PUSH_CHNL-[ 5 ] :DEBUG<43>
    Line     63 (20:10:34)::  Dynamic_DPS.axi-(1) SWITCH DEV TO MASTER :DEBUG<76>
    Line     64 (20:11:09)::  Dynamic_DPS.axi-(1) REBUILT EVENT TABLE :DEBUG<79>
    
  • jbeamjbeam Junior Member Posts: 12
    Using dev arrays to re route devices at runtime

    Criss,

    Here's some example code that I developed to be able to switch between different projector modules and port connection types without having to resend a compiled program to the master. (I used several variables I read from a config file placed on the master to change connection ports and projector brand/type) I think you should be able to adapt this technique to suit your needs. The important thing you were probably missing with your dev variable is that you need to call REBUILD_EVENT() after changing a dev variable that is used for a module or something set at compile time.

    Thanks,
    Jeff Beam


    DEFINE_DEVICE

    dvNULL = 0:0:0

    DEFINE_VARIABLE

    DEV dvCMDS_PROJ_1_DEV_ARRAY[] = { dvNULL }

    DEV dvIP_Projector_1_ARRAY[] = { dvNULL }
    DEV dvW_IP_Projector_1_ARRAY[] = { dvNULL }


    DEV dvCOMM1_DEV_ARRAY[] = { dvNULL }
    DEV dvCOMM2_DEV_ARRAY[] = { dvNULL }
    DEV dvCOMM3_DEV_ARRAY[] = { dvNULL }
    DEV dvCOMM4_DEV_ARRAY[] = { dvNULL }
    DEV dvCOMM5_DEV_ARRAY[] = { dvNULL }



    (***********************************************************)
    (* SUBROUTINE/FUNCTION DEFINITIONS GO BELOW *)
    (***********************************************************)
    (* EXAMPLE: DEFINE_FUNCTION <RETURN_TYPE> <NAME> (<PARAMETERS>) *)
    (* EXAMPLE: DEFINE_CALL '<NAME>' (<PARAMETERS>) *)
    DEFINE_CALL 'PROJECTOR_1_OFF_1_MIN'()
    {
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1], "'POWER=0'"
    }
    DEFINE_CALL 'PROJECTOR_1_OFF'()
    {
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1], "'POWER=0'"
    WAIT 50 { SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1], "'POWER=0'" }
    }

    DEFINE_CALL 'PROJECTOR_1_ON'()
    {
    SEND_COMMAND dvTP_ARRAY,"'PAGE-PROJ_WAIT'"
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1], "'POWER=1'"
    WAIT 50 { SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1], "'POWER=1'" }
    SEND_COMMAND dvTP_ARRAY, "'@TXT',31,sPROJECTOR_1_NAME_TEXT,' is warming up.'"
    nPROJECTOR_1_POWER_STATUS_COMP = 255
    WAIT_UNTIL(nPROJECTOR_1_POWER_STATUS = 1)
    {
    IF(nProjPowerOnSource)
    {
    nSOURCE_SELECTED = nProjPowerOnSource
    CALL 'PAGE_FLIP'(nProjPowerOnSource)
    CALL 'SOURCE_SELECTED' (nProjPowerOnSource)
    }
    }
    }

    DEFINE_CALL 'PROJECTOR_1_INPUT'(INTEGER INP)
    {
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1], "'INPUT=',ITOA(INP)"
    }
    DEFINE_CALL 'PROJECTOR_1_VIDEO_MUTE'(INTEGER INP)
    {
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1], "'MUTE_VIDEO=',ITOA(INP)"
    }
    DEFINE_CALL 'PROJECTOR_1_VIDEO_FREEZE'(INTEGER INP)
    {
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1], "'FREEZE=',ITOA(INP)"
    }
    DEFINE_CALL 'PROJECTOR_1_VIDEO_ASPECT'(INTEGER INP)
    {
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1], "'ASPECT=',ITOA(INP)"
    }
    DEFINE_CALL 'PROJECTOR_1_VIDEO_AUTO_ADJUST'
    {
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1], "'AUTO_ADJUST=1'"
    }
    DEFINE_CALL 'POLL_PROJECTOR_1_POWER'()
    {
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1], "'POWER?'"
    }
    DEFINE_CALL 'POLL_PROJECTOR_1_LAMPTIME'()
    {
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1], "'LAMPTIME?'"
    }

    (***********************************************************)
    (* STARTUP CODE GOES BELOW *)
    (***********************************************************)
    DEFINE_START

    CREATE_BUFFER dvCMDS_PROJ_1_DEV_ARRAY[1],uBUFFER_PROJECTOR_1
    SET_LENGTH_STRING(uBUFFER_PROJECTOR_1,0) // CLEAR OUT ANY JUNK

    CREATE_BUFFER vdvIP_CMDS_1,uBUFFER_IP_1
    SET_LENGTH_STRING(uBUFFER_IP_1,0) // CLEAR OUT ANY JUNK

    SWITCH(nPROJECTOR_1_IP_CONNECT)
    {
    CASE 2: // PROJECTOR WITH BUILT IN ETHERNET
    {
    SWITCH (nPROJECTOR_1_TYPE)
    {
    CASE 0: // DEFAULT TO EPSON IF NOT SET
    {
    dvCMDS_PROJ_1_DEV_ARRAY[1] = vdvIP_CMDS_1_1
    dvIP_Projector_1_ARRAY[1] = dvIP_Projector_1
    dvW_IP_Projector_1_ARRAY[1] = dvNULL
    dvCOMM1_DEV_ARRAY[1] = dvNULL
    dvCOMM2_DEV_ARRAY[1] = dvNULL
    dvCOMM3_DEV_ARRAY[1] = dvNULL
    dvCOMM4_DEV_ARRAY[1] = dvNULL
    dvCOMM5_DEV_ARRAY[1] = dvNULL
    WAIT 5
    {
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'MODEL=',sPROJECTOR_1_MODEL"
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'WARMTIME=',ITOA(nProjector_1_WarmTime)"
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'COOLTIME=',ITOA(nProjector_1_CoolTime)"
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'REINIT='"
    }
    BREAK
    }
    CASE 1: // EPSON
    {
    dvCMDS_PROJ_1_DEV_ARRAY[1] = vdvIP_CMDS_1_1
    dvIP_Projector_1_ARRAY[1] = dvIP_Projector_1
    dvW_IP_Projector_1_ARRAY[1] = dvNULL
    dvCOMM1_DEV_ARRAY[1] = dvNULL
    dvCOMM2_DEV_ARRAY[1] = dvNULL
    dvCOMM3_DEV_ARRAY[1] = dvNULL
    dvCOMM5_DEV_ARRAY[1] = dvNULL
    dvCOMM4_DEV_ARRAY[1] = dvNULL
    WAIT 5
    {
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'MODEL=',sPROJECTOR_1_MODEL"
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'WARMTIME=',ITOA(nProjector_1_WarmTime)"
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'COOLTIME=',ITOA(nProjector_1_CoolTime)"
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'REINIT='"
    }
    BREAK
    }
    // CASE 2: // SANYO
    // {
    // dvCMDS_PROJ_1_DEV_ARRAY[1] = vdvCOMMAND_PROJECTOR_2
    // dvCOMM1_DEV_ARRAY[1] = vdvPROJECTOR_1_DUMMY
    // dvCOMM2_DEV_ARRAY[1] = vdvPROJECTOR_1_DUMMY
    // dvCOMM3_DEV_ARRAY[1] = vdvPROJECTOR_1_DUMMY
    // dvCOMM4_DEV_ARRAY[1] = vdvPROJECTOR_1_DUMMY
    // WAIT 5
    // {
    // SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'IP_MODE=1'"
    // SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'REINIT='"
    // }
    // BREAK
    // }
    // CASE 3: // NEC
    // {
    // dvCMDS_PROJ_1_DEV_ARRAY[1] = vdvCOMMAND_PROJECTOR_3
    // dvCOMM1_DEV_ARRAY[1] = vdvPROJECTOR_1_DUMMY
    // dvCOMM2_DEV_ARRAY[1] = vdvPROJECTOR_1_DUMMY
    // dvCOMM3_DEV_ARRAY[1] = vdvPROJECTOR_1_DUMMY
    // dvCOMM4_DEV_ARRAY[1] = vdvPROJECTOR_1_DUMMY
    // WAIT 5
    // {
    // SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'IP_MODE=1'"
    // SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'REINIT='"
    // }
    // BREAK
    // }
    // CASE 4: // HITACHI
    // {
    // dvCMDS_PROJ_1_DEV_ARRAY[1] = vdvCOMMAND_PROJECTOR_4
    // dvCOMM1_DEV_ARRAY[1] = vdvPROJECTOR_1_DUMMY
    // dvCOMM2_DEV_ARRAY[1] = vdvPROJECTOR_1_DUMMY
    // dvCOMM3_DEV_ARRAY[1] = vdvPROJECTOR_1_DUMMY
    // dvCOMM4_DEV_ARRAY[1] = vdvPROJECTOR_1_DUMMY
    // WAIT 5
    // {
    // SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'IP_MODE=1'"
    // SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'REINIT='"
    // }
    // BREAK
    // }
    }
    IF(LENGTH_STRING(sPROJECTOR_1_IP)){ SEND_COMMAND vdvIP_CMDS_1_1,"'IP_ADDRESS=',sPROJECTOR_1_IP" }
    ELSE{ SEND_COMMAND vdvIP_CMDS_1_1,"'IP_AUTO_CONNECT=0'" SEND_COMMAND vdvIP_CMDS_1_1,"'IP_AUTO_RECONNECT=0'" }
    SEND_COMMAND vdvIP_CMDS_1_1,"'IP_PORT=',ITOA(nPROJECTOR_1_IP_PORT)"
    SEND_COMMAND vdvIP_CMDS_1,"'IP_AUTO_CONNECT=0'"
    SEND_COMMAND vdvIP_CMDS_1,"'IP_AUTO_RECONNECT=0'"
    }
    CASE 0: // SERIAL PORT
    {
    SWITCH (nPROJECTOR_1_TYPE)
    {
    CASE 0: // DEFAULT TO EPSON IF NOT SET
    {
    dvCMDS_PROJ_1_DEV_ARRAY[1] = vdvCOMMAND_PROJECTOR_1
    dvIP_Projector_1_ARRAY[1] = dvNULL
    dvW_IP_Projector_1_ARRAY[1] = dvNULL
    dvCOMM1_DEV_ARRAY[1] = dvPHYSICAL_PORT_PROJECTOR_1
    dvCOMM2_DEV_ARRAY[1] = dvNULL
    dvCOMM3_DEV_ARRAY[1] = dvNULL
    dvCOMM4_DEV_ARRAY[1] = dvNULL
    dvCOMM5_DEV_ARRAY[1] = dvNULL
    WAIT 5
    {
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'MODEL=',sPROJECTOR_1_MODEL"
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'WARMTIME=',ITOA(nProjector_1_WarmTime)"
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'COOLTIME=',ITOA(nProjector_1_CoolTime)"
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'REINIT='"
    }
    BREAK
    }
    CASE 1: // EPSON
    {
    dvCMDS_PROJ_1_DEV_ARRAY[1] = vdvCOMMAND_PROJECTOR_1
    dvIP_Projector_1_ARRAY[1] = dvNULL
    dvW_IP_Projector_1_ARRAY[1] = dvNULL
    dvCOMM1_DEV_ARRAY[1] = dvPHYSICAL_PORT_PROJECTOR_1
    dvCOMM2_DEV_ARRAY[1] = dvNULL
    dvCOMM3_DEV_ARRAY[1] = dvNULL
    dvCOMM4_DEV_ARRAY[1] = dvNULL
    dvCOMM5_DEV_ARRAY[1] = dvNULL
    WAIT 5
    {
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'MODEL=',sPROJECTOR_1_MODEL"
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'WARMTIME=',ITOA(nProjector_1_WarmTime)"
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'COOLTIME=',ITOA(nProjector_1_CoolTime)"
    SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'REINIT='"
    }
    BREAK
    }
    CASE 2: // SANYO
    {
    dvCMDS_PROJ_1_DEV_ARRAY[1] = vdvCOMMAND_PROJECTOR_2
    dvIP_Projector_1_ARRAY[1] = dvNULL
    dvW_IP_Projector_1_ARRAY[1] = dvNULL
    dvCOMM1_DEV_ARRAY[1] = dvNULL
    dvCOMM2_DEV_ARRAY[1] = dvPHYSICAL_PORT_PROJECTOR_1
    dvCOMM3_DEV_ARRAY[1] = dvNULL
    dvCOMM4_DEV_ARRAY[1] = dvNULL
    dvCOMM5_DEV_ARRAY[1] = dvNULL
    WAIT 5 {SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'REINIT='"}
    BREAK
    }
    CASE 3: // NEC
    {
    dvCMDS_PROJ_1_DEV_ARRAY[1] = vdvCOMMAND_PROJECTOR_3
    dvIP_Projector_1_ARRAY[1] = dvNULL
    dvW_IP_Projector_1_ARRAY[1] = dvNULL
    dvCOMM1_DEV_ARRAY[1] = dvNULL
    dvCOMM2_DEV_ARRAY[1] = dvNULL
    dvCOMM3_DEV_ARRAY[1] = dvPHYSICAL_PORT_PROJECTOR_1
    dvCOMM4_DEV_ARRAY[1] = dvNULL
    dvCOMM5_DEV_ARRAY[1] = dvNULL
    WAIT 5 {SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'REINIT='"}
    BREAK
    }
    CASE 4: // HITACHI
    {
    dvCMDS_PROJ_1_DEV_ARRAY[1] = vdvCOMMAND_PROJECTOR_4
    dvIP_Projector_1_ARRAY[1] = dvNULL
    dvW_IP_Projector_1_ARRAY[1] = dvNULL
    dvCOMM1_DEV_ARRAY[1] = dvNULL
    dvCOMM2_DEV_ARRAY[1] = dvNULL
    dvCOMM3_DEV_ARRAY[1] = dvNULL
    dvCOMM4_DEV_ARRAY[1] = dvPHYSICAL_PORT_PROJECTOR_1
    dvCOMM5_DEV_ARRAY[1] = dvNULL
    WAIT 5 {SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'REINIT='"}
    BREAK
    }
    CASE 5: // 3M SCP
    {
    dvCMDS_PROJ_1_DEV_ARRAY[1] = vdvCOMMAND_PROJECTOR_5
    dvIP_Projector_1_ARRAY[1] = dvNULL
    dvW_IP_Projector_1_ARRAY[1] = dvNULL
    dvCOMM1_DEV_ARRAY[1] = dvNULL
    dvCOMM2_DEV_ARRAY[1] = dvNULL
    dvCOMM3_DEV_ARRAY[1] = dvNULL
    dvCOMM4_DEV_ARRAY[1] = dvNULL
    dvCOMM5_DEV_ARRAY[1] = dvPHYSICAL_PORT_PROJECTOR_1
    WAIT 5 {SEND_COMMAND dvCMDS_PROJ_1_DEV_ARRAY[1],"'REINIT='"}
    BREAK
    }
    }
    SEND_COMMAND vdvIP_CMDS_1_1,"'IP_AUTO_CONNECT=0'"
    SEND_COMMAND vdvIP_CMDS_1_1,"'IP_AUTO_RECONNECT=0'"
    SEND_COMMAND vdvIP_CMDS_1,"'IP_AUTO_CONNECT=0'"
    SEND_COMMAND vdvIP_CMDS_1,"'IP_AUTO_RECONNECT=0'"
    }
    }

    REBUILD_EVENT()


    DEFINE_MODULE 'Epson_Projector_Comm' COMM1_1(vdvCOMMAND_PROJECTOR_1,dvCOMM1_DEV_ARRAY[1])
    DEFINE_MODULE 'Sanyo_Projector_Comm' COMM2_1(vdvCOMMAND_PROJECTOR_2,dvCOMM2_DEV_ARRAY[1])
    DEFINE_MODULE 'NEC_Projector_Comm' COMM3_1(vdvCOMMAND_PROJECTOR_3,dvCOMM3_DEV_ARRAY[1])
    DEFINE_MODULE 'Hitachi_Projector_Comm' COMM4_1(vdvCOMMAND_PROJECTOR_4,dvCOMM4_DEV_ARRAY[1])
    DEFINE_MODULE '3M_SCP_Projector_Comm' COMM5_1(vdvCOMMAND_PROJECTOR_5,dvCOMM5_DEV_ARRAY[1])
    DEFINE_MODULE 'IP_Wrapper_Serial_Comm_Module' IP_COMM1(vdvIP_CMDS_1,vdvIP_COMM_1_MOD_DEV,dvW_IP_Projector_1_ARRAY[1])
    DEFINE_MODULE 'Epson_IP_Projector_Comm' IP_COMM1_1(vdvIP_CMDS_1_1,dvIP_Projector_1_ARRAY[1])
  • samossamos Junior Member Posts: 106
    you could use conditional compiling

    #IF_DEFINED


    #IF_NOT_DEFINED
  • David VineDavid Vine Junior Member Posts: 2
    Rebuild the Event Table at Runtime

    QUESTION: Is there a way to add/modify a device d:p:s dinamically in code ?

    ANSWER: Yes. You can create a variable DEV, set the D:P:S of the variable device at runtime, and then use the REBUILD_EVENT() function to rebuild the event table.


    Step #1: Declare your variable device.
    DEFINE_VARIABLE
    
    // Declare a variable device which can have it's D:P:S changed at runtime.
    DEV vdvVariableDevice
    

    Step #2: In DEFINE_START check what the system number is of the master running the code to determine what virtual D:P:S to assignto the variable device. Assign the variable device a D:P:S and immediately rebuild the Event Table.
    DEFINE_START
    
    SWITCH( GET_SYSTEM_NUMBER() )     // what is the system id of this master
    {
              // if this is system 101 set the virtual device to system 102
              CASE 101:     vdvVariableDevice = 33001:1:102
              // if this is system 102 set the virtual device to system 101
              CASE 102:     vdvVariableDevice = 33002:1:101
    }
        
    // rebuild the event table.
    REBUILD_EVENT()
    


    Please let me know if this was what you were after?
  • HARMAN_icraigieHARMAN_icraigie Technical Trainer II, Harman Professional University Posts: 466
    David Vine wrote: »
    QUESTION: Is there a way to add/modify a device d:p:s dinamically in code ?

    ANSWER: Yes. You can create a variable DEV, set the D:P:S of the variable device at runtime, and then use the REBUILD_EVENT() function to rebuild the event table.


    Step #1: Declare your variable device.
    DEFINE_VARIABLE
    
    // Declare a variable device which can have it's D:P:S changed at runtime.
    DEV vdvVariableDevice
    

    Step #2: In DEFINE_START check what the system number is of the master running the code to determine what virtual D:P:S to assignto the variable device. Assign the variable device a D:P:S and immediately rebuild the Event Table.
    DEFINE_START
    
    SWITCH( GET_SYSTEM_NUMBER() )     // what is the system id of this master
    {
              // if this is system 101 set the virtual device to system 102
              CASE 101:     vdvVariableDevice = 33001:1:102
              // if this is system 102 set the virtual device to system 101
              CASE 102:     vdvVariableDevice = 33002:1:101
    }
        
    // rebuild the event table.
    REBUILD_EVENT()
    


    Please let me know if this was what you were after?

    You can pass d.p.s info across masters in command strings and create event tables for devices on other systems without declaring them locally. Reading the device info from a database then populating the device arrays dynamically during runtime works too.
Sign In or Register to comment.