Dashboard works, but cards still need a bit of work
This commit is contained in:
@@ -137,13 +137,16 @@ app.post '/json/notes/update', json.updateNote
|
||||
app.get '/json/pythonStatus', json.checkPythonScripts
|
||||
app.get '/json/pythonRestart', json.restartPythonScripts
|
||||
|
||||
# //-- Tag Values -- //
|
||||
app.get '/json/tagvalues', json.getTagValues
|
||||
app.get '/json/tagvalues/:unixTS', json.getValuesClosestTo
|
||||
|
||||
app.get '/json/:folder/:file', json.singleCardOldway
|
||||
app.get '/json/:folder/:file/taper', json.taper
|
||||
app.post '/json/cards', json.multipleCards
|
||||
app.post '/setup', json.updateSetup
|
||||
|
||||
# //-- Tag Values -- //
|
||||
app.get '/json/tagvalues', json.getTagValues
|
||||
|
||||
|
||||
app.get '*', angular
|
||||
|
||||
|
||||
@@ -151,30 +151,6 @@ wellCtrls.factory('json',function($q, $http, $log){
|
||||
var getFileList = function(date) {
|
||||
var deferred = $q.defer();
|
||||
$http.get('/json/all/' + date).success(function(data) {
|
||||
// var fileList = data.cards;
|
||||
// var files = fileList.map(function(x){
|
||||
// // {"id":481,"Card_ID":4324,"Stroke_Time":"2015-09-21T08:54:14.000Z","Fillage_Percent":100}
|
||||
// var fname = x.split('.')[0];
|
||||
// var reg = /(\d{4})(\d{2})(\d{2})_(\d{2})(\d{2})(\d{2})_(\d*)_(\w*)_(\d*)-(\d*).csv/;
|
||||
// var regArray = reg.exec(x);
|
||||
// var fyear = regArray[1];
|
||||
// var fmonth = regArray[2];
|
||||
// var fday = regArray[3];
|
||||
// var fhour = regArray[4];
|
||||
// var fmin = regArray[5];
|
||||
// var fsec = regArray[6];
|
||||
// var ftype = regArray[8];
|
||||
// var ffillage = parseFloat(regArray[9] + "." + regArray[10]);
|
||||
// var fdatetime = fmonth + '/' + fday + '/' + fyear + ' ' + fhour + ':' + fmin + ':' + fsec;
|
||||
// var fdate = fyear + fmonth + fday;
|
||||
//
|
||||
// return {
|
||||
// filename: fname,
|
||||
// datetime: fdatetime,
|
||||
// fillage: ffillage,
|
||||
// type: ftype
|
||||
// };
|
||||
// });
|
||||
deferred.resolve({
|
||||
files: data.cards
|
||||
});
|
||||
@@ -182,6 +158,26 @@ wellCtrls.factory('json',function($q, $http, $log){
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var getLatestCard = function() {
|
||||
var deferred = $q.defer();
|
||||
$http.get('/json/latestcard/').success(function(data) {
|
||||
deferred.resolve({
|
||||
data: data
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var getCard = function(id) {
|
||||
var deferred = $q.defer();
|
||||
$http.get('/json/card/'+ id.toString()).success(function(data) {
|
||||
deferred.resolve({
|
||||
data: data
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var getTotals = function() {
|
||||
var deferred = $q.defer();
|
||||
$http.get('/json/totals').success(function(data) {
|
||||
@@ -380,6 +376,48 @@ wellCtrls.factory('json',function($q, $http, $log){
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var getCurrentTagValues = function(){
|
||||
var deferred = $q.defer();
|
||||
$http.get('/json/tagvalues').success(function(data) {
|
||||
deferred.resolve({
|
||||
data: data
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var getTagsAtTime = function(unixTS){
|
||||
var deferred = $q.defer();
|
||||
$http.get('/json/tagvalues/' + unixTS).success(function(data) {
|
||||
deferred.resolve({
|
||||
data: data
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var getCurrentStatus = function(){
|
||||
var deferred = $q.defer();
|
||||
$http.get('/json/status').success(function(data) {
|
||||
deferred.resolve({
|
||||
data: data
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var getStatusAtTime = function(unixTS){
|
||||
var deferred = $q.defer();
|
||||
$http.get('/json/status/' + unixTS).success(function(data) {
|
||||
deferred.resolve({
|
||||
data: data
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
return {
|
||||
getDateList: getDateList,
|
||||
@@ -390,6 +428,8 @@ wellCtrls.factory('json',function($q, $http, $log){
|
||||
getPythonStatus: getPythonStatus,
|
||||
restartPythonScripts: restartPythonScripts,
|
||||
getFileList: getFileList,
|
||||
getLatestCard: getLatestCard,
|
||||
getCard: getCard,
|
||||
getFilePage: getFilePage,
|
||||
getCardCount: getCardCount,
|
||||
getTotals: getTotals,
|
||||
@@ -417,7 +457,14 @@ wellCtrls.factory('json',function($q, $http, $log){
|
||||
deleteWellTest: deleteWellTest,
|
||||
undeleteWellTest: undeleteWellTest,
|
||||
updateWellTest: updateWellTest,
|
||||
getDeletedWellTests: getDeletedWellTests
|
||||
getDeletedWellTests: getDeletedWellTests,
|
||||
|
||||
// Tag Data Functions
|
||||
getCurrentTagValues: getCurrentTagValues,
|
||||
getTagsAtTime: getTagsAtTime,
|
||||
|
||||
getCurrentStatus: getCurrentStatus,
|
||||
getStatusAtTime: getStatusAtTime
|
||||
};
|
||||
});
|
||||
|
||||
@@ -599,7 +646,31 @@ wellCtrls.controller('dashboardCtrl', function($scope, $route, $http, $routePara
|
||||
// });
|
||||
});
|
||||
$scope.dashboard = function() {
|
||||
$http.get('/json/latestCard').success(function(cData) {
|
||||
var getCurrentTagValues = json.getCurrentTagValues();
|
||||
getCurrentTagValues.then(function(d){
|
||||
var data = d.data;
|
||||
if (data.status == "OK"){
|
||||
$scope.tagValues = {};
|
||||
for(var i=0; i < data.vals.length; i++){
|
||||
$scope.tagValues[data.vals[i].name] = data.vals[i];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var getCurrentStatus = json.getCurrentStatus();
|
||||
getCurrentStatus.then(function(s){
|
||||
var sData = s.data;
|
||||
sData.datetime = new Date(sData.datetime * 1000);
|
||||
console.log(sData);
|
||||
|
||||
$scope.status = sData.run_status;
|
||||
$scope.status_datetime = new Date(sData.datetime);
|
||||
});
|
||||
|
||||
|
||||
var getLatestCard = json.getLatestCard();
|
||||
getLatestCard.then(function(cData){
|
||||
cData = cData.data;
|
||||
$scope.cardData = cData.card_data[0];
|
||||
//$scope.cardData.dateTime = new Date($scope.cardData.localtime.replace(" ","T"));
|
||||
|
||||
@@ -607,10 +678,12 @@ wellCtrls.controller('dashboardCtrl', function($scope, $route, $http, $routePara
|
||||
return {position:cData.card_data[0].Surface_Position[i], load:cData.card_data[0].Surface_Load[i]};
|
||||
});
|
||||
$scope.surface.push($scope.surface[0]);
|
||||
|
||||
$scope.downhole = cData.card_data[0].Downhole_Position.map(function(a, i){
|
||||
return {position:cData.card_data[0].Downhole_Position[i], load:cData.card_data[0].Downhole_Load[i]};
|
||||
});
|
||||
$scope.downhole.push($scope.downhole[0]);
|
||||
|
||||
var limits = {
|
||||
sMaxPos: $scope.surface.map(function(x){return x.position;}).reduce(function(y,z){return Math.max(y,z);})+ 20,
|
||||
sMinPos: $scope.surface.map(function(x){return x.position;}).reduce(function(y,z){return Math.min(y,z);})- 20,
|
||||
@@ -623,7 +696,7 @@ wellCtrls.controller('dashboardCtrl', function($scope, $route, $http, $routePara
|
||||
$scope.card_graph_data = {
|
||||
surface: $scope.surface,
|
||||
downhole: $scope.downhole
|
||||
}
|
||||
};
|
||||
|
||||
$scope.surfaceOptions = {
|
||||
axes: {
|
||||
@@ -713,20 +786,6 @@ wellCtrls.controller('dashboardCtrl', function($scope, $route, $http, $routePara
|
||||
};
|
||||
});
|
||||
|
||||
var statusMap = {
|
||||
0:"Stopped",
|
||||
1:"Running",
|
||||
2:"Pumped Off",
|
||||
3:"Faulted",
|
||||
4:"Starting",
|
||||
5:"Recovering",
|
||||
100:"Read Error",
|
||||
9999:"PLC Error"
|
||||
};
|
||||
$http.get('/json/status/').success(function(data) {
|
||||
$scope.wellStatus = statusMap[parseInt(data.status)];
|
||||
var sDt = new Date(data.date);
|
||||
});
|
||||
var getTotals = json.getTotals();
|
||||
getTotals.then(function(data){
|
||||
$scope.totals = data.totals;
|
||||
@@ -809,7 +868,7 @@ wellCtrls.controller('cardDataCtrl', function($scope, $http, $routeParams, json,
|
||||
$scope.card_graph_data = {
|
||||
surface: $scope.surface,
|
||||
downhole: $scope.downhole
|
||||
}
|
||||
};
|
||||
|
||||
$scope.surfaceOptions = {
|
||||
axes: {
|
||||
|
||||
@@ -13,52 +13,53 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<pre>{{tagValues}}</pre>
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="active"><a href="/">Last Stroke</a></li>
|
||||
<li><a href="/#/totals">Today's Totals</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 style="text-align:center;">{{cardData.well_name}} Dashboard - Stroke {{cardData.Card_ID}}</h1>
|
||||
<h1 style="text-align:center;">Dashboard - Stroke {{cardData.Card_ID}}</h1>
|
||||
<div style="text-align:center;"><button class="btn btn-primary active" id="refreshButton" ng-click="dashboard()">Refresh Data</button></div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div id="Status" class="gauge well" style="width:95%; text-align:center; margin:10px;"><h4>Status: {{wellStatus}}</h4><h6>at {{statusISO | date: "medium"}}</h6></div>
|
||||
<div id="Status" class="gauge well" style="width:95%; text-align:center; margin:10px;"><h4>Status: {{status}}</h4><h6>Last Changed: {{status_datetime | date: "medium"}}</h6></div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div id="FillageGauge" class="gauge well" style="width:95%; text-align:center; margin:10px;">
|
||||
<h4>Pump Fillage:</h4>
|
||||
<h5>{{cardData.Fillage_Percent | number:3}} %</h5>
|
||||
<h5>{{tagValues.fillage_percent.val | number:3}} %</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div id="FAPGauge" class="gauge well" style="width:95%; text-align:center; margin:10px;">
|
||||
<h4>Fluid Above Pump:</h4>
|
||||
<h5>{{cardData.Fluid_Level | number:3}} ft.</h5>
|
||||
<h5>{{tagValues.fluid_level.val | number:3}} ft.</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div id="PRHPGauge" class="gauge well" style="width:95%; text-align:center; margin:10px;">
|
||||
<h4>Polished Rod HP:</h4>
|
||||
<h5>{{cardData.Polished_Rod_HP | number:3}} HP</h5>
|
||||
<h5>{{tagValues.polished_rod_hp.val | number:3}} HP</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div id="PMPHPGauge" class="gauge well" style="width:95%; text-align:center; margin:10px;">
|
||||
<h4>Pump HP:</h4>
|
||||
<h5>{{cardData.Pump_HP | number:3}} HP</h5>
|
||||
<h5>{{tagValues.pump_hp.val | number:3}} HP</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div id="SpeedGauge" class="gauge well" style="width:95%; text-align:center; margin:10px;">
|
||||
<h4>Speed:</h4>
|
||||
<h5>{{cardData.SPM | number:3}} SPM</h5>
|
||||
<h5>{{tagValues.spm.val | number:3}} SPM</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div id="FluidLoadGauge" class="gauge well" style="width:95%; text-align:center; margin:10px;">
|
||||
<h4>Fluid Load:</h4>
|
||||
<h5>{{cardData.downhole_fluid_load | number:3}} lbs.</h5>
|
||||
<h5>{{tagValues.downhole_fluid_load.val | number:3}} lbs.</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
@@ -77,26 +78,26 @@
|
||||
|
||||
<div class="col-sm-12">
|
||||
<div class="progress" style="margin:10px;">
|
||||
<div class="progress-bar progress-bar-striped active" id="surface_stroke_length" role="progressbar" aria-valuenow="{{ cardData.surface_stroke_length }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ cardData.surface_stroke_length }}%;">
|
||||
Surface Stroke Length: {{ cardData.Surface_Stroke_Length }} in.
|
||||
<div class="progress-bar progress-bar-striped active" id="surface_stroke_length" role="progressbar" aria-valuenow="{{ tagValues.surface_stroke_length.val }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ tagValues.surface_stroke_length.val }}%;">
|
||||
Surface Stroke Length: {{ tagValues.surface_stroke_length.val }} in.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="progress" style="margin:10px;">
|
||||
<div class="progress-bar progress-bar-striped active" id="downhole_gross_stroke" role="progressbar" aria-valuenow="{{ cardData.donwhole_gross_stroke }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ cardData.downhole_gross_stroke }}%;">
|
||||
Downhole Gross Stroke: {{ cardData.Downhole_Gross_Stroke }} in.
|
||||
<div class="progress-bar progress-bar-striped active" id="downhole_gross_stroke" role="progressbar" aria-valuenow="{{ tagValues.donwhole_gross_stroke.val }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ tagValues.downhole_gross_stroke.val }}%;">
|
||||
Downhole Gross Stroke: {{ tagValues.downhole_gross_stroke.val }} in.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="progress" style="margin:10px;">
|
||||
<div class="progress-bar progress-bar-striped active" id="downhole_adjusted_gross_stroke" role="progressbar" aria-valuenow="{{ cardData.downhole_adjusted_gross_stroke }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ cardData.downhole_adjusted_gross_stroke }}%;">
|
||||
Downhole Adjusted Gross Stroke: {{ cardData.Downhole_Adjusted_Gross_Stroke }} in.
|
||||
<div class="progress-bar progress-bar-striped active" id="downhole_adjusted_gross_stroke" role="progressbar" aria-valuenow="{{ tagValues.downhole_adjusted_gross_stroke.val }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ tagValues.downhole_adjusted_gross_stroke.val }}%;">
|
||||
Downhole Adjusted Gross Stroke: {{ tagValues.downhole_adjusted_gross_stroke.val }} in.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="progress" style="margin:10px;">
|
||||
<div class="progress-bar progress-bar-striped active" id="downhole_net_stroke" role="progressbar" aria-valuenow="{{ cardData.downhole_net_stroke }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ cardData.downhole_net_stroke }}%;">
|
||||
Downhole Net Stroke: {{ cardData.Downhole_Net_Stroke }} in.
|
||||
<div class="progress-bar progress-bar-striped active" id="downhole_net_stroke" role="progressbar" aria-valuenow="{{ tagValues.downhole_net_stroke.val }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ tagValues.downhole_net_stroke.val }}%;">
|
||||
Downhole Net Stroke: {{ tagValues.downhole_net_stroke.val }} in.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -104,18 +105,17 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<h1>Surface Card</h1>
|
||||
<div class="surfaceCard" style="height:500px">
|
||||
<linechart data="card_graph_data" options="surfaceOptions"></linechart>
|
||||
</div>
|
||||
<pre>{{cardData}}</pre>
|
||||
<h1>Surface Card</h1>
|
||||
<div class="surfaceCard" style="height:500px">
|
||||
<linechart data="card_graph_data" options="surfaceOptions"></linechart>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12">
|
||||
<h1>Downhole Card</h1>
|
||||
<div class="downholeCard" style="height:500px">
|
||||
<linechart data="card_graph_data" options="downholeOptions"></linechart>
|
||||
</div>
|
||||
<h1>Downhole Card</h1>
|
||||
<div class="downholeCard" style="height:500px">
|
||||
<linechart data="card_graph_data" options="downholeOptions"></linechart>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,59 +1,45 @@
|
||||
|
||||
var wellCtrls = angular.module('wellCtrls', ['n3-line-chart', 'ui.bootstrap', 'ngAnimate', 'ngJustGage']);
|
||||
wellCtrls = angular.module 'wellCtrls', ['n3-line-chart', 'ui.bootstrap', 'ngAnimate', 'ngJustGage']
|
||||
|
||||
var dateConversion = function(raw){
|
||||
var converted = raw.slice(4, 6) + '/' + raw.slice(6, 8) + '/' + raw.slice(0, 4);
|
||||
return {
|
||||
dateConversion = (raw) ->
|
||||
converted = raw.slice(4, 6) + '/' + raw.slice(6, 8) + '/' + raw.slice(0, 4);
|
||||
x =
|
||||
conv: converted,
|
||||
unconv: raw
|
||||
};
|
||||
};
|
||||
x
|
||||
|
||||
var pad = function(str, max) {
|
||||
str = str.toString();
|
||||
if (str.length < max) {
|
||||
return pad('0' + str, max);
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
};
|
||||
pad = (str, max) ->
|
||||
str = str.toString()
|
||||
if str.length < max
|
||||
x = pad '0' + str, max
|
||||
else
|
||||
x = str
|
||||
x
|
||||
|
||||
wellCtrls.factory('Page', function($log) {
|
||||
var title = 'default';
|
||||
var page = 'default';
|
||||
return {
|
||||
title: function() {
|
||||
return title;
|
||||
},
|
||||
setTitle: function(newTitle) {
|
||||
title = newTitle;
|
||||
},
|
||||
page: function() {
|
||||
return page;
|
||||
},
|
||||
setPage: function(newPage) {
|
||||
page = newPage;
|
||||
}
|
||||
};
|
||||
});
|
||||
wellCtrls.factory 'Page', ($log) ->
|
||||
title = 'default'
|
||||
page = 'default'
|
||||
ret =
|
||||
title: () ->
|
||||
title
|
||||
setTitle: (newTitle) ->
|
||||
title = newTitle
|
||||
page: () ->
|
||||
page
|
||||
setPage: (newPage) ->
|
||||
page = newPage
|
||||
|
||||
wellCtrls.factory('Alerts', function($log) {
|
||||
var alerts = [];
|
||||
return {
|
||||
add: function(alt) {
|
||||
alerts.push(alt);
|
||||
},
|
||||
remove: function(indx) {
|
||||
alerts.splice(indx, 1);
|
||||
},
|
||||
clear: function() {
|
||||
alerts = [];
|
||||
},
|
||||
get: function() {
|
||||
return alerts;
|
||||
}
|
||||
};
|
||||
});
|
||||
wellCtrls.factory 'Alerts', ($log) ->
|
||||
alerts = []
|
||||
ret =
|
||||
add: (alt) ->
|
||||
alerts.push alt
|
||||
remove: (indx) ->
|
||||
alerts.splice indx, 1
|
||||
clear: () ->
|
||||
alerts = []
|
||||
get: () ->
|
||||
alerts;
|
||||
|
||||
wellCtrls.factory('json',function($q, $http, $log){
|
||||
var getDateList = function() {
|
||||
@@ -151,30 +137,6 @@ wellCtrls.factory('json',function($q, $http, $log){
|
||||
var getFileList = function(date) {
|
||||
var deferred = $q.defer();
|
||||
$http.get('/json/all/' + date).success(function(data) {
|
||||
// var fileList = data.cards;
|
||||
// var files = fileList.map(function(x){
|
||||
// // {"id":481,"Card_ID":4324,"Stroke_Time":"2015-09-21T08:54:14.000Z","Fillage_Percent":100}
|
||||
// var fname = x.split('.')[0];
|
||||
// var reg = /(\d{4})(\d{2})(\d{2})_(\d{2})(\d{2})(\d{2})_(\d*)_(\w*)_(\d*)-(\d*).csv/;
|
||||
// var regArray = reg.exec(x);
|
||||
// var fyear = regArray[1];
|
||||
// var fmonth = regArray[2];
|
||||
// var fday = regArray[3];
|
||||
// var fhour = regArray[4];
|
||||
// var fmin = regArray[5];
|
||||
// var fsec = regArray[6];
|
||||
// var ftype = regArray[8];
|
||||
// var ffillage = parseFloat(regArray[9] + "." + regArray[10]);
|
||||
// var fdatetime = fmonth + '/' + fday + '/' + fyear + ' ' + fhour + ':' + fmin + ':' + fsec;
|
||||
// var fdate = fyear + fmonth + fday;
|
||||
//
|
||||
// return {
|
||||
// filename: fname,
|
||||
// datetime: fdatetime,
|
||||
// fillage: ffillage,
|
||||
// type: ftype
|
||||
// };
|
||||
// });
|
||||
deferred.resolve({
|
||||
files: data.cards
|
||||
});
|
||||
@@ -182,11 +144,31 @@ wellCtrls.factory('json',function($q, $http, $log){
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var getLatestCard = function() {
|
||||
var deferred = $q.defer();
|
||||
$http.get('/json/latestcard/').success(function(data) {
|
||||
deferred.resolve({
|
||||
data: data
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var getCard = function(id) {
|
||||
var deferred = $q.defer();
|
||||
$http.get('/json/card/'+ id.toString()).success(function(data) {
|
||||
deferred.resolve({
|
||||
data: data
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var getTotals = function() {
|
||||
var deferred = $q.defer();
|
||||
$http.get('/json/totals').success(function(data) {
|
||||
var totalRet = {};
|
||||
var vals = data.totals.values;
|
||||
var vals = data.totals;
|
||||
i=0;
|
||||
while (i < vals.length){
|
||||
totalRet[vals[i].name] = vals[i].value;
|
||||
@@ -390,6 +372,8 @@ wellCtrls.factory('json',function($q, $http, $log){
|
||||
getPythonStatus: getPythonStatus,
|
||||
restartPythonScripts: restartPythonScripts,
|
||||
getFileList: getFileList,
|
||||
getLatestCard: getLatestCard,
|
||||
getCard: getCard,
|
||||
getFilePage: getFilePage,
|
||||
getCardCount: getCardCount,
|
||||
getTotals: getTotals,
|
||||
@@ -600,15 +584,15 @@ wellCtrls.controller('dashboardCtrl', function($scope, $route, $http, $routePara
|
||||
});
|
||||
$scope.dashboard = function() {
|
||||
$http.get('/json/latestCard').success(function(cData) {
|
||||
$scope.cardData = cData.card_data;
|
||||
$scope.cardData = cData.card_data[0];
|
||||
//$scope.cardData.dateTime = new Date($scope.cardData.localtime.replace(" ","T"));
|
||||
|
||||
$scope.surface = cData.card_data.Surface_Position.map(function(a, i){
|
||||
return {position:cData.card_data.Surface_Position[i], load:cData.card_data.Surface_Load[i]};
|
||||
$scope.surface = cData.card_data[0].Surface_Position.map(function(a, i){
|
||||
return {position:cData.card_data[0].Surface_Position[i], load:cData.card_data[0].Surface_Load[i]};
|
||||
});
|
||||
$scope.surface.push($scope.surface[0]);
|
||||
$scope.downhole = cData.card_data.Downhole_Position.map(function(a, i){
|
||||
return {position:cData.card_data.Downhole_Position[i], load:cData.card_data.Downhole_Load[i]};
|
||||
$scope.downhole = cData.card_data[0].Downhole_Position.map(function(a, i){
|
||||
return {position:cData.card_data[0].Downhole_Position[i], load:cData.card_data[0].Downhole_Load[i]};
|
||||
});
|
||||
$scope.downhole.push($scope.downhole[0]);
|
||||
var limits = {
|
||||
@@ -620,6 +604,10 @@ wellCtrls.controller('dashboardCtrl', function($scope, $route, $http, $routePara
|
||||
dMinLoad: $scope.downhole.map(function(x){return x.load;}).reduce(function(y,z){return Math.min(y,z);})- 2000,
|
||||
};
|
||||
$scope.limits = limits;
|
||||
$scope.card_graph_data = {
|
||||
surface: $scope.surface,
|
||||
downhole: $scope.downhole
|
||||
}
|
||||
|
||||
$scope.surfaceOptions = {
|
||||
axes: {
|
||||
@@ -642,12 +630,14 @@ wellCtrls.controller('dashboardCtrl', function($scope, $route, $http, $routePara
|
||||
},
|
||||
series: [
|
||||
{
|
||||
y: 'load',
|
||||
color: 'steelblue',
|
||||
thickness: '2px',
|
||||
type: 'area',
|
||||
striped: true,
|
||||
label: 'Surface Card'
|
||||
axis:"y",
|
||||
key: 'load',
|
||||
dataset: 'surface',
|
||||
color: 'steelblue',
|
||||
type: 'area',
|
||||
striped: true,
|
||||
label: 'Surface Card',
|
||||
id: "surfaceCard"
|
||||
}
|
||||
],
|
||||
lineMode: 'linear',
|
||||
@@ -683,12 +673,14 @@ wellCtrls.controller('dashboardCtrl', function($scope, $route, $http, $routePara
|
||||
},
|
||||
series: [
|
||||
{
|
||||
y: 'load',
|
||||
color: 'steelblue',
|
||||
thickness: '2px',
|
||||
type: 'area',
|
||||
striped: true,
|
||||
label: 'Downhole Card'
|
||||
axis:"y",
|
||||
key: 'load',
|
||||
dataset: 'downhole',
|
||||
color: 'steelblue',
|
||||
type: 'area',
|
||||
striped: true,
|
||||
label: 'Downhole Card',
|
||||
id: "downholeCard"
|
||||
}
|
||||
],
|
||||
lineMode: 'linear',
|
||||
@@ -703,8 +695,6 @@ wellCtrls.controller('dashboardCtrl', function($scope, $route, $http, $routePara
|
||||
drawDots: true,
|
||||
columnsHGap: 5
|
||||
};
|
||||
$scope.surfaceData = $scope.surface;
|
||||
$scope.downholeData = $scope.downhole;
|
||||
});
|
||||
|
||||
var statusMap = {
|
||||
@@ -719,10 +709,7 @@ wellCtrls.controller('dashboardCtrl', function($scope, $route, $http, $routePara
|
||||
};
|
||||
$http.get('/json/status/').success(function(data) {
|
||||
$scope.wellStatus = statusMap[parseInt(data.status)];
|
||||
var sDt = data.date.split('_');
|
||||
$scope.statusDate = dateConversion(sDt[[0]]);
|
||||
$scope.statusTime = sDt[1].slice(0, 2) + ':' + sDt[1].slice(2, 4) + ':' + sDt[1].slice(4, 6);
|
||||
$scope.statusISO = data.ISOdate;
|
||||
var sDt = new Date(data.date);
|
||||
});
|
||||
var getTotals = json.getTotals();
|
||||
getTotals.then(function(data){
|
||||
@@ -803,6 +790,10 @@ wellCtrls.controller('cardDataCtrl', function($scope, $http, $routeParams, json,
|
||||
dMinLoad: $scope.downhole.map(function(x){return x.load;}).reduce(function(y,z){return Math.min(y,z);})- 2000,
|
||||
};
|
||||
$scope.limits = limits;
|
||||
$scope.card_graph_data = {
|
||||
surface: $scope.surface,
|
||||
downhole: $scope.downhole
|
||||
}
|
||||
|
||||
$scope.surfaceOptions = {
|
||||
axes: {
|
||||
@@ -813,24 +804,24 @@ wellCtrls.controller('cardDataCtrl', function($scope, $http, $routeParams, json,
|
||||
},
|
||||
type: 'linear',
|
||||
min: limits.sMinPos,
|
||||
max: limits.sMaxPos,
|
||||
ticks: 7
|
||||
max: limits.sMaxPos
|
||||
},
|
||||
y: {
|
||||
type: 'linear',
|
||||
min: limits.sMinLoad,
|
||||
max: limits.sMaxLoad,
|
||||
ticks: 5
|
||||
max: limits.sMaxLoad
|
||||
}
|
||||
},
|
||||
series: [
|
||||
{
|
||||
y: 'load',
|
||||
axis:"y",
|
||||
key: 'load',
|
||||
dataset: 'surface',
|
||||
color: 'steelblue',
|
||||
thickness: '2px',
|
||||
type: 'area',
|
||||
striped: true,
|
||||
label: 'Surface Card'
|
||||
label: 'Surface Card',
|
||||
id: "surfaceCard"
|
||||
}
|
||||
],
|
||||
lineMode: 'linear',
|
||||
@@ -840,10 +831,7 @@ wellCtrls.controller('cardDataCtrl', function($scope, $http, $routeParams, json,
|
||||
formatter: function(x, y, series) {
|
||||
return 'Position: ' + x + ' in., Load: ' + y + ' lb.';
|
||||
}
|
||||
},
|
||||
drawLegend: true,
|
||||
drawDots: true,
|
||||
columnsHGap: 5
|
||||
}
|
||||
};
|
||||
$scope.downholeOptions = {
|
||||
axes: {
|
||||
@@ -866,12 +854,14 @@ wellCtrls.controller('cardDataCtrl', function($scope, $http, $routeParams, json,
|
||||
},
|
||||
series: [
|
||||
{
|
||||
y: 'load',
|
||||
color: 'steelblue',
|
||||
thickness: '2px',
|
||||
type: 'area',
|
||||
striped: true,
|
||||
label: 'Downhole Card'
|
||||
axis:"y",
|
||||
key: 'load',
|
||||
dataset: 'downhole',
|
||||
color: 'steelblue',
|
||||
type: 'area',
|
||||
striped: true,
|
||||
label: 'Downhole Card',
|
||||
id: "downholeCard"
|
||||
}
|
||||
],
|
||||
lineMode: 'linear',
|
||||
@@ -886,8 +876,6 @@ wellCtrls.controller('cardDataCtrl', function($scope, $http, $routeParams, json,
|
||||
drawDots: true,
|
||||
columnsHGap: 5
|
||||
};
|
||||
$scope.surfaceData = $scope.surface;
|
||||
$scope.downholeData = $scope.downhole;
|
||||
$scope.loading = false;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1341,3 +1341,26 @@ exports.getTagValues = (req, res) ->
|
||||
status:"OK"
|
||||
vals:rows
|
||||
undefined
|
||||
|
||||
|
||||
exports.getValuesClosestTo = (req, res) ->
|
||||
sqlite3 = require('sqlite3').verbose()
|
||||
db = new sqlite3.Database(dbFile)
|
||||
db.serialize ()->
|
||||
query = 'SELECT * FROM tag_vals WHERE name IN (SELECT name FROM tag_vals GROUP BY name) ORDER BY abs(dtime - ?) LIMIT (SELECT COUNT(DISTINCT name) FROM tag_vals)'
|
||||
prepQuery = db.prepare query
|
||||
prepQuery.all req.params.unixTS, (err, rows)->
|
||||
prepQuery.finalize()
|
||||
db.close()
|
||||
if err
|
||||
errMsg =
|
||||
status:"error"
|
||||
message:err
|
||||
query:query
|
||||
console.log errMsg
|
||||
res.json errMsg
|
||||
else
|
||||
res.json
|
||||
status: "OK"
|
||||
vals: rows
|
||||
undefined
|
||||
|
||||
Reference in New Issue
Block a user