Why are Events Happening Twice??
TurnipTruck
Posts: 1,485
Greetings,
I have another strange situation. Some of my button events are occuring twice. For example:
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??
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??
0
Comments
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?
I'll try changing the button channel codes and see what happens.
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?
There are no other events in the program that reference the channel number, nor increment the variable.
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.
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.
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
Thank you.
nPostCount++
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)?
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.
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.
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:
Yeah, you should almost always isolate the feed back to the TP iniating the TO.
You're right; I should have finished my coffee before posting that ... never mind ...