Author: ygrego Date: 2015-06-17 15:13:24 +0000 (Wed, 17 Jun 2015) New Revision: 1735 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1735 Log: Refactoring of controllers in order to separate the managing of video-broadcast object. Modified: oipf/emulator/js/contollers/RemoteControlControllers.js Modified: oipf/emulator/js/contollers/RemoteControlControllers.js =================================================================== --- oipf/emulator/js/contollers/RemoteControlControllers.js 2015-06-17 14:58:07 UTC (rev 1734) +++ oipf/emulator/js/contollers/RemoteControlControllers.js 2015-06-17 15:13:24 UTC (rev 1735) @@ -18,87 +18,58 @@ methodName && $scope[methodName].call($scope, buttonId); }; - $scope.state = 'OFF'; $scope.channel = ""; $scope.channelNumber = ""; $scope.channelNumberActive = false; $scope.volumeViewActive = false; $rootScope.powerChange = false; - $scope.currentVolume = 50; - $scope.setSate = function() { - }; - $scope.setPowerChange = function() { $rootScope.powerChange = !$rootScope.powerChange; console.log($rootScope.powerChange); }; $scope.clickMapping = { - "POWER": "setPowerChange", - "0": "setChannelByNumber", - "1": "setChannelByNumber", - "2": "setChannelByNumber", - "3": "setChannelByNumber", - "4": "setChannelByNumber", - "5": "setChannelByNumber", - "6": "setChannelByNumber", - "7": "setChannelByNumber", - "8": "setChannelByNumber", - "9": "setChannelByNumber", - "V+": "setVolume", - "V-": "setVolume" + "POWER": "setPowerChange", + "0": "setChannelByNumber", + "1": "setChannelByNumber", + "2": "setChannelByNumber", + "3": "setChannelByNumber", + "4": "setChannelByNumber", + "5": "setChannelByNumber", + "6": "setChannelByNumber", + "7": "setChannelByNumber", + "8": "setChannelByNumber", + "9": "setChannelByNumber", + "V+": "setVolume", + "V-": "setVolume" }; - $scope.setChannelByNumber = function(buttonId) { - $scope.channelNumberActive = true; - - if ($scope.channel.length == 0) { - $timeout(function() { - $scope.channel = $scope.channelNumber.toString(); - $scope.channelNumber = ""; - $scope.channelNumberActive = false; - }, 3000); - } - $scope.channelNumber += buttonId; - - }; - - $scope.setVolume = function(buttonId) { - $scope.volumeViewActive = true; - if (buttonId == "V+" && $scope.currentVolume < 100) { - $scope.currentVolume++; - } else if (buttonId == "V-" && $scope.currentVolume > 0) { - $scope.currentVolume--; - } - $timeout(function() { - $scope.volumeViewActive = false; - }, 3000); - }; }]); RemoteControlControllers.controller("PowerStateController", - ["$rootScope", "$scope", "ConfigurationService", function($rootScope, $scope, ConfigurationService) { + ["$rootScope", "$scope", "$timeout", "ConfigurationService", function($rootScope, $scope, $timeout, ConfigurationService) { $scope.onStarting = true; - $scope.videoStyle = "off"; - + $scope.state = "show"; + $scope.beforeON = false; + $rootScope.systemReady = false; $scope.configurationService = ConfigurationService(); $scope.configurationService.localSystem.onPowerStateChange = function(state) { + if ($scope.waitingState == state && $scope.result) { if (state == 0) { - console.log("POWER STATE CHANGE: OFF."); - $scope.videoStyle = "off"; - + $scope.state = "show"; + $rootScope.systemReady = false; } else { - console.log("POWER STATE CHANGE: ON."); - $scope.videoStyle = "on"; + $scope.state = "hidden"; + $rootScope.systemReady = true; + } - } } else { console.log("POWER STATE CHANGE: ERROR."); @@ -118,30 +89,91 @@ if ($scope.configurationService.localSystem.powerState == 0) { $scope.waitingState = 1; - $scope.result = $scope.configurationService.localSystem.setPowerState(1); + $scope.beforeON = true; + $timeout(function() { + $scope.beforeON = false; + $scope.result = $scope.configurationService.localSystem.setPowerState(1); + }, 5000); + } else if ($scope.configurationService.localSystem.powerState == 1) { $scope.waitingState = 0; $scope.result = $scope.configurationService.localSystem.setPowerState(0); } + } else { $scope.onStarting = false; } - }); }]); RemoteControlControllers.controller("VideoBroadcastController", - ["$rootScope", "$scope", "ConfigurationService", function($rootScope, $scope, ConfigurationService) { + ["$rootScope", "$scope", "$timeout", function($rootScope, $scope, $timeout) { + $scope.currentVolume = 50; + $rootScope.channelInfo = false; + $scope.setChannelByNumber = function(buttonId) { + $scope.channelNumberActive = true; + + if ($scope.channel.length == 0) { + $timeout(function() { + $scope.channel = $scope.channelNumber.toString(); + $scope.channelNumber = ""; + $scope.channelNumberActive = false; + }, 3000); + } + $scope.channelNumber += buttonId; + + }; + + $scope.setVolume = function(buttonId) { + $scope.volumeViewActive = true; + if (buttonId == "V+" && $scope.currentVolume < 100) { + $scope.currentVolume++; + } else if (buttonId == "V-" && $scope.currentVolume > 0) { + $scope.currentVolume--; + } + $timeout(function() { + $scope.volumeViewActive = false; + }, 3000); + }; + + $rootScope.$watch("systemReady", function(isReady) { + + if (isReady) { + console.group("VideoBroadcastController"); + console.log("System ready after power ON: active channel info view"); + $rootScope.channelInfo = true; + console.groupEnd("VideoBroadcastController"); + $timeout(function() { + $rootScope.channelInfo = false; + }, 4000); + } + + }); + }]); RemoteControlControllers.controller("PanelChannelController", ["$rootScope", "$scope", function($rootScope, $scope) { $scope.isRequired = false; + + $rootScope.$watch("channelInfo", function(newInfo) { + console.group("PanelChannelController"); + if (newInfo) { + console.log("Panel channel info will be activated."); + $scope.isRequired = true; + + } else if (!newInfo) { + console.log("Panel channel info will be deactivated."); + $scope.isRequired = false; + } + console.groupEnd("PanelChannelController"); + }); + }]);
participants (1)
-
ygregoï¼ users.nuiton.org