Home AMX User Forum AMXForums Archive Threads AMX Applications and Solutions

Can a call call a call?

Quick question: Should I be able to call a call from a call, in Netlinx? I have a problem program which uses logic to first make a call to a DEFINE CALL, which then in turn may call a separate DEFINE CALL. This doesn't seem to work in practice. Is it the case that this just doesn't work? Or are there some rules which must be followed? It compiles just fine, but any call after the first does not seem to be getting run.

Thanks for any and all input on this subject.

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    Tryll wrote:
    Quick question: Should I be able to call a call from a call, in Netlinx?
    Quick answer ? yes you can.

    If you can post the code that you're having issues with, perhaps someone can help.

    Do you know why the crow landed on top of the telephone line? -- He wanted to make a long distance caw.
  • ImpaqtImpaqt Posts: 155
    I think Iran into this before.. If memory serves I had to place the call I was calling from within the call ABOVE the first call in the code...
    Define_Call 'TH_WATCH_VCR'
    {   Call 'TH_ON'
        SEND_STRING dvHTS, "'AU1Z'"
        SEND_STRING dvPRJ,"'@CMP1',$0d" // Projo RGB
        PULSE [dvVCR,27]
        }    
    

    This is a code that works just fine... My TH_ON Callis at the top of the Sub-routines section, while my Source switches are lower inthe code...

    TH_ON Checks to see if the theater is in an ON State, and if not, turns it on before running the source selection call.
  • mpullinmpullin Posts: 949
    Yes, in fact I once wrote a call that called itself. This was before I found out about "XCH":
    DEFINE_CALL 'TV_FAVORITE' (INTEGER Y){
        IF (Y > 99){
    	PULSE[dv_SAT,SAT_NUM+(Y/100)]
    	if (Y % 100 < 10) wait (3) PULSE[dv_SAT,SAT_NUM]
    	wait(5) CALL 'TV_FAVORITE' (Y % 100)
        }
        ELSE IF (Y > 9){
    	PULSE[dv_SAT,SAT_NUM+(Y/10)]
    	wait(5) CALL 'TV_FAVORITE' (Y % 10)
        }
        ELSE{
    	PULSE[dv_SAT,SAT_NUM+Y]
    	wait(5) PULSE[dv_SAT,SAT_ENTER]
        }
    }
    

    I'm much more of a function person.
  • DHawthorneDHawthorne Posts: 4,584
    Yes. A call can even call itself (recursive) ... just be careful it has a proper exit point before it devours all your memory.
  • mpullinmpullin Posts: 949
    DHawthorne wrote:
    Yes. A call can even call itself (recursive) ... just be careful it has a proper exit point before it devours all your memory.

    Yes, an exit strategy is always important otherwise you get caught in a function that eats up your resources and prevents your processor for doing anything else effectively - just like real life! :-D

    BTW congrats on post 1000 Dave!
  • TryllTryll Posts: 33
    Thanks all.

    I'll probably put together an example of what I was doing, which now sounds like it wasn't the cause. Strangely, unrolling the call stack seemed to resolve the issue... obviously _something_ wasn't right that got fixed in the process.

    For the moment, I'm moving on, but I'll probably still put a sample up here so you can set me straight.
  • TryllTryll Posts: 33
    OK. Back from that to create an example for educational feedback.

    DEFINE_CONSTANT
    SOURCE_DVD = 20
    SOURCE_VCR = 21
    SOURCE_CABLE = 22
    SOURCE_SAT = 23
    SOURCE_ATC = 24

    DEFINE_CALL 'SWITCH_SOURCE' (SOURCE_SELECT)
    {

    CURRENT_SOURCE = SOURCE_SELECT

    IF (SOURCE_SELECT <> SOURCE_ATC)
    {
    IF (VPROJ_STATUS <> 'COOLING')
    {
    Call 'PROJECTOR' (POWERON)
    PULSE[LIFT_DN]
    PULSE[SCREEN_DN]
    Wait 20
    CALL 'PROJECTOR' (RGB)
    }
    }
    SWITCH(SOURCE_SELECT)
    {
    CASE SOURCE_ATC: {}
    CASE SOURCE_CABLE:
    {
    SEND_STRING EXTRONSW,'1*2&'
    WAIT 5
    SEND_STRING EXTRONSW, '1*1$'
    SEND_STRING EXTRONDVS, '2!'
    }
    CASE SOURCE_DVD:
    {
    PULSE[DVD_VCR,DVD_DVD_Mode]
    SEND_STRING EXTRONSW,'3*2&'
    WAIT 5
    SEND_STRING EXTRONSW, '2*1$'
    SEND_STRING EXTRONDVS, '2!'
    }
    CASE SOURCE_VCR:
    {
    PULSE[DVD_VCR,DVD_VCR_Mode]
    SEND_STRING EXTRONSW,'2*1&'
    WAIT 5
    SEND_STRING EXTRONSW, '2*1$'
    SEND_STRING EXTRONDVS, '1!'
    }
    CASE SOURCE_SAT:
    {
    SEND_STRING EXTRONSW,'8*1&'
    WAIT 5
    SEND_STRING EXTRONSW, '7*1$'
    SEND_STRING EXTRONDVS, '1!'
    }
    }
    }

    DEFINE_EVENT

    BUTTON_EVENT[TP,14]// audio conference
    BUTTON_EVENT[TP,15]// cable & DSS
    BUTTON_EVENT[TP,16]// Computers
    BUTTON_EVENT[TP,17]// DVD
    BUTTON_EVENT[TP,18]// VCR
    BUTTON_EVENT[TP,19]// Room
    BUTTON_EVENT[TP,20]// Power page
    BUTTON_EVENT[TP,21]// DSS Page
    {
    PUSH:
    {
    SWITCH (BUTTON.INPUT.CHANNEL)
    {
    CASE 14: {CALL 'SWITCH_SOURCE' (SOURCE_ATC)}
    CASE 15: {CALL 'SWITCH_SOURCE' (SOURCE_CABLE)}
    CASE 16: {CALL 'SWITCH_SOURCE' (SOURCE_COMP_1)}
    CASE 17: {CALL 'SWITCH_SOURCE' (SOURCE_DVD)}
    CASE 18: {CALL 'SWITCH_SOURCE' (SOURCE_VCR)}
    CASE 19: {} // Do Nothing
    CASE 20: {} // Do nothing
    CASE 21: {CALL 'SWITCH_SOURCE' (SOURCE_SAT)}
    }
    }
    }


    OK, the next part will be part two. But should the above concept function in theory?

    Thanks guys.
  • DHawthorneDHawthorne Posts: 4,584
    The concept looks sound.

    I would offer a suggestion unrelated to your original question though. You are rightly blocking the projector from turning on when it is in a cooldown state, but you are still switching sources. You should block the entire operation rather than have the rest of the system come on with no projector :). I would also recommend a popup on the panel warning the end user that they tried to turn it back on too soon. This may not matter with a relatively fast projector, but I am seeing more and more of them with cooldowns of as long as 3 minutes. For those, you have to make it very clear why nothing is happening because the consumer doesn't necessarily understand cooldowns.
  • TryllTryll Posts: 33
    Thanks Dave.

    Yes, there is actually a cooldown message being displayed at the time. Obviously, the sample doesn't include all the logic involved, but I was trying to get the overall concept of the process into it. You are right though, it DOES currently do the switching even if the projector is locked out. Cooldown is polled via 232, so no matter how long it takes, we should be set there.

    Still, the guys doing the installs seem to be running into logic issues. One thing I haven't yet figured with Netlinx... how can I "trace" messages into Netlinx studio? The install guys don't really understand debugging, so I would love to write messages into the notifications tab during a troubleshooting run. Can you tell me how I could do this?
  • You can use...

    Send_String 0,"'<whatever you want to say>'"

    This will display in the diagnostics tab. you could put almost anything in the string, including variables. (as long as it is in the 'ASCII' format).
  • DHawthorneDHawthorne Posts: 4,584
    Best way is not to use the notifications tab. Telnet into the master, and type in "msg on" when you connect. Sprinkle your code with statements like "SEND_STRING 0, 'Message here'," and everything sent to port 0 will show up in the telnet session. I generally like to have a way to turn such messages on and off as welll by setting a variable or channel and checking that before sending the string out. I often include an entire routine with a virtual device for a command interface that lets me set these debugging messages on and off, query for system status, and any number of other helpful notifications.

    Don't get me wrong - the notification tab is very useful under some circumstance. But it can be overloaded (crashing Studio or NetLinx Diagnostics), and it's difficult at time to filter exactly the messages you need. And, and you have noticed, the learning curve can be steep for a non-programmer. The telnet window overcomes quite a lot of that, and if you set the customer's router to forward the telnet port to your master, you can do it remotely.

    Oh, and the SEND_STRING 0 output will show up in notifications as well, if you have all devices turned on, or port 0 explictily set for string messages.
  • TryllTryll Posts: 33
    Thanks. This is a case where I'm 300 miles away, and certainly can't get any access to the masters involved. (Many corporate IT rules and firewalls.) The guys doing the install are pretty good... but consider *anything* have to do with code (like adding breakpoints) to be outside of their responsibility. I figure if I can just write some message to them... like: "Please tell me you saw the word PURPLE displayed." it would help me understand what is going on.

    I'll probably attach the trace statements to a variable, so that they are easy to globally turn on and off.

    Thanks again guys. Without the help of this forum, I'd probably toss in the towel on Netlinx.
Sign In or Register to comment.