Home NetLinx Studio

Feedback and Arrays

AdaptelAdaptel Junior MemberPosts: 41
I am a ongoning self-taught AMX programmer and I have made the jump from Axcess to Netlinx a couple months ago. Got a couple questions about feedback, arrays, grouping of channels, & simplifying assignment.

1) When, if anywhere can you use the convention in NL:
(dvMYDEVICE,chMY1stCHAN)..(dvMYDEVICE,chMYlastCHAN) or
(dcMY1stDEVCHAN)..(dcMYlastDEVCHAN)
Can this be done instead of having to assign arrays of channels or devchans for every "group" of buttons, devices, or channels?

2) Can multiple feeback assignments be done without seprate declarations or loops? ie, with these declarations:

DEFINE_DEVICE
dvMSP32 = 128:1:0
dvRELAY8 = 2:1:0

DEFINE_VAR
INTEGER chRELAYS[] = {1,2,3,4,5,6,7,8} (*relays of AXC-REL8*)
INTEGER chMSPBTNS[] = {5,6,7,8,9,10,11,12} (*relay control buttons*)
Instead of doing this:
TIMELINE_EVENT[TL_UPD8FEEDBACK]
{ [dvMSP32,chRELAYS[1]] = [dvRELAY8,chMSPBTNS[1]]
[dvMSP32,chRELAYS[2]] = [dvRELAY8,chMSPBTNS[2]]
etc......
}
or this (partial):
TIMELINE_EVENT[TL_UPD8FEEDBACK]
STACK_VAR CNT
{ FOR (CNT=1 ; CNT<=8 ; CNT++)
[dvMSP32,chRELAYS[CNT]] = [dvRELAY8,chMSPBTNS[CNT]]
}
Is there any convention to assign feedback like this to update more than one feedback element at once? Are there any tricks for groups of devchans or chans?:
TIMELINE_EVENT[TL_UPD8FEEDBACK]
{ [dvMSP32,chRELAYS[]] = [dvRELAY8,chMSPBTNS[]]
}

This may be a simple question and/or terrible example, but any input would be greatly appreciated. Thanx.

Comments

  • DHawthorneDHawthorne Old Timer Posts: 4,584
    I've always gone with the FOR loop like in your example...except it seems to me you have your devices mismatched with the arrays in those examples. You couldn't have [dvRELAY8,chMSPBTNS[1]] because index 1 in chMSPBTNS would have a value of 5, and I assume you really want relay 1. I never tried doing something like your last example - but I would think that if it did work, you need to leave off the empty brackets [] in the references.

    That said (and I don't have the time this moring to load and try it out on a test system), I kind of don't think it will work anyway. An equivalence like that is fine for variables, but not devices - I don't see that it necessarily will update them properly with that kind of syntax.
  • AdaptelAdaptel Junior Member Posts: 41
    Array clarification

    I see the error in my example, just an oversight. I guess the big questions I'm getting at are can more than one feedback element be updated with a single statement (not counting running through a loop). Also, can sequential groups of channels or devchans be specified in a BUTTON_EVENT or CHANNEL_EVENT without them being grouped in an array or combine.
    Thanks again in advance for any input.
  • frthomasfrthomas Junior Member Posts: 176
    For (1), I think it is mostly useable in the DEFINE_COMBINE, LATCHING, etc. stuff. Not really with arrays.

    For (2), I don't think the third one works, even without the []. In your case the two arrays have the same size but what would be supposed to happen if they don't ?

    The NL way of doing your feedback is:

    CHANNEL_EVENT [dvMSP32, chMSPBTNS] {
    ON: ON[dvRELAY8, chRELAYS[GET_LAST(chMSPBTNS)]];
    OFF: OFF[dvRELAY8, chRELAYS[GET_LAST(chMSPBTNS)]];
    }

    That is: act only when a button state change, instead of polling for it every n ms as the timeline does. Use an array to react to a number of buttons. In the event, GET_LAST gives you the index of the array that triggered the event. Use it to index your second array.
    Depending on what you're trying to achieve, using BUTTON_EVENT might be better, don't know. And it may be you want the button feedback to reflect the relay state rather than what I did. And the syntax is probably approximate. But that's more the NL spirit...

    Hope this helps.

    Fred
Sign In or Register to comment.