From 541849fcf20730974c4a20c740d4d825e4327ff8 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 19 Jul 2016 12:26:18 +0200 Subject: [PATCH] Client Virtuel : Gestion par 'machineDefault/init' des 'actions' + des 'states' --- test/client/interface.php | 43 +++++++++++++++++++++++++++++++-------- test/client/lib-min.js | 2 +- test/client/lib.js | 2 +- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/test/client/interface.php b/test/client/interface.php index 6970700..702a4f6 100644 --- a/test/client/interface.php +++ b/test/client/interface.php @@ -219,7 +219,7 @@ /* [0] Initialisation et éléments =========================================================*/ /* (1) Etats du système */ - var STATE = [ false, false, false ]; + var STATE = [ 0, 0, 0 ]; /* (2) Elements du DOM */ var mBox = document.getElementById('machine-box'); @@ -273,6 +273,19 @@ /* (1) Gestion de mise à jour de la led en fonction de l'état ---------------------------------------------------------*/ function updateChips(){ + var STATES = lsi.export('STATES.CNF'); + + /* (1) On vérifie si état correspond */ + for( var s in STATES ){ + + if( previous(STATES[s].global_state, STATE) ) + console.log('matches', STATES[s]); + else + console.log('no matches', STATES[s]); + + } + console.log('---'); + /* (1) Si machine bloquée */ if( STATE[2] ){ STATE[0] = false; @@ -329,20 +342,34 @@ /* [4] Passage de carte =========================================================*/ - var INTERVAL = null; - var COUNT = 0; - var ACTIONS = lsi.export('ACTIONS.CNF'); + var INTERVAL = null; + var COUNT = 0; + var ACTIONS = lsi.export('ACTIONS.CNF'); /* (0) Routine de comptage de temps ---------------------------------------------------------*/ function countRoutine(){ - COUNT++; + /* (1) Si le TIMEOUT actuel n'est pas défini, on quitte */ + var exists = false; + for( var t in Object.keys(ACTIONS) ) + if( t == COUNT ) exists = true; - if( COUNT == 1 ) STATE[0] = !STATE[0]; - if( COUNT == 2 ) STATE[0] = STATE[1] = true; - if( COUNT == 3 ) STATE[2] = true; + // Si aucune action pour ce timeout, on quitte + if( !exists ) return; + + /* (2) Pour chaque action de ce timeout */ + for( var a in Object.keys(ACTIONS[COUNT]) ){ + + /* (3) Si la condition est correcte, On applique la modification de l'état */ + if( previous(ACTIONS[COUNT][a].previous, STATE) ){ + action(ACTIONS[COUNT][a].action, STATE); + break; + } + + } updateChips(); + COUNT++; } /* (1) Appui carte diff --git a/test/client/lib-min.js b/test/client/lib-min.js index ee7b9b8..1446072 100644 --- a/test/client/lib-min.js +++ b/test/client/lib-min.js @@ -5,4 +5,4 @@ b){if(!(parseInt(a)!=a||a>this.maxPin)&&this.pins[a]instanceof Pin){if("boolean" b=parseInt(b);this.values[a].set(b)}};Chip.prototype.setPins=function(a){for(var b=0;b