Changeset 67 in flair-src for trunk/lib/FlairCore


Ignore:
Timestamp:
Aug 29, 2016, 4:58:23 PM (8 years ago)
Author:
Sanahuja Guillaume
Message:

corrections bugs checkpoint map

Location:
trunk/lib/FlairCore/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/FrameworkManager_impl.cpp

    r55 r67  
    181181    status = UDT::close(com_sock);
    182182    if (status != 0)
    183       printf("Error udt::close %s", UDT::getlasterror().getErrorMessage());
     183      Printf("Error udt::close %s", UDT::getlasterror().getErrorMessage());
    184184
    185185    status = UDT::close(file_sock);
    186186    if (status != 0)
    187       printf("Error udt::close %s", UDT::getlasterror().getErrorMessage());
     187      Printf("Error udt::close %s", UDT::getlasterror().getErrorMessage());
    188188
    189189    SleepMS(200); // a revoir, sinon UDT::cleanup bloque en RT
     
    294294        xmlDoc *doc;
    295295        rcv_buf[bytesRead] = 0;
    296 
     296 //Printf("%s\n",rcv_buf);
    297297        doc = xmlReadMemory(rcv_buf, (int)bytesRead, "include.xml",
    298298                            "ISO-8859-1", 0);
  • trunk/lib/FlairCore/src/Map.cpp

    r15 r67  
    2121#include "GeoCoordinate.h"
    2222#include "FrameworkManager.h"
     23#include <cmath>
    2324#include <string.h>
    2425#include <sstream>
     
    8081void Map::ExtraXmlEvent(void) {
    8182
    82   // attention pas rt safe (creation checkpoint)
     83  // attention pas rt safe (creation/destruction checkpoint)
    8384  size_t i = 0;
    8485  while (1) {
    85     // printf("test %i\n",i);
    8686    double latitude, longitude;
    8787    double altitude = 0;
     
    9090    long_prop << "long" << i;
    9191    alt_prop << "alt" << i;
     92
    9293    if (GetPersistentXmlProp(lat_prop.str(), latitude) &&
    9394        GetPersistentXmlProp(long_prop.str(), longitude)) {
    9495      GetPersistentXmlProp(alt_prop.str(), altitude);
     96
    9597      if (i >= checkpoints.size()) {
     98        //add checkpoint
    9699        GeoCoordinate *checkpoint = new GeoCoordinate(
    97100            this, "checkpoint", latitude, longitude, altitude);
    98101        checkpoints.push_back(checkpoint);
    99         // printf("add %i\n",i);
     102      } else if(isnan(latitude) || isnan(longitude)) {
     103        //delete checkpoint
     104        removeCheckpoint(i);
     105        break;//si delete, la station sol n'envoit que cette info
    100106      } else {
     107        //move checkpoint
    101108        checkpoints.at(i)->SetCoordinates(latitude, longitude, altitude);
    102109      }
     
    107114    i++;
    108115  }
    109 
     116/*
    110117  for (size_t i = 0; i < checkpoints.size(); i++) {
    111118    double latitude, longitude, altitude;
    112119    checkpoints.at(i)->GetCoordinates(&latitude, &longitude, &altitude);
    113     // printf("%i %f %f\n",i,latitude,longitude);
     120     printf("%i %f %f\n",i,latitude,longitude);
     121  }*/
     122}
     123
     124void Map::removeCheckpoint(size_t index) {
     125  //left shift
     126  for (size_t i = index; i < checkpoints.size()-1; i++) {
     127    double latitude, longitude, altitude;
     128    checkpoints.at(i+1)->GetCoordinates(&latitude, &longitude, &altitude);
     129    checkpoints.at(i)->SetCoordinates(latitude,longitude,altitude);
    114130  }
     131
     132  //remove last one
     133  delete checkpoints.back();
     134  checkpoints.pop_back();
     135
     136  //remove last one in xml
     137  ostringstream lat_prop, long_prop, alt_prop;
     138  lat_prop << "lat" << checkpoints.size();
     139  long_prop << "long" << checkpoints.size();
     140  alt_prop << "alt" << checkpoints.size();
     141  UnsetPersistentXmlProp(lat_prop.str());
     142  UnsetPersistentXmlProp(long_prop.str());
     143  UnsetPersistentXmlProp(alt_prop.str());
    115144}
    116145
  • trunk/lib/FlairCore/src/Map.h

    r15 r67  
    7777  void ExtraXmlEvent(void);
    7878
     79  void removeCheckpoint(size_t index);
     80
    7981  std::vector<core::GeoCoordinate *> checkpoints;
    8082  std::vector<const core::GeoCoordinate *> to_draw;
  • trunk/lib/FlairCore/src/Widget.cpp

    r15 r67  
    8282  if (GetPersistentXmlProp<double>(prop, tmp)) {
    8383    value = tmp;
     84    return true;
     85  } else {
     86    return false;
     87  }
     88}
     89
     90template <>
     91bool Widget::GetPersistentXmlProp(std::string prop, std::string &value) {
     92  xmlChar *result = NULL;
     93  result = xmlGetProp(pimpl_->file_node, (xmlChar *)prop.c_str());
     94  if (result != NULL) {
     95    value = std::string((char *)result);
     96    xmlFree(result);
    8497    return true;
    8598  } else {
     
    208221}
    209222
     223template <> void Widget::SetPersistentXmlProp(std::string prop, std::string value) {
     224  SetVolatileXmlProp(prop, value);
     225  SetVolatileXmlProp(prop, value, pimpl_->file_node);
     226}
     227
     228void Widget::UnsetPersistentXmlProp(std::string prop) {
     229  xmlUnsetProp(pimpl_->file_node, (xmlChar *)prop.c_str());
     230}
     231
    210232void Widget::SendXml(void) { pimpl_->SendXml(); }
    211233
  • trunk/lib/FlairCore/src/Widget.h

    r15 r67  
    143143  virtual void XmlEvent(void){};
    144144
     145  /*!
     146   * \brief Unset a persistent xml property
     147   *
     148   * Unset an existent property, so it won't be saved.
     149   *
     150   * \param prop property to set
     151   */
     152  void UnsetPersistentXmlProp(std::string prop);
     153
    145154private:
    146155  class Widget_impl *pimpl_;
Note: See TracChangeset for help on using the changeset viewer.