NemoInterface.cpp 17.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
#include "NemoInterface.h"

#include "QGCApplication.h"
#include "QGCLoggingCategory.h"
#include "QGCToolbox.h"
#include "SettingsFact.h"
#include "SettingsManager.h"
#include "WimaSettings.h"

#include <shared_mutex>

#include <QTimer>

14
#include "GenericSingelton.h"
15
#include "geometry/MeasurementArea.h"
16
#include "geometry/geometry.h"
Valentin Platzgummer's avatar
Valentin Platzgummer committed
17
#include "nemo_interface/CommandDispatcher.h"
18
#include "nemo_interface/MeasurementTile.h"
19
#include "nemo_interface/QNemoHeartbeat.h"
20

Valentin Platzgummer's avatar
Valentin Platzgummer committed
21
#include "ros_bridge/include/RosBridgeClient.h"
22 23
#include "ros_bridge/include/messages/geographic_msgs/geopoint.h"
#include "ros_bridge/include/messages/nemo_msgs/heartbeat.h"
Valentin Platzgummer's avatar
Valentin Platzgummer committed
24
#include "ros_bridge/include/messages/nemo_msgs/tile.h"
25 26 27 28 29 30 31
#include "ros_bridge/include/ros_bridge.h"
#include "ros_bridge/rapidjson/include/rapidjson/document.h"
#include "ros_bridge/rapidjson/include/rapidjson/ostreamwrapper.h"
#include "ros_bridge/rapidjson/include/rapidjson/writer.h"

QGC_LOGGING_CATEGORY(NemoInterfaceLog, "NemoInterfaceLog")

Valentin Platzgummer's avatar
Valentin Platzgummer committed
32 33 34 35
#define EVENT_TIMER_INTERVAL 100  // ms
#define NO_HEARTBEAT_TIMEOUT 5000 // ms
auto constexpr static maxResponseTime = std::chrono::milliseconds(10000);
using hrc = std::chrono::high_resolution_clock;
36

Valentin Platzgummer's avatar
Valentin Platzgummer committed
37
using ROSBridgePtr = std::shared_ptr<RosbridgeWsClient>;
38 39 40 41
using UniqueLock = std::unique_lock<std::shared_timed_mutex>;
using SharedLock = std::shared_lock<std::shared_timed_mutex>;

class NemoInterface::Impl {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
42 43
  enum class STATE {
    STOPPED,
Valentin Platzgummer's avatar
Valentin Platzgummer committed
44
    START_BRIDGE,
Valentin Platzgummer's avatar
Valentin Platzgummer committed
45 46 47
    WEBSOCKET_DETECTED,
    TRY_TOPIC_SERVICE_SETUP,
    READY,
Valentin Platzgummer's avatar
Valentin Platzgummer committed
48 49
    TIMEOUT
  };
Valentin Platzgummer's avatar
Valentin Platzgummer committed
50

Valentin Platzgummer's avatar
Valentin Platzgummer committed
51
public:
52
  Impl(NemoInterface *p);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
53
  ~Impl();
54 55 56 57

  void start();
  void stop();

Valentin Platzgummer's avatar
Valentin Platzgummer committed
58 59
  // Tile editing.
  // 	Functions that require communication to device.
Valentin Platzgummer's avatar
Valentin Platzgummer committed
60
  std::future<QVariant> addTiles(const TileArray &tileArray);
61 62
  void removeTiles(const IDArray &idArray);
  void clearTiles();
Valentin Platzgummer's avatar
Valentin Platzgummer committed
63 64

  // 	Functions that don't require communication to device.
65 66 67 68 69
  TileArray getTiles(const IDArray &idArray);
  TileArray getAllTiles();
  LogicalArray containsTiles(const IDArray &idArray);
  std::size_t size();
  bool empty();
Valentin Platzgummer's avatar
Valentin Platzgummer committed
70 71 72 73

  // Progress.
  ProgressArray getProgress();
  ProgressArray getProgress(const IDArray &idArray);
74 75

  NemoInterface::STATUS status();
Valentin Platzgummer's avatar
Valentin Platzgummer committed
76 77 78 79 80
  bool running(); // thread safe
  bool ready();   // thread safe

