just kidding, it was working. adds a totals page
This commit is contained in:
@@ -24,35 +24,33 @@ def readTag(addr, tag):
|
||||
|
||||
def getTotals():
|
||||
today_tags = [
|
||||
{'name':"Average SPM",'tag':"TODAY_Average_SPM"},
|
||||
{'name':"Downhole Net Stroke",'tag':"TODAY_Downhole_NetStroke"},
|
||||
{'name':"Electricity Cost",'tag':"TODAY_Electricity_Cost"},
|
||||
{'name':"Fluid Level",'tag':"TODAY_Fluid_Above_Pump"},
|
||||
{'name':"Inflow Rate",'tag':"TODAY_Inflow_Rate"},
|
||||
{'name':"kWh",'tag':"TODAY_kWh"},
|
||||
{'name':"kWh Regen",'tag':"TODAY_kWh_Regen"},
|
||||
{'name':"Lifting Cost",'tag':"TODAY_Lifting_Cost"},
|
||||
{'name':"Peak Load",'tag':"TODAY_Max_Load"},
|
||||
{'name':"Min Load",'tag':"TODAY_Min_Load"},
|
||||
{'name':"Percent Run",'tag':"TODAY_Percent_Run"},
|
||||
{'name':"Polished Rod HP",'tag':"TODAY_Polished_Rod_HP"},
|
||||
{'name':"Calculated Production",'tag':"TODAY_Production_Calculated"},
|
||||
{'name':"Projected Production",'tag':"TODAY_Production_Projected"},
|
||||
{'name':"Pump HP",'tag':"TODAY_Pump_HP"},
|
||||
{'name':"Pump Intake Presure",'tag':"TODAY_Pump_Intake_Pressure"},
|
||||
{'name':"Surface Stroke Length",'tag':"TODAY_Surface_StrokeLength"},
|
||||
{'name':"Tubing Movement",'tag':"TODAY_Tubing_Movement"}
|
||||
{'name':"Average SPM",'tag':"TODAY_Average_SPM", 'min':0, 'max': 20, 'units':'PSI'},
|
||||
{'name':"Downhole Net Stroke",'tag':"TODAY_Downhole_NetStroke", 'min':0, 'max':150, 'units':'PSI'},
|
||||
{'name':"Electricity Cost",'tag':"TODAY_Electricity_Cost", 'min':0, 'max':100, 'units':'PSI'},
|
||||
{'name':"Fluid Level",'tag':"TODAY_Fluid_Above_Pump", 'min':0, 'max':10000, 'units':'PSI'},
|
||||
{'name':"Inflow Rate",'tag':"TODAY_Inflow_Rate", 'min':0, 'max':100, 'units':'PSI'},
|
||||
{'name':"kWh",'tag':"TODAY_kWh", 'min':0, 'max':100, 'units':'PSI'},
|
||||
{'name':"kWh Regen",'tag':"TODAY_kWh_Regen", 'min':0, 'max':100, 'units':'PSI'},
|
||||
{'name':"Lifting Cost",'tag':"TODAY_Lifting_Cost", 'min':0, 'max':100, 'units':'PSI'},
|
||||
{'name':"Peak Load",'tag':"TODAY_Max_Load", 'min':0, 'max':50000, 'units':'PSI'},
|
||||
{'name':"Min Load",'tag':"TODAY_Min_Load", 'min':0, 'max':50000, 'units':'PSI'},
|
||||
{'name':"Percent Run",'tag':"TODAY_Percent_Run", 'min':0, 'max':100, 'units':'PSI'},
|
||||
{'name':"Polished Rod HP",'tag':"TODAY_Polished_Rod_HP", 'min':0, 'max':25, 'units':'PSI'},
|
||||
{'name':"Calculated Production",'tag':"TODAY_Production_Calculated", 'min':0, 'max':500, 'units':'PSI'},
|
||||
{'name':"Projected Production",'tag':"TODAY_Production_Projected", 'min':0, 'max':500, 'units':'PSI'},
|
||||
{'name':"Pump HP",'tag':"TODAY_Pump_HP", 'min':0, 'max':25, 'units':'PSI'},
|
||||
{'name':"Pump Intake Presure",'tag':"TODAY_Pump_Intake_Pressure", 'min':0, 'max':5000, 'units':'PSI'},
|
||||
{'name':"Surface Stroke Length",'tag':"TODAY_Surface_StrokeLength", 'min':0, 'max':150, 'units':'PSI'},
|
||||
{'name':"Tubing Movement",'tag':"TODAY_Tubing_Movement", 'min':0, 'max':150, 'units':'PSI'}
|
||||
]
|
||||
|
||||
main_plc = getMainPLC()
|
||||
print("PLC IP ADDRESS = {}".format(main_plc['address']))
|
||||
outList = []
|
||||
for tag in today_tags:
|
||||
try:
|
||||
val = readTag(main_plc['address'], tag['tag'])[0]
|
||||
print("READING {}: {}".format(tag['tag'], val))
|
||||
if not math.isnan(val):
|
||||
outList.append({'name':tag['name'], 'value':val})
|
||||
outList.append({'name':tag['name'], 'value':val, 'max':tag['max'], 'min': tag['min'], 'units': tag['units']})
|
||||
except Exception as e:
|
||||
print("Error while reading total: {}".format(e))
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
poconsole.controller('dashboardCtrl', function($scope, $route, $http, Page, $log, Tag) {
|
||||
$log.info("Opened Dashboard");
|
||||
Page.setTitle('Dashboard');
|
||||
Page.setPage('dashboard');
|
||||
$scope.loadDashboard = function(){
|
||||
@@ -35,3 +34,17 @@ poconsole.controller('dashboardCtrl', function($scope, $route, $http, Page, $log
|
||||
|
||||
|
||||
});
|
||||
|
||||
poconsole.controller('todaysTotalsCtrl', function($scope, $route, $http, Page, $log, Tag) {
|
||||
Page.setTitle('Totals');
|
||||
Page.setPage('dashboard');
|
||||
$scope.loadTotals = function(){
|
||||
$scope.loading = true;
|
||||
var getTodayTotals = Tag.getDailyTotals();
|
||||
getTodayTotals.then(function(d){
|
||||
$scope.loading = false;
|
||||
$scope.total_values = d;
|
||||
});
|
||||
};
|
||||
$scope.loadTotals();
|
||||
});
|
||||
|
||||
@@ -34,6 +34,9 @@ tagserver.config([
|
||||
}).when('/notes', {
|
||||
templateUrl: '/templates/notes.html',
|
||||
controller: 'notesCtrl'
|
||||
}).when('/totals', {
|
||||
templateUrl: '/templates/totals.html',
|
||||
controller: 'todaysTotalsCtrl'
|
||||
}).when('/', {
|
||||
templateUrl: '/templates/dashboard.html',
|
||||
controller: 'dashboardCtrl'
|
||||
|
||||
@@ -145,5 +145,13 @@ poconsole.factory('Tag',function($q, $http, $log, dateConversion){
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
service.getDailyTotals = function(){
|
||||
var deferred = $q.defer();
|
||||
$http.get('/api/today_totals').success(function(data) {
|
||||
deferred.resolve(data);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
return service;
|
||||
});
|
||||
|
||||
@@ -19,7 +19,14 @@
|
||||
</div>
|
||||
|
||||
<div ng-if="!error" class="container">
|
||||
|
||||
<div class="row">
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="active"><a href="/#/">Current Tag Values</a></li>
|
||||
<li><a href="/#/">Last Stroke</a></li>
|
||||
<li><a href="/#/totals">Daily Totals</a></li>
|
||||
</ul>
|
||||
<br />
|
||||
<button ng-click="loadDashboard()" class="btn btn-large btn-success"><i class="fa fa-refresh"></i> Reload Dashboard</button>
|
||||
<a href="/csv/all" class="btn btn-large btn-primary"><i class="fa fa-download"></i> Download All Data</a>
|
||||
<div ng-repeat="val in vals">
|
||||
|
||||
31
app/static/templates/totals.html
Normal file
31
app/static/templates/totals.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<div ng-if="loading" class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12 well" style="text-align:center;">
|
||||
<h1>Loading Totals...</h1>
|
||||
<img class="img-responsive" src="/images/loading.gif" style="margin:0 auto;"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="!loading">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li><a href="/#/">Current Tag Values</a></li>
|
||||
<li><a href="/#/">Last Stroke</a></li>
|
||||
<li class="active"><a href="/#/totals">Daily Totals</a></li>
|
||||
</ul>
|
||||
<br />
|
||||
<button ng-click="loadTotals()" class="btn btn-large btn-success"><i class="fa fa-refresh"></i> Reload Dashboard</button>
|
||||
<div ng-repeat="val in total_values">
|
||||
<div class="col-md-4" style="height:200px; margin-bottom:40px;">
|
||||
<just-gage id="{{val.name}}" min='val.min' max='val.max' value='val.value' options="{label:val.units,title:val.name, decimals:2, refreshAnimationType:'bounce', startAnimationType:'bounce'}"></just-gage>
|
||||
<div style="text-align:center">
|
||||
<h5>{{ val.datetime | date: 'medium'}}</h5>
|
||||
<a href="/#/tag/{{val.tag_id}}" class="btn btn-large btn-primary"><i class="fa fa-line-chart"></i> View Data</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user