// es.cc // robert - programme du robot 2005 {{{ // // Copyright (C) 2005 Nicolas Haller // // Robot APB Team/Efrei 2005. // Web: http://assos.efrei.fr/robot/ // Email: robot AT efrei DOT fr // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // }}} #include "es/es.hh" /// Constructeur Es::Es (const Config & config) :proto_(*this), vitesseAsc(/*XXX*/), couleur(/*comment on la récup?*/) { // Récupération des valeurs de configuration dans le fichier pVentouses_ = config.get("es.pVentouses"); init(); } void Es::init(void) { // XXX Bon ca serait cool que l'AVR renvoie toute ses info au reset // On reset l'AVR proto_.send('z'); // XXX z = reset AVR // XXX on récup les données de couleur_ et de jackOut(mais comment??) proto_.sync(); } bool Es::getColor(void) { return couleur_; } bool Es::getAscCurrentPos(void) { return ascCurrentPos_; } bool Es::getAscState(void) { return ascFailure__; } bool Es::AscIsIdle(void) { return ascIdle_; } void Es::monterAsc(void) { proto_.send('m'); ascIdle_ = false; } void Es::descendreAsc(void) { proto_.send('d'); ascIdle_ = false; } void Es::ventouses(void) { proto_.send('v',"b",pVentouses_); } void Es::wait(int timeout) { proto_.wait(timeout); } void receive(char command, const Proto::Frame & frame) { switch(command) { case 'C': //couleur selectionné XXX A voir if(frame.args[0]) couleur_ = true; else couleur_ = false; break; case 'T': //L'ascenceur est en haut proto_.send('F', "b", 0); //XXX on met l'arg?? ascCurrentPos_ = true; ascIdle_ = true; break; case 'B': // XXX L'ascenceur est en bas (ca serait cool si c'était implenté) proto_.send('F', "b", O); // XXX idem ascCurrentPos_ = false; ascIdle_ = true; break; case 'E': // XXX Problème d'ascenseur proto_.send('F', "b", 0); // XXX idem ascCurrentPos_ = false; ascIdle = true; ascFailure_ = true; // XXX Mais alors pour le repasser à false... break; } }