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_");
77 }
78 
79 static bool isMadeByRc(const wxDataViewListCtrl &device_list, unsigned int row)
80 {
81  return device_list.GetTextValue(row, DiscoverFrame::MANUFACTURER) == ROBOCEPTION ||
82  device_list.GetTextValue(row, DiscoverFrame::MODEL).StartsWith("rc_");
83 }
84 
85 static bool isRcVisard(const wxVector<wxVariant> &device)
86 {
87  return device[DiscoverFrame::MODEL].GetString().StartsWith(RC_VISARD);
88 }
89 
90 static bool isRcVisard(const wxDataViewListCtrl &device_list, unsigned int row)
91 {
92  return device_list.GetTextValue(row, DiscoverFrame::MODEL).StartsWith(RC_VISARD);
93 }
94 
95 DiscoverFrame::DiscoverFrame(const wxString& title,
96  const wxPoint& pos) :
97  wxFrame(NULL, wxID_ANY, title, pos, wxSize(1080,350)),
98  device_list_(nullptr),
99  discover_button_(nullptr),
100  filter_input_(nullptr),
101  reset_button_(nullptr),
102  force_ip_button_(nullptr),
103  reset_dialog_(nullptr),
104  force_ip_dialog_(nullptr),
105  about_dialog_(nullptr),
106  menu_event_item_(nullptr),
107  only_rc_sensors_(true),
108  filter_text_()
109 {
110  // spinner
111  wxIcon icon_128(logo_128_xpm);
112  SetIcon(icon_128);
113 
114  wxMemoryInputStream gif_stream(logo_32_rotate_gif,
115  sizeof(logo_32_rotate_gif));
116  spinner_.Load(gif_stream, wxANIMATION_TYPE_GIF);
117 
118  // menu
119  wxMenu *menuFile = new wxMenu();
120  menuFile->Append(wxID_EXIT);
121 
122  wxMenu *menuHelp = new wxMenu();
123  menuHelp->Append(wxID_HELP);
124  menuHelp->Append(wxID_ABOUT);
125 
126  wxMenuBar *menuBar = new wxMenuBar();
127  menuBar->Append(menuFile, "&File");
128  menuBar->Append(menuHelp, "&Help");
129 
130  SetMenuBar(menuBar);
131  CreateStatusBar();
132 
133  // window content
134  auto *panel = new wxPanel(this, wxID_ANY);
135  auto *vbox = new wxBoxSizer(wxVERTICAL);
136 
137  // uppper buttons
138  {
139  auto *button_box = new wxBoxSizer(wxHORIZONTAL);
140  discover_button_ = new wxButton(panel, ID_DiscoverButton, "Rerun Discovery");
141  button_box->Add(discover_button_, 1);
142 
143  button_box->AddSpacer(10);
144  button_box->Add(new wxStaticLine(panel, wxID_ANY, wxDefaultPosition,
145  wxSize(-1,30), wxLI_VERTICAL));
146  button_box->AddSpacer(10);
147 
148  int w, h;
149  discover_button_->GetSize(&w, &h);
150  auto *only_rc_cbox = new wxCheckBox(panel, ID_OnlyRcCheckbox,
151  "Only rc_... devices",
152  wxDefaultPosition, wxSize(-1, h));
153  only_rc_cbox->SetValue(only_rc_sensors_);
154  button_box->Add(only_rc_cbox, 1);
155 
156  button_box->AddSpacer(10);
157  button_box->Add(new wxStaticLine(panel, wxID_ANY, wxDefaultPosition,
158  wxSize(-1,30), wxLI_VERTICAL));
159  button_box->AddSpacer(10);
160 
161  auto *filter_text = new wxStaticText(panel, wxID_ANY, "Filter");
162  button_box->Add(filter_text, 1, wxTOP, 6);
163 
164  button_box->AddSpacer(10);
165  filter_input_ = new wxTextCtrl(panel, ID_FilterTextInput, wxEmptyString,
166  wxDefaultPosition, wxSize(150, -1));
167  filter_input_->SetToolTip("Use * and ? as wildcards");
168  button_box->Add(filter_input_, 0);
169 
170  button_box->Add(-1, 0, wxEXPAND);
171 
172  spinner_ctrl_ = new wxAnimationCtrl(panel, wxID_ANY, spinner_,
173  wxPoint(-1,-1), wxSize(32,32));
174  button_box->Add(spinner_ctrl_, 0);
175 
176  vbox->Add(button_box, 0, wxALL, 10);
177  }
178 
179  // device table
180  {
181  auto *data_box = new wxBoxSizer(wxHORIZONTAL);
182 
183  device_list_ = new wxDataViewListCtrl(panel,
185  wxPoint(-1,-1),
186  wxSize(-1,-1));
187  device_list_->AppendTextColumn("Name",
188  wxDATAVIEW_CELL_INERT,
189  100, wxALIGN_LEFT,
190  wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
191  device_list_->AppendTextColumn("Manufacturer",
192  wxDATAVIEW_CELL_INERT,
193  170, wxALIGN_LEFT,
194  wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
195  device_list_->AppendTextColumn("Model",
196  wxDATAVIEW_CELL_INERT,
197  130, wxALIGN_LEFT,
198  wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
199  device_list_->AppendTextColumn("Serial Number",
200  wxDATAVIEW_CELL_INERT,
201  130, wxALIGN_LEFT,
202  wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
203  device_list_->AppendTextColumn("IP Address",
204  wxDATAVIEW_CELL_INERT,
205  120, wxALIGN_LEFT,
206  wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
207  device_list_->AppendTextColumn("MAC Address",
208  wxDATAVIEW_CELL_INERT,
209  130, wxALIGN_LEFT,
210  wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
211  device_list_->AppendTextColumn("Interface(s)",
212  wxDATAVIEW_CELL_INERT,
213  130, wxALIGN_LEFT,
214  wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
215  device_list_->AppendTextColumn("Reachable",
216  wxDATAVIEW_CELL_INERT,
217  80, wxALIGN_CENTER,
218  wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
219 
220  device_list_->SetToolTip("Double-click row to open WebGUI in browser.");
221 
222  data_box->Add(device_list_, 1, wxEXPAND);
223 
224  vbox->Add(data_box, 1, wxLEFT | wxRIGHT | wxEXPAND, 10);
225  }
226 
227  {
228  auto *button_box = new wxBoxSizer(wxHORIZONTAL);
229  reset_button_ = new wxButton(panel, ID_ResetButton, "Reset rc_visard");
230  button_box->Add(reset_button_, 1);
231  int w, h;
232  reset_button_->GetSize(&w, &h);
233 
234  force_ip_button_ = new wxButton(panel, ID_ForceIpButton,
235  "Set temporary IP address");
236  button_box->Add(force_ip_button_, 1);
237 
238  reconnect_button_ = new wxButton(panel, ID_ReconnectButton,
239  "Reconnect device");
240  button_box->Add(reconnect_button_, 1);
241 
242  button_box->Add(-1, 0, wxEXPAND);
243 
244  auto *help_button = new wxContextHelpButton(panel, ID_Help_Discovery,
245  wxDefaultPosition, wxSize(h,h));
246  button_box->Add(help_button, 0);
247 
248  vbox->Add(button_box, 0, wxTOP | wxLEFT | wxRIGHT, 10);
249  }
250 
251  panel->SetSizer(vbox);
252  Centre();
253 
254  help_ctrl_ = new wxHtmlHelpController(wxHF_DEFAULT_STYLE, panel);
255  help_ctrl_->AddBook("memory:help.hhp");
256 
257  Connect(ID_DiscoverButton,
258  wxEVT_COMMAND_BUTTON_CLICKED,
259  wxCommandEventHandler(DiscoverFrame::onDiscoverButton));
260  Connect(wxID_ANY,
261  wxEVT_COMMAND_DISCOVERY_COMPLETED,
262  wxThreadEventHandler(DiscoverFrame::onDiscoveryCompleted));
263  Connect(wxID_ANY,
264  wxEVT_COMMAND_DISCOVERY_ERROR,
265  wxThreadEventHandler(DiscoverFrame::onDiscoveryError));
266  Connect(ID_ResetButton,
267  wxEVT_COMMAND_BUTTON_CLICKED,
268  wxCommandEventHandler(DiscoverFrame::onResetButton));
269  Connect(ID_ForceIpButton,
270  wxEVT_COMMAND_BUTTON_CLICKED,
271  wxCommandEventHandler(DiscoverFrame::onForceIpButton));
272  Connect(ID_ReconnectButton,
273  wxEVT_COMMAND_BUTTON_CLICKED,
274  wxCommandEventHandler(DiscoverFrame::onReconnectButton));
275  Connect(ID_Help_Discovery,
276  wxEVT_COMMAND_BUTTON_CLICKED,
277  wxCommandEventHandler(DiscoverFrame::onHelpDiscovery));
278  Connect(ID_DataViewListCtrl,
279  wxEVT_DATAVIEW_ITEM_ACTIVATED,
280  wxDataViewEventHandler(DiscoverFrame::onDeviceDoubleClick));
281  Connect(ID_DataViewListCtrl,
282  wxEVT_DATAVIEW_SELECTION_CHANGED,
283  wxDataViewEventHandler(DiscoverFrame::onDeviceSelection));
284  Connect(ID_DataViewListCtrl,
285  wxEVT_DATAVIEW_ITEM_CONTEXT_MENU,
286  wxDataViewEventHandler(DiscoverFrame::onDataViewContextMenu));
287  Connect(ID_OpenWebGUI,
288  wxEVT_MENU,
289  wxMenuEventHandler(DiscoverFrame::onOpenWebGUI));
290  Connect(ID_CopyName,
291  wxEVT_MENU,
292  wxMenuEventHandler(DiscoverFrame::onCopy));
293  Connect(ID_CopyManufacturer,
294  wxEVT_MENU,
295  wxMenuEventHandler(DiscoverFrame::onCopy));
296  Connect(ID_CopyModel,
297  wxEVT_MENU,
298  wxMenuEventHandler(DiscoverFrame::onCopy));
299  Connect(ID_CopySerial,
300  wxEVT_MENU,
301  wxMenuEventHandler(DiscoverFrame::onCopy));
302  Connect(ID_CopyIP,
303  wxEVT_MENU,
304  wxMenuEventHandler(DiscoverFrame::onCopy));
305  Connect(ID_CopyMac,
306  wxEVT_MENU,
307  wxMenuEventHandler(DiscoverFrame::onCopy));
308  Connect(ID_ResetButton,
309  wxEVT_MENU,
310  wxMenuEventHandler(DiscoverFrame::onResetContextMenu));
311  Connect(ID_ForceIpButton,
312  wxEVT_MENU,
313  wxMenuEventHandler(DiscoverFrame::onForceIpContextMenu));
314  Connect(ID_ReconnectButton,
315  wxEVT_MENU,
316  wxMenuEventHandler(DiscoverFrame::onReconnectContextMenu));
317  Connect(wxID_EXIT,
318  wxEVT_MENU,
319  wxCommandEventHandler(DiscoverFrame::onExit));
320  Connect(wxID_ABOUT,
321  wxEVT_MENU,
322  wxCommandEventHandler(DiscoverFrame::onAbout));
323  Connect(wxID_HELP,
324  wxEVT_MENU,
325  wxCommandEventHandler(DiscoverFrame::onHelp));
326  Connect(ID_OnlyRcCheckbox,
327  wxEVT_CHECKBOX,
328  wxCommandEventHandler(DiscoverFrame::onOnlyRcCheckbox));
329  Connect(ID_FilterTextInput,
330  wxEVT_TEXT,
331  wxCommandEventHandler(DiscoverFrame::onFilterTextChange));
332 
333  reset_dialog_ = new ResetDialog(help_ctrl_, panel, wxID_ANY);
334  force_ip_dialog_ = new ForceIpDialog(help_ctrl_, panel, wxID_ANY);
335  reconnect_dialog_ = new ReconnectDialog(help_ctrl_, panel, wxID_ANY);
336  about_dialog_ = new AboutDialog(panel, wxID_ANY);
337 
338  wxPersistentRegisterAndRestore(this, "discover_frame");
339 
340  // start discovery on startup
341  wxCommandEvent evt;
342  onDiscoverButton(evt);
343 }
344 
346 {
347  discover_button_->Disable();
348  reset_button_->Disable();
349  force_ip_button_->Disable();
350  reconnect_button_->Disable();
351  spinner_ctrl_->Play();
352 }
353 
355 {
356  discover_button_->Enable();
357  reset_button_->Enable();
358  force_ip_button_->Enable();
359  reconnect_button_->Enable();
360  spinner_ctrl_->Stop();
361 
362  // on Windows, wxAnimationCtrl is sometimes not stopping even if
363  // Stop was called. Calling it multiple times reduces the chance
364  // of this happening.
365  spinner_ctrl_->Stop();
366  spinner_ctrl_->Stop();
367 }
368 
369 void DiscoverFrame::onDiscoverButton(wxCommandEvent &)
370 {
371  setBusy();
372 
373  auto *thread = new DiscoverThread(this);
374  if (thread->Run() != wxTHREAD_NO_ERROR)
375  {
376  std::cerr << "Could not spawn thread" << std::endl;
377  delete thread;
378  thread = nullptr;
379 
380  clearBusy();
381  }
382 }
383 
384 void DiscoverFrame::onDiscoveryCompleted(wxThreadEvent &event)
385 {
386  updateDeviceList(event.GetPayload<std::vector<wxVector<wxVariant>>>());
387 
388  clearBusy();
389 }
390 
391 void DiscoverFrame::updateDeviceList(const std::vector<wxVector<wxVariant>> &d)
392 {
393  device_list_->DeleteAllItems();
394 
395  std::vector<bool> show_in_reset_dialog;
396 
397  last_data_ = d;
398  for(const auto& d : last_data_)
399  {
400  const bool matches_filter = [&] {
401  if (!filter_text_.empty())
402  {
403  const auto& filter_text = filter_text_;
404  const bool none = std::none_of(d.begin(), d.end(), [&filter_text](const wxVariant& v) {
405  const auto s = v.GetString().ToStdString();
406  return wildcardMatch(s.begin(), s.end(), filter_text.begin(), filter_text.end());
407  });
408  if (none)
409  {
410  return false;
411  }
412  }
413  return true;
414  }();
415 
416  if (matches_filter && (!only_rc_sensors_ || isMadeByRc(d)))
417  {
418  device_list_->AppendItem(d);
419  show_in_reset_dialog.push_back(isRcVisard(d));
420  }
421  }
422 
423  reset_dialog_->setDiscoveredSensors(device_list_->GetStore(), show_in_reset_dialog);
426 }
427 
428 void DiscoverFrame::onDiscoveryError(wxThreadEvent &event)
429 {
430  std::ostringstream oss;
431  oss << "An error occurred during discovery: " << event.GetString();
432  wxMessageBox(oss.str(), "Error", wxOK | wxICON_ERROR);
433 
434  clearBusy();
435 }
436 
437 void DiscoverFrame::onResetButton(wxCommandEvent &)
438 {
439  openResetDialog(device_list_->GetSelectedRow());
440 }
441 
442 void DiscoverFrame::onForceIpButton(wxCommandEvent &)
443 {
444  openForceIpDialog(device_list_->GetSelectedRow());
445 }
446 
447 void DiscoverFrame::onReconnectButton(wxCommandEvent &)
448 {
449  openReconnectDialog(device_list_->GetSelectedRow());
450 }
451 
452 void DiscoverFrame::onHelpDiscovery(wxCommandEvent&)
453 {
454  help_ctrl_->Display("help.htm#discovery");
455 }
456 
457 void DiscoverFrame::onDeviceDoubleClick(wxDataViewEvent &event)
458 {
459  const auto item = event.GetItem();
460  const auto row = device_list_->ItemToRow(item);
461 
462  if (row == wxNOT_FOUND)
463  {
464  return;
465  }
466 
467  openWebGUI(row);
468 }
469 
470 void DiscoverFrame::onDeviceSelection(wxDataViewEvent &event)
471 {
472  const auto item = event.GetItem();
473  const auto row = device_list_->ItemToRow(item);
474 
475  if (row == wxNOT_FOUND)
476  {
477  return;
478  }
479 
480  reset_button_->Enable(isRcVisard(*device_list_, row));
481 }
482 
483 void DiscoverFrame::onDataViewContextMenu(wxDataViewEvent &event)
484 {
485  menu_event_item_.reset(new std::pair<int, int>(
486  device_list_->ItemToRow(event.GetItem()),
487  event.GetColumn()));
488 
489  if (menu_event_item_->first < 0)
490  {
491  return;
492  }
493 
494  wxMenu menu;
495  menu.Append(ID_CopyName, "Copy name");
496  menu.Append(ID_CopyManufacturer, "Copy manufacturer");
497  menu.Append(ID_CopyModel, "Copy model");
498  menu.Append(ID_CopySerial, "Copy serial number");
499  menu.Append(ID_CopyIP, "Copy IP address");
500  menu.Append(ID_CopyMac, "Copy MAC address");
501 
502  if (isMadeByRc(*device_list_, static_cast<unsigned int>(menu_event_item_->first)))
503  {
504  menu.AppendSeparator();
505  menu.Append(ID_OpenWebGUI, "Open &WebGUI");
506  menu.AppendSeparator();
507  if (isRcVisard(*device_list_, static_cast<unsigned int>(menu_event_item_->first)))
508  {
509  menu.Append(ID_ResetButton, "Reset");
510  }
511  }
512 
513  menu.Append(ID_ForceIpButton, "Set temporary IP");
514  menu.Append(ID_ReconnectButton, "Reconnect");
515 
516  PopupMenu(&menu);
517 }
518 
519 void DiscoverFrame::onCopy(wxMenuEvent &evt)
520 {
521  int column;
522  switch (evt.GetId())
523  {
524  case ID_CopyName:
525  column = NAME;
526  break;
527 
528  case ID_CopyManufacturer:
529  column = MANUFACTURER;
530  break;
531 
532  case ID_CopyModel:
533  column = MODEL;
534  break;
535 
536  case ID_CopySerial:
537  column = SERIAL;
538  break;
539 
540  case ID_CopyIP:
541  column = IP;
542  break;
543 
544  case ID_CopyMac:
545  column = MAC;
546  break;
547 
548  default:
549  return;
550  }
551 
552  const auto row = static_cast<unsigned int>(menu_event_item_->first);
553  const auto cell = device_list_->GetTextValue(row, column);
554 
555  if (wxTheClipboard->Open())
556  {
557  wxTheClipboard->SetData(new wxTextDataObject(cell));
558  wxTheClipboard->Close();
559  }
560 }
561 
562 void DiscoverFrame::onOpenWebGUI(wxMenuEvent &)
563 {
564  if (!menu_event_item_ ||
565  menu_event_item_->first < 0)
566  {
567  return;
568  }
569 
571 }
572 
574 {
575  if (!menu_event_item_ ||
576  menu_event_item_->first < 0)
577  {
578  return;
579  }
580 
582 }
583 
585 {
586  if (!menu_event_item_ ||
587  menu_event_item_->first < 0)
588  {
589  return;
590  }
591 
593 }
594 
596 {
597  if (!menu_event_item_ ||
598  menu_event_item_->first < 0)
599  {
600  return;
601  }
602 
604 }
605 
606 void DiscoverFrame::onExit(wxCommandEvent &)
607 {
608  Close(true);
609 }
610 
611 void DiscoverFrame::onHelp(wxCommandEvent&)
612 {
613  help_ctrl_->Display("help.htm");
614 }
615 
616 void DiscoverFrame::onOnlyRcCheckbox(wxCommandEvent &evt)
617 {
618  only_rc_sensors_ = evt.IsChecked();
620 }
621 
622 void DiscoverFrame::onFilterTextChange(wxCommandEvent &evt)
623 {
624  filter_text_ = evt.GetString();
625  std::transform(filter_text_.begin(), filter_text_.end(), filter_text_.begin(), ::tolower);
626  if (!filter_text_.empty())
627  {
628  if (filter_text_.front() != '*')
629  { filter_text_ = '*' + filter_text_; }
630  if (filter_text_.back() != '*')
631  { filter_text_ = filter_text_ + '*'; }
632  }
634 }
635 
636 void DiscoverFrame::onAbout(wxCommandEvent &)
637 {
638  about_dialog_->ShowModal();
639 }
640 
642 {
643  if (row != wxNOT_FOUND)
644  {
645  reset_dialog_->setActiveSensor(static_cast<unsigned int>(row));
646  }
647 
648  reset_dialog_->Show();
649 }
650 
652 {
653  if (row != wxNOT_FOUND)
654  {
655  force_ip_dialog_->setActiveSensor(static_cast<unsigned int>(row));
656  }
657 
658  force_ip_dialog_->Show();
659 }
660 
662 {
663  if (row != wxNOT_FOUND)
664  {
665  reconnect_dialog_->setActiveSensor(static_cast<unsigned int>(row));
666  }
667 
668  reconnect_dialog_->Show();
669 }
670 
672 {
673  if (isMadeByRc(*device_list_, row))
674  {
675  const auto ip_wxstring = device_list_->GetTextValue(
676  static_cast<unsigned int>(row), IP);
677  wxLaunchDefaultBrowser("http://" + ip_wxstring + "/");
678  }
679 }
680 
681 BEGIN_EVENT_TABLE(DiscoverFrame, wxFrame)
682 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.
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 Sat Oct 22 2022 02:52:17