Announcement

Collapse
No announcement yet.

Problem with JDS flags after hs2.0

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem with JDS flags after hs2.0

    Hey all,

    I had a reliable script for caller ID announcements that worked for years under HS1.7 . After my upgrade to HS2.0 its acting odd.

    Here's the main part of the script:


    ' if incoming call and CO on hook and not muted then:
    '
    I = 0
    '
    Do While hs.IsOn("\2") and hs.IsOff("\3") and hs.IsOff("K10")
    i = I + 1
    if I = 1 then hs.speakex dev, "Incoming phone call. ", 1
    hs.speakex dev, str_Caller + ". " + fs.value, 1
    if I = 5 then exit sub
    hs.waitsecs 2
    Loop

    "\2" is JDS Incoming call flag, and "\3" is JDS CO on-hook flag.

    The problem is that HS doesn't recognize that the phone has been picked up (off-hook = "\3" = On") and it keeps speaking the announcement. That's why I added the i=5 exit sub line.

    Once the loop has finished (via the i=5 exit) the HS log then shows the JDS flags kicking in. But they don't get recognized until after the loop is finished. I added the waitsecs line thinking that would give the CPU time to recognize the flag change, but it didn't make a difference.

    Any ideas?

    Thanks!

    #2
    A few thoughts:

    It looks like you are only announcing the call once (I=1). So why the Do Loop? I don't know the rest of your script, but won't a simple If (3 conditions true) Then (announce call) work?

    It's been a while since I scripted with Do Loops, but I vaguely recall having issues with not seeing either variable or flag changes, not sure which. I think I got around it by using Exit Do. In other words, something like:

    If x and y, then
    Do
    blah blah
    If z (go off-hook) then
    Exit Do
    End If
    d=d+1
    if d>100000 then
    d=0
    exit do
    End If
    Loop
    End If

    The d counter is an exit just in case z never changes.

    Mark
    Mark

    Comment


      #3
      Have you tried the WaitEvents function in place of the WaitSecs? I have not used WaitEvents, but the entry in the Users Guide makes it sound like it may do what you want. I'm curious to know how/if it works.
      Mike____________________________________________________________ __________________
      HS3 Pro Edition 3.0.0.548, NUC i3

      HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

      Comment


        #4
        Hmm - looking at the WaitEvents it appears that the script will stop and wait for some Homeseer thing to happen before the script continues.

        I assume this means that my loop would stop executing, while it was waiting for some such event.

        I'll give it a try - but I suspect what will happen is it will do the first announce, and then stop until some other HS activity takes place.

        I think I might also try removing from a loop, ( a variation of MarkS's suggestion above) maybe the "do while" somehow takes precedence (which doesn't make sense - since it worked under HS1.7)

        Like:

        If <conditions> speak
        waitsecs 1
        if <conditions> speak
        waitsecs 1
        if <conditions> speak
        waitsecs 1
        etc

        Not very elegant......

        Comment


          #5
          OK - this is now driving me crazy. I'm way down on WAF and have to fix this...

          I tried "waitevents", didn't help.

          I'm now using:

          if hs.IsOn("\2") and hs.IsOff("\3") and hs.IsOff("K10") then
          hs.speak str_Caller + ". " + str_Digits, True, "Master2efault"
          hs.waitsecs 1
          end if

          if hs.IsOn("\2") and hs.IsOff("\3") and hs.IsOff("K10") then
          hs.speak str_Caller + ". " + str_Digits, True, "Master2efault"
          hs.waitsecs 1
          end if

          if hs.IsOn("\2") and hs.IsOff("\3") and hs.IsOff("K10") then
          hs.speak str_Caller + ". " + str_Digits, True, "Master2efault"
          hs.waitsecs 1
          end if



          \2 & \3 are JDS flags - and they just don't update. Once HS does the announcement, the flags are changed. But HS is not aware that the flags have changed during the announcement.

          Help! Any Ideas?

          Comment


            #6
            Two questions: What initiates the script? I assume it is the incoming call ("/2"?). Also, have you tried the script both with and without the 'wait for script to finish' box checked?

            In any case, if the problem is resolved by terminating the script, perhaps you can use the DelayTrigger function to call the event again rather than looping within a script. Obviously, you'd need logic to prevent an endless loop.
            Mike____________________________________________________________ __________________
            HS3 Pro Edition 3.0.0.548, NUC i3

            HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

            Comment


              #7
              The script is called directly from Stargate via the ASCII Out command. I need to do it like that so I can pass the CID variable. (Maybe there's other ways, like loading CID into a variable and that HS would have access to ).

              You've got me thinking though, maybe I can use my script to launch separate events that do the announcement.

              Comment


                #8
                I came across to some references about multi-threading scripts in another post. This caused me to experiment with a few things that might shed light on this.

                If I call my script (.txt) directly from stargate, neither wait events or waitsecs allows HS to recognize the JDS flags being changed while the script is running.

                I changed my original script to .vb, and made a new script that I called from Stargate:

                Sub Mainl(CID)
                hs.runex phonecall.vb, "Main", CID
                End

                When I did this, it worked. So - I changed my SG code to call the .vb version directly, (via ASCII Out) and it did not work.

                So my conclusion is:

                By kicking off the .vb script from within HS, it started in a new thread and the script was able to see JDS flag changes while the script was in operation. (Because HS was free to recognize/update the flags when running separately in its own thread).

                But - the SG plug-in must not have initiated a new thread when I called the .VB script directly, since it acted just like the .txt single thread version.

                I just thought I'd share this for future people using the search within the forum.

                Comment


                  #9
                  Good detective work! This sounds like an excellent candidate for a feature request / bug fix so that the plug-in will integrate more completely with the multi-threading capability of HS2.
                  Mike____________________________________________________________ __________________
                  HS3 Pro Edition 3.0.0.548, NUC i3

                  HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

                  Comment


                    #10
                    The last thing I need to do is re-do the entire process and confirm that I see a new thread in the Windows Process Manager when HS kicks off the .vb script, and that there is not a new thread when SG kicks off the .vb script. That would be conclusive proof.

                    Comment

                    Working...
                    X