mirror of
				https://github.com/DigitalDevices/octonet.git
				synced 2023-10-10 11:36:52 +00:00 
			
		
		
		
	Added fan readout to monitor
This commit is contained in:
		@@ -59,6 +59,14 @@ if ddbridge then
 | 
				
			|||||||
  ddbridge:close()
 | 
					  ddbridge:close()
 | 
				
			||||||
  if devid == "0307dd01" then 
 | 
					  if devid == "0307dd01" then 
 | 
				
			||||||
    fanstate = 1
 | 
					    fanstate = 1
 | 
				
			||||||
 | 
					    ddbridge = io.open("/sys/class/ddbridge/ddbridge0/fanspeed1","r"); 
 | 
				
			||||||
 | 
					    if ddbridge then
 | 
				
			||||||
 | 
					      local fs = tonumber(ddbridge:read("*l"))
 | 
				
			||||||
 | 
					      ddbridge:close()
 | 
				
			||||||
 | 
					      if fs > 0 and fs < 17000 then 
 | 
				
			||||||
 | 
					         fanstate = -2
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
  end 
 | 
					  end 
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -68,7 +68,16 @@ function myFunction(response) {
 | 
				
			|||||||
       document.getElementById("TGraph").style.display = "none";
 | 
					       document.getElementById("TGraph").style.display = "none";
 | 
				
			||||||
       document.getElementById("NoSensor").style.display = "block";
 | 
					       document.getElementById("NoSensor").style.display = "block";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    if( Sensor.FanSpeed )
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					       document.getElementById("FanStatus").firstChild.nodeValue  = "Fan: "+ Sensor.FanSpeed + " rpm";
 | 
				
			||||||
 | 
					       document.getElementById("FanStatus").style.display = "inline";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if( Sensor.FanState >= 0 )
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					       document.getElementById("FanStatus").firstChild.nodeValue  = "Fan: "+ ( Sensor.FanState > 0 ? "ON" : "OFF" );
 | 
				
			||||||
 | 
					       document.getElementById("FanStatus").style.display = "inline";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function OnLoad()
 | 
					function OnLoad()
 | 
				
			||||||
@@ -81,7 +90,7 @@ function OnLoad()
 | 
				
			|||||||
</head>
 | 
					</head>
 | 
				
			||||||
<body onload="OnLoad()">
 | 
					<body onload="OnLoad()">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<table class="maintable" align="center">
 | 
					<table class="maintable">
 | 
				
			||||||
  <colgroup>
 | 
					  <colgroup>
 | 
				
			||||||
    <col width="182px"/>
 | 
					    <col width="182px"/>
 | 
				
			||||||
    <col width="728px"/>
 | 
					    <col width="728px"/>
 | 
				
			||||||
@@ -106,12 +115,35 @@ function OnLoad()
 | 
				
			|||||||
            </td>
 | 
					            </td>
 | 
				
			||||||
         </table>
 | 
					         </table>
 | 
				
			||||||
         -->
 | 
					         -->
 | 
				
			||||||
        <h3 align="center">Frontend Temperature</h3>
 | 
					        <table style="margin: auto; width: 100%; text-align: center">
 | 
				
			||||||
        <div id="NoSensor" align="center" style="display: none">
 | 
					           <colgroup>
 | 
				
			||||||
 | 
					             <col width="25%"/>
 | 
				
			||||||
 | 
					             <col width="50%"/>
 | 
				
			||||||
 | 
					             <col width="25%"/>
 | 
				
			||||||
 | 
					           </colgroup>
 | 
				
			||||||
 | 
					           <tr>
 | 
				
			||||||
 | 
					            <td></td>
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					               <p>
 | 
				
			||||||
 | 
					               <h3 style="margin: auto; width: 100%; text-align: center">Frontend Temperature</h3>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					              <div id="FanStatus" style="display: none; margin: auto; width: 100%; margin-top: 0px; text-align: right; font-size:70%">
 | 
				
			||||||
 | 
					                  Fan: 2000 rpm
 | 
				
			||||||
 | 
					              </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					           </tr>
 | 
				
			||||||
 | 
					        </table>
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        <div id="NoSensor" style="display: none; margin: auto; width: 100%; text-align: center">
 | 
				
			||||||
            <p>
 | 
					            <p>
 | 
				
			||||||
            No temperature sensors available
 | 
					            No temperature sensors available
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <div id="TGraph" align="center" style="display: block">
 | 
					        <div id="TGraph" align="center" style="display: block">
 | 
				
			||||||
            <svg Id="svg" width="720px" height="330px">
 | 
					            <svg Id="svg" width="720px" height="330px">
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,7 +33,7 @@ function ReadLine(file)
 | 
				
			|||||||
   if tmp then
 | 
					   if tmp then
 | 
				
			||||||
      local values = {}
 | 
					      local values = {}
 | 
				
			||||||
      local value
 | 
					      local value
 | 
				
			||||||
      for value in string.gmatch(tmp,"(%d+)") do
 | 
					      for value in string.gmatch(tmp,"(%-?%d+)") do
 | 
				
			||||||
         table.insert(values,tonumber(value))
 | 
					         table.insert(values,tonumber(value))
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
      return values
 | 
					      return values
 | 
				
			||||||
@@ -42,6 +42,18 @@ function ReadLine(file)
 | 
				
			|||||||
   end
 | 
					   end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function ReadFanSpeed()
 | 
				
			||||||
 | 
					   local f = io.open("/sys/class/ddbridge/ddbridge0/fanspeed1","r"); 
 | 
				
			||||||
 | 
					   if f then
 | 
				
			||||||
 | 
					      local fs = tonumber(f:read("*l"))
 | 
				
			||||||
 | 
					      f:close()
 | 
				
			||||||
 | 
					      if fs > 0 and fs < 17000 then 
 | 
				
			||||||
 | 
					         return fs
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					   end
 | 
				
			||||||
 | 
					   return nil
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if method == "GET" then
 | 
					if method == "GET" then
 | 
				
			||||||
   data = ""
 | 
					   data = ""
 | 
				
			||||||
   status = " 204"
 | 
					   status = " 204"
 | 
				
			||||||
@@ -65,6 +77,11 @@ if method == "GET" then
 | 
				
			|||||||
      data = data .. "\"Interval\":\""..Interval.."\",\n"
 | 
					      data = data .. "\"Interval\":\""..Interval.."\",\n"
 | 
				
			||||||
      data = data .. "\"FanState\":\""..FanState.."\",\n"
 | 
					      data = data .. "\"FanState\":\""..FanState.."\",\n"
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
 | 
					      local FanSpeed = ReadFanSpeed()
 | 
				
			||||||
 | 
					      if FanSpeed then
 | 
				
			||||||
 | 
					         data = data .. "\"FanSpeed\":\""..FanSpeed.."\",\n"
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      data = data .. "\"SensorData\": [\n"
 | 
					      data = data .. "\"SensorData\": [\n"
 | 
				
			||||||
      local i,j
 | 
					      local i,j
 | 
				
			||||||
      for i = 1,NumSensors,1 do
 | 
					      for i = 1,NumSensors,1 do
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user