Announcement

Collapse
No announcement yet.

Script help

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

    #46
    An Emergengy Alert solution

    Originally posted by stipus View Post
    Can you post the script you created and the list of errors. We'll try to work this out.
    I solved it my way.
    Made a VBScript that does the control/flow
    (WB_SipCall.txt, rename to .vbs)

    Sub Main()

    '*********************************************************** *****************
    'Script made by Wim Brouwenstijn, aka Hammy, november 2010
    '
    'This is a VBscript to be used in alarmsituation in conjunction with a VB.NET script that handles the connection and message
    'It tries to reach one or more telephonenumbers to speak an alarm message
    'It tries to reach the telephonenumber until the stop criteria and/or a specified tries
    'Script can be used in a Homeseer Event, without parms
    'A HS device is needed for the Stop value to store
    '*********************************************************** *****************



    Dim objSip
    Set objSip = hs.Plugin("SIP Connector")

    hs.SetDeviceValue "(98", 2 'Stop criteria set to 2=is calling, to be set to 3=calling stopped, in VB.NET ScriptToCall
    hs.SetDeviceString "(98", "Is Calling"

    Dim intCount
    intCount = 0

    Dim intTries
    intTries = 600 'Maximum times to try to reach a telephonenumber when it does not pickup or respond with DTFcode

    Dim intWait
    intWait = 90 'Number of seconds to wait before another try to reach a telephonenumber

    Dim arrTelephonenumber(10)
    arrTelephonenumber(0) = "1234567890" 'First telephonenumber to try to reach

    arrTelephonenumber(1) = "1234567890" 'Second telephonenumber to try to reach

    arrTelephonenumber(2) = "" 'Third telephonenumber to try to reach

    Dim intArr
    intArr = 2

    Dim intTel
    intTel = 0

    Dim strScriptToCall
    strScriptToCall = "sip_outgoing_Noodsituatie.vb"



    While hs.DeviceValue("(98") = 2 AND intCount < intTries

    intTel = 0

    While hs.DeviceValue("(98") = 2 AND intTel < intArr

    objSip.PlaceCall arrTelephonenumber(intTel), strScriptToCall

    hs.WaitSecs intWait

    intTel = intTel + 1

    wend

    intCount = intCount + 1

    Wend

    hs.SetDeviceString "(98", "Calling Stopped"
    hs.SetDeviceStatus "N13", 3 'Noodsituatie wordt uitgezet, iemand heeft op de telefoon oproep gereageerd

    'MsgBox("Stopped after times: " & intCount)

    End Sub


    and a tailord standard VB.NET Sip_script that does the Sip handling (WB_sip_outgoing_Alert.txt, rename to .vb)

    Imports HSPI_SIP

    Sub CallConnected( ByVal c as SipCall )
    c.StartInBandDTMFRecognition()
    Menu( c )
    End Sub

    Sub Menu( ByVal c as SipCall )
    c.SpeechVoice = "ScanSoft Claire_Full_22kHz"
    c.SpeakTextWait( "This is an Emergy Call! etc" )
    c.SpeakTextWait( "Tos stop calling, press 0 etc" )
    c.SetTimeout( 5 )
    End Sub

    Sub HeardDTMF( ByVal c as SipCall )
    Dim code as String = c.DtmfCode
    Dim dtmf as String = c.DtmfString

    If code = "0" Then
    hs.SetDeviceValue ("(98", 3)
    c.StopSpeaking()
    c.SpeakTextWait( "You pressed 0, calling will be stopped!" )
    c.Hangup()
    End if
    End Sub

    Sub Timeout( ByVal c as SipCall )
    Dim count as Integer = c.TimeoutCount
    If count > 3 Then
    c.SpeakTextWait( "End of Message!" )
    c.Hangup()
    Else
    Menu( c )
    End If
    End Sub

    Sub TransferFailed( ByVal c as SipCall )
    c.SpeakTextWait( "Sorry, there is a technical problem" )
    c.Hangup()
    End Sub

    Sub CallHungup( ByVal c as SipCall )

    End Sub

    If someone could make the first script in VB.NET, I'll be obliged.
    I could use that to start learning VB.NET

    Good Luck,
    Hammy
    Attached Files
    Last edited by Hammy; November 7, 2010, 11:21 AM. Reason: neater script

    Comment

    Working...
    X