<%=hs.plugin("Web Wrapper").Header("Brewhouse",0, False)%> <%@ LANGUAGE=VBScript %> <% ' -------------------------------------------------------------------- ' Guest Header (Logging) ' -------------------------------------------------------------------- If UCase(Request.ServerVariables("AUTH_USER")) = "GUEST" Then If UCase(hs.GetINISetting("Misc","LogGuestActivity","NO")) = "YES" Then Call hs.WriteLog("Guest Activity", Request.ServerVariables("REMOTE_ADDR") & " is Accessing [Brewhouse] Page") End If End If Sub Build_Screen() Dim ChamberCount, StartDate, StartTemp, Highlight Dim ChangeType1, ChangeDate1, ChangeTemp1 Dim ChangeType2, ChangeDate2, ChangeTemp2 Dim ChangeType3, ChangeDate3, ChangeTemp3 Dim ChangeType4, ChangeDate4, ChangeTemp4 Dim Dryhop, DryhopDate, TotalDays Dim DeviceCodes, FanCode, HeatCode, StatusColor response.write "
" response.write "" response.write "" response.write "" response.write "" response.write "" response.write "" response.write "" 'Split the screen Response.Write "" response.write "" response.write "
The Fermenator
Freezer Temp: " & Trim(hs.GetINISetting("SensorData", "Sensor5probe", "")) & " F" & "
" & vbnewline 'Make sure the number of chambers is specified. If Trim(hs.GetINISetting("Brewhouse", "ChamberCount", "")) = "" Then hs.SaveINISetting "Brewhouse", "ChamberCount", "" Call hs.WriteLog("Brewhouse.asp", "Please assign the total number of chambers in the [Brewhouse] section of settings.ini") Response.Write "" & vbnewline Else ChamberCount = Trim(hs.GetINISetting("Brewhouse", "ChamberCount", "")) For i = 1 To CInt(ChamberCount) 'Load Device Codes DeviceCodes = Trim(hs.GetINISetting("Brewhouse", "DeviceCodes" & CStr(i), "")) If DeviceCodes <> "" Then SP = Split(DeviceCodes ,"|") FanCode=SP(0) HeatCode=SP(1) End If 'Load Beer name & misc info KeyInfo = Trim(hs.GetINISetting("Brewhouse", "BeerData" & CStr(i), "")) If KeyInfo <> "" Then SP = Split(KeyInfo ,"|") Beer=SP(0) 'TODO other info about the beer 'HCDC=SP(1) End If 'Load Main Values KeyInfo = Trim(hs.GetINISetting("Brewhouse", "Schedule" & CStr(i), "")) If KeyInfo <> "" Then SP = Split(KeyInfo ,"|") StartDate=SP(0) StartTemp=SP(1) ChangeType1=SP(2) ChangeDate1=SP(3) ChangeTemp1=SP(4) ChangeType2=SP(5) ChangeDate2=SP(6) ChangeTemp2=SP(7) ChangeType3=SP(8) ChangeDate3=SP(9) ChangeTemp3=SP(10) ChangeType4=SP(11) ChangeDate4=SP(12) ChangeTemp4=SP(13) End If 'Load DryHop Values KeyInfo = Trim(hs.GetINISetting("Brewhouse", "Dryhop" & CStr(i), "0")) SP = Split(KeyInfo ,"|") If SP(0) <> "0" then Dryhop = " checked " DryhopDate=SP(1) DryhopDays=SP(2) Else Dryhop = "" End If 'Write data to page 'Set empty text if chamber is not in use If Beer = "" Then Beer = "Empty" End If response.write "" & vbnewline 'Gray out previous stages Highlight = DisablePreviousFields(StartDate) response.write "" & Vbnewline response.write "" & Vbnewline response.write "" & Vbnewline response.write "" & Vbnewline 'Stage 1 Controls Highlight = DisablePreviousFields(ChangeDate1) Response.Write "" & Vbnewline 'Stage 2 Controls Highlight = DisablePreviousFields(ChangeDate2) Response.Write "" & Vbnewline 'Stage 3 Controls Highlight = DisablePreviousFields(ChangeDate3) Response.Write "" & Vbnewline 'Stage 4 Controls Highlight = DisablePreviousFields(ChangeDate4) Response.Write "" & Vbnewline 'Dryhop checkbox & date Response.Write "" & Vbnewline Response.Write "" & vbnewline response.write "
Please assign the total number of chambers in the [Brewhouse] section of settings.ini and click Update All
" & Vbnewline Response.Write "
" & Vbnewline 'Calc days in fermenter If StartDate <> "" Then iTemp = DateDiff("D", CDate(StartDate), Now) If iTemp > 1 Then TotalDays = iTemp & " Days" Else TotalDays = iTemp & " Day" End If End If 'Set cooling and heating codes If hs.devicestatus(FanCode) = "3" Then FanStatus = "  OFF " ElseIf hs.devicestatus(FanCode) = "17" Then FanStatus = "       " Else FanStatus = "  ON  " End If If hs.devicestatus(HeatCode) = "3" Then HeatStatus = "  OFF " ElseIf hs.devicestatus(HeatCode) = "17" Then HeatStatus = "       " Else HeatStatus = "  ON  " End If response.write "" & Vbnewline Response.Write "
Chamber " & i & " - " & Beer & "
" & Vbnewline response.write "" & Vbnewline response.write "" & Vbnewline response.write "
Beer Temp: " & hs.GetINISetting("SensorData", "Sensor" & i & "Probe", "") & " F" & "     Total Time: " & TotalDays & "
Chamber Temp: " & hs.GetINISetting("SensorData", "Sensor" & i & "Device", "") & " F" & "   " & "" & "
Cooling: " & FanStatus & "     Humidity: " & hs.GetINISetting("SensorData", "Sensor" & i & "Humidity", "") & "
Heat: " & HeatStatus & "     Reported: " & hs.GetINISetting("SensorData", "Sensor" & i & "LastSeen", "") & "
Beer:
Start:       Temp:
" & vbnewline Response.Write ":"& vbnewline Response.Write "       Temp:
" & vbnewline Response.Write ":" & vbnewline Response.Write "       Temp:
" & vbnewline Response.Write ":" & vbnewline Response.Write "       Temp:
" & vbnewline Response.Write ":"& vbnewline Response.Write "       Temp:
" & "     Dryhop:        Days: " & vbnewline Response.Write "
" & Vbnewline 'Response.Write "" 'Check to see if we are on our 2nd column If CStr(i) = "2" Then Response.Write "
" End If 'Clear our variables for the next time through Beer="" FanCode="" HeatCode="" StartDate="" StartTemp="" DryhopDate="" DryhopDays="" TotalDays="" Next End If response.write "
" & Vbnewline response.write "" response.write "" & Vbnewline response.write "
" response.write "
" & Vbnewline response.write "
" & Vbnewline End Sub Function DisablePreviousFields(ChangeDate) If Trim(ChangeDate) <> "" Then If DateDiff("d", Now, ChangeDate) < "0" Then DisablePreviousFields = "background-color: Gray" Else DisablePreviousFields = "background-color: White" End If End If End Function Sub Update_INI Dim Dryhop, ChamberCount ChamberCount = Trim(hs.GetINISetting("Brewhouse", "ChamberCount", "")) 'Loop through chambers and update ini values For i = 1 To CInt(ChamberCount) If Trim(hs.GetINISetting("Brewhouse", "DeviceCodes" & CStr(i), "")) = "" Then hs.SaveINISetting "Brewhouse", "DeviceCodes" & CStr(i), "" If Trim(hs.GetINISetting("Brewhouse", "BeerData" & CStr(i), "")) <> "Empty" Then Call hs.WriteLog("Brewhouse.asp", "Please assign device codes for Chamber " & CStr(i) & " in the [Brewhouse] section of settings.ini") Response.Write "
Please assign device codes for Chamber " & CStr(i) & " in the [Brewhouse] section of settings.ini
Format should be pipe delimited like FanCode|HeatCode (Ex. D7|D8)
" & vbnewline End If End If hs.SaveINISetting "Brewhouse", "BeerData" & CStr(i), Request.Form(i & "_Beer") 'TODO Add Device Codes Stuff & "|" & Request.Form(i & "_HCDC") hs.SaveINISetting "Brewhouse", "Schedule" & CStr(i), Request.Form(i & "_StartDate") & "|" & Request.Form(i & "_StartTemp") & "|" & Request.Form(i & "_ChangeType1") & "|" & Request.Form(i & "_ChangeDate1") & "|" & Request.Form(i & "_ChangeTemp1") & "|" & Request.Form(i & "_ChangeType2") & "|" & Request.Form(i & "_ChangeDate2") & "|" & Request.Form(i & "_ChangeTemp2") & "|" & Request.Form(i & "_ChangeType3") & "|" & Request.Form(i & "_ChangeDate3") & "|" & Request.Form(i & "_ChangeTemp3") & "|" & Request.Form(i & "_ChangeType4") & "|" & Request.Form(i & "_ChangeDate4") & "|" & Request.Form(i & "_ChangeTemp4") Dryhop = Request.Form(i & "_Dryhop") If Dryhop = "on" Then hs.SaveINISetting "Brewhouse", "Dryhop" & CStr(i), "1" & "|" & Request.Form(i & "_DryhopDate") & "|" & Request.Form(i & "_DryhopDays") Else hs.SaveINISetting "Brewhouse", "Dryhop" & CStr(i), "0" & "|" End If Next End Sub Sub ClearFields(Index) hs.SaveINISetting "Brewhouse", "BeerData" & Index, "" hs.SaveINISetting "Brewhouse", "Schedule" & Index, "||None|||None|||None|||None||" hs.SaveINISetting "Brewhouse", "Dryhop" & Index, "0|" End Sub 'Check who is logged in and if it is a guest then 'don't let the update or add buttons work Who = UCase(Request.ServerVariables("AUTH_USER")) IF Request.Form("SUBMIT") = "UPDATE ALL" And Who <> "GUEST" Then Update_INI ElseIf Request.Form("SUBMIT") = "CLEAR CHAMBER 1" Then ClearFields(1) ElseIf Request.Form("SUBMIT") = "CLEAR CHAMBER 2" Then ClearFields(2) ElseIf Request.Form("SUBMIT") = "CLEAR CHAMBER 3" Then ClearFields(3) ElseIf Request.Form("SUBMIT") = "CLEAR CHAMBER 4" Then ClearFields(4) End If Build_Screen 'Put the Footer on the Page %>