123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- var starter = angular.module('starter.controllers', [])
- //登录页面控制器
- starter.controller('loginCtrl',["$scope",'$state','$ionicLoading','$timeout','$ionicPopup',function($scope,$state,$ionicLoading,$timeout,$ionicPopup){
- $scope.vm = {
- mobile:'',
- password:''
- };
- $scope.login = function(){
- if($scope.vm.username == 'admin' && $scope.vm.password == 'admin'){
- $ionicLoading.show({
- template: '<div class="loader"><svg class="circular"><circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"/></svg></div>'
- });
- $timeout(function(){
- $ionicLoading.hide();
- $state.go('home')
- },1500);
-
- }else{
- var alertPopup = $ionicPopup.alert({
- title: '账号密码不正确',
- template: '唯一账号密码:admin!!!'
- });
- $timeout(function() {
- ionicMaterialInk.displayEffect();
- }, 0);
- }
- }
- }])
- //主页面控制器
- starter.controller('homeCtrl',["$scope",'$http','$timeout','$ionicLoading','$state',function($scope,$http,$timeout,$ionicLoading,$state){
- $http({
- method:'get',
- url:'http://172.31.40.29/list',
- }).success(function(newItem){
- $scope.excals = newItem
- })
-
- $scope.doRefresh = function(){
- $ionicLoading.show({
- tcontent: 'Loading',
- animation: 'fade-in',
- showBackdrop: true,
- maxWidth: 200,
- showDelay: 0
- });
- $http({
- method:'get',
- url:'http://172.31.40.29/list',
- }).success(function(newItem){
- $timeout(function(){
- $ionicLoading.hide();
- $scope.excals = newItem
- });
- })
- .finally(function() {
- $scope.$broadcast('scroll.refreshComplete');
- });
-
- }
-
- $scope.getName = function(item){
- name = this.$$watchers[0].last;
- $state.go('show',{item:name})
- }
- }])
-
-
- //数据展示控制器
- starter.controller('showCtrl',["$scope",'$ionicHistory','$state','$http',function($scope,$ionicHistory,$state,$http){
- $scope.tabs = [{"title":"主页","url":"line.html"},
- {"title":"TN曲线","url":"tn.html"},
- {"title":"五轴图","url":"zhou.html"},
- {"title":"效率云图","url":"strom.html"}];
- $scope.name = name;
-
- $scope.go = function(result){
- $state.go(result)
- };
- $scope.isActiveTab = function(tabUrl){
- return tabUrl == $scope.currentTab;
- };
- $scope.onClickTab = function(tab){
- $scope.currentTab = tab.url;
- if(tab.title==="TN曲线"){
- $http({
- method:'get',
- url:'http://172.31.40.29/data/'+name
- }).success(function(req){
- $scope.item= req.speed;
- $scope.data = [req.torque,req.v,req.p,req.a,req.efficiency]
- })
- }
- };
- //TN曲线图
- $scope.legend = ["扭矩", "电压",'输入功率','电流','效率'];
-
- $scope.item = ['200rpm','400rpm','600rpm','800rpm','1000rpm','1200rpm','1400rpm','1600rpm','1800rpm','2000rpm','2200rpm','2400rpm'];
- $scope.num = [0,1,2,3,4];
- $scope.data = [
- [1,1,1,1,1,1,1,1,1,1,1,1], //扭矩
- [196,196,196,196,196,196,196,196,196,196,196,196,], //电压
- [500,500,500,500,500,500,500,500,500,500,500,500,], //输入功率
- [4,4,4,4,4,4,4,4,4,4,4,4], //电流
- [68,68,68,68,68,68,68,68,68,68,68,68,]//效率
- ];
-
- }])
-
- starter.directive('line', function() {
- return {
- scope: {
- id: "@",
- legend: "=",
- item: "=",
- num:"=",
- data: "="
- },
- restrict: 'E',
- template: '<div style="height:700px;"></div>',
- replace: true,
- link: function($scope, element, attrs, controller) {
- var colors = ['#a62ca6', '#8e0515', '#45baf3','#ff2420','#1a9a1a'];
- var option = {
- color:colors,
- // 提示框,鼠标悬浮交互时的信息提示
- tooltip: {
- show: true,
- trigger: 'axis'
- },
- grid:{
- left:'23%'
- },
- //图例
- legend: {
- data: $scope.legend ,
- textStyle:{
- fontSize:22
- }
- },
- // toolbox: {
- // feature: {
- // dataView: {show: true, readOnly: false},
- // restore: {show: true},
- // saveAsImage: {show: true}
- // }
- // },
- // 横轴坐标轴
- xAxis: [
- {
- type: 'category',
- // boundaryGap:false,
- axisLabel:{
- textStyle:{
- fontSize:20
- }
- },
- data: $scope.item
- }
- ],
-
- // 纵轴坐标轴
- yAxis: [
- {
- type: 'value',
- // name: '扭\n矩\n(N*m)',
- min: 0,
- max: 4,
- position: 'left',
- offset:205,
- axisLine: {
- lineStyle: {
- color: colors[0],
- width:2
- }
- },
- axisLabel:{
- margin:20,
- textStyle:{
- fontSize:18
- }
- }
- },
- {
- type: 'value',
- // name: '电\n压\n(V)',
- min: 193,
- max: 202,
- position: 'left',
- offset: 150,
- axisLine: {
- lineStyle: {
- color: colors[1],
- width:2
- }
- },
- axisLabel:{
- margin:15,
- textStyle:{
- fontSize:18
- }
- },
- },
- {
- type: 'value',
- // name: '输\n入\n功\n率\n(W)',
- min: 0,
- max: 1300,
- position: 'left',
- offset:90,
- axisLine: {
- lineStyle: {
- color: colors[2],
- width:2
- }
- },
- axisLabel:{
- textStyle:{
- fontSize:18
- }
- },
- },
- {
- type: 'value',
- // name: '电\n流\n(A)',
- min: 1,
- max: 6,
- position: 'left',
- offset:45,
- axisLine: {
- lineStyle: {
- color: colors[3],
- width:2
- }
- },
- axisLabel:{
- margin:20,
- textStyle:{
- fontSize:18
- }
- },
- },
- {
- type: 'value',
- // name: '效\n率\n(%)',
- min: 10,
- max: 80,
- position: 'left',
- offset:0,
- axisLine: {
- lineStyle: {
- color: colors[4],
- width:2
- }
- },
- axisLabel:{
- margin:15,
- textStyle:{
- fontSize:18
- }
- },
- }
- ],
- // 数据内容数组
- series: function(){
- var serie=[];
- for(var i=0;i<$scope.legend.length;i++){
- var item = {
- name : $scope.legend[i],
- type: 'line',
- yAxisIndex:$scope.num[i],
- data: $scope.data[i]
- };
- serie.push(item);
- }
- return serie;
- }()
-
- };
- var myChart = echarts.init(document.getElementById($scope.id),'macarons');
- myChart.setOption(option);
- }
- };
- })
|