  const QString &infoString();
  const QString &warningString();
81

Valentin Platzgummer's avatar
Valentin Platzgummer committed
82 83 84 85
  void _addTilesLocal(const TileArray &tileArray);
  void _removeTilesLocal(const IDArray &idArray);
  void _clearTilesLocal();
  void _updateProgress(ProgressArray progressArray);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
86 87 88
  void _setHeartbeat(const QNemoHeartbeat &hb);
  void _setInfoString(const QString &info);
  void _setWarningString(const QString &warning);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
89

90
private:
Valentin Platzgummer's avatar
Valentin Platzgummer committed
91 92 93
  typedef std::chrono::time_point<std::chrono::high_resolution_clock> TimePoint;
  typedef std::map<long, MeasurementTile> TileMap;
  typedef ros_bridge::messages::nemo_msgs::heartbeat::Heartbeat Heartbeat;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
94
  typedef nemo_interface::CommandDispatcher Dispatcher;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
95

Valentin Platzgummer's avatar
Valentin Platzgummer committed
96 97
  void _doTopicServiceSetup();
  void _doAction(); // does action according to state
98

Valentin Platzgummer's avatar
Valentin Platzgummer committed
99 100
  bool _setState(STATE s); // not thread safe
  static bool _ready(STATE s);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
101 102 103
  static bool _running(STATE s);
  static void _translate(STATE state, NemoInterface::STATUS &status);
  static void _translate(Heartbeat hb, STATE &state);
104

Valentin Platzgummer's avatar
Valentin Platzgummer committed
105
  std::atomic<STATE> _state;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
106 107 108
  ROSBridgePtr _pRosBridge;
  TileMap _tileMap;
  NemoInterface *_parent;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
109 110 111 112 113 114
  Dispatcher _dispatcher;
  QString _infoString;
  QString _warningString;
  QTimer _timeoutTimer;
  QTimer _connectionTimer;
  QNemoHeartbeat _lastHeartbeat;
115 116 117 118 119 120
};

using StatusMap = std::map<NemoInterface::STATUS, QString>;
static StatusMap statusMap{
    std::make_pair<NemoInterface::STATUS, QString>(
        NemoInterface::STATUS::NOT_CONNECTED, "Not Connected"),
Valentin Platzgummer's avatar
Valentin Platzgummer committed
121 122
    std::make_pair<NemoInterface::STATUS, QString>(NemoInterface::STATUS::READY,
                                                   "Ready"),
123 124 125 126 127 128 129 130
    std::make_pair<NemoInterface::STATUS, QString>(
        NemoInterface::STATUS::TIMEOUT, "Timeout"),
    std::make_pair<NemoInterface::STATUS, QString>(
        NemoInterface::STATUS::INVALID_HEARTBEAT, "Error"),
    std::make_pair<NemoInterface::STATUS, QString>(
        NemoInterface::STATUS::WEBSOCKET_DETECTED, "Websocket Detected")};

NemoInterface::Impl::Impl(NemoInterface *p)
Valentin Platzgummer's avatar
Valentin Platzgummer committed
131
    : _state(STATE::STOPPED), _parent(p) {
132 133 134 135 136 137 138

  // ROS Bridge.
  WimaSettings *wimaSettings =
      qgcApp()->toolbox()->settingsManager()->wimaSettings();
  auto connectionStringFact = wimaSettings->rosbridgeConnectionString();
  auto setConnectionString = [connectionStringFact, this] {
    auto connectionString = connectionStringFact->rawValue().toString();
Valentin Platzgummer's avatar
Valentin Platzgummer committed
139
    if (is_valid_port_path(connectionString.toLocal8Bit().data())) {
140 141 142 143 144 145
    } else {
      qgcApp()->warningMessageBoxOnMainThread(
          "Nemo Interface",
          "Websocket connection string possibly invalid: " + connectionString +
              ". Trying to connect anyways.");
    }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
146 147 148 149 150 151 152 153

    if (this->_pRosBridge) {
      this->_pRosBridge->reset();
    }
    this->_pRosBridge = std::make_shared<RosbridgeWsClient>(
        connectionString.toLocal8Bit().data());
    this->_pRosBridge->reset();
    qCritical() << "NemoInterface: add reset code here";
154 155 156 157 158
  };
  connect(connectionStringFact, &SettingsFact::rawValueChanged,
          setConnectionString);
  setConnectionString();

Valentin Platzgummer's avatar
Valentin Platzgummer committed
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
  // Heartbeat timeout.
  connect(&this->_timeoutTimer, &QTimer::timeout,
          [this] { this->_setState(STATE::TIMEOUT); });

  // Connection timer (temporary workaround)
  connect(&this->_connectionTimer, &QTimer::timeout, [this] {
    if (this->_pRosBridge->connected()) {
      if (this->_state == STATE::START_BRIDGE ||
          this->_state == STATE::TIMEOUT) {
        this->_setState(STATE::WEBSOCKET_DETECTED);
        this->_doAction();
      }
    } else {
      if (this->_state == STATE::TRY_TOPIC_SERVICE_SETUP ||
          this->_state == STATE::READY) {
        this->_setState(STATE::TIMEOUT);
        this->_doAction();
      }
    }
  });
179 180
}

