I downloaded the following script from this forum some time back and was using it to track power failures on my laptop during the HS2 days.
Recently the laptop shutdown due to a power failure in the middle of a storm and damaged the HS3 database. Thankfully I was able to recover by having a backup.
While trying to avoid a further occurrence I went back to my old HS2 system and tried to resurrect the old script, however it through up more errors than I have the expertise to deal with under HS3 and Win7.
----------------------------------------------------------
Public Sub Main(ByVal parm As Object)
Dim strPower As String
Dim power As Type = GetType(System.Windows.Forms.PowerStatus)
Dim pi As System.Reflection.PropertyInfo() = power.GetProperties()
Dim objPropval As Object = pi(0).GetValue(System.Windows.Forms.SystemInformation.PowerS tatus, Nothing)
strPower = objPropval.ToString
hs.SetDeviceString("1989", strPower)
If strPower = "Online" Then
hs.SetDeviceValue("1989", 100)
Else
hs.SetDeviceValue("1989", 0)
End If
objPropval = Nothing
pi = Nothing
power = Nothing
End Sub
----------------------------------------------------------
The only thing changed is the device number eg "B1" to my device number 1989.
Appreciate if anyone can help convert this script to HS3, its a little gem and I'm sure it will be useful to others.
Recently the laptop shutdown due to a power failure in the middle of a storm and damaged the HS3 database. Thankfully I was able to recover by having a backup.
While trying to avoid a further occurrence I went back to my old HS2 system and tried to resurrect the old script, however it through up more errors than I have the expertise to deal with under HS3 and Win7.
----------------------------------------------------------
Public Sub Main(ByVal parm As Object)
Dim strPower As String
Dim power As Type = GetType(System.Windows.Forms.PowerStatus)
Dim pi As System.Reflection.PropertyInfo() = power.GetProperties()
Dim objPropval As Object = pi(0).GetValue(System.Windows.Forms.SystemInformation.PowerS tatus, Nothing)
strPower = objPropval.ToString
hs.SetDeviceString("1989", strPower)
If strPower = "Online" Then
hs.SetDeviceValue("1989", 100)
Else
hs.SetDeviceValue("1989", 0)
End If
objPropval = Nothing
pi = Nothing
power = Nothing
End Sub
----------------------------------------------------------
The only thing changed is the device number eg "B1" to my device number 1989.
Appreciate if anyone can help convert this script to HS3, its a little gem and I'm sure it will be useful to others.
Comment