Home AMX User Forum NetLinx Studio

Using Variables in M2M communication

Hello all,
Just wanted to know if it is possible to set a variable on one central controller and look at that same variable from another central controller using M2M communication? If so, how would you do it?

Thanks!

Comments

  • truetrue Posts: 307
    Nope. Need to roll your own methods to share data.
  • myer0244 wrote: »
    Hello all,
    Just wanted to know if it is possible to set a variable on one central controller and look at that same variable from another central controller using M2M communication? If so, how would you do it?

    Thanks!

    Level on a virtual device.
  • PhreaKPhreaK Posts: 966
    Level events are a simple way to handle numerical types, but for anything else the variable serialization functions (variable_to_string() and string_to_variable()) are your friend as these will serialize any of your data, including user defined types.

    Rather than relying on shooting raw info between the masters you may also want to look at your system architecture to see if you can encapsulate functionality and let things play nice between a group of modules using a set of defined API's (whether that be SNAPI, or one of your own design). This will allow you to request only the data you need when required through virtual devices - again if you are needing any complex data types they can be serialized.

    If you're using duet then there a lot more sexy ways of handling this too...
  • DHawthorneDHawthorne Posts: 4,584
    You can easily share numeric values with a level on a virtual device. My habit in M2M systems is to give each separate system it's own virtual and define it on every other system. Then it's trivial to check a level on any of them, and even more so if you use CREATE_LEVEL to link them to a local variable.

    For strings, you can pass messages among the virtual devices very easily as well, and you can use the virtual devices as an interface for one system to request action from another; a paradigm I use all the time when I have local theaters acting as zones on a multi-room audio system that has a separate master.

    It's only when you have to share complex data, like structures or multi-level arrays that it gets hairy. But honestly, I try to design my systems so that never comes up.
  • staticatticstaticattic Posts: 200
    M2M with multi dim arrays

    I have a question along this same topic. In my building, there is one Master Master that all of the sub masters talk to. The Master Master controls a Pesa Cheetah 512 x 512 video matrix. Each sub master has an 8 x 8 Pesa video matrix in their rooms. I need to pass vairables from the Master Master to the sub-masters when they need it. For example, the 512 x 512 matrix has a DSS head end as poart of its inputs. So, if Room 1 wants to watch CNN here's what happens:

    Room 1 asks for CNN.
    Each room has multiple outputs from the 512 matrix, so the user is also asked what tie line they want to use for CNN.
    For room 1, we'll say inputs 1 - 4 on the local matrix are tied to outputs 40 - 43 of the 512 x 512 matrix.
    Once the user selects a tie line, room 1 sends a command to a virtual device.
    SEND_COMMAND vdvDEVICE, 'ROUTE=DSS 1 PORT x' (Port x equals the input of the local matrix)
    Room 1 sends a command to a virtual device on the Master Master that represents room 1.
    The Master Master uses a DATA_EVENT to parse the data rx'd on the vdvDEVICE:
    DATA_EVENT[vdvDEVICE]
    {
               COMMAND:
               {
                      STACK_VAR INTEGER nRoom
                      STACK_VAR INTEGER nIndex, nIndex2, nRoomIN, nRoomOUT
                      STACK_VAR INTEGER nIn, nOut
                      STACK_VAR INTEGER nRoomIndex
                      nRoom = GET_LAST(vdvDEVICE)
                      SELECT
                      {
                             ACTIVE(FIND_STRING(DATA.TEXT,"'ROUTE='",1)):
                             {
                                      REMOVE_STRING(DATA.TEXT,"'ROUTE='",1)
                                      SELECT
                                      {
                                                 ACTIVE(LEFT_STRING(DATA.TEXT,3) = 'DSS'):
                                                 {
                                                           REMOVE_STRING(DATA.TEXT,"'DSS'",1)
                                                           nIn = ATOI(DATA.TEXT)
                                                 } 
                                      }
                                      REMOVE_STRING(DATA.TEXT, ',' ,1)
                                      SELECT
                                      {
                                              ACTIVE(FIND_STRING(DATA.TEXT,"'PORT'",1)):
                                              {
                                                      REMOVE_STRING(DATA.TEXT,"'PORT'",1)
                                                      nINDEX2 = ATOI(DATA.TEXT)
                                                      nOUT = nRoomOutputs[nRoom][nIndex2]
                                              }
                                      }
                                      fnDoRoute(nIn,nOut,BOTH)
                             }
                      }
               }
    }
    

    Now the Master Master knows which room asked for CNN and which port they are using. The fnDoRoute builds the string to send to the 512 x 512 matrix and now, room 1 is watching CNN.

    I want to pass the feedback from the 512 x 512 matrix to the sub-master. The sub-master, via direct feedback, would then place the CNN logo on the appropriate button on the TP and that's what I am not quite sure how to do. If Room 1 has 4 outputs from the 512 x 512 matrix, I was thinking on the sub-master I need to create an array with each index representing individual tie lines. If the user wanted CNN on tie line 3, then everywhere they sent tie line 3, the CNN logo would display. How can I populate that array? Once I get the array populated, I'm good from there. I just need a push in the right direction. There are over 100 sub-masters communicating with the Master Master, so I was thinking each room's array needs to be updated only when that room makes a change vice all of the sub-masters trying to talk to the Master Master at once. Thanks.
  • viningvining Posts: 4,368
    I would use STRING_TO_VAR / VAR_TO_STRING to pass MD array and structures from one master's virtual dev to another master's virtual dev. I've never tried a MD array but I would expect it to work as it does with structures. Just use your DATA_EVENT sting/command event handler to ask for, send and receive the data you want. On one side convert your structure to a string, send the string to your requesting master and on the receiving master convert it back to a structure and away you go.

    Create a common inlcude file for the arrays or structures and pull it into every master so your arrays or structures are guaranteed idenctical across the entire system. If the file is ever changed you'll need to re-compile and update every master.
  • We have a similar issue I'm hoping to get help with. I'm pretty new at the Master to Master feature, so it's likely I've missed something simple.

    We have mostly completed a large residence with an NI-3100 master running the whole affair, several NI-2100s throughout the house, and 1 NI-900 controlling the client's young son's bedroom media system. We are using an RF remote and AxLink interface in the son's room and his entire project is running on the NI-900.

    The client has asked us for a button on his Master Bedroom MVP-5200i that will allow him (Dad) to disable the son's system to enforce "no TV time". I can think of a couple of solutions if everything were running on one master, but with the son's system on a separate master, I'm stymied.

    For the remotely located NI-2100s I simply loaded a blank file onto each so that they would be doing something and am only using them as remotely located RS232 and IR ports. The son's NI-900 is connected to the NI-3100 but the only feature we originally programmed was including this room in a single "whole house off" macro.

    I think what I need is the correct syntax for a variable that can be set from the client's bedroom that will be checked by the son's master before executing any system on macros.

    Any help is appreciated.

    Shane
  • viningvining Posts: 4,368
    Probably the simplest thing to do would be create a virtual device in the kid's master. Then depending on the type of values you want create a channel event if Boolean values will suffice or a level event if you need non Boolean values. Create an event handler, channel or level in both the kid's master and the main master. You need to define the virtual in the main master too with the kid's system number in the definition. When values change in the kid's room set a corresponding channel or level and this will trigger the event handler in the main You can then either track the channels/levels or have these events set variables in both the kid's and main master. To enable or disable, turn all off, you can just set a channel or send a level and the handler in the kid's can set your var and do what it needs to do and provide feedback to the main.
Sign In or Register to comment.