Skip to content

Commit

Permalink
Adding Vmin/Vnom/Vmax for cells:
Browse files Browse the repository at this point in the history
- Now using the 3 values to compare specifications in battery_comparator.
- Updated READMEs and changed flight time page to a "work in progress" message.
  • Loading branch information
Gregczc committed May 11, 2020
1 parent 5c34ab8 commit 39f29f6
Show file tree
Hide file tree
Showing 12 changed files with 228 additions and 248 deletions.
5 changes: 3 additions & 2 deletions README.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ Le programme se présente actuellement sous la forme d'un serveur web auto-hébe

Pour l'instant, RC-Calc vous permet de :
- Régler le nombre de mV/A de la sonde de tension pour avoir une mesure précise de la consommation d'énergie/courant. Pratique pour des vols long-range en toute sereinité !
- Configurer vos batteries : choisissez vos cellules, le nombre d'éléments en série et en parallèle et obtenez les caractéristiques de la batterie telles que la tension, le courant max, son énergie et autres. Utile pour se lancer dans la création de pack li-ion maison !
- Configurer vos batteries : choisissez vos cellules, le nombre d'éléments en série et en parallèle et obtenez les caractéristiques de la batterie telles que la tension, le courant max, son énergie et autres. Une fois configurées, un comparateur permet de trouver quel pack correspond au mieux à l'utilisation. Utile pour se lancer dans la création de pack li-ion maison !

## Quelles fonctionnalités sont à prévoir ?

D'autres outils doivent encore être inclus dans ce programme et donneront les fonctionnalités suivantes :
- Un comparateur de batteries, pour mieux observer les différences de performances entre deux packs et faire le bon choix de cellules.
- Un carnet de vol, pour suivre ses temps et distance de vol et pouvoir déterminer rapidement si un nouvel équipement comme un changement de batterie, d'hélice ou autre a un impact sur les performances habituelles.
- Une traductoin complète en français : la traduction, bien que proposée, n'est qu'en partie fonctionnelle.

J'ai également d'autres outils en réserve mais ne suis pas sûr s'ils devraient être inclus, car ils sont très spéciques et ont donné des résultats limités pour l'instant. Par exemple : un calculateur de centre de gravité pour ailes volantes.

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ It is currently under the form of a self-hosted web server. It means that when y

For now, RC-Calc allows you to:
- Set the proper mV/A for your current sensor, in order to get an accurate power/energy draw reading in your OSD. Might be useful for sweet long-range flights!
- Build the ultimate li-ion pack. Choose your cells, series and parallel configuration and you will get the weight, price, voltage, capacity of the pack to determine what suits best your needs!
- Build the ultimate li-ion pack. Choose your cells, series and parallel configuration and you will get the weight, price, voltage, capacity of the pack. Once configured, a battery comparator is available to determine what suits best your needs!

## What's next?
I have some tools that just need to be included in this program and will give the following features:
- A battery comparator : to help you decide between two packs you would like to build.
- A flight time tracking tool: log your flight times and distances so you can quickly tell if this new battery, propeller or any other equipment actually gives you more performance than usual.


I also have some other tools but I don't really know if they should be included since they are really specific and gave limited results for now, such as a CG calculator for example.

