System Number in define_device?

JeffJeff Junior MemberPosts: 374
I think what I want to do isn't possible, but I thought I'd check to see if anyone knows how to do it.

I'd like to define a device on a remote system, with the port on the remote system matching the system number of my local system. For example, I'd like System 4 to define this device as 10001:4:1, and I'd like System 52 to define the device as 10001:52:1.

Every other piece of code on these systems is identical. Right now, I've just made the entire code an include file, and the individual files for each room just have this device definition and the include file called, but I'd love to get just one .axs file that gets loaded to every room.

defining it as 10001:system_number:1 doesn't work. putting the device definition after define_constant and defining the system number as a constant doesn't work.

Is there any way to do this? Or am I just dreaming?

J

Comments

  • matt95gsrmatt95gsr Junior Member Posts: 164
    Perhaps you could define all the devices in your code, put them in an array, and then reference the system number as an element of the array (dvPanels[SYSTEM_NUMBER]) in the actual code. I've not tried it, though this would probably work. However, unless you plan real well for the future, you'd still have to update the code every time you add a system.
  • annuelloannuello Junior Member Posts: 294
    I often use the same code & TP file for several different rooms. Rather than having a different port for each room, you would probably be better off having a different system number. In your code you can refer to "the system that this code is running on" by using system number 0. The system number can be set using NLS. If I want to access a device on a remote system, then (& only then) do I verbosly specify the system number.
    dvTp = 10128:1:0
    vdvMyVirtual = 33001:1:0
    vdvRemoteDevice = 33001:1:15
    

    The main problem I see of going down the port approach is with virtual devices. I believe they can only utilise port 1. You could probably even have all your systems set to #1 provided they don't interact with each other or a RMS server. However, in practice I find it useful to allocate a different number to each system. Admittedly, I use both RMS and Master2Master, so I _have_ to use different system numbers. It also makes it easier for G4 touch panels - I use Auto Mode where I jsut specify the system number that the panel connects to (rather than the IP address).

    Where equipment in rooms differ slightly from my 'standard' design, I tend to use compiler directives.
    PROGRAM_NAME = 'test'
    
    //Assume NI-3100 unless specified here
    #define NXI  //Comment this out for NI-3100 code
    
    DEFINE_DEVICE
    dvProj = 5001:1:0
    #if_defined NXI
    dvRelays = 5001:7:0
    #else
    dvRelays = 5001:8:0
    #end_if
    
    You then have to manipulate the #define flags before compiling. I suppose you could just as easily put these into the include files that you are already using.

    Roger McLean
    Swinburne Uni
  • JeffJeff Junior Member Posts: 374
    I'm already using 0 for everything except my master panel.

    Basically, what I have is a master touchpanel sitting on my desk. It has a complete set of buttons for every room in the building. What I have done so far is make every room's page the same, with the projector power on button always being channel 1, and the projector power off button is always channel 2. For controlling system two, all of the buttons are on port 2. For controlling system 53, all of the buttons are on port 53. This makes it easy to not keep renumbering every time I had a new button, and means I can load the same code on everything.

    However, this means that for each room, in the code I need to have
    dvMasterTP  =  10001:4:1
    

    In this instance, 4 is the local system number, and 1 is my master system number. For system 53, you would see
    dvMasterTP  =  10001:53:1
    

    So what I'm trying to figure out how to do, is get the code to not need me to manually enter the system number each time. It seems, however, that system_number isn't actually an integer. Does anyone know the appropriate use for that keyword?

    J
  • DHawthorneDHawthorne Junior Member Posts: 4,584
    If you address all the systems with different system numbers, there is no need to use the port to determine what system is in use. Doing it that way also pretty much kills the concept of being able to use multiple ports of a panel on the same system. If you want to run the same code on all of them, the 0 system number shortcut takes care of the system number for you. I fell like I must be missing something, because it sounds like you are beating your head against the wall to try to make something happen that is already in the master because you want to doi it a different way. Easier to go with how it was designed in a case like this.

    And, for the record, Annuello: you can define virtual devices with multiple ports.
  • matt95gsrmatt95gsr Junior Member Posts: 164
    SYSTEM_NUMBER should be an integer, as reported by NetLinx Keywords help file. I'm currently using it as such in the job I'm working on today, and it works fine for pulling the appropriate element out of an array of room names (RoomName[SYSTEM_NUMBER]). I'm still not sure how to accomplish what you're after, and I'm not sure if you could use SYSTEM_NUMBER in DEFINE_DEVICE at all, but I did want to mention that I've at least been successful in using it. Unfortunately I'm on a job site and they're using all the systems so I can't play around with this one, but I'm sure interested to see the end solution to your idea.
  • matt95gsrmatt95gsr Junior Member Posts: 164
    How about combining with a virtual device. I just tried using SYSTEM_NUMBER in DEFINE_DEVICE, and it won't compile which I'll assume is the same result you've gotten. However, it will compile if I create a virtual TP and then combine it with the dynamically numbered TP later on in the code. Again, I can't test it on a real system, but it does compile without complaining. It may at least be a step in the right direction.
    DEFINE_COMBINE
    (vdvMasterTP,10001:SYSTEM_NUMBER:0)
    
  • JeffJeff Junior Member Posts: 374
    The trick is, this master panel sits on my desk and has to control all of the systems. Within the rooms, they all work perfectly without this little bit of code. This is so that my master panel knows which system it is talking to (or more accurately, the remote rooms know that the master panel is talking to them).

    Basically, the master panel (which is on system 1) has a title page with buttons for each room. I hit the room button and it goes to a page for that room.

    The page for system 3 has a projector power on button for it. That button is channel 1, port 3. System 3 has defined on it dvMasterTP as 10001:3:1. there's a projector on button event for [dvMasterTP,1]

    The page for system 51 similarly has a projector power on button for it. That button is still channel 1, but is now port 51. System 51 has the same projector on button event for [dvMasterTP,1]. However, I have to differently define dvMasterTP as 10001:51:1. The events are all identical in every room, but changing up this panel definition means I can't load the same file to everything.

    I was hoping that I could use system_number in define_device and just define it as 10001:system_number:1. That way every system would automatically define dvMasterTP correctly. Its not really a big deal, I have a workaround already (the entirety of the code is in an include file and then each room has a file that is basically such
    define_device
    
    dvMasterTP = 10001:4:1
    
    include 'StandardRoom'
    

    Still, I'd like to find a way to do it all with one file.

    ----

    If I define dvMasterTP as 10001:system_number_1, I get the following error

    C10204: RHS for [DVMASTERTP] is not a constant

    My guess is this means that define_device and define_constant are both things that are taken care of at compile time, not at run time, and there's nothing I can do to make the device definitions change dynamically, but if someone would like to point out how I'm wrong . . . .

    J
  • JeffJeff Junior Member Posts: 374
    Wow. Nice work

    define_combine did it.

    can't do it in a device array, it appears to pretty much HAVE to happen in define_combine. Still, thats amazing.

    Thanks so much

    J
  • matt95gsrmatt95gsr Junior Member Posts: 164
    Cool, I'm glad that worked. Good thing you're quick to respond, too. Now I can stick that in the memory bank and not spend my day going through the potential solution without having anywhere to test it.
  • JeffJeff Junior Member Posts: 374
    :)

    So far I've only tried it on one room. I watched Notifications though, and I can see both my master panel button presses and the virtual device's button presses, which means its definitely working correctly. Once I've tried it on multiple rooms, I'll let you know how its working.

    J
Sign In or Register to comment.