ENH: clean codes about device

JIRA: [STUDIO-13609]
Change-Id: I591de7033360b9570600006cfbce2148a8d031d5
(cherry picked from commit e9c774be8f4c89b8dafa14ef56913612fb68bd0c)
This commit is contained in:
xin.zhang
2025-08-01 17:34:35 +08:00
committed by Noisyfox
parent e17c8bfb80
commit 4a787f6ff8
115 changed files with 7238 additions and 5492 deletions

View File

@@ -0,0 +1,64 @@
#include <nlohmann/json.hpp>
#include "DevLamp.h"
// TODO: remove this include
#include "slic3r/GUI/DeviceManager.hpp"
using namespace nlohmann;
namespace Slic3r
{
static std::string _light_effect_str(DevLamp::LIGHT_EFFECT effect)
{
switch (effect)
{
case Slic3r::DevLamp::LIGHT_EFFECT_ON:
return "on";
case Slic3r::DevLamp::LIGHT_EFFECT_OFF:
return "off";
case Slic3r::DevLamp::LIGHT_EFFECT_FLASHING:
return "flashing";
default:
return "unknown";
}
return "unknown";
}
void DevLamp::CtrlSetChamberLight(LIGHT_EFFECT effect)
{
// copied from others, TODO CHECK
command_set_chamber_light(effect);
command_set_chamber_light2(effect);
}
int DevLamp::command_set_chamber_light(LIGHT_EFFECT effect, int on_time, int off_time, int loops, int interval)
{
json j;
j["system"]["command"] = "ledctrl";
j["system"]["led_node"] = "chamber_light";
j["system"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["system"]["led_mode"] = _light_effect_str(effect);
j["system"]["led_on_time"] = on_time;
j["system"]["led_off_time"] = off_time;
j["system"]["loop_times"] = loops;
j["system"]["interval_time"] = interval;
return m_owner->publish_json(j);
}
int DevLamp::command_set_chamber_light2(LIGHT_EFFECT effect, int on_time, int off_time, int loops, int interval)
{
json j;
j["system"]["command"] = "ledctrl";
j["system"]["led_node"] = "chamber_light2";
j["system"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["system"]["led_mode"] = _light_effect_str(effect);
j["system"]["led_on_time"] = on_time;
j["system"]["led_off_time"] = off_time;
j["system"]["loop_times"] = loops;
j["system"]["interval_time"] = interval;
return m_owner->publish_json(j);
}
}