GrpcPrint/PrintS/Config/bean/MachineCfg.cpp
2024-03-19 17:45:12 +08:00

160 lines
6.5 KiB
C++

#include "MachineCfg.h"
#include "../../utils/TimeHelper.h"
#include "../../utils/StringHelper.h"
#include "SystemBase.h"
#include "HbdLanguage.h"
#include "IOVersion.h"
MachineCfg::MachineCfg()
{
m_serial = "";
m_Name = "HBD1200";
m_language = HbdLanguage::zh_CN;
m_I18NLang = "zh_CN";
m_MachineType = MachineTypeCfg::HBD_1200;
m_ScanControl = RTC5;
m_PulifierType = PurifierTypeCfg::HBD_PURIFIER_3;
m_fontSize = 25.0f;
m_fontScale = 0.8f;
m_lastStartTime = time(0);
m_lastShutdownTime = time(0);
m_LockPassword = "123";
m_LockAlpha = 1.0f;
m_LockIdleTime = 10;
m_ExpriedTime = time(0);
//m_IsRemoteConnect = true;
m_ConnectPassword = "hbd_remote";
m_Location = "";
m_PlatformShape = 0;
m_SupportNonEncMagic = true;
m_PrintStrategy = DATA; //¶à¼¤¹â´òÓ¡²ßÂÔ
m_PlatformLength = 600;
m_PlatformWidth = 600;
m_IsIntelli = true;
m_IOVersion = 0;
m_MachineCode = "";
m_CodeMap[MachineTypeCfg::HBD_1000].push_back("HBD 1000");
m_CodeMap[MachineTypeCfg::HBD_1200].push_back("HBD 1200");
m_CodeMap[MachineTypeCfg::HBD_1200_OLD].push_back("HBD 1200V0");
m_CodeMap[MachineTypeCfg::HBD_1500].push_back("HBD 1500");
m_CodeMap[MachineTypeCfg::HBD_E1000].push_back("HBD E1000");
}
MachineCfg::~MachineCfg()
{
}
void MachineCfg::GetUpdateSql(vector<string>& ups)
{
char buffer[512];
string updateSql = "UPDATE " + TABLE_NAME + " SET " + FIELD_VALUE + "='%s' WHERE " + FIELD_CODE + "='%s'";
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), m_serial.c_str(), CODE_SERIAL.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), m_Name.c_str(), CODE_NAME.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_language).c_str(), CODE_LANGUAGE.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_MachineType).c_str(), CODE_MACHINE_TYPE.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_ScanControl).c_str(), CODE_SCAN_CONTROL.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_PulifierType).c_str(), CODE_PULIFIER_TYPE.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_lastStartTime).c_str(), CODE_LAST_START_TIME.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_lastShutdownTime).c_str(), CODE_LAST_SHUTDOWN_TIME.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), m_LockPassword.c_str(), CODE_LOCK_PASSWORD.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_LockAlpha).c_str(), CODE_LOCK_ALPHA.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_LockIdleTime).c_str(), CODE_LOCK_IDLE_TIME.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_ExpriedTime).c_str(), CODE_EXPIRED_TIME.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), m_ConnectPassword.c_str() , CODE_CONNECT_PASSWORD.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), m_Location.c_str(), CODE_LOCATION.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_PlatformShape).c_str(), CODE_SHAPE.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_SupportNonEncMagic).c_str(), CODE_SUPPORT_NON_ENC_MAGIC.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_PrintStrategy).c_str(), CODE_PRINT_STRATEGY.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_PlatformLength).c_str(), CODE_PLATFORM_LENGTH.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_PlatformWidth).c_str(), CODE_PLATFORM_WIDTH.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), m_IsIntelli ? "1" : "0", CODE_IS_INTELLI.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_IOVersion).c_str(), CODE_IO_VERSION.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_SupplyMachineVersion).c_str(), CODE_SUPPLY_MACHINE_VERSION.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), m_MachineCode.c_str(), CODE_MACHINE_CODE.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), m_I18NLang.c_str(), CODE_I18N_LANG.c_str());
ups.push_back(buffer);
}
const string MachineCfg::TABLE_NAME = "MachineCfg";
const string MachineCfg::FIELD_CODE = "code";
const string MachineCfg::FIELD_VALUE = "value";
const string MachineCfg::CODE_SERIAL = "Serial";
const string MachineCfg::CODE_NAME = "name";
const string MachineCfg::CODE_LANGUAGE = "Language";
const string MachineCfg::CODE_MACHINE_TYPE = "machine_type";
const string MachineCfg::CODE_SCAN_CONTROL = "scan_control";
const string MachineCfg::CODE_PULIFIER_TYPE = "purifier_type";
const string MachineCfg::CODE_LAST_START_TIME = "last_start_time";
const string MachineCfg::CODE_LAST_SHUTDOWN_TIME = "last_shutdown_time";
const string MachineCfg::CODE_FONT_SIZE = "font_size";
const string MachineCfg::CODE_FONT_SCALE = "font_scale";
const string MachineCfg::CODE_LOCK_PASSWORD = "lock_password";
const string MachineCfg::CODE_LOCK_ALPHA = "lock_alpha";
const string MachineCfg::CODE_LOCK_IDLE_TIME = "idle_time";
const string MachineCfg::CODE_EXPIRED_TIME = "expired_time";
const string MachineCfg::CODE_HEATING_ENABLE = "heat_enable";
//const string MachineCfg::CODE_IS_REMOTE_CONNECT = "is_remote_connect";
const string MachineCfg::CODE_CONNECT_PASSWORD = "connect_password";
const string MachineCfg::CODE_LOCATION = "location";
const string MachineCfg::CODE_SHAPE = "shape";
const string MachineCfg::CODE_SUPPORT_NON_ENC_MAGIC = "support_non_enc_magic";
const string MachineCfg::CODE_PRINT_STRATEGY = "print_strategy";
const string MachineCfg::CODE_PLATFORM_WIDTH = "platform_width";
const string MachineCfg::CODE_PLATFORM_LENGTH = "platform_length";
const string MachineCfg::CODE_IS_INTELLI = "is_intelli";
const string MachineCfg::CODE_IO_VERSION = "io_version";
const string MachineCfg::CODE_SUPPLY_MACHINE_VERSION = "SupplyMachineVersion";
const string MachineCfg::CODE_MACHINE_CODE = "MachineCode";
const string MachineCfg::CODE_I18N_LANG = "I18NLang";
map<int, vector<string>> MachineCfg::m_CodeMap = map<int, vector<string>>();