If you have some improvement ideas, please see the [contribution section](#Contribution).
Expand All @@ -41,6 +39,7 @@ For now, 2 ways are available to use this tool :
Be aware that RC-Calc will build a database in the *db* folder, so make sure to save its content when moving to a different version of the software.

### Documentation

A detailed documentation is on its way using Sphinx.

## Contribution
Expand Down
Binary file modified db/user.db
Binary file not shown.
24 changes: 14 additions & 10 deletions web/battery_comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def initialize_db():
c.execute("PRAGMA foreign_keys = ON;")

c.execute('''CREATE TABLE IF NOT EXISTS Cells ( name text,
voltage real,
voltage_min real,
voltage_nom real,
voltage_max real,
energy real,
capacity real,
max_current real,
Expand Down Expand Up @@ -61,15 +63,17 @@ def get_cells_and_batteries(status='ok'):
cells = []
for cell in c.execute("SELECT * FROM Cells"):
cells.append({
'Name': cell[0],
'Voltage': cell[1],
'Energy': cell[2],
'Capacity': cell[3],
'Max Current': cell[4],
'Weight': cell[5],
'Price': cell[6],
'Currency': cell[7],
'Data-sheet': False if cell[8] == b"0" else True
'Name': cell[0],
'Voltage Min': cell[1],
'Voltage Nom': cell[2],
'Voltage Max': cell[3],
'Energy': cell[4],
'Capacity': cell[5],
'Max Current': cell[6],
'Weight': cell[7],
'Price': cell[8],
'Currency': cell[9],
'Data-sheet': False if cell[10] == b"0" else True
})

cellID2Name = dict(c.execute("SELECT cell_id, name FROM Cells").fetchall())
Expand Down
24 changes: 14 additions & 10 deletions web/battery_configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def initialize_db():
c.execute("PRAGMA foreign_keys = ON;")

c.execute('''CREATE TABLE IF NOT EXISTS Cells ( name text,
voltage real,
voltage_min real,
voltage_nom real,
voltage_max real,
energy real,
capacity real,
max_current real,
Expand Down Expand Up @@ -61,15 +63,17 @@ def get_cells_and_batteries(status='ok'):
cells = []
for cell in c.execute("SELECT * FROM Cells"):
cells.append({
'Name': cell[0],
'Voltage': cell[1],
'Energy': cell[2],
'Capacity': cell[3],
'Max Current': cell[4],
'Weight': cell[5],
'Price': cell[6],
'Currency': cell[7],
'Data-sheet': False if cell[8] == b"0" else True
'Name': cell[0],
'Voltage Min': cell[1],
'Voltage Nom': cell[2],
'Voltage Max': cell[3],
'Energy': cell[4],
'Capacity': cell[5],
'Max Current': cell[6],
'Weight': cell[7],
'Price': cell[8],
'Currency': cell[9],
'Data-sheet': False if cell[10] == b"0" else True
})

cellID2Name = dict(c.execute("SELECT cell_id, name FROM Cells").fetchall())
Expand Down
48 changes: 27 additions & 21 deletions web/cell_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def initialize_db():
c = conn.cursor()
c.execute("PRAGMA foreign_keys = ON;")
c.execute('''CREATE TABLE IF NOT EXISTS Cells ( name text,
voltage real,
voltage_min real,
voltage_nom real,
voltage_max real,
energy real,
capacity real,
max_current real,
Expand All @@ -55,26 +57,28 @@ def get_cells(status='ok'):
c = conn.cursor()
c.execute("PRAGMA foreign_keys = ON;")

json_cells = []
cells = []
for cell in c.execute("SELECT * FROM Cells"):
json_cells.append({
'Name': cell[0],
'Voltage': cell[1],
'Energy': cell[2],
'Capacity': cell[3],
'Max Current': cell[4],
'Weight': cell[5],
'Price': cell[6],
'Currency': cell[7],
'Data-sheet': False if cell[8] == b"0" else True
cells.append({
'Name': cell[0],
'Voltage Min': cell[1],
'Voltage Nom': cell[2],
'Voltage Max': cell[3],
'Energy': cell[4],
'Capacity': cell[5],
'Max Current': cell[6],
'Weight': cell[7],
'Price': cell[8],
'Currency': cell[9],
'Data-sheet': False if cell[10] == b"0" else True
})

conn.commit()
conn.close()

json_cells.append({'Status': status})
cells.append({'Status': status})

return json.dumps(json_cells)
return json.dumps(cells)


def get_datasheet(name):
Expand Down Expand Up @@ -113,9 +117,9 @@ def add_cell(request):
else:
blob = sqlite3.Binary(b"0")

cell = (request.form['Name'], request.form['Voltage'], request.form['Energy'], request.form['Capacity'],
request.form['Max Current'], request.form['Weight'], request.form['Price'], request.form['Currency'],
blob.tobytes(), None)
cell = (request.form['Name'], request.form['Voltage Min'], request.form['Voltage Nom'], request.form['Voltage Max'],
request.form['Energy'], request.form['Capacity'], request.form['Max Current'], request.form['Weight'],
request.form['Price'], request.form['Currency'], blob.tobytes(), None)

conn = sqlite3.connect('db/user.db')
c = conn.cursor()
Expand All @@ -128,7 +132,7 @@ def add_cell(request):

else:
# Insert a row of data
c.execute("INSERT INTO Cells VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", cell)
c.execute("INSERT INTO Cells VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", cell)

# Save (commit) the changes
conn.commit()
Expand Down Expand Up @@ -193,12 +197,14 @@ def edit_cell(request):
status = "alreadyExisting"

else:
update = (request.form['Name'], request.form['Voltage'], request.form['Energy'], request.form['Capacity'],
update = (request.form['Name'], request.form['Voltage Min'], request.form['Voltage Nom'],
request.form['Voltage Max'], request.form['Energy'], request.form['Capacity'],
request.form['Max Current'], request.form['Weight'], request.form['Price'], request.form['Currency'],
request.form['InitialName'])

c.execute('''UPDATE Cells SET name = ?, voltage = ?, energy = ?, capacity = ?, max_current = ?, weight = ?,
price = ?, currency = ? WHERE name = ?''', update)
c.execute('''UPDATE Cells SET name = ?, voltage_min = ?, voltage_nom = ?, voltage_max = ?, energy = ?,
capacity = ?, max_current = ?, weight = ?, price = ?, currency = ? WHERE name = ?''', update)

status = "datasheet" if datasheet_error else "successUpdated"
conn.commit()

Expand Down
100 changes: 2 additions & 98 deletions web/flight_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,109 +18,13 @@
# along with RC-Calc. If not, see <http://www.gnu.org/licenses/>.


import io
from flask import Blueprint


def new_entry_form(plane):

return """
<div class="card">
<div class="card-header text-center">New Entry</div>
<div class="card-body">
<form class="form-group row" method="POST" action="" novalidate>
<div class="form-group text-center">
<label for="formFlightNumber-""" + plane + """">#</label>
<input type="text" class="form-control form-control-sm formFlightNumber" id="formFlightNumber-""" + plane + """" placeholder="1" readonly name="formFlightNumber-""" + plane + """">
</div>
<div class="form-group text-center">
<label for="formFlightTime-""" + plane + """">Flight Time</label>
<div class="input-group input-group-sm">
<input type="time" class="form-control formFlightTime" id="formFlightTime-""" + plane + """" name="formFlightTime-""" + plane + """">
<div class="invalid-tooltip">Please enter the flight time.</div>
</div>
</div>
<div class="form-group text-center">
<label for="formDistance-""" + plane + """">Distance</label>
<div class="input-group input-group-sm">
<input type="number" step="0.1" min="0" class="form-control formDistance" id="formDistance-""" + plane + """" placeholder="45.4" name="formDistance-""" + plane + """">
<div class="input-group-append">
<span class="input-group-text">km</span>
</div>
<div class="invalid-tooltip">Please enter the distance flown.</div>
</div>
</div>
<div class="form-group text-center">
<label for="formEnergy-""" + plane + """">Energy</label>
<div class="input-group input-group-sm">
<input type="number" step="0.1" min="0" class="form-control formEnergy" id="formEnergy-""" + plane + """" placeholder="53.2" name="formEnergy-""" + plane + """">
<div class="input-group-append">
<span class="input-group-text">Wh</span>
</div>
<div class="invalid-tooltip">Please enter the energy used.</div>
</div>
</div>
<div class="form-group text-center">
<label for="formBattery-""" + plane + """">Battery</label>
<div class="input-group input-group-sm">
<input type="number" step="0.1" min="0" class="form-control formBattery" id="formBattery-""" + plane + """" placeholder="125.2" name="formBattery-""" + plane + """">
<div class="input-group-append">
<div class="input-group-text">Wh</div>
</div>
<div class="invalid-tooltip">Please enter the battery energy.</div>
</div>
</div>
<div class="form-group text-center">
<label for="formDescription-""" + plane + """">Description </label>
<div class="input-group input-group-sm">
<textarea class="form-control formDescription" id="formDescription-""" + plane + """" placeholder="eg. With 12x6 propeller, without wind, pretty aggressive flight etc." name="formDescription-""" + plane + """"></textarea>
<div class="invalid-tooltip">Please enter a description.</div>
</div>
</div>
<div class="form-group text-center">
<label for="formSave-""" + plane + """" class="invisible">Save</label>
<div class="input-group">
<button type="submit" class="btn btn-primary btn-sm form-control-sm text-bottom formSave" id="formSave-""" + plane + """" name="formSave-""" + plane + """" value="clicked">Save</button>
</div>
</div>
</form>
</div>
</div>
"""
from flask import Blueprint, render_template


flight_time = Blueprint('flight-time', __name__)


@flight_time.route('/')
def show():
# Getting the usual content of flight-time.html as a string
html = io.open("./web/templates/flight-time.html", "r", encoding="utf-8").read()

plane_list = ["Skyhunter", "S800", "Easystar"]

for number, plane in enumerate(plane_list):
tab_header = "<a class=\"nav-item nav-link "
tab_header += "active\"" if not number else "\""
tab_header += (" id=\"nav-" + plane + "-tab\" data-toggle=\"tab\" href=\"#nav-"
+ plane + "\" role=\"tab\" aria-controls=\"nav-")
tab_header += plane + "\" aria-selected=\""
tab_header += "true" if not number else "false"
tab_header += "\">" + plane + "</a>\n\t\t\t\t\t<!-- Plane tab header marker -->"

html = html.replace("""<!-- Plane tab header marker -->""", tab_header)

tab_content = "<div class=\"tab-pane fade show "
tab_content += "active\"" if not number else "\""
tab_content += " id=\"nav-" + plane + "\" role=\"tabpanel\" aria-labelledby=\"nav-" + plane + "-tab\">"
tab_content += new_entry_form(plane) + "</div>\n\t\t\t\t<!-- Plane tab content marker -->"

html = html.replace("""<!-- Plane tab content marker -->""", tab_content)

return html
return render_template('flight-time.html')
Loading

0 comments on commit 39f29f6

Please sign in to comment.