GrpcPrint/PrintC/ChartletManager.cpp

361 lines
16 KiB
C++
Raw Normal View History

2024-04-01 18:26:14 +08:00
#include "ChartletManager.h"
#include "global.h"
ChartletManager::ChartletManager()
{
}
ChartletManager::~ChartletManager()
{
delete m_pDB;
for (map<string, TextureBean*>::iterator it = m_TextureMap.begin(); it != m_TextureMap.end(); it++) {
TextureBean* tb = it->second;
delete tb;
tb = NULL;
}
m_TextureMap.clear();
}
ChartletManager* ChartletManager::GetInstance()
{
static ChartletManager manager;
return &manager;
}
bool ChartletManager::Init()
{
char buffer[256];
string databasepath = g_AppPath + "chartlet.hbd";
m_pDB = new SQLite::Database(databasepath, SQLite::OPEN_READWRITE);
m_pDB->exec("PRAGMA key = '!hbd_admin'");
if (!m_pDB->tableExists("chartlet"))return false;
sprintf_s(buffer, sizeof(buffer), "SELECT * FROM chartlet LIMIT 0");
SQLite::Statement query(*m_pDB, buffer);
try {
query.getColumnIndex("ctex");
}
catch (SQLite::Exception&) {
m_pDB->exec("ALTER TABLE chartlet ADD COLUMN ctex INTEGER DEFAULT 1");
m_pDB->exec("UPDATE chartlet set ctex=1");
}
sprintf_s(buffer, sizeof(buffer), "select code,src from chartlet where code='%s' or code='%s'", SPLASH_BG.c_str(),SPLASH_BG_EN.c_str());
SQLite::Statement query2(*m_pDB, string(buffer));
bool rel = false;
while (query2.executeStep()) {
string code = query2.getColumn("code").getString();
SQLite::Column colBlob = query2.getColumn("src");
int blobsize = colBlob.getBytes();
TextureBean* bean = new TextureBean();
bean->m_PData = new unsigned char[blobsize];
bean->m_DataLen = blobsize;
memcpy_s(bean->m_PData, blobsize, colBlob.getBlob(), blobsize);
m_TextureMap[code] = bean;
rel = true;
}
return rel;
}
void ChartletManager::LoadLogoIcon()
{
char buffer[256];
sprintf_s(buffer, sizeof(buffer), "select code,src from chartlet where code like 'ico_logo%%'");
SQLite::Statement query(*m_pDB, string(buffer));
while (query.executeStep()) {
string code = query.getColumn("code").getString();
SQLite::Column colBlob = query.getColumn("src");
int blobsize = colBlob.getBytes();
TextureBean* bean = new TextureBean();
bean->m_PData = new unsigned char[blobsize];
bean->m_DataLen = blobsize;
memcpy_s(bean->m_PData, blobsize, colBlob.getBlob(), blobsize);
m_TextureMap[code] = bean;
}
if (m_TextureMap.find(ICO_LOGO_48) == m_TextureMap.end() ||
m_TextureMap.find(ICO_LOGO_32) == m_TextureMap.end() ||
m_TextureMap.find(ICO_LOGO_16) == m_TextureMap.end())
{
m_HasIcoLogo = false;
}
else {
m_AppLogo48 = m_TextureMap[ICO_LOGO_48];
m_AppLogo32 = m_TextureMap[ICO_LOGO_32];
m_AppLogo16 = m_TextureMap[ICO_LOGO_16];
m_AppLogo48En = m_TextureMap[ICO_LOGO_48_EN];
m_AppLogo32En = m_TextureMap[ICO_LOGO_32_EN];
m_AppLogo16En = m_TextureMap[ICO_LOGO_16_EN];
m_HasIcoLogo = true;
}
}
void ChartletManager::LoadCharlet()
{
char buffer[256];
sprintf_s(buffer, sizeof(buffer), "select code,src,ctex from chartlet");
SQLite::Statement query(*m_pDB, string(buffer));
while (query.executeStep())
{
string code = query.getColumn("code").getString();
int ctex = query.getColumn("ctex").getInt();
if (ctex == 0)continue;
SQLite::Column colBlob = query.getColumn("src");
int blobsize = colBlob.getBytes();
TextureBean* bean = new TextureBean();
bean->m_PData = new unsigned char[blobsize];
bean->m_DataLen = blobsize;
memcpy_s(bean->m_PData, blobsize, colBlob.getBlob(), blobsize);
bean->Load();
TextureBean* old = m_TextureMap[code];
if (old != NULL)delete old;
m_TextureMap[code] = bean;
}
//m_RecyBottle = m_TextureMap[RECY_BOTTLE];
m_LogoTitle = m_TextureMap[LOGO_TITLE];
m_LogoTitleEn = m_TextureMap[LOGO_TITLE_EN];
m_ScreenWin = m_TextureMap[SCREEN_WIN];
m_ScreenFull = m_TextureMap[SCREEN_FULL];
m_AppClose = m_TextureMap[APP_CLOSE];
m_ToolbarRight = m_TextureMap[TOOLBAR_RIGHT];
m_AutoOxygenDisable = m_TextureMap[AUTO_OXYGEN_DISABLE];
m_AutoOxygenEnable = m_TextureMap[AUTO_OXYGEN_ENABLE];
m_LaserOff = m_TextureMap[LASER_OFF];
m_LaserOn = m_TextureMap[LASER_ON];
m_LightOff = m_TextureMap[LIGHT_OFF];
m_LightOn = m_TextureMap[LIGHT_ON];
m_HeatOff = m_TextureMap[HEAT_OFF];
m_HeatOn = m_TextureMap[HEAT_ON];
m_CheckDisable = m_TextureMap[CHECK_DISABLE];
m_CheckEnable = m_TextureMap[CHECK_ENABLE];
m_FitView = m_TextureMap[FIT_VIEW];
m_Lock = m_TextureMap[LOCK];
m_StartDisable = m_TextureMap[START_DISABLE];
m_StartEnable = m_TextureMap[START_ENABLE];
m_Pause = m_TextureMap[PAUSE];
m_StopDisable = m_TextureMap[STOP_DISABLE];
m_StopEnable = m_TextureMap[STOP_ENABLE];
m_SystemStatus = m_TextureMap[SYSTEM_STATUS];
m_SafeDoorStatus = m_TextureMap[SAFEDOOR_STATUS];
m_PositionStatus = m_TextureMap[POSITION_STATUS];
m_PositionPowder = m_TextureMap[POSITION_POWDER];
m_OxygenStatus = m_TextureMap[OXYGEN_STATUS];
m_HExpand = m_TextureMap[HEXPAND];
m_HNarrow = m_TextureMap[HNARROW];
m_UpArrowGreenBar = m_TextureMap[UP_ARROW_GREEN_BAR];
m_UpArrowRedBar = m_TextureMap[UP_ARROW_RED_BAR];
m_UpArrowGreen = m_TextureMap[UP_ARROW_GREEN];
m_UpArrowRed = m_TextureMap[UP_ARROW_RED];
m_DownArrowGreenBar = m_TextureMap[DOWN_ARROW_GREEN_BAR];
m_DownArrowRedBar = m_TextureMap[DOWN_ARROW_RED_BAR];
m_DownArrowGreen = m_TextureMap[DOWN_ARROW_GREEN];
m_DownArrowRed = m_TextureMap[DOWN_ARROW_RED];
m_ToZero = m_TextureMap[TO_ZERO];
m_LeftArrowGreen = m_TextureMap[LEFT_ARROW_GREEN];
m_LeftArrowGreenBar = m_TextureMap[LEFT_ARROW_GREEN_BAR];
m_LeftArrowRed = m_TextureMap[LEFT_ARROW_RED];
m_LeftArrowRedBar = m_TextureMap[LEFT_ARROW_RED_BAR];
m_RightArrowGreen = m_TextureMap[RIGHT_ARROW_GREEN];
m_RightArrowGreenBar = m_TextureMap[RIGHT_ARROW_GREEN_BAR];
m_RightArrowRed = m_TextureMap[RIGHT_ARROW_RED];
m_RightArrowRedBar = m_TextureMap[RIGHT_ARROW_RED_BAR];
m_Cursor = m_TextureMap[CURSOR];
m_Mold = m_TextureMap[MOLD];
m_Arm = m_TextureMap[ARM];
m_CoverBody = m_TextureMap[COVER_BODY];
m_CoverArm = m_TextureMap[COVER_ARM];
m_CoverMold = m_TextureMap[COVER_MOLD];
m_CoverPowder = m_TextureMap[COVER_POWDER];
m_PowderDown = m_TextureMap[POWDER_DOWN];
m_MotionBg = m_TextureMap[MOTION_BG];
m_LeftPressure = m_TextureMap[LEFT_PRESSURE];
m_RightPressure = m_TextureMap[RIGHT_PRESSURE];
m_MoldSupportLeft = m_TextureMap[MOLD_SUPPORT_LEFT];
m_MoldSupportRight = m_TextureMap[MOLD_SUPPORT_RIGHT];
m_JackUp = m_TextureMap[JACK_UP];
m_BasePlatform = m_TextureMap[BASE_PLATFORM];
m_LoadIn = m_TextureMap[LOAD];
m_LoadOut = m_TextureMap[UNLOAD];
m_CleanCloseConnect = m_TextureMap[CLEAN_CLOSE_CONNECT ];
m_CleanCloseDisconnect = m_TextureMap[CLEAN_CLOSE_UNCONNECT];
m_CleanOpenConnect = m_TextureMap[CLEAN_OPEN_CONNECT];
m_CleanOpenDisconnect = m_TextureMap[CLEAN_OPEN_UNCONNECT];
m_ResetException = m_TextureMap[RESET_EXCEPTION];
m_AlarmRemove = m_TextureMap[ALARM_REMOVE];
m_MoldMove3RSepDisable = m_TextureMap[MOLD_MOVE_3R_SEP_DISABLE];
m_MoldMove3RSepEnable = m_TextureMap[MOLD_MOVE_3R_SEP_Enable];
m_MoldMove3RSeping = m_TextureMap[MOLD_MOVE_3R_SEPING];
m_MoldMoveDeoxygenDisable = m_TextureMap[MOLD_MOVE_DEOXYGEN_DISABLE];
m_MoldMoveDeoxygenEnable = m_TextureMap[MOLD_MOVE_DEOXYGEN_ENABLE];
m_MoldMoveDeoxygening = m_TextureMap[MOLD_MOVE_DEOXYGENING];
m_MoldMoveDownestDisable = m_TextureMap[MOLD_MOVE_DOWNEST_DISABLE];
m_MoldMoveDownestEnable = m_TextureMap[MOLD_MOVE_DOWNEST_ENABLE];
m_MoldMoveDownesting = m_TextureMap[MOLD_MOVE_DOWNESTING];
m_MoldMovePlatformDisable = m_TextureMap[MOLD_MOVE_PLATFORM_DISABLE];
m_MoldMovePlatformEnable = m_TextureMap[MOLD_MOVE_PLATFORM_ENABLE];
m_MoldMovePlatforming = m_TextureMap[MOLD_MOVE_PLATFORMING];
m_MoldMovePlatformBottomDisable = m_TextureMap[MOLD_MOVE_PLATFORM_BOTTOM_DISABLE];
m_MoldMovePlatformBottomEnable = m_TextureMap[MOLD_MOVE_PLATFORM_BOTTOM_ENABLE];
m_MoldMovePlatformBottoming = m_TextureMap[MOLD_MOVE_PLATFORM_BOTTOMING];
m_MoldMoveSepDisable = m_TextureMap[MOLD_MOVE_SEP_DISABLE];
m_MoldMoveSepEnable = m_TextureMap[MOLD_MOVE_SEP_ENABLE];
m_MoldMoveSeping = m_TextureMap[MOLD_MOVE_SEPING];
m_LoadCleanPosDisable = m_TextureMap[LOAD_CLEAN_POS_DISABLE];
m_LoadCleanPosEnable = m_TextureMap[LOAD_CLEAN_POS_ENABLE];
m_LoadCleanPosing = m_TextureMap[LOAD_CLEAN_POSING];
m_LoadHandPosDisable = m_TextureMap[LOAD_HAND_POS_DISABLE];
m_LoadHandPosEnable = m_TextureMap[LOAD_HAND_POS_ENABLE];
m_LoadHandPosing = m_TextureMap[LOAD_HAND_POSING];
m_LoadPrintPosDisable = m_TextureMap[LOAD_PRINT_POS_DISABLE];
m_LoadPrintPosEnable = m_TextureMap[LOAD_PRINT_POS_ENABLE];
m_LoadPrintPosing = m_TextureMap[LOAD_PRINT_POSING];
m_LoadWaitPosDisable = m_TextureMap[LOAD_WAIT_POS_DISABLE];
m_LoadWaitPosEnable = m_TextureMap[LOAD_WAIT_POS_ENABLE];
m_LoadWaitPosing = m_TextureMap[LOAD_WAIT_POSING];
m_ArmAcceptPosDisable = m_TextureMap[ARM_ACCEPT_POS_DISABLE];
m_ArmAcceptPosEnable = m_TextureMap[ARM_ACCEPT_POS_ENABLE];
m_ArmAcceptPosing = m_TextureMap[ARM_ACCEPT_POSING];
m_ArmFrontDropPosDisable = m_TextureMap[ARM_FRONT_DROP_POS_DIABLE];
m_ArmFrontDropPosEnable = m_TextureMap[ARM_FRONT_DROP_POS_ENABLE];
m_ArmFrontDropPosing = m_TextureMap[ARM_FRONT_DROP_POSING];
m_SetPlatformLevelPos = m_TextureMap[SET_PLATFORM_LEVEL_POS];
m_GreenRound = m_TextureMap[GREEN_ROUND];
m_RedRound = m_TextureMap[RED_ROUND];
m_AppLogo48 = m_TextureMap[ICO_LOGO_48];
m_AppLogo32 = m_TextureMap[ICO_LOGO_32];
m_AppLogo16 = m_TextureMap[ICO_LOGO_16];
m_AppLogo48En = m_TextureMap[ICO_LOGO_48_EN];
m_AppLogo32En = m_TextureMap[ICO_LOGO_32_EN];
m_AppLogo16En = m_TextureMap[ICO_LOGO_16_EN];
}
string ChartletManager::SPLASH_BG = "splash_bg";
string ChartletManager::SPLASH_BG_EN = "splash_bg_en";
string ChartletManager::CURSOR = "cursor";
string ChartletManager::LEFT_ARROW_GREEN="left_arrow_green";
string ChartletManager::LEFT_ARROW_GREEN_BAR = "left_arrow_green_bar";
string ChartletManager::LEFT_ARROW_RED = "left_arrow_red";
string ChartletManager::LEFT_ARROW_RED_BAR = "left_arrow_red_bar";
string ChartletManager::UP_ARROW_GREEN = "up_arrow_green";
string ChartletManager::UP_ARROW_GREEN_BAR = "up_arrow_green_bar";
string ChartletManager::UP_ARROW_RED = "up_arrow_red";
string ChartletManager::UP_ARROW_RED_BAR = "up_arrow_red_bar";
string ChartletManager::RIGHT_ARROW_GREEN = "right_arrow_green";
string ChartletManager::RIGHT_ARROW_GREEN_BAR = "right_arrow_green_bar";
string ChartletManager::RIGHT_ARROW_RED = "right_arrow_red";
string ChartletManager::RIGHT_ARROW_RED_BAR = "right_arrow_red_bar";
string ChartletManager::DOWN_ARROW_GREEN = "down_arrow_green";
string ChartletManager::DOWN_ARROW_GREEN_BAR = "down_arrow_green_bar";
string ChartletManager::DOWN_ARROW_RED = "down_arrow_red";
string ChartletManager::DOWN_ARROW_RED_BAR = "down_arrow_red_bar";
string ChartletManager::AXIS_ON = "axis_on";
string ChartletManager::AXIS_OFF = "axis_off";
string ChartletManager::HEXPAND = "hexpand";
string ChartletManager::HNARROW = "hnarrow";
string ChartletManager::LOAD = "load";
string ChartletManager::UNLOAD = "unload";
string ChartletManager::START_ENABLE = "start_enable";
string ChartletManager::START_DISABLE = "start_disable";
string ChartletManager::PAUSE_ENABLE = "pause_enable";
string ChartletManager::PAUSE_DISABLE = "pause_disable";
string ChartletManager::STOP_ENABLE = "stop_enable";
string ChartletManager::STOP_DISABLE = "stop_disable";
string ChartletManager::REMOVE = "remove";
string ChartletManager::AUTO_OXYGEN_ENABLE = "autooxygen_enable";
string ChartletManager::AUTO_OXYGEN_DISABLE = "autooxygen_disable";
string ChartletManager::OXYGEN_STATUS = "oxygen_status";
string ChartletManager::SYSTEM_STATUS = "system_status";
string ChartletManager::SAFEDOOR_STATUS = "safedoor_status";
string ChartletManager::POSITION_STATUS = "position_status";
string ChartletManager::LOCK = "lock";
string ChartletManager::MOLD = "mold";
string ChartletManager::TOOLBAR_RIGHT = "toolbar_right";
string ChartletManager::ARM = "arm";
string ChartletManager::DEDUSTE_ENABLE = "deduste_enable";
string ChartletManager::DEDUSTE_DISABLE = "deduste_disable";
string ChartletManager::FIT_VIEW = "fit_view";
string ChartletManager::TO_ZERO = "to_zero";
string ChartletManager::LOGO_TITLE = "logo_title";
string ChartletManager::LOGO_TITLE_EN = "logo_title_en";
string ChartletManager::SCREEN_WIN = "screen_win";
string ChartletManager::SCREEN_FULL = "screen_full";
string ChartletManager::APP_CLOSE = "app_close";
string ChartletManager::LASER_ON = "laser_on";
string ChartletManager::LASER_OFF = "laser_off";
string ChartletManager::LIGHT_ON = "light_on";
string ChartletManager::LIGHT_OFF = "light_off";
string ChartletManager::COVER_BODY = "cover_body";
string ChartletManager::COVER_ARM = "cover_arm";
string ChartletManager::COVER_MOLD = "cover_mold";
string ChartletManager::COVER_POWDER = "cover_powder";
string ChartletManager::PAUSE = "pause";
string ChartletManager::POSITION_POWDER = "position_powder";
string ChartletManager::HEAT_OFF = "heat_off";
string ChartletManager::HEAT_ON = "heat_on";
string ChartletManager::POWDER_DOWN = "powder_down";
string ChartletManager::CHECK_ENABLE = "check_enable";
string ChartletManager::CHECK_DISABLE = "check_disable";
string ChartletManager::MOTION_BG="motion_bg";
string ChartletManager::LEFT_PRESSURE = "left_pressure";
string ChartletManager::RIGHT_PRESSURE = "right_pressure";
string ChartletManager::MOLD_SUPPORT_LEFT = "mold_support_left";
string ChartletManager::MOLD_SUPPORT_RIGHT = "mold_support_right";
string ChartletManager::JACK_UP = "jackup";
string ChartletManager::BASE_PLATFORM = "base_platform";
string ChartletManager::CLEAN_CLOSE_CONNECT="clean_close_connect";
string ChartletManager::CLEAN_CLOSE_UNCONNECT="clean_close_unconnect";
string ChartletManager::CLEAN_OPEN_CONNECT="clean_open_connect";
string ChartletManager::CLEAN_OPEN_UNCONNECT="clean_open_unconnect";
string ChartletManager::RESET_EXCEPTION = "reset_exception";
string ChartletManager::ALARM_REMOVE = "alarm_remove";
string ChartletManager::MOLD_MOVE_3R_SEP_DISABLE="moldMove3RSepDisable";
string ChartletManager::MOLD_MOVE_3R_SEP_Enable="moldMove3RSepEnable";
string ChartletManager::MOLD_MOVE_3R_SEPING="moldMove3RSeping";
string ChartletManager::MOLD_MOVE_DEOXYGEN_DISABLE="moldMoveDeoxygenDisable";
string ChartletManager::MOLD_MOVE_DEOXYGEN_ENABLE="moldMoveDeoxygenEnable";
string ChartletManager::MOLD_MOVE_DEOXYGENING="moldMoveDeoxygening";
string ChartletManager::MOLD_MOVE_DOWNEST_DISABLE="moldMoveDownestDisable";
string ChartletManager::MOLD_MOVE_DOWNEST_ENABLE="moldMoveDownestEnable";
string ChartletManager::MOLD_MOVE_DOWNESTING="moldMoveDownesting";
string ChartletManager::MOLD_MOVE_PLATFORM_DISABLE="moldMovePlatformDisable";
string ChartletManager::MOLD_MOVE_PLATFORM_ENABLE="moldMovePlatformEnable";
string ChartletManager::MOLD_MOVE_PLATFORMING="moldMovePlatforming";
string ChartletManager::MOLD_MOVE_PLATFORM_BOTTOM_DISABLE="moldMovePlatformBottomDisable";
string ChartletManager::MOLD_MOVE_PLATFORM_BOTTOM_ENABLE="moldMovePlatformBottomEnable";
string ChartletManager::MOLD_MOVE_PLATFORM_BOTTOMING="moldMovePlatformBottoming";
string ChartletManager::MOLD_MOVE_SEP_DISABLE="moldMoveSepDisable";
string ChartletManager::MOLD_MOVE_SEP_ENABLE="moldMoveSepEnable";
string ChartletManager::MOLD_MOVE_SEPING="moldMoveSeping";
string ChartletManager::LOAD_CLEAN_POS_DISABLE = "loadCleanPosDisable";
string ChartletManager::LOAD_CLEAN_POS_ENABLE = "loadCleanPosEnable";
string ChartletManager::LOAD_CLEAN_POSING = "loadCleanPosing";
string ChartletManager::LOAD_HAND_POS_DISABLE = "loadHandPosDisable";
string ChartletManager::LOAD_HAND_POS_ENABLE = "loadHandPosEnable";
string ChartletManager::LOAD_HAND_POSING = "loadHandPosing";
string ChartletManager::LOAD_PRINT_POS_DISABLE = "loadPrintPosDisable";
string ChartletManager::LOAD_PRINT_POS_ENABLE = "loadPrintPosEnable";
string ChartletManager::LOAD_PRINT_POSING = "loadPrintPosing";
string ChartletManager::LOAD_WAIT_POS_DISABLE = "loadWaitPosDisable";
string ChartletManager::LOAD_WAIT_POS_ENABLE = "loadWaitPosEnable";
string ChartletManager::LOAD_WAIT_POSING = "loadWaitPosing";
string ChartletManager::ARM_ACCEPT_POS_DISABLE = "ArmAcceptPosDisable";
string ChartletManager::ARM_ACCEPT_POS_ENABLE = "ArmAcceptPosEnable";
string ChartletManager::ARM_ACCEPT_POSING = "ArmAcceptPosing";
string ChartletManager::ARM_FRONT_DROP_POS_DIABLE = "ArmFrontDropPosDisable";
string ChartletManager::ARM_FRONT_DROP_POS_ENABLE = "ArmFrontDropPosEnable";
string ChartletManager::ARM_FRONT_DROP_POSING = "ArmFrontDropPosing";
string ChartletManager::SET_PLATFORM_LEVEL_POS = "SetPlatformLevelPos";
string ChartletManager::GREEN_ROUND = "GreenRound";
string ChartletManager::RED_ROUND = "RedRound";
string ChartletManager::ICO_LOGO_48 = "ico_logo_48";
string ChartletManager::ICO_LOGO_32 = "ico_logo_32";
string ChartletManager::ICO_LOGO_16 = "ico_logo_16";
string ChartletManager::ICO_LOGO_48_EN = "ico_logo_48_en";
string ChartletManager::ICO_LOGO_32_EN = "ico_logo_32_en";
string ChartletManager::ICO_LOGO_16_EN = "ico_logo_16_en";