// 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), log_("Es") { // Récupération des valeurs de configuration dans le fichier loadConfig(config); proto_.open(tty_); } void Es::init(void) { // On reset l'AVR proto_.send('z'); // XXX Voir pour envoyer les config } bool Es::wait(int timeout /*-1*/) { return proto_.wait(timeout); } /// Récupère le File Descriptor int Es::getFd(void) { return proto_.getFd(); } void Es::loadConfig(const Config & config) { tty_ = config.get("es.tty"); } // Envoie de la config des sensors RVB void Es::setRVBSensorsConfig(int false_ic, int max_ov) { proto_.send('p',"bw", false_ic, max_ov); } // Envoie de la config des sniff RVB void Es::setRVBSniffConfig(int ref_ratio) { proto_.send('x', "b", ref_ratio); } void Es::receive(char command, const Proto::Frame & frame) { } // Règle les stats des sensors RVB void Es::setRVBSensorsStat(int mask_captor, int freq) { proto_.send('S', "wb", mask_captor, freq); } // règle la couleur actuelle comme référente void Es::setRefColor(int mask_captor, int mode) { proto_.send('r', "wb", mask_captor, mode); } /// Règle les stats si le "sensors is seen" // XXX Faudra lui filer un vrai nom quand même void Es::setRVBSeenStat(int mask_captor, int freq) { proto_.send('A', "wb", mask_captor, freq); } // Discute avec les servo... void Es::setServoPos(int servoNb, int servoPos) { proto_.send('m', "bb", servoNb, servoPos); } // Règle la vitesse des turbines void Es::setTurbineSpeed(int turbNb, int speed) { proto_.send('v', "bw", turbNb, speed); } // Règle le sens de rotation du barillet void Es::setTheMeaningOfRotationOfBarillet(int answer) { proto_.send('w', "b", answer); } // Init n°2 of barillet void Es::init2Barillet(void) { proto_.send('g'); } // Dépose une balle du barillet void Es::deposeBalle(void) { proto_.send('d'); } /// Extrait une balle void Es::extraitBalle(void) { proto_.send('e'); } /// Rotation du barillet void Es::rotationBarillet(int posFinal) { proto_.send('t', "b", posFinal); } bool Es::sync(void) { return proto_.sync(); }