GrpcPrint/PrintS/Config/bean/MachineCfg.cpp

203 lines
8.9 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(new StrData("serial", u8""))
, m_Name(new StrData("Name", u8"","HBD E1000"))
, m_language(new IntData("language", u8"", HbdLanguage::zh_CN))
, m_MachineType(new IntData("MachineType", u8"", MachineTypeCfg::HBD_E1000))
, m_ScanControl(new IntData("ScanControl", u8"", RTC5))
, m_IsIntelli(new BoolData("IsIntelli", u8"", true))
, m_PulifierType(new IntData("PulifierType", u8"", PurifierTypeCfg::M1))
, m_fontSize(new FloatData("fontSize", u8"", 25.0f))
, m_fontScale(new FloatData("fontScale", u8"", 1.0f))
, m_lastStartTime(new TimetData("lastStartTime", u8"", time(0)))
, m_lastShutdownTime(new TimetData("lastShutdownTime", u8"", time(0)))
, m_LockPassword(new StrData("LockPassword", u8"", "123"))
, m_LockAlpha(new FloatData("LockAlpha", u8"", 1.0f))
, m_LockIdleTime(new IntData("LockIdleTime", u8"", 10))
, m_ExpriedTime(new TimetData("ExpriedTime", u8"", time(0)))
, m_ConnectPassword(new StrData("ConnectPassword", u8"", "hbd_remote"))
, m_Location(new StrData("Location", u8""))
, m_PlatformShape(new IntData("PlatformShape", u8""))
, m_SupportNonEncMagic(new BoolData("SupportNonEncMagic", u8"",true))
, m_PrintStrategy(new IntData("PrintStrategy", u8"多激光打印策略", DATA))
, m_PlatformLength(new IntData("PlatformLength", u8"", 600))
, m_PlatformWidth(new IntData("PlatformWidth", u8"", 600))
, m_IOVersion(new IntData("IOVersion", u8""))
, m_SupplyMachineVersion(new IntData("SupplyMachineVersion", u8""))
, m_UseTouchScreen(new BoolData("UseTouchScreen", u8"",true))
, m_MachineCode(new StrData("MachineCode", u8""))
, m_MachineCodeAss(new StrData("MachineCodeAss", u8""))
{
//m_serial = "";
//m_Name = "HBD E1000";
//m_language = HbdLanguage::zh_CN;
//m_MachineType = MachineTypeCfg::HBD_E1000;
//m_ScanControl = RTC5;
//m_PulifierType = PurifierTypeCfg::M1;
//m_fontSize = 25.0f;
//m_fontScale = 1.0f;
//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");
size_t ptrSize = sizeof(nullptr); //指针大小
void* startPtr = &m_startFlag + 1;
size_t count = ((size_t)&m_endFlag - (size_t)startPtr) / ptrSize;
InsertMp(startPtr, count);
auto item = m_CodeMap.begin();
while(item != m_CodeMap.end()) {
//#pragma pack(1)
string key = to_string(item->first);
BaseData* p = new StrData(key, u8"", item->second[0]);
//#pragma pack()
InsertMp(key,p);
++item;
}
}
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->GetValueStr().c_str(), CODE_SERIAL.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), m_Name->GetValueStr().c_str(), CODE_NAME.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), m_language->GetValueStr().c_str(), CODE_LANGUAGE.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), m_MachineType->GetValueStr().c_str(), CODE_MACHINE_TYPE.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_ScanControl->GetValue()).c_str(), CODE_SCAN_CONTROL.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_PulifierType->GetValue()).c_str(), CODE_PULIFIER_TYPE.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_lastStartTime->GetValue()).c_str(), CODE_LAST_START_TIME.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_lastShutdownTime->GetValue()).c_str(), CODE_LAST_SHUTDOWN_TIME.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), m_LockPassword->GetValueStr().c_str(), CODE_LOCK_PASSWORD.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_LockAlpha->GetValue()).c_str(), CODE_LOCK_ALPHA.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_LockIdleTime->GetValue()).c_str(), CODE_LOCK_IDLE_TIME.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_ExpriedTime->GetValue()).c_str(), CODE_EXPIRED_TIME.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), m_ConnectPassword->GetValueStr().c_str(), CODE_CONNECT_PASSWORD.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), m_Location->GetValueStr().c_str(), CODE_LOCATION.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_PlatformShape->GetValue()).c_str(), CODE_SHAPE.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_SupportNonEncMagic->GetValue()).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->GetValue()).c_str(), CODE_PRINT_STRATEGY.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_PlatformLength->GetValue()).c_str(), CODE_PLATFORM_LENGTH.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_PlatformWidth->GetValue()).c_str(), CODE_PLATFORM_WIDTH.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), m_IsIntelli->GetValue() ? "1" : "0", CODE_IS_INTELLI.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_IOVersion->GetValue()).c_str(), CODE_IO_VERSION.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_SupplyMachineVersion->GetValue()).c_str(), CODE_SUPPLY_MACHINE_VERSION.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), to_string(m_UseTouchScreen->GetValue()).c_str(), CODE_USE_TOUCH_SCREEN.c_str());
ups.push_back(buffer);
sprintf_s(buffer, sizeof(buffer), updateSql.c_str(), m_MachineCode->GetValueStr().c_str(), CODE_MACHINE_CODE.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_USE_TOUCH_SCREEN = "UseTouchScreen";
const string MachineCfg::CODE_MACHINE_CODE = "MachineCode";
map<int, vector<string>> MachineCfg::m_CodeMap = map<int, vector<string>>();