Valentin Platzgummer's avatar
Valentin Platzgummer committed
181 182
NemoInterface::Impl::~Impl() {}

183
void NemoInterface::Impl::start() {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
184 185 186 187
  if (!running()) {
    this->_setState(STATE::START_BRIDGE);
    this->_doAction();
  }
188 189 190
}

void NemoInterface::Impl::stop() {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
191 192 193 194 195
  if (running()) {
    this->_setState(STATE::STOPPED);
    this->_connectionTimer.stop();
    this->_doAction();
  }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
196 197
}

Valentin Platzgummer's avatar
Valentin Platzgummer committed
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
std::future<QVariant>
NemoInterface::Impl::addTiles(const TileArray &tileArray) {
  using namespace nemo_interface;

  if (this->ready()) {

    // create command.
    auto pRosBridge = this->_pRosBridge;
    auto pDispatcher = &this->_dispatcher;
    Task sendTilesCommand([pRosBridge, tileArray, pDispatcher,
                           this](std::promise<QVariant> promise) {
      // create json object
      rapidjson::Document request;
      auto &allocator = request.GetAllocator();
      rapidjson::Value jsonTileArray(rapidjson::kArrayType);
      for (const auto &tile : tileArray) {
        const auto it = _tileMap.find(tile.id());
        if (Q_LIKELY(it == _tileMap.end())) {

          using namespace ros_bridge::messages;
          rapidjson::Value jsonTile(rapidjson::kObjectType);
          if (!nemo_msgs::tile::toJson(tile, jsonTile, allocator)) {
            qCDebug(NemoInterfaceLog)
                << "addTiles(): not able to create json object: tile id: "
                << tile.id() << " progress: " << tile.progress()
                << " points: " << tile.path();
          }
          jsonTileArray.PushBack(jsonTile, allocator);
        }
      } // for
      rapidjson::Value tileKey("in_tile_array");
      request.AddMember(tileKey, jsonTileArray, allocator);

      // create response handler.
      auto promise_response = std::make_shared<std::promise<void>>();
      auto future_response = promise_response->get_future();
      auto responseHandler =
          [promise_response](
              std::shared_ptr<WsClient::Connection> connection,
              std::shared_ptr<WsClient::InMessage> in_message) mutable {
            qDebug() << "addTiles: in_message" << in_message->string().c_str();
            promise_response->set_value();
            connection->send_close(1000);
          };

      // call service.
      pRosBridge->callService("/nemo/add_tiles", responseHandler, request);

      // wait for response.
      auto tStart = hrc::now();
      bool abort = true;
      do {
        auto status = future_response.wait_for(std::chrono::milliseconds(100));
        if (status == std::future_status::ready) {
          abort = false;
          break;
        }
      } while (hrc::now() - tStart < maxResponseTime ||
               pDispatcher->interruptionPoint());

      if (abort) {
        qCWarning(NemoInterfaceLog) << "Websocket not responding to request.";
        promise.set_value(QVariant(false));
        return;
      }

      qCritical() << "addTiles(): ToDo: add return value checking here.";

      // update local tiles
      QMetaObject::invokeMethod(
          this->_parent, std::bind(&Impl::_addTilesLocal, this, tileArray));

      // return success
      promise.set_value(QVariant(true));
      return;
    }); // sendTilesCommand

    // dispatch command and return.
    auto ret = _dispatcher.dispatch(sendTilesCommand);
    return ret;
  } else {
    std::promise<QVariant> p;
    p.set_value(QVariant(false));
    return p.get_future();
  }
}
Valentin Platzgummer's avatar
Valentin Platzgummer committed
284

