Initial work on web based voltage calculator
This commit is contained in:
30
powerweb/web.py
Normal file
30
powerweb/web.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from bottle import get, post, request, run, route
|
||||
from power_calcs import calculate
|
||||
|
||||
voltage_limit = 11.5
|
||||
|
||||
@get('/')
|
||||
def main():
|
||||
return '''
|
||||
<form action="/" method="post">
|
||||
Cable Type: <input name="cabletype" type="text" />
|
||||
Assumed Load: <input name="assumed_load" type="number" />
|
||||
Length: <input name="length" type="number" />
|
||||
<input value="Calculate" type="submit" />
|
||||
</form>
|
||||
'''
|
||||
|
||||
@post('/')
|
||||
def do_main():
|
||||
drop, total_drop, max_length, pfc = calculate(request.forms.get('cabletype'), float(request.forms.get('assumed_load')), int(request.forms.get('length')))
|
||||
page = ""
|
||||
page += f"Voltage Drop (per ampere per metre): {drop}mV/A/m<br>"
|
||||
page += f"Total drop at {request.forms.get('assumed_load')}A over {request.forms.get('length')}m is: {total_drop:.1f}V<br>"
|
||||
page += f"Maximum length of cable at this load: {int(max_length)}m<br>"
|
||||
page += f"Estimated PFC is {pfc:.1f}A<br>"
|
||||
|
||||
if total_drop > voltage_limit:
|
||||
page += "<span style='color: red'>FAILED: VOLTAGE DROP TOO HIGH</span>"
|
||||
return page
|
||||
|
||||
run(host='localhost', port=8080, debug=True)
|
||||
Reference in New Issue
Block a user