50 #include <wx/dialog.h> 52 #include <wx/button.h> 53 #include <wx/valgen.h> 54 #include <wx/msgdlg.h> 56 #include <wx/cshelp.h> 59 wxWindow *parent, wxWindowID
id,
62 const wxString &name) :
69 auto *button_box =
new wxBoxSizer(wxHORIZONTAL);
71 "Reset Parameters", wxDefaultPosition,
72 wxDefaultSize, wxBU_EXACTFIT);
73 button_box->Add(reset_param_button, 0, wxEXPAND);
75 "Reset Network", wxDefaultPosition,
76 wxDefaultSize, wxBU_EXACTFIT);
77 button_box->Add(reset_gige_button, 0, wxEXPAND);
78 auto *reset_all_button =
new wxButton(panel,
ID_Reset_All,
79 "Reset All", wxDefaultPosition,
80 wxDefaultSize, wxBU_EXACTFIT);
81 button_box->Add(reset_all_button, 0, wxEXPAND);
84 wxDefaultPosition, wxDefaultSize,
86 button_box->Add(switch_part_button, 0, wxEXPAND);
88 button_box->AddSpacer(20);
90 switch_part_button->GetSize(&w, &h);
91 auto *help_button =
new wxContextHelpButton(panel,
ID_Help_Reset,
92 wxDefaultPosition, wxSize(h,h));
93 button_box->Add(help_button, 0, wxEXPAND);
95 vbox->Add(button_box, 0, wxLEFT | wxRIGHT | wxBOTTOM, 15);
121 std::string func_name(
"");
124 switch(event.GetId())
128 func_name =
"reset parameters";
135 func_name =
"reset network parameters";
142 func_name =
"reset all";
149 func_name =
"switch partition";
155 throw std::runtime_error(
"Unknown event ID");
160 std::array<uint8_t, 6> mac =
getMac();
165 std::ostringstream reset_check_str;
166 reset_check_str <<
"Are you sure to " << func_name <<
167 " of rc_visard with MAC-address " << mac_string <<
"?";
168 const int reset_check_answer =
169 wxMessageBox(reset_check_str.str(),
"", wxYES_NO);
171 if (reset_check_answer == wxYES)
173 bool try_again =
false;
176 wol.
send({{0xEE, 0xEE, 0xEE, func_id}});
178 auto sent_dialog =
new wxMessageDialog(
180 "Please check whether rc_visard's LED turned white and whether rc_visard is rebooting.",
181 "Command sent", wxOK | wxCANCEL | wxCANCEL_DEFAULT | wxCENTRE);
182 sent_dialog->SetOKCancelLabels(
"Try again",
"Done");
183 const int sent_answer = sent_dialog->ShowModal();
184 try_again = sent_answer == wxID_OK;
191 catch(
const std::runtime_error& ex)
193 wxMessageBox(ex.what(),
"Error", wxOK | wxICON_ERROR);
198 wxMessageBox(std::string(
"rcdiscover probably requires root/admin ") +
199 "privileges for this operation.",
200 "Operation not permitted",
201 wxOK | wxICON_ERROR);
std::string getMacString() const
wxBoxSizer * getVerticalBox()
Dialog for Magic Packets reset of rc_visard.
Class for Magic Packet (Wake-on-Lan (WOL)) reset of device.
Exception representing an "operation not permitted" error.
Base class for dialogs for sending commands to a camera.
void displayHelp(const std::string §ion)
void onResetButton(wxCommandEvent &event)
Event handler for click on one of the four reset buttons.
std::array< uint8_t, 6 > getMac() const
void send() const
Send Magic Packet without any data ("password").
void onHelpButton(wxCommandEvent &)
Event handler for help button.