Valentin Platzgummer's avatar
Valentin Platzgummer committed
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
TileArray NemoInterface::Impl::getTiles(const IDArray &idArray) {
  TileArray tileArray;

  for (const auto &id : idArray) {
    const auto it = _tileMap.find(id);
    if (it != _tileMap.end()) {
      tileArray.append(it->second);
    }
  }

  return tileArray;
}

TileArray NemoInterface::Impl::getAllTiles() {
  TileArray tileArray;

  for (const auto &entry : _tileMap) {
    tileArray.append(entry.second);
  }

  return tileArray;
}

LogicalArray NemoInterface::Impl::containsTiles(const IDArray &idArray) {
  LogicalArray logicalArray;

  for (const auto &id : idArray) {
    const auto &it = _tileMap.find(id);
    logicalArray.append(it != _tileMap.end());
  }

  return logicalArray;
}

std::size_t NemoInterface::Impl::size() { return _tileMap.size(); }

bool NemoInterface::Impl::empty() { return _tileMap.empty(); }

ProgressArray NemoInterface::Impl::getProgress() {
  ProgressArray progressArray;

  for (const auto &entry : _tileMap) {
    progressArray.append(TaggedProgress{entry.first, entry.second.progress()});
  }

  return progressArray;
}

ProgressArray NemoInterface::Impl::getProgress(const IDArray &idArray) {
  ProgressArray progressArray;

  for (const auto &id : idArray) {
    const auto it = _tileMap.find(id);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
338
    if (it != _tileMap.end()) {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
339 340 341 342 343
      progressArray.append(TaggedProgress{it->first, it->second.progress()});
    }
  }

  return progressArray;
344 345
}

Valentin Platzgummer's avatar
Valentin Platzgummer committed
346 347 348 349
NemoInterface::STATUS NemoInterface::Impl::status() {
  NemoInterface::STATUS status;
  _translate(this->_state, status);
  return status;
350 351
}

Valentin Platzgummer's avatar
Valentin Platzgummer committed
352
bool NemoInterface::Impl::running() { return _running(this->_state); }
353

Valentin Platzgummer's avatar
Valentin Platzgummer committed
354
bool NemoInterface::Impl::ready() { return _ready(this->_state.load()); }
355

Valentin Platzgummer's avatar
Valentin Platzgummer committed
356
const QString &NemoInterface::Impl::infoString() { return _infoString; }
357

Valentin Platzgummer's avatar
Valentin Platzgummer committed
358
const QString &NemoInterface::Impl::warningString() { return _warningString; }
359

Valentin Platzgummer's avatar
Valentin Platzgummer committed
360 361
void NemoInterface::Impl::_addTilesLocal(const TileArray &tileArray) {
  bool anyChanges = false;
362

Valentin Platzgummer's avatar
Valentin Platzgummer committed
363 364 365 366 367 368 369 370 371 372 373 374
  for (const auto &tile : tileArray) {
    const auto id = tile.id();
    const auto it = _tileMap.find(id);
    if (Q_LIKELY(it == _tileMap.end())) {
      auto ret = _tileMap.insert(std::make_pair(id, tile));
      anyChanges = true;
      Q_ASSERT(ret.second == true);
      Q_UNUSED(ret);
    } else {
      qCDebug(NemoInterfaceLog)
          << "_addTilesLocal(): tile with id " << id << " already inserted.";
    }
375 376
  }

Valentin Platzgummer's avatar
Valentin Platzgummer committed
377 378
  if (anyChanges) {
    emit _parent->tilesChanged();
379
  }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426
}

void NemoInterface::Impl::_removeTilesLocal(const IDArray &idArray) {
  bool anyChanges = false;
  for (const auto &id : idArray) {
    const auto it = _tileMap.find(id);
    if (Q_LIKELY(it != _tileMap.end())) {
      _tileMap.erase(it);
      anyChanges = true;
    } else {
      qCDebug(NemoInterfaceLog)
          << "_removeTilesLocal(): tile with id " << id << " not found.";
    }
  }

  if (anyChanges) {
    emit _parent->tilesChanged();
  }
}

void NemoInterface::Impl::_clearTilesLocal() {
  if (!_tileMap.empty()) {
    _tileMap.clear();
    emit _parent->tilesChanged();
  }
}

void NemoInterface::Impl::_updateProgress(ProgressArray progressArray) {
  for (auto itPair = progressArray.begin(); itPair != progressArray.end();) {

    const auto &id = itPair->first;
    auto it = _tileMap.find(id);

    if (Q_LIKELY(it != _tileMap.end())) {
      const auto &progress = itPair->second;
      it->second.setProgress(progress);
      ++itPair;
    } else {
      qCDebug(NemoInterfaceLog)
          << "_updateProgress(): tile with id " << id << " not found.";
      itPair = progressArray.erase(itPair);
    }
  }

  emit _parent->progressChanged(progressArray);
}

Valentin Platzgummer's avatar
Valentin Platzgummer committed
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451
void NemoInterface::Impl::_setHeartbeat(const QNemoHeartbeat &hb) {
  if (this->_lastHeartbeat != hb) {
    _lastHeartbeat = hb;
    if (ready()) {
      this->_timeoutTimer.stop();
      this->_timeoutTimer.start(NO_HEARTBEAT_TIMEOUT);
    }
  }
}

void NemoInterface::Impl::_setInfoString(const QString &info) {
  if (_infoString != info) {
    _infoString = info;
    emit this->_parent->infoStringChanged();
  }
}

void NemoInterface::Impl::_setWarningString(const QString &warning) {
  if (_warningString != warning) {
    _warningString = warning;
    emit this->_parent->warningStringChanged();
  }
}

void NemoInterface::Impl::_doTopicServiceSetup() {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
452
  using namespace ros_bridge::messages;
453 454

  // Subscribe nemo progress.
Valentin Platzgummer's avatar
Valentin Platzgummer committed
455 456
  const char *progressClient = "client:/nemo/progress";
  this->_pRosBridge->addClient(progressClient);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
457
  this->_pRosBridge->subscribe(
Valentin Platzgummer's avatar
Valentin Platzgummer committed
458 459 460 461 462 463
      progressClient, "/nemo/progress",
      [this](std::shared_ptr<WsClient::Connection> connection,
             std::shared_ptr<WsClient::InMessage> in_message) {
        qDebug() << "doTopicServiceSetup(): /nemo/progress: "
                 << in_message->string().c_str();
        qDebug() << "impl missing";
464
      });
Valentin Platzgummer's avatar
Valentin Platzgummer committed
465 466 467
  // Subscribe heartbeat msg.
  const char *heartbeatClient = "client:/nemo/heartbeat";
  this->_pRosBridge->addClient(heartbeatClient);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
468
  this->_pRosBridge->subscribe(
Valentin Platzgummer's avatar
Valentin Platzgummer committed
469 470 471 472 473 474
      heartbeatClient, "/nemo/heartbeat",
      [this](std::shared_ptr<WsClient::Connection> connection,
             std::shared_ptr<WsClient::InMessage> in_message) {
        qDebug() << "doTopicServiceSetup(): /nemo/heartbeat: "
                 << in_message->string().c_str();
        qDebug() << "impl missing";
475 476 477
      });
}

