FIX:update load/unload command for n3s
Change-Id: Ic4655f368a0ffb0e16139dee1fd1ffc34236e9eb
This commit is contained in:
parent
6a9fd6678e
commit
fc32042639
|
@ -2081,71 +2081,70 @@ int MachineObject::command_set_chamber(int temp)
|
||||||
return this->publish_json(j.dump(), 1);
|
return this->publish_json(j.dump(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MachineObject::command_ams_switch(int tray_index, int old_temp, int new_temp)
|
//int MachineObject::command_ams_switch(int tray_index, int old_temp, int new_temp)
|
||||||
{
|
//{
|
||||||
assert(!is_enable_np);
|
// assert(!is_enable_np);
|
||||||
|
//
|
||||||
|
// BOOST_LOG_TRIVIAL(trace) << "ams_switch to " << tray_index << " with temp: " << old_temp << ", " << new_temp;
|
||||||
|
//
|
||||||
|
// if (old_temp < 0) old_temp = FILAMENT_DEF_TEMP;
|
||||||
|
// if (new_temp < 0) new_temp = FILAMENT_DEF_TEMP;
|
||||||
|
// int result = 0;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// //command
|
||||||
|
// if (is_support_command_ams_switch) {
|
||||||
|
// command_ams_change_filament(tray_index, old_temp, new_temp);
|
||||||
|
// }
|
||||||
|
// //gcode
|
||||||
|
// else {
|
||||||
|
// std::string gcode = "";
|
||||||
|
// if (tray_index == 255) {
|
||||||
|
// gcode = DeviceManager::load_gcode(printer_type, "ams_unload.gcode");
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// // include VIRTUAL_TRAY_MAIN_ID
|
||||||
|
// gcode = DeviceManager::load_gcode(printer_type, "ams_load.gcode");
|
||||||
|
// boost::replace_all(gcode, "[next_extruder]", std::to_string(tray_index));
|
||||||
|
// boost::replace_all(gcode, "[new_filament_temp]", std::to_string(new_temp));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// result = this->publish_gcode(gcode);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return result;
|
||||||
|
//}
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(trace) << "ams_switch to " << tray_index << " with temp: " << old_temp << ", " << new_temp;
|
int MachineObject::command_ams_change_filament(bool load, std::string ams_id, std::string slot_id, int old_temp, int new_temp)
|
||||||
if (old_temp < 0) old_temp = FILAMENT_DEF_TEMP;
|
|
||||||
if (new_temp < 0) new_temp = FILAMENT_DEF_TEMP;
|
|
||||||
|
|
||||||
std::string gcode = "";
|
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
//command
|
|
||||||
if (is_support_command_ams_switch) {
|
|
||||||
command_ams_change_filament(tray_index, old_temp, new_temp);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
std::string gcode = "";
|
|
||||||
if (tray_index == 255) {
|
|
||||||
gcode = DeviceManager::load_gcode(printer_type, "ams_unload.gcode");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// include VIRTUAL_TRAY_MAIN_ID
|
|
||||||
gcode = DeviceManager::load_gcode(printer_type, "ams_load.gcode");
|
|
||||||
boost::replace_all(gcode, "[next_extruder]", std::to_string(tray_index));
|
|
||||||
boost::replace_all(gcode, "[new_filament_temp]", std::to_string(new_temp));
|
|
||||||
}
|
|
||||||
|
|
||||||
result = this->publish_gcode(gcode);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MachineObject::command_ams_change_filament(int tray_id, int old_temp, int new_temp)
|
|
||||||
{
|
{
|
||||||
json j;
|
json j;
|
||||||
j["print"]["command"] = "ams_change_filament";
|
try {
|
||||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
auto tray_id = 0;
|
||||||
j["print"]["target"] = tray_id;
|
if (ams_id < "16") {
|
||||||
j["print"]["curr_temp"] = old_temp;
|
tray_id = atoi(ams_id.c_str()) * 4 + atoi(slot_id.c_str());
|
||||||
j["print"]["tar_temp"] = new_temp;
|
}
|
||||||
return this->publish_json(j.dump());
|
|
||||||
}
|
|
||||||
|
|
||||||
int MachineObject::command_ams_change_filament2(bool load_or_unload, int ams_id, int slot_id, int old_temp, int new_temp)
|
|
||||||
{
|
|
||||||
assert(is_enable_np);
|
|
||||||
|
|
||||||
json j;
|
j["print"]["command"] = "ams_change_filament";
|
||||||
j["print"]["command"] = "ams_change_filament";
|
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
j["print"]["curr_temp"] = old_temp;
|
||||||
//j["print"]["target"] = ams_id == VIRTUAL_TRAY_MAIN_ID?VIRTUAL_TRAY_DEPUTY_ID:slot_id; /*this is not used in new protocol*/
|
j["print"]["tar_temp"] = new_temp;
|
||||||
j["print"]["curr_temp"] = old_temp;
|
j["print"]["ams_id"] = atoi(ams_id.c_str());
|
||||||
j["print"]["tar_temp"] = new_temp;
|
|
||||||
j["print"]["ams_id"] = ams_id;
|
|
||||||
|
|
||||||
// the new protocol
|
if (!load) {
|
||||||
if (load_or_unload)
|
j["print"]["target"] = 255;
|
||||||
{
|
j["print"]["slot_id"] = 255; // the new protocol to mark unload
|
||||||
j["print"]["slot_id"] = slot_id;
|
|
||||||
}
|
} else {
|
||||||
else
|
if (tray_id == 0) {
|
||||||
{
|
j["print"]["target"] = atoi(ams_id.c_str());
|
||||||
j["print"]["slot_id"] = 255;// the new protocol to mark unload
|
} else {
|
||||||
}
|
j["print"]["target"] = tray_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
j["print"]["slot_id"] = atoi(slot_id.c_str());
|
||||||
|
}
|
||||||
|
} catch (const std::exception &) {}
|
||||||
|
|
||||||
return this->publish_json(j.dump());
|
return this->publish_json(j.dump());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1120,9 +1120,8 @@ public:
|
||||||
int command_set_nozzle_new(int nozzle_id, int temp);
|
int command_set_nozzle_new(int nozzle_id, int temp);
|
||||||
int command_set_chamber(int temp);
|
int command_set_chamber(int temp);
|
||||||
// ams controls
|
// ams controls
|
||||||
int command_ams_switch(int tray_index, int old_temp = 210, int new_temp = 210);
|
//int command_ams_switch(int tray_index, int old_temp = 210, int new_temp = 210);
|
||||||
int command_ams_change_filament(int tray_id, int old_temp = 210, int new_temp = 210);
|
int command_ams_change_filament(bool load, std::string ams_id, std::string slot_id, int old_temp = 210, int new_temp = 210);
|
||||||
int command_ams_change_filament2(bool load_or_unload, int ams_id, int slot_id, int old_temp = 210, int new_temp = 210);
|
|
||||||
int command_ams_user_settings(int ams_id, bool start_read_opt, bool tray_read_opt, bool remain_flag = false);
|
int command_ams_user_settings(int ams_id, bool start_read_opt, bool tray_read_opt, bool remain_flag = false);
|
||||||
int command_ams_switch_filament(bool switch_filament);
|
int command_ams_switch_filament(bool switch_filament);
|
||||||
int command_ams_air_print_detect(bool air_print_detect);
|
int command_ams_air_print_detect(bool air_print_detect);
|
||||||
|
|
|
@ -4175,12 +4175,11 @@ void StatusPanel::on_ams_load_curr()
|
||||||
|
|
||||||
if (obj->is_enable_np) {
|
if (obj->is_enable_np) {
|
||||||
try {
|
try {
|
||||||
if (!curr_ams_id.empty() && !curr_can_id.empty()) {
|
if (!curr_ams_id.empty() && !curr_can_id.empty()) { obj->command_ams_change_filament(true, curr_ams_id, "0", old_temp, new_temp);
|
||||||
obj->command_ams_change_filament2(true, stoi(curr_ams_id), 0, old_temp, new_temp);
|
|
||||||
}
|
}
|
||||||
} catch (...) {}
|
} catch (...) {}
|
||||||
} else {
|
} else {
|
||||||
obj->command_ams_switch(254, old_temp, new_temp);
|
obj->command_ams_change_filament(true, "254", "0", old_temp, new_temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4216,12 +4215,12 @@ void StatusPanel::on_ams_load_curr()
|
||||||
if (obj->is_enable_np) {
|
if (obj->is_enable_np) {
|
||||||
try {
|
try {
|
||||||
if (!curr_ams_id.empty() && !curr_can_id.empty()) {
|
if (!curr_ams_id.empty() && !curr_can_id.empty()) {
|
||||||
obj->command_ams_change_filament2(true, stoi(curr_ams_id), stoi(curr_can_id), old_temp, new_temp);
|
obj->command_ams_change_filament(true, curr_ams_id, curr_can_id, old_temp, new_temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (...){}
|
catch (...){}
|
||||||
} else {
|
} else {
|
||||||
obj->command_ams_switch(tray_index, old_temp, new_temp);
|
obj->command_ams_change_filament(true, curr_ams_id, curr_can_id, old_temp, new_temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4273,17 +4272,17 @@ void StatusPanel::on_ams_switch(SimpleEvent &event)
|
||||||
void StatusPanel::on_ams_unload(SimpleEvent &event)
|
void StatusPanel::on_ams_unload(SimpleEvent &event)
|
||||||
{
|
{
|
||||||
if (obj) {
|
if (obj) {
|
||||||
|
std::string curr_ams_id = m_ams_control->GetCurentAms();
|
||||||
|
std::string curr_can_id = m_ams_control->GetCurrentCan(curr_ams_id);
|
||||||
|
|
||||||
if (obj->is_enable_np) {
|
if (obj->is_enable_np) {
|
||||||
try {
|
try {
|
||||||
std::string curr_ams_id = m_ams_control->GetCurentAms();
|
|
||||||
std::string curr_can_id = m_ams_control->GetCurrentCan(curr_ams_id);
|
|
||||||
|
|
||||||
for (auto ext : obj->m_extder_data.extders) {
|
for (auto ext : obj->m_extder_data.extders) {
|
||||||
if (ext.snow.ams_id == curr_ams_id && ext.snow.slot_id == curr_can_id) { obj->command_ams_change_filament2(false, stoi(curr_ams_id), 0); }
|
if (ext.snow.ams_id == curr_ams_id && ext.snow.slot_id == curr_can_id) { obj->command_ams_change_filament(false, curr_ams_id, "255"); }
|
||||||
}
|
}
|
||||||
} catch (...) {}
|
} catch (...) {}
|
||||||
} else {
|
} else {
|
||||||
obj->command_ams_switch(255);
|
obj->command_ams_change_filament(false, curr_ams_id, "255");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue