Page 2 of 2

Re: Housebot crashes randomly

Posted: Tue Mar 23, 2010 12:05 pm
by raptor_demon
Hi,

I have disabled all JS scripts and everything seems stable.

I am going to keep them disabled for another week or so and see what happens.

Raptor

Re: Housebot crashes randomly

Posted: Tue Mar 23, 2010 12:41 pm
by Steve Horn
Then try adding them back in one at a time.

Re: Housebot crashes randomly

Posted: Sat Mar 27, 2010 9:24 pm
by ScottBot
The dump file definitely pointed to the scripts. As you add them back and find the problem script, post as much of the script details as you can. There's probably one line in the script that is doing something that is throwing the server into a problem state.

Re: Housebot crashes randomly

Posted: Wed Mar 31, 2010 9:13 pm
by raptor_demon
Ok,

no crashes since my last post, so i have enabled one script:


I did not write the script, it was written By Osler and some other of the great guys from this forum :D .

Code: Select all

Option Explicit
On Error Resume Next

'MsgBox "Script is starting."

Dim URL
Dim File
Dim xmlHTTP
Dim ADOStream
Dim Date1
Dim WshShell

Date1 = Day(Date)&"-"&Month(Date)&"-"&Year(Date)&"-"&hour(now)&"h"&minute(now)&"m"&second(now)
URL = "http://192.168.2.160/image.jpg"
File = "D:\shares\Photos\Security Cam2\Security-"&Date1&".jpg"

'Set WshShell = WScript.CreateObject("WScript.Shell")
Set xmlHTTP = CreateObject("MSXML2.XMLHTTP")

If Err.Number <> 0 Then
   'MsgBox "There was a problem creating the objects. Error code: " & Err.Number
End If

'MsgBox "Objects created."
Call xmlHTTP.open ("GET", URL, False)
xmlHTTP.send()


If Err.Number <> 0 Then
   'MsgBox "There was a problem sending the HTTP request. Error code: " & Err.Number
End If

'WScript.Sleep 500
Sleep 500
If xmlHTTP.status = 200 Then

   'MsgBox "Camera server reached successfully."

   Set ADOStream = CreateObject("ADODB.Stream")

  'MsgBox "ADOStream object created."

   With ADOStream
         .Type = 1
         .Open()
         .Write(xmlHTTP.responseBody)
         .SaveToFile File, 2
         .Close()
   End With

 ' MsgBox "Image saved."

   Set ADOStream = Nothing
Else
   'MsgBox "Camera server returned " & xmlHTTP.status & ". Unable to connect."
End If
Set xmlHTTP = Nothing
'Set WshShell = Nothing
which is triggered by the attached task.(sorry bout the black boxes my screen grab soft hates RDP).
screengrab1.jpg
screengrab1.jpg (49.36 KiB) Viewed 9249 times
the other script has been removed for the current test.

All of my scripts are varients of the one posted above.

Pls let me know if you find any issues in the code.

EDIT* while posting this message HB crashed, so i guess this script crashes it...

Thanks

Raptor

Re: Housebot crashes randomly

Posted: Wed Mar 31, 2010 10:47 pm
by roussell
Have you tried removing one of the "Run Script" lines from the task? I'm assuming that the two lines are essentially the same file with file/path names changed to represent the specified camera. I'm wondering if the two scripts are running in the same thread and trying to share memory/variables/etc. If that's the case, you can either combine all of the cameras into one script or make script devices for each instance and then in your task set each script device to "Running" to grab the images. That way each script will run in a separate thread and should eliminate any funky problems.

Terry

Re: Housebot crashes randomly

Posted: Thu Apr 01, 2010 4:53 am
by Richard Naninck
I am with Roussel on this. Try to comment out one of the two Run Script lines and see what happens.

Ultimately you would want to rewrite the script so that it is simply always running and have the task just trigger an event so that the script starts doing what it should. That way you can deconflict timing much better.
First the one step and then it should be easy to do a rewrite (maybe with a little help if you need it)

Re: Housebot crashes randomly

Posted: Thu Apr 01, 2010 9:58 am
by raptor_demon
Hi,

The test was with only one script active. I deleted the other one to prevent issues.

I am testing a work around by using webcamxp to take my snapshots and post them to a HB dir for display on the SWremote.

Then i will call this script for doorbell and motion events only to prevent it running every XX seconds.

I am not able to write any VBscript at this time, just don;t know how todo it. :(

Thanks

raptor

Re: Housebot crashes randomly

Posted: Fri Apr 23, 2010 8:46 am
by raptor_demon
Ok HB crashed again last night only 4 hrs after putting in a new script :(

To recap there were no scripts running except this one which was triggered once an hour.

The code is an exact copy of Richard's logging script with 4 lines i added at the top.

What am i doing wrong with my coding that it works for a few hours then fails?

Raptor

Code: Select all


Option Explicit
Dim CurTemp
CurTemp= GetPropertyValue("Thermostat 1.Current Temperature")
Call WriteLog("On", CurTemp)





'-------------------------------------------------------
'- Write Log Line --------------------------------------
'-------------------------------------------------------
Sub WriteLog(strLogFlag, strLogLine)
Dim FileSystem
Dim StdOut
Dim FileName
Dim AlarmLog
Dim LogLines
Dim LogCount
Dim nit

   On Error Resume Next
   If strLogFlag = "On" Then

      AlarmLog = GetPropertyValue("Alarm Status.Log")

      If AlarmLog = "No items present" Then
         AlarmLog = ""
      End If

      LogLines = Split(AlarmLog, vbLF)
      LogCount = UBound(LogLines)
      AlarmLog = "*S-" & vbTAB & GetPropertyValue("System Time.TimeAndDate") & "  " & strLogLine

      If LogCount > 300 Then
         LogCount = 300
      End If
      
      For nit = 0 to LogCount
         LogLines(nit) = Replace(LogLines(nit), "*S-", "")
         AlarmLog      = AlarmLog & vbLF & LogLines(nit)
      Next

      SetPropertyValue "Alarm Status.Log", AlarmLog
      Sleep 150 'Keep this Sleep here to prevent LogLines to be overwritten because of delay between HouseBot and script

      If GetPropertyValue("Alarm Status.Log Switch File") = "On" Then
         FileName       = GetPropertyValue("Alarm Status.Log File Path")
         Set FileSystem = CreateObject("Scripting.FileSystemObject")   
         Set StdOut     = FileSystem.OpenTextFile(FileName, 8, True)
                   
         If Err.Number = 0 Then
            StdOut.Write Date & " - " & Time & " - " & strLogLine & vbCRLF
            StdOut.Close
         Else
            Status = Err.Description
            Err.Clear
         End If
                   
         Set StdOut     = Nothing
         Set FileSystem = Nothing
      End If
   End If
   strLogLine = ""
End Sub