Valentin Platzgummer's avatar
Valentin Platzgummer committed
478
void NemoInterface::Impl::_doAction() {
479
  // Check ROS Bridge status and do setup if necessary.
Valentin Platzgummer's avatar
Valentin Platzgummer committed
480 481 482
  switch (this->_state) {
  case STATE::STOPPED:
    if (this->_pRosBridge->running()) {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
483
      this->_pRosBridge->reset();
484
    }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
485
    break;
486

Valentin Platzgummer's avatar
Valentin Platzgummer committed
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503
  case STATE::START_BRIDGE:
  case STATE::TIMEOUT:
    this->_pRosBridge->reset();
    this->_pRosBridge->run();
    this->_connectionTimer.start(EVENT_TIMER_INTERVAL);
    break;
  case STATE::WEBSOCKET_DETECTED:
    this->_setState(STATE::TRY_TOPIC_SERVICE_SETUP);
    this->_doAction();
    break;
  case STATE::TRY_TOPIC_SERVICE_SETUP:
    this->_doTopicServiceSetup();
    this->_setState(STATE::READY);
    break;
  case STATE::READY:
    break;
  };
504 505
}

Valentin Platzgummer's avatar
Valentin Platzgummer committed
506
bool NemoInterface::Impl::_setState(STATE s) {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
507 508
  if (s != this->_state) {
    this->_state = s;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
509
    emit this->_parent->statusChanged();
510 511 512 513 514 515
    return true;
  } else {
    return false;
  }
}

Valentin Platzgummer's avatar
Valentin Platzgummer committed
516 517 518 519 520 521 522 523
bool NemoInterface::Impl::_ready(NemoInterface::Impl::STATE s) {
  return s == STATE::READY;
}

bool NemoInterface::Impl::_running(NemoInterface::Impl::STATE s) {
  return s != STATE::STOPPED;
}

524 525
// ===============================================================
// NemoInterface
526 527 528 529 530 531 532 533 534
NemoInterface::NemoInterface()
    : QObject(), pImpl(std::make_unique<NemoInterface::Impl>(this)) {}

NemoInterface *NemoInterface::createInstance() { return new NemoInterface(); }

NemoInterface *NemoInterface::instance() {
  return GenericSingelton<NemoInterface>::instance(
      NemoInterface::createInstance);
}
535 536 537 538 539 540 541

NemoInterface::~NemoInterface() {}

void NemoInterface::start() { this->pImpl->start(); }

void NemoInterface::stop() { this->pImpl->stop(); }

542
void NemoInterface::addTiles(const TileArray &tileArray) {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
543
  this->pImpl->addTiles(tileArray);
544 545 546 547 548 549 550 551 552 553 554 555
}

void NemoInterface::removeTiles(const IDArray &idArray) {
  this->pImpl->removeTiles(idArray);
}

void NemoInterface::clearTiles() { this->pImpl->clearTiles(); }

TileArray NemoInterface::getTiles(const IDArray &idArray) {
  return this->pImpl->getTiles(idArray);
}

Valentin Platzgummer's avatar
Valentin Platzgummer committed
556
TileArray NemoInterface::getAllTiles() { return this->pImpl->getAllTiles(); }
557 558 559 560 561 562 563 564 565

LogicalArray NemoInterface::containsTiles(const IDArray &idArray) {
  return this->pImpl->containsTiles(idArray);
}

std::size_t NemoInterface::size() { return this->pImpl->size(); }

bool NemoInterface::empty() { return this->pImpl->empty(); }

Valentin Platzgummer's avatar
Valentin Platzgummer committed
566 567 568 569 570 571 572 573
ProgressArray NemoInterface::getProgress() {
  return this->pImpl->getProgress();
}

ProgressArray NemoInterface::getProgress(const IDArray &idArray) {
  return this->pImpl->getProgress(idArray);
}

574
NemoInterface::STATUS NemoInterface::status() const {
575 576 577 578 579 580 581
  return this->pImpl->status();
}

QString NemoInterface::statusString() const {
  return statusMap.at(this->pImpl->status());
}

Valentin Platzgummer's avatar
Valentin Platzgummer committed
582 583 584 585 586
QString NemoInterface::infoString() const { return this->pImpl->infoString(); }

QString NemoInterface::warningString() const {
  return this->pImpl->warningString();
}
587 588 589 590 591 592

QString NemoInterface::editorQml() {
  return QStringLiteral("NemoInterface.qml");
}

bool NemoInterface::running() { return this->pImpl->running(); }