MAXH20-44 complete. Increments version to 8

This commit is contained in:
Patrick McDonagh
2017-11-01 13:16:39 -05:00
parent 0db98991f1
commit 7e3cade4dc
4 changed files with 102 additions and 5 deletions

View File

@@ -32,6 +32,39 @@
</form>
</div>
</div>
<div class="col-md-6 box-me entry-top-level" id="cost_per_bbl">
<div style="margin-left:15px;">
<h2>Cost per BBL</h2>
<form class="form-inline">
<div class="form-group" style="margin-bottom:15px;">
<label
class="sr-only"
for="<%= channels["flowmonitor.cost_per_bbl"].channelId %>">Cost Per BBL ($)</label>
<div class="input-group">
<input
class="form-control channel_value"
type="number"
step="any"
value="<%=channels['flowmonitor.cost_per_bbl'].value %>">
<div class="input-group-addon">$</div>
</div>
</div>
<hr />
<a
href="#"
data-confirm-message="Are you sure you want to do this?"
data-refreshpause="1"
data-command=""
data-staticsend=1.0
data-channelId="<%= channels["flowmonitor.cost_per_bbl"].channelId %>"
data-techname="<%=channels["flowmonitor.cost_per_bbl"].techName %>"
data-name="<%= channels["flowmonitor.cost_per_bbl"].name%>"
data-nodechannelcurrentId="<%= channels["flowmonitor.cost_per_bbl"].nodechannelcurrentId %>"
id="<%= channels["flowmonitor.cost_per_bbl"].channelId %>"
class="btn btn-large btn-theme animated setstatic material-icons">send</a>
</form>
</div>
</div>
</div>
<script>

View File

@@ -154,6 +154,66 @@
</span>
</div>
</div>
<div class='col-xs-3 text-center box-me'>
<h2>Gallons This Month</h2>
<h4 data-updatevalue="gal_total_thismonth">
<%= Math.round(channels["flowmonitor.gal_total_thismonth"].value * 100) / 100 %>
</h4>
<p data-timeupdate="gal_total_thismonth">
<%= channels["flowmonitor.gal_total_thismonth"].timestamp %>
</p>
</div>
<div class='col-xs-3 text-center box-me'>
<h2>Gallons Last Month</h2>
<h4 data-updatevalue="gal_total_lastmonth">
<%= Math.round(channels["flowmonitor.gal_total_lastmonth"].value * 100) / 100 %>
</h4>
<p data-timeupdate="gal_total_lastmonth">
<%= channels["flowmonitor.gal_total_lastmonth"].timestamp %>
</p>
</div>
<div class='col-xs-3 text-center box-me'>
<h2>BBL This Month</h2>
<h4 data-updatevalue="bbl_total_thismonth">
<%= Math.round(channels["flowmonitor.bbl_total_thismonth"].value * 100) / 100 %>
</h4>
<% if (channels["flowmonitor.cost_per_bbl"].value > 0.0){ %>
<h4 data-updatevalue="bbl_total_thismonth">
$<%= Math.round(channels["flowmonitor.bbl_total_thismonth"].value * channels["flowmonitor.cost_per_bbl"].value * 100) / 100 %>
</h4>
<% } %>
<p data-timeupdate="bbl_total_thismonth">
<%= channels["flowmonitor.bbl_total_thismonth"].timestamp %>
</p>
</div>
<div class='col-xs-3 text-center box-me'>
<h2>BBL Last Month</h2>
<h4 data-updatevalue="bbl_total_lastmonth">
<%= Math.round(channels["flowmonitor.bbl_total_lastmonth"].value * 100) / 100 %>
</h4>
<% if (channels["flowmonitor.cost_per_bbl"].value > 0.0){ %>
<h4 data-updatevalue="bbl_total_lastmonth">
$<%= Math.round(channels["flowmonitor.bbl_total_lastmonth"].value * channels["flowmonitor.cost_per_bbl"].value * 100) / 100 %>
</h4>
<% } %>
<p data-timeupdate="bbl_total_lastmonth">
<%= channels["flowmonitor.bbl_total_lastmonth"].timestamp %>
</p>
</div>
</div>
<div class="row box-me">
<div class='col-xs-12'>

View File

@@ -3,7 +3,7 @@
"driverFileName":"flow-monitor.py",
"deviceName":"flowmonitor",
"driverId":"0140",
"releaseVersion":"7",
"releaseVersion":"8",
"files": {
"file1":"flow-monitor.py",
"file2":"utilities.py"}

View File

@@ -130,7 +130,7 @@ class start(threading.Thread, deviceBase):
self.GPM_MAX = 100.0
self.daemon = True
self.version = "7"
self.version = "8"
self.finished = threading.Event()
threading.Thread.start(self)
@@ -166,7 +166,7 @@ class start(threading.Thread, deviceBase):
runstatus_ch = Channel('run_status', 0.5, 600)
date_reset = False
month_reset = False
month_reset = True
gal_totalizer_value = 0.0
bbl_totalizer_value = 0.0
@@ -200,6 +200,8 @@ class start(threading.Thread, deviceBase):
cursor.execute(CREATE_FLOWDATA_TABLE)
cursor.execute(INSERT_BLANK_FLOWDATA)
conn.commit()
except IndexError:
self.flowmonitor_resetdatabase(None, None)
try:
cursor.execute('SELECT * FROM scaling_data WHERE id = 1')
@@ -241,7 +243,7 @@ class start(threading.Thread, deviceBase):
if gpm_val < 0:
gpm_val = 0
else:
gpm_val = 4.0
gpm_val = 0.0
bpd_val = (gpm_val / gal_per_bbl) * 60.0 * 24.0
@@ -333,7 +335,9 @@ class start(threading.Thread, deviceBase):
cursor = conn.cursor()
try:
cursor.execute('SELECT * FROM flow_data WHERE id = 1')
cursor.execute(CLEAR_FLOWDATA)
cursor.execute('DROP TABLE flow_data')
cursor.execute(CREATE_FLOWDATA_TABLE)
cursor.execute(INSERT_BLANK_FLOWDATA)
conn.commit()
print("DATABASE HAS BEEN RESET!")
except sqlite3.OperationalError: