discover-frame.cc
Go to the documentation of this file.
1 /*
2  * rcdiscover - the network discovery tool for Roboception devices
3  *
4  * Copyright (c) 2017 Roboception GmbH
5  * All rights reserved
6  *
7  * Author: Raphael Schaller
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * 3. Neither the name of the copyright holder nor the names of its contributors
20  * may be used to endorse or promote products derived from this software without
21  * specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 // placed here to make sure to include winsock2.h before windows.h
37 #include "rcdiscover/wol.h"
38 #include "rcdiscover/utils.h"
39 
40 #include "discover-frame.h"
41 
42 #include "discover-thread.h"
43 #include "event-ids.h"
44 #include "reset-dialog.h"
45 #include "force-ip-dialog.h"
46 #include "reconnect-dialog.h"
47 #include "about-dialog.h"
48 #include "resources.h"
49 
50 #include <memory>
51 #include <sstream>
52 #include <algorithm>
53 
54 #include <wx/frame.h>
55 #include <wx/dataview.h>
56 #include <wx/button.h>
57 #include <wx/animate.h>
58 #include <wx/mstream.h>
59 #include <wx/menu.h>
60 #include <wx/panel.h>
61 #include <wx/sizer.h>
62 #include <wx/clipbrd.h>
63 #include <wx/dc.h>
64 #include <wx/msgdlg.h>
65 #include <wx/html/helpctrl.h>
66 #include <wx/cshelp.h>
67 #include <wx/statline.h>
68 #include <wx/persist/toplevel.h>
69 
70 #include "resources/logo_128.xpm"
72 
73 static bool isMadeByRc(const wxVector<wxVariant> &device)
74 {
75  return device[DiscoverFrame::MANUFACTURER].GetString() == ROBOCEPTION ||
76  device[DiscoverFrame::MODEL].GetString().StartsWith(RC_VISARD) ||
77  device[DiscoverFrame::MODEL].GetString().StartsWith(RC_CUBE);
78 }
79 
80 static bool isMadeByRc(const wxDataViewListCtrl &device_list, unsigned int row)
81 {
82  return device_list.GetTextValue(row, DiscoverFrame::MANUFACTURER) == ROBOCEPTION ||
83  device_list.GetTextValue(row, DiscoverFrame::MODEL).StartsWith(RC_VISARD) ||
84  device_list.GetTextValue(row, DiscoverFrame::MODEL).StartsWith(RC_CUBE);
85 }
86 
87 static bool isRcVisard(const wxVector<wxVariant> &device)
88 {
89  return device[DiscoverFrame::MODEL].GetString().StartsWith(RC_VISARD);
90 }
91 
92 static bool isRcVisard(const wxDataViewListCtrl &device_list, unsigned int row)
93 {
94  return device_list.GetTextValue(row, DiscoverFrame::MODEL).StartsWith(RC_VISARD);
95 }
96 
97 DiscoverFrame::DiscoverFrame(const wxString& title,
98  const wxPoint& pos) :
99  wxFrame(NULL, wxID_ANY, title, pos, wxSize(1080,350)),
100  device_list_(nullptr),
101  discover_button_(nullptr),
102  filter_input_(nullptr),
103  reset_button_(nullptr),
104  force_ip_button_(nullptr),
105  reset_dialog_(nullptr),
106  force_ip_dialog_(nullptr),
107  about_dialog_(nullptr),
108  menu_event_item_(nullptr),
109  only_rc_sensors_(true),
110  filter_text_()
111 {
112  // spinner
113  wxIcon icon_128(logo_128_xpm);
114  SetIcon(icon_128);
115 
116  wxMemoryInputStream gif_stream(logo_32_rotate_gif,
117  sizeof(logo_32_rotate_gif));
118  spinner_.Load(gif_stream, wxANIMATION_TYPE_GIF);
119 
120  // menu
121  wxMenu *menuFile = new wxMenu();
122  menuFile->Append(wxID_EXIT);
123 
124  wxMenu *menuHelp = new wxMenu();
125  menuHelp->Append(wxID_HELP);
126  menuHelp->Append(wxID_ABOUT);
127 
128  wxMenuBar *menuBar = new wxMenuBar();
129  menuBar->Append(menuFile, "&File");
130  menuBar->Append(menuHelp, "&Help");
131 
132  SetMenuBar(menuBar);
133  CreateStatusBar();
134 
135  // window content
136  auto *panel = new wxPanel(this, wxID_ANY);
137  auto *vbox = new wxBoxSizer(wxVERTICAL);
138 
139  // uppper buttons
140  {
141  auto *button_box = new wxBoxSizer(wxHORIZONTAL);
142  discover_button_ = new wxButton(panel, ID_DiscoverButton, "Rerun Discovery");
143  button_box->Add(discover_button_, 1);
144 
145  button_box->AddSpacer(10);
146  button_box->Add(new wxStaticLine(panel, wxID_ANY, wxDefaultPosition,
147  wxSize(-1,30), wxLI_VERTICAL));
148  button_box->AddSpacer(10);
149 
150  int w, h;
151  discover_button_->GetSize(&w, &h);
152  auto *only_rc_cbox = new wxCheckBox(panel, ID_OnlyRcCheckbox,
153  "Only Roboception devices",
154  wxDefaultPosition, wxSize(-1, h));
155  only_rc_cbox->SetValue(only_rc_sensors_);
156  button_box->Add(only_rc_cbox, 1);
157 
158  button_box->AddSpacer(10);
159  button_box->Add(new wxStaticLine(panel, wxID_ANY, wxDefaultPosition,
160  wxSize(-1,30), wxLI_VERTICAL));
161  button_box->AddSpacer(10);
162 
163  auto *filter_text = new wxStaticText(panel, wxID_ANY, "Filter");
164  button_box->Add(filter_text, 1, wxTOP, 6);
165 
166  button_box->AddSpacer(10);
167  filter_input_ = new wxTextCtrl(panel, ID_FilterTextInput, wxEmptyString,
168  wxDefaultPosition, wxSize(150, -1));
169  filter_input_->SetToolTip("Use * and ? as wildcards");
170  button_box->Add(filter_input_, 0);
171 
172  button_box->Add(-1, 0, wxEXPAND);
173 
174  spinner_ctrl_ = new wxAnimationCtrl(panel, wxID_ANY, spinner_,
175  wxPoint(-1,-1), wxSize(32,32));
176  button_box->Add(spinner_ctrl_, 0);
177 
178  vbox->Add(button_box, 0, wxALL, 10);
179  }
180 
181  // device table
182  {
183  auto *data_box = new wxBoxSizer(wxHORIZONTAL);
184 
185  device_list_ = new wxDataViewListCtrl(panel,
187  wxPoint(-1,-1),
188  wxSize(-1,-1));
189  device_list_->AppendTextColumn("Name",
190  wxDATAVIEW_CELL_INERT,
191  100, wxALIGN_LEFT,
192  wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
193  device_list_->AppendTextColumn("Manufacturer",
194  wxDATAVIEW_CELL_INERT,
195  170, wxALIGN_LEFT,
196  wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
197  device_list_->AppendTextColumn("Model",
198  wxDATAVIEW_CELL_INERT,
199  130, wxALIGN_LEFT,
200  wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
201  device_list_->AppendTextColumn("Serial Number",
202  wxDATAVIEW_CELL_INERT,
203  130, wxALIGN_LEFT,
204  wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
205  device_list_->AppendTextColumn("IP Address",
206  wxDATAVIEW_CELL_INERT,
207  120, wxALIGN_LEFT,
208  wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
209  device_list_->AppendTextColumn("MAC Address",
210  wxDATAVIEW_CELL_INERT,
211  130, wxALIGN_LEFT,
212  wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
213  device_list_->AppendTextColumn("Interface(s)",
214  wxDATAVIEW_CELL_INERT,
215  130, wxALIGN_LEFT,
216  wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
217  device_list_->AppendTextColumn("Reachable",
218  wxDATAVIEW_CELL_INERT,
219  80, wxALIGN_CENTER,
220  wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
221 
222  device_list_->SetToolTip("Double-click row to open WebGUI in browser.");
223 
224  data_box->Add(device_list_, 1, wxEXPAND);
225 
226  vbox->Add(data_box, 1, wxLEFT | wxRIGHT | wxEXPAND, 10);
227  }
228 
229  {
230  auto *button_box = new wxBoxSizer(wxHORIZONTAL);
231  reset_button_ = new wxButton(panel, ID_ResetButton, "Reset rc_visard");
232  button_box->Add(reset_button_, 1);
233  int w, h;
234  reset_button_->GetSize(&w, &h);
235 
236  force_ip_button_ = new wxButton(panel, ID_ForceIpButton,
237  "Set temporary IP address");
238  button_box->Add(force_ip_button_, 1);
239 
240  reconnect_button_ = new wxButton(panel, ID_ReconnectButton,
241  "Reconnect device");
242  button_box->Add(reconnect_button_, 1);
243 
244  button_box->Add(-1, 0, wxEXPAND);
245 
246  auto *help_button = new wxContextHelpButton(panel, ID_Help_Discovery,
247  wxDefaultPosition, wxSize(h,h));
248  button_box->Add(help_button, 0);
249 
250  vbox->Add(button_box, 0, wxTOP | wxLEFT | wxRIGHT, 10);
251  }
252 
253  panel->SetSizer(vbox);
254  Centre();
255 
256  help_ctrl_ = new wxHtmlHelpController(wxHF_DEFAULT_STYLE, panel);
257  help_ctrl_->AddBook("memory:help.hhp");
258 
259  Connect(ID_DiscoverButton,
260  wxEVT_COMMAND_BUTTON_CLICKED,
261  wxCommandEventHandler(DiscoverFrame::onDiscoverButton));
262  Connect(wxID_ANY,
263  wxEVT_COMMAND_DISCOVERY_COMPLETED,
264  wxThreadEventHandler(DiscoverFrame::onDiscoveryCompleted));
265  Connect(wxID_ANY,
266  wxEVT_COMMAND_DISCOVERY_ERROR,
267  wxThreadEventHandler(DiscoverFrame::onDiscoveryError));
268  Connect(ID_ResetButton,
269  wxEVT_COMMAND_BUTTON_CLICKED,
270  wxCommandEventHandler(DiscoverFrame::onResetButton));
271  Connect(ID_ForceIpButton,
272  wxEVT_COMMAND_BUTTON_CLICKED,
273  wxCommandEventHandler(DiscoverFrame::onForceIpButton));
274  Connect(ID_ReconnectButton,
275  wxEVT_COMMAND_BUTTON_CLICKED,
276  wxCommandEventHandler(DiscoverFrame::onReconnectButton));
277  Connect(ID_Help_Discovery,
278  wxEVT_COMMAND_BUTTON_CLICKED,
279  wxCommandEventHandler(DiscoverFrame::onHelpDiscovery));
280  Connect(ID_DataViewListCtrl,
281  wxEVT_DATAVIEW_ITEM_ACTIVATED,
282  wxDataViewEventHandler(DiscoverFrame::onDeviceDoubleClick));
283  Connect(ID_DataViewListCtrl,
284  wxEVT_DATAVIEW_SELECTION_CHANGED,
285  wxDataViewEventHandler(DiscoverFrame::onDeviceSelection));
286  Connect(ID_DataViewListCtrl,
287  wxEVT_DATAVIEW_ITEM_CONTEXT_MENU,
288  wxDataViewEventHandler(DiscoverFrame::onDataViewContextMenu));
289  Connect(ID_OpenWebGUI,
290  wxEVT_MENU,
291  wxMenuEventHandler(DiscoverFrame::onOpenWebGUI));
292  Connect(ID_CopyName,
293  wxEVT_MENU,
294  wxMenuEventHandler(DiscoverFrame::onCopy));
295  Connect(ID_CopyManufacturer,
296  wxEVT_MENU,
297  wxMenuEventHandler(DiscoverFrame::onCopy));
298  Connect(ID_CopyModel,
299  wxEVT_MENU,
300  wxMenuEventHandler(DiscoverFrame::onCopy));
301  Connect(ID_CopySerial,
302  wxEVT_MENU,
303  wxMenuEventHandler(DiscoverFrame::onCopy));
304  Connect(ID_CopyIP,
305  wxEVT_MENU,
306  wxMenuEventHandler(DiscoverFrame::onCopy));
307  Connect(ID_CopyMac,
308  wxEVT_MENU,
309  wxMenuEventHandler(DiscoverFrame::onCopy));
310  Connect(ID_ResetButton,
311  wxEVT_MENU,
312  wxMenuEventHandler(DiscoverFrame::onResetContextMenu));
313  Connect(ID_ForceIpButton,
314  wxEVT_MENU,
315  wxMenuEventHandler(DiscoverFrame::onForceIpContextMenu));
316  Connect(ID_ReconnectButton,
317  wxEVT_MENU,
318  wxMenuEventHandler(DiscoverFrame::onReconnectContextMenu));
319  Connect(wxID_EXIT,
320  wxEVT_MENU,
321  wxCommandEventHandler(DiscoverFrame::onExit));
322  Connect(wxID_ABOUT,
323  wxEVT_MENU,
324  wxCommandEventHandler(DiscoverFrame::onAbout));
325  Connect(wxID_HELP,
326  wxEVT_MENU,
327  wxCommandEventHandler(DiscoverFrame::onHelp));
328  Connect(ID_OnlyRcCheckbox,
329  wxEVT_CHECKBOX,
330  wxCommandEventHandler(DiscoverFrame::onOnlyRcCheckbox));
331  Connect(ID_FilterTextInput,
332  wxEVT_TEXT,
333  wxCommandEventHandler(DiscoverFrame::onFilterTextChange));
334 
335  reset_dialog_ = new ResetDialog(help_ctrl_, panel, wxID_ANY);
336  force_ip_dialog_ = new ForceIpDialog(help_ctrl_, panel, wxID_ANY);
337  reconnect_dialog_ = new ReconnectDialog(help_ctrl_, panel, wxID_ANY);
338  about_dialog_ = new AboutDialog(panel, wxID_ANY);
339 
340  wxPersistentRegisterAndRestore(this, "discover_frame");
341 
342  // start discovery on startup
343  wxCommandEvent evt;
344  onDiscoverButton(evt);
345 }
346 
348 {
349  discover_button_->Disable();
350  reset_button_->Disable();
351  force_ip_button_->Disable();
352  reconnect_button_->Disable();
353  spinner_ctrl_->Play();
354 }
355 
357 {
358  discover_button_->Enable();
359  reset_button_->Enable();
360  force_ip_button_->Enable();
361  reconnect_button_->Enable();
362  spinner_ctrl_->Stop();
363 
364  // on Windows, wxAnimationCtrl is sometimes not stopping even if
365  // Stop was called. Calling it multiple times reduces the chance
366  // of this happening.
367  spinner_ctrl_->Stop();
368  spinner_ctrl_->Stop();
369 }
370 
371 void DiscoverFrame::onDiscoverButton(wxCommandEvent &)
372 {
373  setBusy();
374 
375  auto *thread = new DiscoverThread(this);
376  if (thread->Run() != wxTHREAD_NO_ERROR)
377  {
378  std::cerr << "Could not spawn thread" << std::endl;
379  delete thread;
380  thread = nullptr;
381 
382  clearBusy();
383  }
384 }
385 
386 void DiscoverFrame::onDiscoveryCompleted(wxThreadEvent &event)
387 {
388  updateDeviceList(event.GetPayload<std::vector<wxVector<wxVariant>>>());
389 
390  clearBusy();
391 }
392 
393 void DiscoverFrame::updateDeviceList(const std::vector<wxVector<wxVariant>> &d)
394 {
395  device_list_->DeleteAllItems();
396 
397  std::vector<bool> show_in_reset_dialog;
398 
399  last_data_ = d;
400  for(const auto& d : last_data_)
401  {
402  const bool matches_filter = [&] {
403  if (!filter_text_.empty())
404  {
405  const auto& filter_text = filter_text_;
406  const bool none = std::none_of(d.begin(), d.end(), [&filter_text](const wxVariant& v) {
407  const auto s = v.GetString().ToStdString();
408  return wildcardMatch(s.begin(), s.end(), filter_text.begin(), filter_text.end());
409  });
410  if (none)
411  {
412  return false;
413  }
414  }
415  return true;
416  }();
417 
418  if (matches_filter && (!only_rc_sensors_ || isMadeByRc(d)))
419  {
420  device_list_->AppendItem(d);
421  show_in_reset_dialog.push_back(isRcVisard(d));
422  }
423  }
424 
425  reset_dialog_->setDiscoveredSensors(device_list_->GetStore(), show_in_reset_dialog);
428 }
429 
430 void DiscoverFrame::onDiscoveryError(wxThreadEvent &event)
431 {
432  std::ostringstream oss;
433  oss << "An error occurred during discovery: " << event.GetString();
434  wxMessageBox(oss.str(), "Error", wxOK | wxICON_ERROR);
435 
436  clearBusy();
437 }
438 
439 void DiscoverFrame::onResetButton(wxCommandEvent &)
440 {
441  openResetDialog(device_list_->GetSelectedRow());
442 }
443 
444 void DiscoverFrame::onForceIpButton(wxCommandEvent &)
445 {
446  openForceIpDialog(device_list_->GetSelectedRow());
447 }
448 
449 void DiscoverFrame::onReconnectButton(wxCommandEvent &)
450 {
451  openReconnectDialog(device_list_->GetSelectedRow());
452 }
453 
454 void DiscoverFrame::onHelpDiscovery(wxCommandEvent&)
455 {
456  help_ctrl_->Display("help.htm#discovery");
457 }
458 
459 void DiscoverFrame::onDeviceDoubleClick(wxDataViewEvent &event)
460 {
461  const auto item = event.GetItem();
462  const auto row = device_list_->ItemToRow(item);
463 
464  if (row == wxNOT_FOUND)
465  {
466  return;
467  }
468 
469  openWebGUI(row);
470 }
471 
472 void DiscoverFrame::onDeviceSelection(wxDataViewEvent &event)
473 {
474  const auto item = event.GetItem();
475  const auto row = device_list_->ItemToRow(item);
476 
477  if (row == wxNOT_FOUND)
478  {
479  return;
480  }
481 
482  reset_button_->Enable(isRcVisard(*device_list_, row));
483 }
484 
485 void DiscoverFrame::onDataViewContextMenu(wxDataViewEvent &event)
486 {
487  menu_event_item_.reset(new std::pair<int, int>(
488  device_list_->ItemToRow(event.GetItem()),
489  event.GetColumn()));
490 
491  if (menu_event_item_->first < 0)
492  {
493  return;
494  }
495 
496  wxMenu menu;
497  menu.Append(ID_CopyName, "Copy name");
498  menu.Append(ID_CopyManufacturer, "Copy manufacturer");
499  menu.Append(ID_CopyModel, "Copy model");
500  menu.Append(ID_CopySerial, "Copy serial number");
501  menu.Append(ID_CopyIP, "Copy IP address");
502  menu.Append(ID_CopyMac, "Copy MAC address");
503 
504  if (isMadeByRc(*device_list_, static_cast<unsigned int>(menu_event_item_->first)))
505  {
506  menu.AppendSeparator();
507  menu.Append(ID_OpenWebGUI, "Open &WebGUI");
508  menu.AppendSeparator();
509  if (isRcVisard(*device_list_, static_cast<unsigned int>(menu_event_item_->first)))
510  {
511  menu.Append(ID_ResetButton, "Reset");
512  }
513  }
514 
515  menu.Append(ID_ForceIpButton, "Set temporary IP");
516  menu.Append(ID_ReconnectButton, "Reconnect");
517 
518  PopupMenu(&menu);
519 }
520 
521 void DiscoverFrame::onCopy(wxMenuEvent &evt)
522 {
523  int column;
524  switch (evt.GetId())
525  {
526  case ID_CopyName:
527  column = NAME;
528  break;
529 
530  case ID_CopyManufacturer:
531  column = MANUFACTURER;
532  break;
533 
534  case ID_CopyModel:
535  column = MODEL;
536  break;
537 
538  case ID_CopySerial:
539  column = SERIAL;
540  break;
541 
542  case ID_CopyIP:
543  column = IP;
544  break;
545 
546  case ID_CopyMac:
547  column = MAC;
548  break;
549 
550  default:
551  return;
552  }
553 
554  const auto row = static_cast<unsigned int>(menu_event_item_->first);
555  const auto cell = device_list_->GetTextValue(row, column);
556 
557  if (wxTheClipboard->Open())
558  {
559  wxTheClipboard->SetData(new wxTextDataObject(cell));
560  wxTheClipboard->Close();
561  }
562 }
563 
564 void DiscoverFrame::onOpenWebGUI(wxMenuEvent &)
565 {
566  if (!menu_event_item_ ||
567  menu_event_item_->first < 0)
568  {
569  return;
570  }
571 
573 }
574 
576 {
577  if (!menu_event_item_ ||
578  menu_event_item_->first < 0)
579  {
580  return;
581  }
582 
584 }
585 
587 {
588  if (!menu_event_item_ ||
589  menu_event_item_->first < 0)
590  {
591  return;
592  }
593 
595 }
596 
598 {
599  if (!menu_event_item_ ||
600  menu_event_item_->first < 0)
601  {
602  return;
603  }
604 
606 }
607 
608 void DiscoverFrame::onExit(wxCommandEvent &)
609 {
610  Close(true);
611 }
612 
613 void DiscoverFrame::onHelp(wxCommandEvent&)
614 {
615  help_ctrl_->Display("help.htm");
616 }
617 
618 void DiscoverFrame::onOnlyRcCheckbox(wxCommandEvent &evt)
619 {
620  only_rc_sensors_ = evt.IsChecked();
622 }
623 
624 void DiscoverFrame::onFilterTextChange(wxCommandEvent &evt)
625 {
626  filter_text_ = evt.GetString();
627  std::transform(filter_text_.begin(), filter_text_.end(), filter_text_.begin(), ::tolower);
628  if (!filter_text_.empty())
629  {
630  if (filter_text_.front() != '*')
631  { filter_text_ = '*' + filter_text_; }
632  if (filter_text_.back() != '*')
633  { filter_text_ = filter_text_ + '*'; }
634  }
636 }
637 
638 void DiscoverFrame::onAbout(wxCommandEvent &)
639 {
640  about_dialog_->ShowModal();
641 }
642 
644 {
645  if (row != wxNOT_FOUND)
646  {
647  reset_dialog_->setActiveSensor(static_cast<unsigned int>(row));
648  }
649 
650  reset_dialog_->Show();
651 }
652 
654 {
655  if (row != wxNOT_FOUND)
656  {
657  force_ip_dialog_->setActiveSensor(static_cast<unsigned int>(row));
658  }
659 
660  force_ip_dialog_->Show();
661 }
662 
664 {
665  if (row != wxNOT_FOUND)
666  {
667  reconnect_dialog_->setActiveSensor(static_cast<unsigned int>(row));
668  }
669 
670  reconnect_dialog_->Show();
671 }
672 
674 {
675  if (isMadeByRc(*device_list_, row))
676  {
677  const auto ip_wxstring = device_list_->GetTextValue(
678  static_cast<unsigned int>(row), IP);
679  wxLaunchDefaultBrowser("http://" + ip_wxstring + "/");
680  }
681 }
682 
683 BEGIN_EVENT_TABLE(DiscoverFrame, wxFrame)
684 END_EVENT_TABLE()
static const std::string ROBOCEPTION
Definition: resources.h:21
void openResetDialog(int row)
Open device reset dialog.
void onFilterTextChange(wxCommandEvent &evt)
Event handler for change of the filter text box.
static bool isRcVisard(const wxVector< wxVariant > &device)
void openReconnectDialog(int row)
Open Reconnect dialog.
static bool isMadeByRc(const wxVector< wxVariant > &device)
static const std::string RC_VISARD
Definition: resources.h:22
Dialog for Magic Packets reset of rc_visard.
Definition: reset-dialog.h:48
void onHelp(wxCommandEvent &)
Event handler for "help" item in window menu.
void onForceIpButton(wxCommandEvent &)
Event handler for ForceIP button click.
DiscoverFrame(const wxString &title, const wxPoint &pos)
Constructor.
void onReconnectButton(wxCommandEvent &)
Event handler for Reconnect button click.
bool wildcardMatch(std::string::const_iterator str_first, std::string::const_iterator str_last, std::string::const_iterator p_first, std::string::const_iterator p_last)
Definition: utils.h:156
std::vector< wxVector< wxVariant > > last_data_
std::unique_ptr< std::pair< int, int > > menu_event_item_
std::string filter_text_
ReconnectDialog * reconnect_dialog_
void onDeviceDoubleClick(wxDataViewEvent &event)
Event handler for double click on a device.
void onDiscoveryError(wxThreadEvent &event)
Event handler for erroneous device discovery.
void onOpenWebGUI(wxMenuEvent &)
Event handler for "open web gui" context menu item.
void onResetContextMenu(wxMenuEvent &)
Event handler for "reset" context menu item.
ResetDialog * reset_dialog_
Dialog for sending FORCEIP_CMD to camera.
void onOnlyRcCheckbox(wxCommandEvent &evt)
Event handler for change of the "only RC cameras" checkbox.
void onResetButton(wxCommandEvent &)
Event handler for Reset button click.
Main window in which the table of discovered devices is displayed.
void updateDeviceList(const std::vector< wxVector< wxVariant >> &d)
Updates the device table.
void openForceIpDialog(int row)
Open Force IP dialog.
About dialog.
Definition: about-dialog.h:44
wxButton * force_ip_button_
ForceIpDialog * force_ip_dialog_
AboutDialog * about_dialog_
void onCopy(wxMenuEvent &)
Event handler for "copy" context menu item.
wxAnimationCtrl * spinner_ctrl_
wxButton * discover_button_
wxAnimation spinner_
Thread in which the discovery of devices is run.
Dialog for sending FORCEIP_CMD with IP set to 0 to camera.
unsigned char logo_32_rotate_gif[]
Definition: logo_32_rotate.h:1
void onDataViewContextMenu(wxDataViewEvent &event)
Event handler for right mouse button click on device.
void openWebGUI(int row)
Open WebGUI for device in specific row.
void setDiscoveredSensors(const wxDataViewListModel *sensor_list, const std::vector< bool > &show={})
Set list of discovered devices to provide a drop down menu to the user.
void onDiscoveryCompleted(wxThreadEvent &event)
Event handler for completed device discovery.
wxButton * reset_button_
void clearBusy()
Stop spinner rotation.
wxTextCtrl * filter_input_
void onDiscoverButton(wxCommandEvent &)
Event handler for Discovery button click.
void onExit(wxCommandEvent &)
Event handler for exit command.
wxHtmlHelpController * help_ctrl_
wxButton * reconnect_button_
void onForceIpContextMenu(wxMenuEvent &)
Event handler for "force ip" context menu item.
void onDeviceSelection(wxDataViewEvent &event)
Event handler for selection of a device.
void setActiveSensor(const unsigned int row)
Select a specific device of the list set by setDiscoveredSensors.
void onReconnectContextMenu(wxMenuEvent &)
Event handler for "reconnect" context menu item.
static const std::string RC_CUBE
Definition: resources.h:23
wxDataViewListCtrl * device_list_
void onHelpDiscovery(wxCommandEvent &)
Event handler for help button.
void onAbout(wxCommandEvent &)
Event handler for "about" item in window menu.
void setBusy()
Let spinner rotate.


rcdiscover
Author(s): Heiko Hirschmueller , Raphael Schaller
autogenerated on Sun Apr 18 2021 02:16:32