stats.asp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
  2. <%
  3. Option Explicit
  4. Response.Buffer = True
  5. Server.ScriptTimeOut = 1800
  6. Call OpenConn()
  7. Dim Conn, temp1, temp2, temp3, inputVoltage, dumpEnergy, str
  8. temp1 = sqlSumLog("WTH10_1_Temp")
  9. temp2 = sqlSumLog("WTH10_2_Temp")
  10. temp3 = sqlSumLog("RC_netmate_line1InputCurrent")
  11. inputVoltage = sqlSumLog("RC_netmate_line1InputCurrent")
  12. dumpEnergy = sqlSumLog("RC_netmate_BatteryPowerSupplyTimeleft")
  13. str = "<?xml>" & vbCrLf
  14. str = str & " <date>" & now & "</date>" & vbCrLf
  15. str = str & " <temp1>" & temp1 & "</temp1>" & vbCrLf
  16. str = str & " <temp2>" & temp2 & "</temp2>" & vbCrLf
  17. str = str & " <temp3>" & temp3 & "</temp3>" & vbCrLf
  18. str = str & " <input voltage>" & inputVoltage & "</input voltage>" & vbCrLf
  19. str = str & " <dump energy>" & dumpEnergy & "</dump energy>" & vbCrLf
  20. str = str & "</xml>"
  21. response.write str
  22. function sqlSumLog(varname)
  23. dim rsSqlSumLog
  24. set rsSqlSumLog = Conn.execute("select curr_value from t_summary_log where varname = '"&varname&"'")
  25. if rsSqlSumLog.bof and rsSqlSumLog.eof then
  26. sqlSumLog = -1
  27. else
  28. sqlSumLog = rsSqlSumLog(0)
  29. end if
  30. rsSqlSumLog.close
  31. set rsSqlSumLog = nothing
  32. end function
  33. Sub OpenConn()
  34. On Error Resume Next
  35. Dim ConnStr
  36. ConnStr = "DRIVER={PostgreSQL ODBC Driver(UNICODE)}; SERVER=127.0.0.1; port=5432; DATABASE=whdx; UID=postgres; PWD=stoneu;"
  37. Set Conn = Server.CreateObject("ADODB.Connection")
  38. Conn.open ConnStr
  39. If Err Then
  40. Err.Clear
  41. Set Conn = Nothing
  42. Response.Write "Connection Error!"
  43. Response.End
  44. End If
  45. End Sub
  46. Sub CloseConn()
  47. On Error Resume Next
  48. If IsObject(Conn) Then
  49. Conn.Close
  50. Set Conn = Nothing
  51. End If
  52. End Sub
  53. Call CloseConn()
  54. %>