Home AMX User Forum NetLinx Studio

Problem in getting Data events

Hi forum members,
We are facing a problem in getting data events. I am enclosing the code underneath. For the time being we are trying that a when a button is pressed in Macro button page a string gets displayed. We are looking forward to display status of fire alarm system on the interface connected on RS-232.

DEFINE_VARIABLE
TP1Buffer[1024]

DEFINE_START
CREATE_BUFFER dvTP1, TP1Buffer

DEFINE_EVENT

BUTTON_EVENT[dvTP1_FEATURE_MacroButtons1, 261]
{
PUSH:
{
SEND_STRING dvTP1, "'It is a test'"
//SEND_COMMAND vdvLIGHTSYSTEM1, 'LIGHTSYSTEMSTATE-16:4,OFF'
}
}

DATA_EVENT[dvTP1]
{
STRING:
{
TP1Buffer = DATA.TEXT
SEND_STRING 0, "'String send was =', Data.TEXT"
}
}

Best Regards

Comments

  • regallionregallion Posts: 95
    I think your problem is here:

    TP1Buffer = DATA.TEXT

    CREATE_BUFFER will automatically fill TP1Buffer with incoming data. I'm not sure what will be in data.text but you're overwriting TP1Buffer I think!

    CREATE_BUFFER is typically used if you're expecting large amounts of data. Either remove the line TP1Buffer = DATA.TEXT or remove CREATE_BUFFER dvTP1, TP1Buffer.
  • rizwanrizwan Posts: 4
    The issue is that the data event does not get triggered at all.
  • DHawthorneDHawthorne Posts: 4,584
    Your data event is set to react to a string coming from the panel. This will be stuff like internal page tracking, contents of text fields, etc. In your macro button, you are sending a string to the panel, which it is happily ignoring. There is no mechanism in the panel to take a string it has received from code and send it out again as a string in a data event.

    You would be better off abstracting the process with a virtual device. Use your macro to send a command to the virtual, and use the COMMAND handler to do whatever parsing might be necessary to display it.
  • rizwan wrote: »
    The issue is that the data event does not get triggered at all.
    EDIT: Had some text basically saying the same thing as DHawthorne.

    However, I'm guessing that the text that you are sending to the touchpanel doesn't show up on the touchpanel either. This is because you have to send the text to a button using the ^TXT command. Instead of a send_string dvTP1, you'll want to use a send_command dvTP1, '^TXT-a,b,It is a test', where a is the address of the button you want to send the text too and b is the state you want to send it to, with 0 being all states.

    Hope that helps.
  • champchamp Posts: 261
    As previously mentioned you cannot catch commands sent to a physical device but you can catch commands sent to a virtual device. Here is how to code it:
    DEFINE_DEVICE
    
    dvTP1 = 33001:1:0	// virtual touch panel  (note name not changed to avoid changing anywhere else in the program).
    dvTP1_Real = 10001:1:0	// the actual touch panel
    DEFINE_COMBINE(dvTP1, dvTP1_Real)	// all events from the real touch panel will be presented at the virtual device so all code referring to dvTP1 will still work.
    
    DEFINE_CONSTANT
    INTEGER nAdrTextField = 1
    
    DEFINE_EVENT
    DATA_EVENT[dvTP1]
    {
    	COMMAND: SEND_STRING 0, "'dvTP1 Command sent was =', DATA.TEXT"
    }
    
    BUTTON_EVENT[dvTP1_FEATURE_MacroButtons1, 261]
    {
    	PUSH:
    	{
    		SEND_COMMAND dvTP1, "'^TXT-', ITOA(nAdrTextField),',0,It is a test'"
    		//SEND_COMMAND vdvLIGHTSYSTEM1, 'LIGHTSYSTEMSTATE-16:4,OFF'
    	}
    }
    

    You are also able to see any commands sent to a physical device in Netlinx Notifications so this code is not actually necessary if all you want it for is debugging.

    I have used this type of code in the past to catch events sent from within AMX modules to a touchpanel, for instance the easiest way to see current RMS meeting info is to catch the text events sent to the touchpanel.
  • rizwanrizwan Posts: 4
    Thanks a lot for your prompt replies. But the problem still persists.

    The additions that I have made are that I have changes the type of button with channel number 262 to a test INPUT. and defines ButtonAddress = 11 as the address field shows 11 in TPDesign.
    Then a DEFINE_COMBINE (vdvTP1, dvTP1) was defined.
    and the two functions for 261 macro button and the data event for vdvTP1 are added below. Still no success. If I debug the cursor comes to the SEND_COMMAND line but on running forward it does not triggers the dat even for vdvTP1. There is no indication in the notification area even.

    DEFINE_CONSTANT
    INTEGER ButtonAddress = 11

    DEFINE_EVENT
    BUTTON_EVENT[dvTP1_FEATURE_MacroButtons1, 261]
    {
    PUSH:
    {
    SEND_COMMAND vdvTP1, "'^TXT-',ITOA(ButtonAddress),',0,It is a test'"
    }
    }

    DATA_EVENT[vdvTP1]
    {
    COMMAND:
    {
    SEND_STRING 0, "'vdvTP1 sent command was : ', DATA.TEXT"
    }
    }

    Besst Regards,
  • viningvining Posts: 4,368
    If this thread is related to your other thread and you're using a DUET module as specified in the other thread you'll need to enable "PASSBACK" or the DUET module will block anything from triggering a data_event outside of the DUET module.
  • HedbergHedberg Posts: 671
    rizwan wrote: »
    Thanks a lot for your prompt replies. But the problem still persists.

    The additions that I have made are that I have changes the type of button with channel number 262 to a test INPUT. and defines ButtonAddress = 11 as the address field shows 11 in TPDesign.
    Then a DEFINE_COMBINE (vdvTP1, dvTP1) was defined.
    and the two functions for 261 macro button and the data event for vdvTP1 are added below. Still no success. If I debug the cursor comes to the SEND_COMMAND line but on running forward it does not triggers the dat even for vdvTP1. There is no indication in the notification area even.

    DEFINE_CONSTANT
    INTEGER ButtonAddress = 11

    DEFINE_EVENT
    BUTTON_EVENT[dvTP1_FEATURE_MacroButtons1, 261]
    {
    PUSH:
    {
    SEND_COMMAND vdvTP1, "'^TXT-',ITOA(ButtonAddress),',0,It is a test'"
    }
    }

    DATA_EVENT[vdvTP1]
    {
    COMMAND:
    {
    SEND_STRING 0, "'vdvTP1 sent command was : ', DATA.TEXT"
    }
    }

    Besst Regards,


    I think that you are still making the same basic mistake that David Hawthorne explained. You are expecting something sent TO a touch panel to trigger a data_event for that touch panel. You can't do that, as far as I know. The data_event[dvTP] will respond to stuff created by the touch panel. If the touch panel reports a page flip (when you turn on page tracking), the touch panel data_event is where you will track it. If the touch panel sends a string to the processor, you can see it in the data_event. Touch panels coming on line: you'll see it in the online: handler in the data_event. But, strings and commands sent to the touch panel will not echo back to the processor and trigger a handler in the data_event.
Sign In or Register to comment.