184 lines
6.3 KiB
C++
184 lines
6.3 KiB
C++
#include "Machine.h"
|
|
#include "../external/imgui/imgui.h"
|
|
#include "../external/imgui/imgui_internal.h"
|
|
#include "../external/imgui/imgui_custom.h"
|
|
#include "HBD1000.h"
|
|
#include "HBD1200.h"
|
|
#include "HBD1200OLD.h"
|
|
#include "HBD1500.h"
|
|
#include "HBDE1000.h"
|
|
#include "../global.h"
|
|
#include "../config/configmanager.h"
|
|
|
|
Machine::Machine(MachineTypeCfg::MachineTypeId type)
|
|
: m_Type(type)
|
|
, m_IOCfgWrapper(nullptr)
|
|
, m_RunCfg(nullptr){
|
|
|
|
|
|
}
|
|
|
|
Machine::~Machine() {
|
|
|
|
}
|
|
|
|
|
|
void Machine::Init() {
|
|
m_IOCfgWrapper = ConfigManager::Instance()->GetIoCfgWrapper();
|
|
m_RunCfg = ConfigManager::Instance()->GetRunCfg();
|
|
|
|
CheckIO();
|
|
}
|
|
|
|
Machine* Machine::CreateInstance(int type)
|
|
{
|
|
Machine* machine = nullptr;
|
|
if (type == MachineTypeCfg::HBD_1000) {
|
|
machine = new HBD1000(MachineTypeCfg::MachineTypeId(type));
|
|
}
|
|
else if (type == MachineTypeCfg::HBD_1500) {
|
|
machine = new HBD1500(MachineTypeCfg::MachineTypeId(type));
|
|
}
|
|
else if (type == MachineTypeCfg::HBD_1200_OLD) {
|
|
machine = new HBD1200OLD(MachineTypeCfg::MachineTypeId(type));
|
|
}
|
|
else if (type == MachineTypeCfg::HBD_1200) {
|
|
machine = new HBD1200(MachineTypeCfg::MachineTypeId(type));
|
|
}
|
|
else if (type == MachineTypeCfg::HBD_E1000) {
|
|
machine = new HBDE1000(MachineTypeCfg::MachineTypeId(type));
|
|
}
|
|
return machine;
|
|
}
|
|
|
|
|
|
void Machine::DrawAnalogExt()
|
|
{
|
|
EnvUIAssist* ui = m_SysParamWrapper->GetEnvUIAssist();
|
|
|
|
ImGui::SameLine();
|
|
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
|
|
ImGui::SameLine();
|
|
ImGui::BeginGroup();
|
|
if (ImGui::InputFloat(_(u8"清粉箱除氧设定值").c_str(), ui->m_CleanBoxDeoxygenSetValue->GetUIValue(), 0, 0, "%.2f", ImGuiInputTextFlags_EnterReturnsTrue))
|
|
{
|
|
ui->m_CleanBoxDeoxygenSetValue->SetValue(ui->m_CleanBoxDeoxygenSetValue->GetValue());
|
|
}
|
|
if (ImGui::InputFloat(_(u8"清粉箱测氧仪下限").c_str(), ui->m_CleanBoxOxygenDownLimit->GetUIValue(), 0, 0, "%.2f", ImGuiInputTextFlags_EnterReturnsTrue))
|
|
{
|
|
ui->m_CleanBoxOxygenDownLimit->SetValue(ui->m_CleanBoxOxygenDownLimit->GetValue());
|
|
}
|
|
if (ImGui::InputFloat(_(u8"清粉箱测氧仪上限").c_str(), ui->m_CleanBoxOxygenUpLimit->GetUIValue(), 0, 0, "%.2f", ImGuiInputTextFlags_EnterReturnsTrue))
|
|
{
|
|
ui->m_CleanBoxOxygenUpLimit->SetValue(ui->m_CleanBoxOxygenUpLimit->GetValue());
|
|
}
|
|
if (ImGui::InputFloat(_(u8"清粉箱泄压值").c_str(), ui->m_CleanBoxPressureReleaseValue->GetUIValue(), 0, 0, "%.2f", ImGuiInputTextFlags_EnterReturnsTrue))
|
|
{
|
|
ui->m_CleanBoxPressureReleaseValue->SetValue(ui->m_CleanBoxPressureReleaseValue->GetValue());
|
|
}
|
|
if (ImGui::InputFloat(_(u8"打印小车1报警重量").c_str(), ui->m_PrintCar1AlarmWeight->GetUIValue(), 0, 0, "%.2f", ImGuiInputTextFlags_EnterReturnsTrue))
|
|
{
|
|
ui->m_PrintCar1AlarmWeight->SetValue(ui->m_PrintCar1AlarmWeight->GetValue());
|
|
}
|
|
if (ImGui::InputFloat(_(u8"打印小车2报警重量").c_str(), ui->m_PrintCar2AlarmWeight->GetUIValue(), 0, 0, "%.2f", ImGuiInputTextFlags_EnterReturnsTrue))
|
|
{
|
|
ui->m_PrintCar2AlarmWeight->SetValue(ui->m_PrintCar2AlarmWeight->GetValue());
|
|
}
|
|
if (ImGui::InputFloat(_(u8"清粉小车1报警重量").c_str(), ui->m_CleanCar1AlarmWeight->GetUIValue(), 0, 0, "%.2f", ImGuiInputTextFlags_EnterReturnsTrue))
|
|
{
|
|
ui->m_CleanCar1AlarmWeight->SetValue(ui->m_CleanCar1AlarmWeight->GetValue());
|
|
}
|
|
if (ImGui::InputFloat(_(u8"清粉小车2报警重量").c_str(), ui->m_CleanCar2AlarmWeight->GetUIValue(), 0, 0, "%.2f", ImGuiInputTextFlags_EnterReturnsTrue))
|
|
{
|
|
ui->m_CleanCar2AlarmWeight->SetValue(ui->m_CleanCar2AlarmWeight->GetValue());
|
|
}
|
|
|
|
|
|
ImGui::EndGroup();
|
|
|
|
ImGui::SameLine();
|
|
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
|
|
ImGui::SameLine();
|
|
ImGui::BeginGroup();
|
|
if (ImGui::InputFloat(_(u8"料位棒长度").c_str(), ui->m_PowderLevelLength->GetUIValue(), 0, 0, "%.2f", ImGuiInputTextFlags_EnterReturnsTrue))
|
|
{
|
|
ui->m_PowderLevelLength->SetValue(ui->m_PowderLevelLength->GetValue());
|
|
}
|
|
|
|
//wxxtest
|
|
//if (ImGui::InputFloat(_(u8"料位棒计算长度").c_str(), &m_RunCfg->m_PowderStickCalcLength, 0, 0, "%.2f", ImGuiInputTextFlags_EnterReturnsTrue))
|
|
//{
|
|
// if (m_RunCfg->m_PowderStickCalcLength <= 0.0f) {
|
|
// m_RunCfg->m_PowderStickCalcLength = 1.0f;
|
|
// }
|
|
//}
|
|
|
|
if (ImGui::InputFloat(_(u8"料位棒当前值").c_str(), ui->m_PowderLevelValue->GetUIValue(), 0, 0, "%.2f", ImGuiInputTextFlags_EnterReturnsTrue))
|
|
{
|
|
ui->m_PowderLevelValue->SetValue(ui->m_PowderLevelValue->GetValue());
|
|
}
|
|
|
|
if (ImGui::InputFloat(_(u8"打印室换气泄压值").c_str(), ui->m_PrintAirRenewalPresRelValue->GetUIValue(), 0, 0, "%.2f", ImGuiInputTextFlags_EnterReturnsTrue))
|
|
{
|
|
ui->m_PrintAirRenewalPresRelValue->SetValue(ui->m_PrintAirRenewalPresRelValue->GetValue());
|
|
}
|
|
ImGui::EndGroup();
|
|
}
|
|
|
|
|
|
void Machine::DrawIO(bool* isShow)
|
|
{
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 6));
|
|
ImGui::Begin(_(u8"IO调试").c_str(), isShow, ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_HorizontalScrollbar);
|
|
ImGui::PopStyleVar();
|
|
ImGui::BeginTabBar(u8"IO_TAB");
|
|
if (ImGui::BeginTabItem(_(u8"输出").c_str())) {
|
|
int group_cnt = ceil(m_IOCfgWrapper->m_OutputCfgs.size() / 20.0f);
|
|
for (int i = 0; i < group_cnt; i++) {
|
|
ImGui::BeginGroup();
|
|
for (int j = 0; j < 20 && (i * 20 + j) < m_IOCfgWrapper->m_OutputCfgs.size(); j++) {
|
|
IOCfg* ocfg = m_IOCfgWrapper->m_OutputCfgs[i * 20 + j];
|
|
if (ImGui::ToggleButton((to_string(ocfg->m_Id) + ocfg->m_Code).c_str(), ocfg->IsActive(), g_Admin >= ocfg->m_AuthLess)) {
|
|
ocfg->SetActive(!ocfg->IsActive());
|
|
}
|
|
ImGui::SameLine();
|
|
ImGui::Text("%s", ocfg->m_ShowContent.c_str());
|
|
}
|
|
ImGui::EndGroup();
|
|
|
|
if (i < group_cnt - 1) {
|
|
ImGui::SameLine();
|
|
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
|
|
ImGui::SameLine();
|
|
}
|
|
}
|
|
ImGui::EndTabItem();
|
|
}
|
|
|
|
if (ImGui::BeginTabItem(_(u8"输入").c_str())) {
|
|
int group_cnt = ceil(m_IOCfgWrapper->m_InputCfgs.size() / 21.0f);
|
|
for (int i = 0; i < group_cnt; i++) {
|
|
ImGui::BeginGroup();
|
|
for (int j = 0; j < 21 && (i * 21 + j) < m_IOCfgWrapper->m_InputCfgs.size(); j++) {
|
|
IOCfg* ocfg = m_IOCfgWrapper->m_InputCfgs[i * 21 + j];
|
|
ImGui::ToggleButton((to_string(ocfg->m_Id) + ocfg->m_Code).c_str(), ocfg->IsActive(), false);
|
|
ImGui::SameLine();
|
|
ImGui::Text("%s", ocfg->m_ShowContent.c_str());
|
|
}
|
|
ImGui::EndGroup();
|
|
|
|
if (i < group_cnt - 1) {
|
|
ImGui::SameLine();
|
|
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
|
|
ImGui::SameLine();
|
|
}
|
|
}
|
|
ImGui::EndTabItem();
|
|
}
|
|
ImGui::EndTabBar();
|
|
|
|
|
|
ImGui::End();
|
|
}
|