Home AMX User Forum NetLinx Studio

Why are Events Happening Twice??

Greetings,

I have another strange situation. Some of my button events are occuring twice. For example:
BUTTON_EVENT [dAV,31] //LESS DELAY
{
PUSH:
    {
    IF (nAV_ON_DELAYS[nAV_ON_DELAY_SELECTED]>0)
	{
	nAV_ON_DELAYS[nAV_ON_DELAY_SELECTED]=(nAV_ON_DELAYS[nAV_ON_DELAY_SELECTED]-1)
	SEND_COMMAND dAV,"'@TXT',33,ITOA(nAV_ON_DELAYS[nAV_ON_DELAY_SELECTED]),' Tenths'"
	}
    }
}

Only one push and release show up in notifications, but the variable gets incremented twice. Some other events were doing the same thing, but they mysteriously stopped.

Any ideas??

Comments

  • viningvining Posts: 4,368
    You'll most likely have to put a break on the button event, run debug and step through it. It's possible in some remote corner of the code that same variable is being affected.

    I had a similar situation a few weeks ago where on a certain group of buttons values got incremented or deremented twice and in debug it would actually step through the button event twice off a single button push. That shouldn't even be possible. The affected button were numbers 1 - 25 so I changed them to 40 - 65 and the problem went away. I still don't know why but I was adding to an AMX module which as far as I know only used TP buttons starting in the 150's which is why I added my button starting at one. But who knows what they did inside the module, using a do_push to set channels? I don't know and most likely never will.

    Is this strictly your own code? Or are you modifying an existing AMX module like I was doing?
  • TurnipTruckTurnipTruck Posts: 1,485
    Strictly my own code, nothing to do with any module. This is absolutely the only reference to the button and to anything that has the ability to increment the variable.

    I'll try changing the button channel codes and see what happens.
  • Greetings,

    I have another strange situation. Some of my button events are occuring twice. For example:
    BUTTON_EVENT [dAV,31] //LESS DELAY
    {
    PUSH:
        {
        IF (nAV_ON_DELAYS[nAV_ON_DELAY_SELECTED]>0)
    	{
    	nAV_ON_DELAYS[nAV_ON_DELAY_SELECTED]=(nAV_ON_DELAYS[nAV_ON_DELAY_SELECTED]-1)
    	SEND_COMMAND dAV,"'@TXT',33,ITOA(nAV_ON_DELAYS[nAV_ON_DELAY_SELECTED]),' Tenths'"
    	}
        }
    }
    

    Only one push and release show up in notifications, but the variable gets incremented twice. Some other events were doing the same thing, but they mysteriously stopped.

    Any ideas??
    We never had such a problem before....
    This only could happen if the same event is somehow twice in the code.
    Maybe a copy-and-paste mistake, or some kind of condition which is executing the [dAV,31] twice.
    Is the TXT command also sent twice?
  • TurnipTruckTurnipTruck Posts: 1,485
    Yes, the variable text is being sent twice. The first time with the variable incremented by one, the second time with the variable incremented by two.

    There are no other events in the program that reference the channel number, nor increment the variable.
  • travtrav Posts: 188
    If you don't find it can you attach the axs file ?
  • mpullinmpullin Posts: 949
    Yes, post the axs file to give us the best chance of solving the problem. Could also be something funky with the Touchpanel Design file, maybe two buttons in the same place and one has pass-through?

    Also, here's something for you to try: make another button that does DO_PUSH(dAV,31) and push that one instead of the button in question, see what happens.

    Also, try moving the code to the RELEASE event and not the PUSH and see if problem still persists.
  • TurnipTruckTurnipTruck Posts: 1,485
    No far, no luck. On the same system, I am having another similar problem:
    BUTTON_EVENT [dHOUSE_SOUND,11] //VOLUME DOWN
    {
    PUSH:
        {
        LOCAL_VAR INTEGER nTP
        nTP=GET_LAST(dHOUSE_SOUND)
        IF (sDX810_OUTS[nZONE_SELECTED[nTP]].VOLUME>0)
    	{
    	TO [dHOUSE_SOUND[nTP],11]
    	sDX810_OUTS[nZONE_SELECTED[nTP]].VOLUME=(sDX810_OUTS[nZONE_SELECTED[nTP]].VOLUME-1)
    	}
        }
    HOLD [2,REPEAT]:
        {
        LOCAL_VAR INTEGER nTP
        nTP=GET_LAST(dHOUSE_SOUND)
        IF (sDX810_OUTS[nZONE_SELECTED[nTP]].VOLUME>0)
    	{
    	sDX810_OUTS[nZONE_SELECTED[nTP]].VOLUME=(sDX810_OUTS[nZONE_SELECTED[nTP]].VOLUME-1)
    	}
        }
    }
    
    Touching the button on the UI increments the variable once. Keeping your finger on the button for the hold, increments the value twice for each hold repeat.
  • travtrav Posts: 188
    Decrements.. but yeah I get what you mean... So instead of decrementing by one the event is being fired twice as per your original problem :/ seems odd.. much like a level event for a panel being generated internallly in the Ni when the panel is rebooted :/ (pet peeve excuse me) Any chance of getting the entire axs file so I can try it locally here ?

    It appears the dHouseSound is just another port on your dvTP but without the rest of the code to look at it makes it hard to pin down the error. Those events look fine (although I didn't realise that LOCAL_VAR's scope was limited to the section of the event they are in rather than the entire event) and without the entire axs file it is hard to do anything apart from point out the obvious things to try which I'm sure you have already done :)
  • TurnipTruckTurnipTruck Posts: 1,485
    I will get the code posted soon. It is part of a much larger program, so I will pull out only what is related.

    Thank you.
  • travtrav Posts: 188
    roger that

    nPostCount++
  • viningvining Posts: 4,368
    But are you stepping through the button_event twice on a single push. What's your button's feed back type? If it's channel type how are you handling the feedback in the code. Pulse, TO, or equal to a variable or something?
  • TurnipTruckTurnipTruck Posts: 1,485
    I swapped out the master, nother NXC-ME running the same firmware and the problem went away. Putting back the original master, even after some un-related code revisions brings the problem back.
  • viningvining Posts: 4,368
    Well that's good. So if you do a clean disk you'll most likely be fine once you reload everything.
  • DHawthorneDHawthorne Posts: 4,584
    In your second example, you have a bit of recursive code. The PUSH event calls a a TO to the same channel that triggered the event in the first place, causing another PUSH on that channel. I'm a little surprised it doesn't crash and burn.

    The first one looks fine to me though. Is there any chance there is a module in the project working on the same event space (same port and channels)?
  • TurnipTruckTurnipTruck Posts: 1,485
    DHawthorne wrote:
    The PUSH event calls a a TO to the same channel that triggered the event in the first place, causing another PUSH on that channel. I'm a little surprised it doesn't crash and burn.

    The TO statement generates the feedback for the button press. This is a method I have been using for a long time and have seen others use. I was unaware that it could cause any conflict.

    It has always been my understanding that the BUTTON_EVENT....PUSH referred to the "input" side of the channel. Whereas the TO is referring to the "output" side of the channel for the button feedback. At least that what I was taught years ago in Axcess classes.
  • mpullinmpullin Posts: 949
    BUTTON_EVENT [dHOUSE_SOUND,11] //VOLUME DOWN
    {
    PUSH:
        {
        LOCAL_VAR INTEGER nTP
        nTP=GET_LAST(dHOUSE_SOUND)
        IF (sDX810_OUTS[nZONE_SELECTED[nTP]].VOLUME>0)
    	{
    	TO [dHOUSE_SOUND[nTP],11]
    -snip-
    

    Try replacing TO[dHOUSE_SOUND[nTP],11] with TO[BUTTON.INPUT.CHANNEL,BUTTON.INPUT.DEVICE]. I believe TO[BUTTON.INPUT] also works for some reason. BUTTON.INPUT automatically refers to the current event, so why not take advantage of it?
  • TurnipTruckTurnipTruck Posts: 1,485
    mpullin wrote:
    Try replacing TO[dHOUSE_SOUND[nTP],11] with TO[BUTTON.INPUT.CHANNEL,BUTTON.INPUT.DEVICE]. I believe TO[BUTTON.INPUT] also works for some reason. BUTTON.INPUT automatically refers to the current event, so why not take advantage of it?

    Poin taken about using the bult-in handlers. However, my method is working and hasn't caused any problems in the past. My double-push problem that started this thread seems to have been solved by swapping the master.
  • viningvining Posts: 4,368
    The only problem I've had with TOing a button (I think) is when I've had the feedback on the same button also tied to an ON [dev,Button] event for the same push. They don't work together cuz on the push you TO the button and the push event does the ON [dev,Button] event but on releasing the button (releasing the TO) you basically do a OFF [dev,Button] event.

    Otherwise I've been using TOs for everything that isn't control by a variable's state. Occasionaly I'll use the momentary setting in TD4.

    mpullin wrote:
    Try replacing TO[dHOUSE_SOUND[nTP],11] with TO[BUTTON.INPUT.CHANNEL,BUTTON.INPUT.DEVICE]. I believe TO[BUTTON.INPUT] also works for some reason. BUTTON.INPUT automatically refers to the current event, so why not take advantage of it?

    Yeah, you should almost always isolate the feed back to the TP iniating the TO.
  • DHawthorneDHawthorne Posts: 4,584
    The TO statement generates the feedback for the button press. This is a method I have been using for a long time and have seen others use. I was unaware that it could cause any conflict.

    It has always been my understanding that the BUTTON_EVENT....PUSH referred to the "input" side of the channel. Whereas the TO is referring to the "output" side of the channel for the button feedback. At least that what I was taught years ago in Axcess classes.

    You're right; I should have finished my coffee before posting that ... never mind ... :)
Sign In or Register to comment.