From 3a4e985cd98d043946c1aeb2d25afd5a2146079d Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 19 Jul 2016 14:55:51 +0200 Subject: [PATCH] =?UTF-8?q?Client=20Virtuel=20:=20Impl=C3=A9mentation=20de?= =?UTF-8?q?s=20PINS+CHIPS+STATES+GLOBAL=5FSTATES+ACTIONS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/client/interface.php | 6 ++++-- test/client/lib-min.js | 8 ++++---- test/client/lib.js | 17 ++++++++++------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/test/client/interface.php b/test/client/interface.php index 4b29100..ffeb493 100644 --- a/test/client/interface.php +++ b/test/client/interface.php @@ -282,7 +282,7 @@ /* (2) Si l'état correspond */ if( previous(STATES[s].global_state, STATE) ){ - console.log('STATE', STATE, 'matches', STATES[s].global_state); + console.log('STATE', STATE.join(''), 'matches', STATES[s].global_state); /* (3) On applique l'état à chaque CHIP */ for( var c in CHIPS ){ @@ -296,8 +296,10 @@ var values = CHIPS[c].states[STATES[s].chips[c]]; /* (6) On applique les valeurs */ - for( var p in pins ) + for( var p in pins ){ board.set( parseInt(pins[p]), parseInt(values[p]) ); + console.log('board.set(', parseInt(pins[p]), ',', parseInt(values[p]), ');'); + } } diff --git a/test/client/lib-min.js b/test/client/lib-min.js index 1446072..26bd0f5 100644 --- a/test/client/lib-min.js +++ b/test/client/lib-min.js @@ -1,8 +1,8 @@ var Pin;(function(){Pin=function(a){parseInt(a)==a&&0<=a&&255>=a?this.value=parseInt(a):this.value=0};Pin.prototype={value:this.value};Pin.prototype.set=function(a){parseInt(a)==a&&0<=a&&255>=a&&(this.value=parseInt(a))};Pin.prototype.get=function(){return this.value}})();var Board; -(function(){Board=function(a){if(!(parseInt(a)!=a||1>a)){this.maxPin=a;this.pins=[];this.listener=[];for(a=0;athis.maxPin)&&this.pins[a]instanceof Pin){if("boolean"==typeof b)b=b?255:0;else if(b!=parseInt(b)||0>b||255a)){this.maxPin=a;this.pins=[];this.listener=[];for(a=0;athis.maxPin)&&this.pins[a]instanceof Pin){if("boolean"==typeof b)b=b?255:0;else if(b!=parseInt(b)||0>b||255=a)){if("boolean"==typeof b)b=b?255:0;else if(b!=parseInt(b)||0>b||255 1) this.container.addClass('active'); + else this.container.remClass('active'); }; @@ -352,6 +353,7 @@ var action; (function(){ + /* RETOURNE SI UN ETAT EST CORRECT * * @previous Condition d'état @@ -382,7 +384,8 @@ var action; for( var i = 0 ; i < action.length ; i++ ) if( action[i] == 'x' ) continue; - else state[i] = action[i]; + else state[i] = parseInt(action[i]); }; + })();