Home AMX User Forum NetLinx Studio
Options

Dumb Q: diff btwn Button.Input.Device & Button.SourceDev?

Inside an event handler, what's the diff btwn the .input.device and .sourceDev?

Thx in advance,
Bill

Comments

  • Options
    DHawthorneDHawthorne Posts: 4,584
    .sourceDev is not a member of the DEVCHAN structure. Where did you get that from? I suspect it's a custom structure you are using; it's not part of the NetLInx library.
  • Options
    youstrayoustra Posts: 135
    It's on page 63 of netlinx programming manual, also in the NL keywords help file.
  • Options
    DHawthorne wrote:
    .sourceDev is not a member of the DEVCHAN structure. Where did you get that from? I suspect it's a custom structure you are using; it's not part of the NetLInx library.
    Where in the question do you see a reference to a DEVCHAN structure?

    Also: page 63 of the manual does not really answer the question, so...... Good Question :D
  • Options
    Button.SourceDev is the originator DEV of the Button Event. 99% of the time it is the same as Button.Input.Device. But it does not have to be the same. For instance, when NetLinx Studio (we'll say Studio is at 32001:1:1) using Diagnostics emulates a panel (and we'll say the panel is at 128:1:1), and Studio sends a push, the Button.SourceDev would be 32001:1:1 and the Button.Input.Device would be 128:1:1.
  • Options
    Button.SourceDev is the originator DEV of the Button Event. 99% of the time it is the same as Button.Input.Device. But it does not have to be the same. For instance, when NetLinx Studio (we'll say Studio is at 32001:1:1) using Diagnostics emulates a panel (and we'll say the panel is at 128:1:1), and Studio sends a push, the Button.SourceDev would be 32001:1:1 and the Button.Input.Device would be 128:1:1.
    Is this the case with combined devices as well? (in that : button.input.device references the virtual device and button.sourcedev references the actual source device?)
  • Options
    Is this the case with combined devices as well? (in that : button.input.device references the virtual device and button.sourcedev references the actual source device?)

    There is a difference...but not as you stated.

    In a combined situation, the master is really intercepting the input from the real device, and creating a push from the virtual device. So in an event for a combined device, the button.input.device contains the DEV for the virtual used in the combine, and the button.sourceDev contains 0:1:x since the master was the originator of the processed message (even though the real device started the chain of events, the originator of the message used in the event was the master)

    There could be a philosophical argument made as to whether what you describe would be proper behavior, or whether what is implemented is proper behavior. That being said...I do not think it would be changed because it is possible the change could break some systems already deployed.
  • Options
    DHawthorneDHawthorne Posts: 4,584
    Where in the question do you see a reference to a DEVCHAN structure?

    Also: page 63 of the manual does not really answer the question, so...... Good Question :D
    It was an assumption, since that is how BUTTON.INPUT.CHANNEL is generally used. I guess I just phrased my question badly, I was wondering where sourceDev came from, since I had never seen it before.
  • Options
    Joe HebertJoe Hebert Posts: 2,159
    Button.SourceDev is the originator DEV of the Button Event. 99% of the time it is the same as Button.Input.Device. But it does not have to be the same. For instance, when NetLinx Studio (we'll say Studio is at 32001:1:1) using Diagnostics emulates a panel (and we'll say the panel is at 128:1:1), and Studio sends a push, the Button.SourceDev would be 32001:1:1 and the Button.Input.Device would be 128:1:1.
    Consider the following code:
    DEFINE_DEVICE
    dvTP = 10001:1:1
    
    DEFINE_EVENT
    BUTTON_EVENT[dvTP,1] {
    
       PUSH: {
          
          IF(BUTTON.INPUT.DEVICE = BUTTON.SOURCEDEV) {
    	 //do something here
          }
       }
    }
    
    Let?s say we?re working in a secure environment and we don?t want any outside sources (Emulate a Device, Control a Device, Telnet, etc) to be able to execute code at any time. Would the ?do something here? only get executed if and only if someone literally pushed button 1 on the physical device 10001? Just curious.

    Thanks.
  • Options
    cwpartridgecwpartridge Posts: 120
    Joe Hebert wrote:
    Consider the following code:
    DEFINE_DEVICE
    dvTP = 10001:1:1
    
    DEFINE_EVENT
    BUTTON_EVENT[dvTP,1] {
    
       PUSH: {
          
          IF(BUTTON.INPUT.DEVICE = BUTTON.SOURCEDEV) {
    	 //do something here
          }
       }
    }
    
    Let?s say we?re working in a secure environment and we don?t want any outside sources (Emulate a Device, Control a Device, Telnet, etc) to be able to execute code at any time. Would the ?do something here? only get executed if and only if someone literally pushed button 1 on the physical device 10001? Just curious.

    Thanks.

    "Upon further review...the call on the field is reversed."

    It appears sourceDev is almost exclusively populated with the master's DEV. I'll have to dig further to see when it is not and is instead populated with the actual source DEV. Sorry for the misinformation. I was working from memory and did not validate before I submitted my original response. My apologies. I'll post when I have more info.
Sign In or Register to comment.