diff --git a/test/client/interface.php b/test/client/interface.php index 88a0f36..ef4efc1 100644 --- a/test/client/interface.php +++ b/test/client/interface.php @@ -250,13 +250,17 @@ lsi.import('STATES.CNF', response.states); }); - /* (5) On initialise les puces */ + /* (5) On initialise la carte + les puces */ + var board = new Board(50); + var chip = { led: new LedInterface( new Chip(1, 2, 3), led ), r1: new RelayInterface( new Chip(4), r1 ), r2: new RelayInterface( new Chip(5), r2 ) }; + board.plug( chip.led ) + /* [1] Fonctions =========================================================*/ diff --git a/test/client/lib-min.js b/test/client/lib-min.js index 23a5120..ee7b9b8 100644 --- a/test/client/lib-min.js +++ b/test/client/lib-min.js @@ -1,6 +1,6 @@ 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 Interface contenant la carte - * @chip Carte à brancher + * @chipInterface Interface contenant la carte et la mise à jour * */ - Board.prototype.plug = function(listener, chip){ + Board.prototype.plug = function(chipInterface){ /* [0] Vérification des paramètres =========================================================*/ - if( !(chip instanceof Chip) ) + if( !(chipInterface.chip instanceof Chip) ) return false; /* [1] Vérification des Pins =========================================================*/ - for( var i = 0 ; i < chip.pins.length ; i++ ) + for( var i = 0 ; i < chipInterface.chip.pins.length ; i++ ) if( this.pins[i] instanceof Pin ) // si pin déja prise return false; /* [2] Branchement + on lie l'interface =========================================================*/ - for( var i = 0 ; i < chip.pins.length ; i++ ){ - this.pins[i] = chip.values[i]; - this.listener[i] = listener; + for( var i = 0 ; i < chipInterface.chip.pins.length ; i++ ){ + this.pins[i] = chipInterface.chip.values[i]; + this.listener[i] = chipInterface; } };