From bce1487a433b4a9bfde65cd68abfedc15c0ef1ce Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 19 Jul 2016 10:52:06 +0200 Subject: [PATCH] =?UTF-8?q?Modification=20BDD=20:=20Saisie=20des=20valeurs?= =?UTF-8?q?=20de=20test=20pour=20le=20client=20virtuel=20(puces=20+=20pins?= =?UTF-8?q?=20+=20=C3=A9tats)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/client/interface.php | 12 ++++++++---- test/client/lib.js | 10 ++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/test/client/interface.php b/test/client/interface.php index ef4efc1..6675582 100644 --- a/test/client/interface.php +++ b/test/client/interface.php @@ -254,12 +254,16 @@ 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 ) + led: new LedInterface( new Chip('serial', [1, 2, 3]), led ), + r1: new RelayInterface( new Chip('serial', [4]), r1 ), + r2: new RelayInterface( new Chip('serial', [5]), r2 ) }; - board.plug( chip.led ) + var chipList = Object.keys(chip); + + // Branchement des puces + for( var i = 0 ; i < chipList.length ; i++ ) + board.plug( chip[chipList[i]] ); /* [1] Fonctions diff --git a/test/client/lib.js b/test/client/lib.js index 54f508f..79c1acd 100644 --- a/test/client/lib.js +++ b/test/client/lib.js @@ -78,7 +78,7 @@ var Board; /* [2] Branchement + on lie l'interface =========================================================*/ - for( var i = 0 ; i < chipInterface.chip.pins.length ; i++ ){ + for( i = 0 ; i < chipInterface.chip.pins.length ; i++ ){ this.pins[i] = chipInterface.chip.values[i]; this.listener[i] = chipInterface; } @@ -166,7 +166,7 @@ var Chip; this.pins = pins; this.values = []; - for( var i = 0 ; i < this.pins.length ; i++ ) + for( i = 0 ; i < this.pins.length ; i++ ) this.values[i] = new Pin(0); }; @@ -336,10 +336,8 @@ var RelayInterface; * */ RelayInterface.prototype.update = function(){ - if( this.chip.pin[0] ) - this.container.addClass('active'); - else - this.container.remClass('active'); + if( this.chip.pin[0] ) this.container.addClass('active'); + else this.container.remClass('active'); };