// 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" #include "config/config.hh" /// Constructeur Es::Es (const Config & config) :proto_(*this) { // Récupération des valeurs de configuration dans le fichier loadConfig(config); proto_.open(tty_); 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(); angle1_ = 0; dist1_ = 0; angle2_ = 0; dist2_ = 0; angle3_ = 0; dist3_ = 0; ascIdle_ = true; ascFailure_ = false; proto_.send('P',"bbbbbb", ascMinHaut_, ascMaxHaut_, ascAccHaut_, ascMinBas_, ascMaxBas_, ascAccBas_); ascCurrentPos_ = false; } bool Es::getAscCurPos(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 Es::loadConfig(const Config & config) { tty_ = config.get("es.tty"); ascMinHaut_ = config.get("es.ascMinHaut"); ascMaxHaut_ = config.get("es.ascMaxHaut"); ascAccHaut_ = config.get("es.ascAccHaut"); ascMinBas_ = config.get("es.ascMinBas"); ascMaxBas_ = config.get("es.ascMaxBas"); ascAccBas_ = config.get("es.ascAccBas"); pVentouses_ = config.get("es.pVentouses"); } void Es::receive(char command, const Proto::Frame & frame) { switch(command) { case 'T': //L'ascenceur est en haut proto_.send('F', "b", 0); //XXX on met l'arg?? ascCurrentPos_ = true; ascIdle_ = true; break; case 'I': // XXX L'ascenceur est en bas (ca serait cool si c'était implenté) proto_.send('F', "b", 0); // 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; case 't': // Cachalot de Romain(Tourelle) // XXX A CODER break; } }