Home AMX User Forum NetLinx Studio

Weird Behav on Recursive DO_PUSH with PLK-DMS

Weird thing going on...in a button_event, I try to do a redirect with do_push. So if someone pushes channel 15, I want that to be as if they pushed channel 32. (It's to enable high-level shortcuts of an otherwise nested menu item. Big system, 50+ DMS with big menu tree...)

In reality, when someone pushes 15, it shows up in the Notifications tab of Studio as a push on the virtual KP (say 34121, as defined in the code). But the ensuing do_push shows up in Notifications as an entirely different virtual device (say 36893). The new virtual
device (36893) is not defined in code, but does appear in device tree inside studio.

Simplified code is below. A couple of questions:

1. Am I breaking a rule by recursing a do_push on the PLK-DMS?
2. Where/why did this undefined virtual device 36893 come from? Some other module? All the code I mention here is in the master source file.
BUTTON_EVENT[avKP, 0] {
    PUSH: {
	integer iKP
	integer iButton
	dev	vdvKP

	iKP = get_last(avKP);
	iButton = button.input.channel;
	vdvKP = button.input.device;

send_string 0, "'Button pressed kpd/btn: ', itoa(vdvKP.number), '/', itoa(iButton)";
This command shows the results you'd expect, i.e., 34121/15
Continuing...
		do_push(vdvKP, aiKPShortcutLookup[iKP][iButton - KP_CH_SHORTCUT_MIN + 1]);

The Notifications tab shows
Line 19 :: Input Status:Released [34121:1:1] - Channel 15 - 13:10:07
Line 20 :: Input Status:Released [34121:1:1] - Channel 15 - 13:10:07
Line 21 :: Input Status:Released [36893:1:1] - Channel 32 - 13:10:08
Line 22 :: Input Status:Released [36893:1:1] - Channel 32 - 13:10:08

Bizarre to me - I'd expect all 4 lines to be on device 34121.

Anyone got ideas?

-Bill

Comments

  • I'm puzzled too, but here are a couple of observations:

    If you want to do_push avTP, why are you copying button.input.device into a local variable vdvTP and then pushing that? It is evidently acquiring the wrong value somehow, so a workaround would be to do_push avTP.

    Is the do_push code within the button_event - if not it won't see the local variable vdvTP, maybe it's seeing something else. Unlikely I agree.

    I wonder what button.sourcedev contains.
  • youstrayoustra Posts: 135
    avKP is an array, so we only want to do_push on the specific keypad that triggered the event. The vdvKP variable shows up as the correct device in the send_string statement. To answer your question, the do_push is within the event.

    I did try a sendstring on sourcedev.number and it showed up as device 0.
  • alexanboalexanbo Posts: 282
    I think it's to do with how the modules for plk-dms keypads work. They create virtual devices and do some generally weird things to make them work with Netlinx.

    Instead of using the button.device.input you'd be better off using a reference to the avKP array that you got using get_last.

    So

    do_push(avKP[iKP], blah blah blah)

    would probably do the trick
  • youstrayoustra Posts: 135
    Thanks - I tried your suggestion (do_push on avKP[iKP] and got the same bizarre result.

    At this point, I suppose I should just assume that this ain't do-able ...unless anyone can confirm that it's worked for them.
    -Bill
  • Spire_JeffSpire_Jeff Posts: 1,917
    I'm not sure if this will fix your problem, but I found that using DO_PUSH_TIMED(DEVICE,BUTTON,1) worked and DO_PUSH did not.

    The other thing I just thought of, you could just put the code you want to execute in place of the DO_PUSH. If you are worried about maintaining the code in multiple places, you could always create a CALL or a FUNCTION to consolidate the code.

    Hope this helps,

    Jeff
  • youstrayoustra Posts: 135
    Thanks for the idea, Jeff. I didn't work though - got the same result with do_push_timed.

    This is kind of a big system, so I don't want to re-create the code...I'll just have to go back and encapsulate it better elsewhere so I can make simple single-line calls.

    Sometimes this stuff feels like shareware...
Sign In or Register to comment.