• R/O
  • SSH
  • HTTPS

qrobosdk: コミット


コミットメタ情報

リビジョン1986 (tree)
日時2012-05-07 20:42:57
作者satofumi

ログメッセージ

added debug code

変更サマリ

差分

--- trunk/programs/UrgViewer/UrgViewerWindow.cpp (revision 1985)
+++ trunk/programs/UrgViewer/UrgViewerWindow.cpp (revision 1986)
@@ -35,6 +35,8 @@
3535 #include <QSettings>
3636 #include <QCloseEvent>
3737
38+#include <cstdio>
39+
3840 using namespace qrk;
3941 using namespace std;
4042
@@ -89,13 +91,15 @@
8991 vector<int> draw_line_indexes_;
9092 vector<Point<long> > draw_line_points_;
9193
94+ int error_count_;
9295
96+
9397 pImpl(int argc, char *argv[], UrgViewerWindow* widget)
9498 : widget_(widget), urg_(argc, argv), serial_connection_(NULL),
9599 capture_setting_widget_(urg_), connect_thread_(urg_),
96100 draw_intensity_(false), last_timestamp_(InvalidTimestamp),
97101 last_record_time_(QDateTime::currentDateTime()),
98- settings_(NULL), set_length_view_(false)
102+ settings_(NULL), set_length_view_(false), error_count_(0)
99103 {
100104 com_finder_.addBaseName("/dev/ttyACM");
101105 com_finder_.addBaseName("/dev/tty.usbmodem");
@@ -396,6 +400,15 @@
396400
397401 void captureHandler(void)
398402 {
403+#if 1
404+ enum { Reconnect_error_times = 100 };
405+ if (error_count_ > Reconnect_error_times) {
406+ reconnect();
407+ error_count_ = 0;
408+ return;
409+ }
410+#endif
411+
399412 LockGuard guard(urg_mutex_);
400413
401414 vector<long> data;
@@ -411,11 +424,12 @@
411424 n = urg_.captureWithIntensity(data, intensity_data, &timestamp);
412425 }
413426 if (n <= 0) {
427+ ++error_count_;
414428 return;
415429 }
430+ error_count_ = 0;
416431
417432 #if defined(DEBUG)
418- // !!! debug message
419433 QDateTime current = QDateTime::currentDateTime();
420434 if (last_record_time_.secsTo(current) >= 60) {
421435 log_printf("%s\n",
@@ -477,6 +491,14 @@
477491 }
478492
479493
494+ void reconnect(void)
495+ {
496+ // !!! Ethernet 専用の実装になっているのを修正する
497+ widget_->connectPressed(false, "192.168.0.10", 10940);
498+ widget_->connectPressed(true, "192.168.0.10", 10940);
499+ }
500+
501+
480502 void setPlayConnection(void)
481503 {
482504 // 接続操作を disable にする
@@ -560,8 +582,7 @@
560582 }
561583
562584
563-void UrgViewerWindow::connectPressed(bool connection,
564- const string& device)
585+void UrgViewerWindow::connectPressed(bool connection, const string& device)
565586 {
566587 LockGuard guard(pimpl->urg_mutex_);
567588
旧リポジトリブラウザで表示