245 lines
8.3 KiB
C++
245 lines
8.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"
|
|
#include "../DataManage/DataHandle.h"
|
|
|
|
Machine::Machine(MachineTypeCfg::MachineTypeId type)
|
|
: m_Type(type)
|
|
, m_IOCfgWrapper(nullptr)
|
|
, m_RunCfg(nullptr)
|
|
, m_Axis(nullptr)
|
|
, m_LoadInResut(0)
|
|
, m_LoadOutResut(0)
|
|
, m_LoadInProcStep(0)
|
|
, m_LoadOutProcStep(0)
|
|
, m_isLoadIn(false)
|
|
, m_isLoadOut(false)
|
|
, m_WaitConnectBoxCommit(false){
|
|
|
|
InitializeCriticalSection(&m_LoadCS);
|
|
}
|
|
|
|
Machine::~Machine() {
|
|
DeleteCriticalSection(&m_LoadCS);
|
|
}
|
|
|
|
|
|
void Machine::Init() {
|
|
m_IOCfgWrapper = ConfigManager::Instance()->GetIoCfgWrapper();
|
|
m_RunCfg = ConfigManager::Instance()->GetRunCfg();
|
|
m_ParamLimitCfg = ConfigManager::Instance()->GetParamLimitCfg();
|
|
m_ExtCfg = ConfigManager::Instance()->GetExtCfg();
|
|
|
|
m_MoldAxisCfg = &ConfigManager::Instance()->m_MoldCfg;
|
|
m_LoadAxisCfg = &ConfigManager::Instance()->m_LoadCfg;
|
|
m_ArmAxisCfg = &ConfigManager::Instance()->m_ArmCfg;
|
|
m_SupplyAxisCfg = &ConfigManager::Instance()->m_SupplyCfg;
|
|
m_CleanAxisCfg = &ConfigManager::Instance()->m_CleanCfg;
|
|
|
|
CheckIO();
|
|
}
|
|
|
|
void Machine::SetWaitConnectBoxCommit(bool commit) {
|
|
DataHandle::Instance()->SetPushMsg(WRITETYPE::LOADPARAM, "WaitConnectBoxCommit", to_string(commit), iBOOL);
|
|
//m_WaitConnectBoxCommit = commit;
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
|
|
void Machine::Update(const ReadData& rd) {
|
|
EnterCriticalSection(&m_LoadCS);
|
|
auto it = rd.its.begin();
|
|
while (it != rd.its.end()) {
|
|
if (it->nameKey == "LoadInResult") {
|
|
m_LoadInResut = stoi(it->strValue);
|
|
}
|
|
else if (it->nameKey == "LoadOutResult") {
|
|
m_LoadOutResut = stoi(it->strValue);
|
|
}
|
|
else if (it->nameKey == "LoadInProcStep") {
|
|
m_LoadInProcStep = stoi(it->strValue);
|
|
}
|
|
else if (it->nameKey == "LoadOutProcSetp") {
|
|
m_LoadOutProcStep = stoi(it->strValue);
|
|
}
|
|
else if (it->nameKey == "LoadInfo") {
|
|
m_LoadInfo = it->strValue;
|
|
}
|
|
else if (it->nameKey == "IsLoadIn") {
|
|
m_isLoadIn = (bool)stoi(it->strValue);
|
|
}
|
|
else if (it->nameKey == "IsLoadOut") {
|
|
m_isLoadOut = (bool)stoi(it->strValue);
|
|
}
|
|
else if (it->nameKey == "WaitConnectBoxCommit") {
|
|
m_WaitConnectBoxCommit = (bool)stoi(it->strValue);
|
|
}
|
|
else if (it->nameKey == "NeedWaitSelectOutPos") {
|
|
m_NeedWaitSelectOutPos = (bool)stoi(it->strValue);
|
|
}
|
|
else {
|
|
printf("error, key %s do not find...", it->nameKey.c_str());
|
|
}
|
|
++it;
|
|
}
|
|
LeaveCriticalSection(&m_LoadCS);
|
|
} |