#include "PowderEstimateCfg.h" #include "BaseConfig.h" PowderEstimateCfg::PowderEstimateCfg() { m_PowderPerGrid = 8; m_PE1.m_SpaceGrid=200; m_PE2.m_SpaceGrid = 1000; m_PE3.m_SpaceGrid = 1000; m_PE4.m_SpaceGrid = 1000; m_PE5.m_SpaceGrid = 1000; m_RemainPowderGrid = 0; m_StartSupplyPos = 0; m_StopSupplyPos = 2; m_StartSupplyQty = 20.0f; m_StopSupplyQty = 50.0f; m_AutoSupplyEnable = false; m_AutoSupplyTimeoutMinute = 10; InitializeCriticalSection(&m_RemainCS); } PowderEstimateCfg::~PowderEstimateCfg() { DeleteCriticalSection(&m_RemainCS); } void PowderEstimateCfg::Init(int posSize) { vector pes; pes.push_back(&m_PE1); pes.push_back(&m_PE2); pes.push_back(&m_PE3); pes.push_back(&m_PE4); pes.push_back(&m_PE5); for (int i = 0; i < posSize; i++) { if (posSize <= pes.size()) { m_PEVec.push_back(pes[i]); } } } void PowderEstimateCfg::GetUpdateSql(vector& ups) { char buffer[512]; sprintf_s(buffer, sizeof(buffer), "UPDATE %s set %s=", BaseConfig::TABLE_NAME.c_str(), BaseConfig::FIELD_CONFIG_VALUE.c_str() ); string strhead(buffer); sprintf_s(buffer, sizeof(buffer), " WHERE %s='%s' AND %s=", BaseConfig::FIELD_CONFIG_NAME.c_str(), CONFIG_NAME.c_str(), BaseConfig::FIELD_CONFIG_CODE.c_str() ); string strtail(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_PowderPerGrid).c_str(), strtail.c_str(), FIELD_POWDER_PER_GRID.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_PE1.m_SpaceGrid).c_str(), strtail.c_str(), FIELD_SPACE_GRID1.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_PE2.m_SpaceGrid).c_str(), strtail.c_str(), FIELD_SPACE_GRID2.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_PE3.m_SpaceGrid).c_str(), strtail.c_str(), FIELD_SPACE_GRID3.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_PE4.m_SpaceGrid).c_str(), strtail.c_str(), FIELD_SPACE_GRID4.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_PE5.m_SpaceGrid).c_str(), strtail.c_str(), FIELD_SPACE_GRID5.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_PE1.m_PowderPercent).c_str(), strtail.c_str(), FIELD_POWDER_PERCENT1.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_PE2.m_PowderPercent).c_str(), strtail.c_str(), FIELD_POWDER_PERCENT2.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_PE3.m_PowderPercent).c_str(), strtail.c_str(), FIELD_POWDER_PERCENT3.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_PE4.m_PowderPercent).c_str(), strtail.c_str(), FIELD_POWDER_PERCENT4.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_PE5.m_PowderPercent).c_str(), strtail.c_str(), FIELD_POWDER_PERCENT5.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_RemainPowderGrid).c_str(), strtail.c_str(), FIELD_REMAIN_POWDER_GRID.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_StartSupplyPos).c_str(), strtail.c_str(), FIELD_START_SUPPLY_POS.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_StopSupplyPos).c_str(), strtail.c_str(), FIELD_STOP_SUPPLY_POS.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), m_AutoSupplyEnable?"1":"0", strtail.c_str(), FIELD_AUTO_SUPPLY_ENABLE.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_AutoSupplyTimeoutMinute).c_str(), strtail.c_str(), FIELD_AUTO_SUPPLY_TIMEOUT_MINUTE.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_StartSupplyQty).c_str(), strtail.c_str(), FIELD_START_SUPPLY_QTY.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_StopSupplyQty).c_str(), strtail.c_str(), FIELD_STOP_SUPPLY_QTY.c_str()); ups.push_back(buffer); } const string PowderEstimateCfg::CONFIG_NAME="PowderEstimate"; const string PowderEstimateCfg::FIELD_POWDER_PER_GRID="PowderPerGrid"; const string PowderEstimateCfg::FIELD_SPACE_GRID1="SpaceGrid1"; const string PowderEstimateCfg::FIELD_SPACE_GRID2 = "SpaceGrid2"; const string PowderEstimateCfg::FIELD_SPACE_GRID3 = "SpaceGrid3"; const string PowderEstimateCfg::FIELD_SPACE_GRID4 = "SpaceGrid4"; const string PowderEstimateCfg::FIELD_SPACE_GRID5 = "SpaceGrid5"; const string PowderEstimateCfg::FIELD_POWDER_PERCENT1="PowderPercent1"; const string PowderEstimateCfg::FIELD_POWDER_PERCENT2 = "PowderPercent2"; const string PowderEstimateCfg::FIELD_POWDER_PERCENT3 = "PowderPercent3"; const string PowderEstimateCfg::FIELD_POWDER_PERCENT4 = "PowderPercent4"; const string PowderEstimateCfg::FIELD_POWDER_PERCENT5 = "PowderPercent5"; const string PowderEstimateCfg::FIELD_REMAIN_POWDER_GRID = "RemainPowderGrid"; const string PowderEstimateCfg::FIELD_START_SUPPLY_POS = "StartSupplyPos"; const string PowderEstimateCfg::FIELD_STOP_SUPPLY_POS = "StopSupplyPos"; const string PowderEstimateCfg::FIELD_AUTO_SUPPLY_ENABLE="AutoSupplyEnable"; const string PowderEstimateCfg::FIELD_AUTO_SUPPLY_TIMEOUT_MINUTE = "AutoSupplyTimeoutMinute"; const string PowderEstimateCfg::FIELD_START_SUPPLY_QTY = "StartSupplyQty"; const string PowderEstimateCfg::FIELD_STOP_SUPPLY_QTY = "StopSupplyQty";