NEW: parse camera recording and resolution fields

Change-Id: I8aa5af228d6ad50ff495577652c2ba716f6cc3b3
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
Stone Li 2022-11-01 16:36:37 +08:00 committed by Lane.Wei
parent a8ad6e9f69
commit 1eacc5d38f
4 changed files with 36 additions and 21 deletions

View file

@ -54,7 +54,7 @@ CameraPopup::CameraPopup(wxWindow *parent, MachineObject* obj)
m_text_recording->SetForegroundColour(TEXT_COL); m_text_recording->SetForegroundColour(TEXT_COL);
m_switch_recording = new SwitchButton(m_panel); m_switch_recording = new SwitchButton(m_panel);
if (obj) if (obj)
m_switch_recording->SetValue(obj->camera_recording); m_switch_recording->SetValue(obj->camera_recording_when_printing);
top_sizer->Add(m_text_timelapse, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, FromDIP(5)); top_sizer->Add(m_text_timelapse, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, FromDIP(5));
top_sizer->Add(m_switch_timelapse, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, FromDIP(5)); top_sizer->Add(m_switch_timelapse, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, FromDIP(5));

View file

@ -1148,7 +1148,12 @@ bool MachineObject::has_timelapse()
return camera_timelapse; return camera_timelapse;
} }
bool MachineObject::has_recording() bool MachineObject::is_recording_enable()
{
return camera_recording_when_printing;
}
bool MachineObject::is_recording()
{ {
return camera_recording; return camera_recording;
} }
@ -1621,6 +1626,7 @@ void MachineObject::reset()
last_update_time = std::chrono::system_clock::now(); last_update_time = std::chrono::system_clock::now();
m_push_count = 0; m_push_count = 0;
camera_recording = false; camera_recording = false;
camera_recording_when_printing = false;
camera_timelapse = false; camera_timelapse = false;
printing_speed_mag = 100; printing_speed_mag = 100;
gcode_file_prepare_percent = 0; gcode_file_prepare_percent = 0;
@ -2198,16 +2204,32 @@ int MachineObject::parse_json(std::string payload)
} }
#pragma endregion #pragma endregion
#pragma region options
try {
if (jj.contains("option")) {
if (jj["option"].is_number()) {
int option = jj["option"].get<int>();
if ((option & (1 << 0)) != 0) {
camera_recording = true;
} else {
camera_recording = false;
}
}
}
}
catch(...) {
}
#pragma endregion
#pragma region camera #pragma region camera
// parse camera info // parse camera info
try { try {
if (jj.contains("ipcam")) { if (jj.contains("ipcam")) {
if (jj["ipcam"].contains("ipcam_record")) { if (jj["ipcam"].contains("ipcam_record")) {
if (jj["ipcam"]["ipcam_record"].get<std::string>() == "enable") { if (jj["ipcam"]["ipcam_record"].get<std::string>() == "enable") {
camera_recording = true; camera_recording_when_printing = true;
} }
else { else {
camera_recording = false; camera_recording_when_printing = false;
} }
} }
if (jj["ipcam"].contains("timelapse")) { if (jj["ipcam"].contains("timelapse")) {
@ -2597,9 +2619,9 @@ int MachineObject::parse_json(std::string payload)
this->camera_timelapse = false; this->camera_timelapse = false;
} else if (j["camera"]["command"].get<std::string>() == "ipcam_record_set") { } else if (j["camera"]["command"].get<std::string>() == "ipcam_record_set") {
if (j["camera"]["control"].get<std::string>() == "enable") if (j["camera"]["control"].get<std::string>() == "enable")
this->camera_recording = true; this->camera_recording_when_printing = true;
if (j["camera"]["control"].get<std::string>() == "disable") if (j["camera"]["control"].get<std::string>() == "disable")
this->camera_recording = false; this->camera_recording_when_printing = false;
} }
} }
} }

View file

@ -498,6 +498,7 @@ public:
/* camera */ /* camera */
bool has_ipcam { false }; bool has_ipcam { false };
bool camera_recording { false }; bool camera_recording { false };
bool camera_recording_when_printing { false };
bool camera_timelapse { false }; bool camera_timelapse { false };
bool camera_has_sdcard { false }; bool camera_has_sdcard { false };
bool xcam_first_layer_inspector { false }; bool xcam_first_layer_inspector { false };
@ -532,7 +533,8 @@ public:
bool is_sdcard_printing(); bool is_sdcard_printing();
bool has_sdcard(); bool has_sdcard();
bool has_timelapse(); bool has_timelapse();
bool has_recording(); bool is_recording_enable();
bool is_recording();
MachineObject(NetworkAgent* agent, std::string name, std::string id, std::string ip); MachineObject(NetworkAgent* agent, std::string name, std::string id, std::string ip);

View file

@ -1371,7 +1371,7 @@ void StatusPanel::update(MachineObject *obj)
update_error_message(); update_error_message();
} }
upodate_camera_state(obj->has_recording(), obj->has_timelapse(), obj->has_sdcard()); upodate_camera_state(obj->is_recording_enable(), obj->has_timelapse(), obj->has_sdcard());
m_machine_ctrl_panel->Thaw(); m_machine_ctrl_panel->Thaw();
} }
@ -1744,14 +1744,6 @@ void StatusPanel::update_ams(MachineObject *obj)
for (auto tray_it = ams_it->second->trayList.begin(); tray_it != ams_it->second->trayList.end(); tray_it++) { for (auto tray_it = ams_it->second->trayList.begin(); tray_it != ams_it->second->trayList.end(); tray_it++) {
std::string tray_id = tray_it->first; std::string tray_id = tray_it->first;
int tray_id_int = atoi(tray_id.c_str()); int tray_id_int = atoi(tray_id.c_str());
if (obj->ams_insert_flag < 0) {
// old protocol
if ((obj->tray_read_done_bits & (1 << (ams_id_int * 4 + tray_id_int))) == 0) {
m_ams_control->PlayRridLoading(ams_id, tray_id);
} else {
m_ams_control->StopRridLoading(ams_id, tray_id);
}
} else {
// new protocol // new protocol
if ((obj->tray_reading_bits & (1 << (ams_id_int * 4 + tray_id_int))) != 0) { if ((obj->tray_reading_bits & (1 << (ams_id_int * 4 + tray_id_int))) != 0) {
m_ams_control->PlayRridLoading(ams_id, tray_id); m_ams_control->PlayRridLoading(ams_id, tray_id);
@ -1759,7 +1751,6 @@ void StatusPanel::update_ams(MachineObject *obj)
m_ams_control->StopRridLoading(ams_id, tray_id); m_ams_control->StopRridLoading(ams_id, tray_id);
} }
} }
}
} catch (...) {} } catch (...) {}
} }
// update rfid button style // update rfid button style