Home AMX User Forum NetLinx Studio

Defining a device a bit differently. How to?

Hello all! First off I will explain what I am trying to do here:

- I have several classrooms that will have an identical program/UI. The only thing that will differ in these programs will be the System Number.

- I have a centralized admin system that can control each of the classrooms using simple M2M.

- On the admin system touch panel, when I select a room I want to control, the control buttons "Channel Port" on the page are set to the corresponding room's System Number. EXAMPLE: Push button for System 10's room controls --> Button "Channel Port" on Admin TP's page that popped up is set as 10 for each button.


NOW for my dilemma:
On each rooms program, it wont let me define the remote admin tp as such:
DEFINE_DEVICE
dvAdminTP = 10001:SYSTEM.NUMBER:50
I get the error: "Symbol [SYSTEM] not defined"

Anyone know a way to do this without modifying each room's program individually? Thanks Much!

Comments

  • After a bit of thinking, I think I would do something like this.
    DEFINE_DEVICE
    
    dvMaster		= 0:1:0
    dvRoomTP		= 10001:1:0 //This is the room's touchpanel
    
    DEFINE_VARIABLE
    dev vdvAdminTP //This is the Admin TP
    
    integer nSysID
    (*  If the touchpanel buttons are identical, you could do something like this.
    dev vdvTP[]=
    {
    	vdvAdminTP,
    	dvRoomTP
    }*)
    
    DEFINE_EVENT
    data_event[dvMaster]
    {
    	online:
    	{
    		nSysID = get_system_number()
    		
    		vdvAdminTP = 10001:nSysID:50
    		send_string 0,"'vdvAdminTP is defined as ',itoa(vdvAdminTP.NUMBER),':',itoa(vdvAdminTP.PORT),':',itoa(vdvAdminTP.SYSTEM)"
    	}
    }
    

    This works, as tested on an NI-3000 with the latest firmware. Then in the events for your touchpanel you can either use a DEV array or you can just use the vdvAdminTP for the events from the Admin touchpanel. Hope that helps.
  • dev vdvTP[]=
    {
    	vdvAdminTP,
    	dvRoomTP
    }
    

    When I use the dev array, at the line "vdvAdminTP," i get the error "Initializer is not a constant"
  • Ok, that makes some sense. Sorry about that. Try this:
    DEFINE_VARIABLE
    dev vdvAdminTP //This is the Admin TP
    
    integer nSysID
    //If the touchpanel buttons are identical, you could do something like this. Set the array members in the online event
    dev vdvTP[2]
    
    DEFINE_EVENT
    data_event[dvMaster]
    {
    	online:
    	{
    		nSysID = get_system_number()
    		
    		vdvAdminTP = 10001:nSysID:50
    		
    		vdvTP[1] = vdvAdminTP
    		vdvTP[2] = dvRoomTP
    		send_string 0,"'vdvAdminTP is defined as ',itoa(vdvAdminTP.NUMBER),':',itoa(vdvAdminTP.PORT),':',itoa(vdvAdminTP.SYSTEM)"
    	}
    }
    

    or, alternatively, try
    DEFINE_START
    vdvTP[1] = vdvAdminTP
    vdvTP[2] = dvRoomTP
    
  • Compiles successfully =) much obliged!
  • AuserAuser Posts: 506
    vdvAdminTP = 10001:nSysID:50
    

    You'll need a call to rebuild_event() to rebuild the event tables if you have any events for vdvTP or vdvAdminTP as far as I can see (or else the event tables won't be updated when vdvAdminTP changes).
    DEFINE_START
    vdvTP[1] = vdvAdminTP
    vdvTP[2] = dvRoomTP
    

    Odds are you'll need to set_length_array(vdvTP, 2) and rebuild_event() if the dev array is not a constant and you populate it at runtime like this. vdvTP will have a default length of 0, as opposed to its size of 2, and you will need to reflect how many devs are stored in the array before updating the event tables from memory.
Sign In or Register to comment.