| xqd
@@ -30,24 +30,31 @@ starter.controller('loginCtrl',["$scope",'$state','$ionicLoading','$timeout','$i
|
|
|
}])
|
|
|
//主页面控制器
|
|
|
starter.controller('homeCtrl',["$scope",'$http','$timeout','$ionicLoading','$state','$ionicPopup','config',function($scope,$http,$timeout,$ionicLoading,$state,$ionicPopup,config){
|
|
|
- $http({
|
|
|
- method:'get',
|
|
|
- url:config.server+'/list',
|
|
|
- }).success(function(newItem){
|
|
|
- $scope.excals = newItem
|
|
|
- })
|
|
|
-
|
|
|
- $scope.doRefresh = function(){
|
|
|
+ $scope.doRefresh = function(sec){
|
|
|
+ if($scope.isChecked.checked){
|
|
|
+ mytimer = $timeout(function() {
|
|
|
+ $scope.doRefresh(sec);
|
|
|
+ }, sec*1000);
|
|
|
+ localStorage.refreshtime=sec;
|
|
|
+ }else{
|
|
|
+ $timeout.cancel(mytimer);
|
|
|
+ localStorage.refreshtime=0;
|
|
|
+ }
|
|
|
+ console.log(mytimer);
|
|
|
+ $scope.refresh();
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.refresh = function(){
|
|
|
$ionicLoading.show({
|
|
|
- template: '加载中...',
|
|
|
- });
|
|
|
- $http({
|
|
|
+ template: '加载中...',
|
|
|
+ });
|
|
|
+ $http({
|
|
|
method:'get',
|
|
|
url:config.server+'/list',
|
|
|
}).success(function(newItem){
|
|
|
$timeout(function(){
|
|
|
- $ionicLoading.hide();
|
|
|
$scope.excals = newItem
|
|
|
+ $ionicLoading.hide();
|
|
|
});
|
|
|
}).error(function(){
|
|
|
$timeout(function(){
|
| xqd
@@ -66,142 +73,72 @@ starter.controller('homeCtrl',["$scope",'$http','$timeout','$ionicLoading','$sta
|
|
|
.finally(function() {
|
|
|
$scope.$broadcast('scroll.refreshComplete');
|
|
|
});
|
|
|
-
|
|
|
}
|
|
|
+ var mytimer;
|
|
|
+ $scope.$on('$ionicView.beforeEnter', function () {
|
|
|
+ $scope.refreshtime = 5;
|
|
|
+ $scope.isChecked = { checked: localStorage.refreshtime!=0?true:false };
|
|
|
+ if(localStorage.refreshtime!=0){
|
|
|
+ $scope.refreshtime = localStorage.refreshtime;
|
|
|
+ $timeout.cancel(mytimer);
|
|
|
+ $scope.doRefresh(localStorage.refreshtime);
|
|
|
+ }else{
|
|
|
+ $scope.refresh();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $scope.$on('$ionicView.beforeLeave', function () {
|
|
|
+ console.log(mytimer);
|
|
|
+ $timeout.cancel(mytimer);
|
|
|
+ });
|
|
|
$scope.getName = function(name){
|
|
|
$state.go('show',{item:name});
|
|
|
}
|
|
|
+ $scope.blur = function(sec){
|
|
|
+ if($scope.isChecked.checked){
|
|
|
+ localStorage.refreshtime=sec;
|
|
|
+ }else{
|
|
|
+ localStorage.refreshtime=0;
|
|
|
+ }
|
|
|
+ }
|
|
|
}])
|
|
|
|
|
|
//数据展示控制器
|
|
|
starter.controller('showCtrl',["$scope",'$ionicHistory','$state','$timeout','$stateParams','$http','$ionicLoading','$ionicPopup','config',function($scope,$ionicHistory,$state,$timeout,$stateParams,$http,$ionicLoading,$ionicPopup,config){
|
|
|
+ var newtimer;
|
|
|
$scope.$on('$ionicView.beforeEnter', function () {
|
|
|
- $http({
|
|
|
- method:'get',
|
|
|
- url:config.server+'/list',
|
|
|
- }).success(function(newItem){
|
|
|
- $scope.excels = newItem
|
|
|
- })
|
|
|
name = $stateParams.item;
|
|
|
$scope.name = name;
|
|
|
- $ionicLoading.show({
|
|
|
- template: '加载中...',
|
|
|
- });
|
|
|
- $http({
|
|
|
- method:'get',
|
|
|
- url:config.server+'/data/'+name
|
|
|
- }).success(function(req){
|
|
|
- $timeout(function() {
|
|
|
- $ionicLoading.hide();
|
|
|
- //主页参数
|
|
|
- $scope.table1 = req.t.t1;
|
|
|
- $scope.table2 = req.t.t2;
|
|
|
- $scope.table3 = req.t.t3;
|
|
|
- $scope.table4 = req.t.t4;
|
|
|
-
|
|
|
- //tn曲线图参数
|
|
|
- $scope.item1= req.speed;
|
|
|
- $scope.data2 = [req.torque,req.v,req.p,req.a,req.efficiency];
|
|
|
- //五轴图参数
|
|
|
- $scope.item2 = req.nj;
|
|
|
- $scope.data3 = [req.glys,req.ssgl,req.xl,req.zs,req.dl];
|
|
|
- //效率云图
|
|
|
- $scope.item3= req.n_speed;
|
|
|
- $scope.data4 = [req.n_torque,req.n_v,req.n_p,req.n_a,req.n_efficiency];
|
|
|
- console.log(req.n_speed);
|
|
|
- console.log($scope.data4);
|
|
|
-
|
|
|
-// var Stat = G2.Stat;
|
|
|
-// var vvvdata = [];
|
|
|
-// // for(var i = 0; i <= 20; i ++) {
|
|
|
-// // for(var j = 0; j <= 20; j ++) {
|
|
|
-// // var x = i*25.6;
|
|
|
-// // var y = j*19.2;
|
|
|
-// // var z = 700-(x+0.5*y)+Math.random()*(400);
|
|
|
-// // console.log(x);
|
|
|
-// // console.log(y);
|
|
|
-// // console.log(z);
|
|
|
-// //
|
|
|
-// // }
|
|
|
-// // }
|
|
|
-// var data1 = $scope.a;
|
|
|
-// var data2 = $scope.b;
|
|
|
-// var data3 = $scope.c;
|
|
|
-
|
|
|
-// for(var i=0;i<=212;i++){
|
|
|
-// var x = data1[i];
|
|
|
-// var y = data2[i];
|
|
|
-// var z = data3[i];
|
|
|
-// vvvdata.push({
|
|
|
-// l:x,
|
|
|
-// g: y,
|
|
|
-// Altitude:z
|
|
|
-// });
|
|
|
-// console.log(x+'x')
|
|
|
-// console.log(y+'y')
|
|
|
-// console.log(z+'z')
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-// var chart = new G2.Chart({
|
|
|
-// id: 'c1',
|
|
|
-// forceFit: true,
|
|
|
-// height: 1000
|
|
|
-// });
|
|
|
-// //为了将数据与图片上的位置完全吻合,我们需要将横轴和纵轴的范围设定为数据对应范围,并将范围优化处理关闭
|
|
|
-// var defs = {
|
|
|
-// 'l': {
|
|
|
-// type: 'linear',
|
|
|
-// min: 2735,
|
|
|
-// max: 2900,
|
|
|
-// nice: false//优化处理关闭
|
|
|
-// },
|
|
|
-// 'g': {
|
|
|
-// type: 'linear',
|
|
|
-// min: 0,
|
|
|
-// max: 2,
|
|
|
-// nice: false
|
|
|
-// },
|
|
|
-// 'Altitude': {
|
|
|
-// tickCount:5
|
|
|
-// }
|
|
|
-// };
|
|
|
-
|
|
|
-// chart.source(vvvdata,defs);
|
|
|
-// chart.contour().position(Stat.smooth.loess.triangular('l*g*Altitude',0.01)).color('Altitude','hue').size(3);
|
|
|
-// chart.render();
|
|
|
-// document.getElementById('newchats').style.display='none';
|
|
|
-
|
|
|
- });
|
|
|
- }).error(function(){
|
|
|
- $timeout(function(){
|
|
|
- $ionicLoading.hide();
|
|
|
- var alertPopup = $ionicPopup.alert({
|
|
|
- title: '连接超时',
|
|
|
- buttons: [
|
|
|
- {
|
|
|
- text: '<b>确定</b>',
|
|
|
- type: 'button-calm',
|
|
|
- },
|
|
|
- ]
|
|
|
- });
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
+ $scope.doSelected(name);
|
|
|
});
|
|
|
+ $scope.$on('$ionicView.beforeLeave', function () {
|
|
|
+ $timeout.cancel(newtimer);
|
|
|
+ });
|
|
|
|
|
|
- $scope.change = function(selectedName){
|
|
|
- $scope.name = selectedName;
|
|
|
+ $scope.change = function(name){
|
|
|
+ $timeout.cancel(mytimer);
|
|
|
+ $scope.name = name;
|
|
|
+ $scope.doSelected(name);
|
|
|
+ }
|
|
|
+ $scope.doSelected = function(name){
|
|
|
+ if(localStorage.refreshtime!=0){
|
|
|
+ newtimer = $timeout(function() {
|
|
|
+ $scope.doSelected(name);
|
|
|
+ }, localStorage.refreshtime*1000);
|
|
|
+ }else{
|
|
|
+ $timeout.cancel(mytimer);
|
|
|
+ }
|
|
|
+ $scope.selectedName(name);
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.selectedName = function(name){
|
|
|
$ionicLoading.show({
|
|
|
template: '加载中...',
|
|
|
});
|
|
|
$http({
|
|
|
method:'get',
|
|
|
- url:config.server+'/data/'+selectedName
|
|
|
+ url:config.server+'/data/'+name
|
|
|
}).success(function(req){
|
|
|
- $ionicLoading.hide();
|
|
|
- $timeout(function() {
|
|
|
+ // $timeout(function() {
|
|
|
//主页参数
|
|
|
$scope.table1 = req.t.t1;
|
|
|
$scope.table2 = req.t.t2;
|
| xqd
@@ -213,9 +150,15 @@ starter.controller('showCtrl',["$scope",'$ionicHistory','$state','$timeout','$st
|
|
|
//五轴图参数
|
|
|
$scope.item2 = req.nj;
|
|
|
$scope.data3 = [req.glys,req.ssgl,req.xl,req.zs,req.dl];
|
|
|
- });
|
|
|
+ //效率云图
|
|
|
+ $scope.item3= req.n_speed;
|
|
|
+ $scope.data4 = [req.n_torque,req.n_v,req.n_p,req.n_a,req.n_efficiency];
|
|
|
+ // console.log(req.n_speed);
|
|
|
+ // console.log($scope.data4);
|
|
|
+ // });
|
|
|
+ $ionicLoading.hide();
|
|
|
}).error(function(){
|
|
|
- $timeout(function(){
|
|
|
+ // $timeout(function(){
|
|
|
$ionicLoading.hide();
|
|
|
var alertPopup = $ionicPopup.alert({
|
|
|
title: '连接超时',
|
| xqd
@@ -226,12 +169,9 @@ starter.controller('showCtrl',["$scope",'$ionicHistory','$state','$timeout','$st
|
|
|
},
|
|
|
]
|
|
|
});
|
|
|
- })
|
|
|
- })
|
|
|
+ // })
|
|
|
+ });
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
$scope.tabs = [
|
|
|
{"title":"主页","url":"line.html"},
|
|
|
{"title":"TN曲线","url":"tn.html"},
|