Announcement

Collapse
No announcement yet.

Compiling script C:\PROGRAM FILES (X86)\HOMESEER HS3\scripts

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Compiling script C:\PROGRAM FILES (X86)\HOMESEER HS3\scripts

    Moved from HS3 Linux to HS3 windows. After that I will move to HS4 windows. Doing the upgrade in steps for minimal loss of service. So far so good. Looks like everything is back except some custom scripts I had in the Linux box no longer work in the windows environment. Here is the script. I stole from the forms it years back when I first started with HS and modified it slightly for my needs. It is a simple countdown script for my gate hold open timer.

    Sub Main(ByVal pram as Object)
    Dim StartVar as string ' Set this to the countdown starting value
    Dim pram as string
    Dim test as string
    'test = hs.CAPIGetStatus(18).Value
    'hs.writelog("Value", + test)
    pram = hs.CAPIGetStatus(18).Value

    If pram = 300 then
    pram = 3600

    End if

    If pram = 400 then
    pram = 7200
    End if

    If pram = 500 then
    pram = 10800
    End if

    IF pram = 600 then
    pram = 180
    End if

    'IF pram = 600 then
    'pram = 2
    'End if

    StartVar = pram
    Dim x as Integer
    'hs.writelog("StartTime", + StartVar)
    'hs.writelog("pram ", + pram )
    x = Convert.ToInt32(hs.TimerValue("GATE HOLD").TotalSeconds)
    'hs.writelog("X", + x)
    'hs.SetDeviceValueByRef(16, StartVar - x, True)
    'hs.SetDeviceString(16, StartVar - x & " seconds", True)
    'hs.writelog("Utility Countdown","Updating")

    Dim hms as TimeSpan = TimeSpan.FromSeconds(StartVar - x)
    Dim h = hms.Hours.ToString
    Dim m = hms.Minutes.ToString
    Dim s = hms.Seconds.ToString
    hs.SetDeviceString(197, h & ":" & m & ":" & s, True)
    'hs.SetDeviceString(16, m & " min " & s & " sec", True)
    hs.SetDeviceValueByRef(197, StartVar - x, True)
    'hs.SetDeviceString(18, h & ":" & m & ":" & s, True)
    ' hs.SetDeviceValueByRef(18, StartVar - x, True)

    If x >= StartVar then
    hs.WaitSecs(1)
    hs.SetDeviceValueByRef(197, StartVar, True)
    'hs.SetDeviceString(16, StartVar & " seconds", True)
    hs.SetDeviceValueByRef(18, 0, True) 'Set to Close
    hs.SetDeviceString(197, 0, True)
    'hs.SetDeviceString(18, 0, True)
    'hs.SetDeviceString(18, "", True) ' Fix for Bad Device String

    hs.CAPIControlHandler(hs.CAPIGetSingleControl(97, true, "Off", false, true))
    hs.WaitSecs(2)
    hs.CAPIControlHandler(hs.CAPIGetSingleControl(97, true, "Off", false, true))

    End If
    End Sub



    Andy



    #2
    How are you calling the script? Do you see anything in the logs?

    Comment


      #3
      Through and event action. That is what I see in the event log... The Compile script error.

      Comment


        #4
        Try removing (comment out) the third line "Dim pram as string", OR change the "pram" parameter name in the first line to something else.

        Declaring "pram" twice will cause an error.

        Comment


          #5
          Take a look at tenholde's tenscripting for HS4. The error is flagged in the VS environment. I suspect the Mono compiler for Linux is more forgiving.
          "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

          Comment


            #6
            http://tenholder.net/tenWare2/tenScripting/default.aspx
            tenholde

            Comment


              #7
              That worked removed line 3 and no issues.

              Thanks much for the help.

              Comment

              Working...
              X