#include "ScanTestCfg.h" #include "ScanCfg.h" #include "../../utils/StringHelper.h" #include "../../utils/ConverType.hpp" ScanTestCfg::ScanTestCfg() { m_debug_shape=0; m_shape_size=10; m_shape_size_min=1; m_shape_size_max=280; m_laser_power=20; m_laser_power_min=0; m_laser_power_max=100; m_defocus=0.0; m_defocus_min=0.0; m_defocus_max=100.0; m_is_cycle=false; m_cross_x=0.0; m_cross_y=0.0; m_z_distance=0.0; m_IsAutoHeatingScanner = false; m_AutoHeatingScannerMinutes = 20; m_AutoHeatingScannerSize = 280; m_AutoHeatingScannerSpeed = 1000; m_mark_test_start_x = 0.0f; m_mark_test_start_y = 0.0f; m_mark_test_end_x = 0.0f; m_mark_test_end_y = 0.0f; } ScanTestCfg::~ScanTestCfg() { } void ScanTestCfg::GetUpdateSql(int cno,vector& ups) { char buffer[512]; sprintf_s(buffer, sizeof(buffer), "UPDATE %s set %s=", ScanCfg::TABLE_NAME.c_str(), ScanCfg::FIELD_SCAN_VALUE.c_str() ); string strhead(buffer); sprintf_s(buffer, sizeof(buffer), " WHERE %s=%d AND %s='%s' AND %s=", ScanCfg::FIELD_CNO.c_str(), cno, ScanCfg::FIELD_CONFIG_NAME.c_str(), CONFIG_NAME.c_str(), ScanCfg::FIELD_SCAN_CODE.c_str() ); string strtail(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_debug_shape).c_str(), strtail.c_str(), FIELD_DEBUG_SHAPE.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_shape_size).c_str(), strtail.c_str(), FIELD_SHAPE_SIZE.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_laser_power).c_str(), strtail.c_str(), FIELD_LASER_POWER.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_defocus).c_str(), strtail.c_str(), FIELD_DEFOCUS.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), m_IsAutoHeatingScanner ? "1" : "0", strtail.c_str(), FIELD_IS_AUTO_HEATING_SCANNER.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_AutoHeatingScannerMinutes).c_str(), strtail.c_str(), FIELD_AUTO_HEATING_SCANNER_MINUTES.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_AutoHeatingScannerSize).c_str(), strtail.c_str(), FIELD_AUTO_HEATING_SCANNER_SIZE.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_AutoHeatingScannerSpeed).c_str(), strtail.c_str(), FIELD_AUTO_HEATING_SCANNER_SPEED.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_mark_test_start_x).c_str(), strtail.c_str(), FIELD_MARK_TEST_START_X.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_mark_test_start_y).c_str(), strtail.c_str(), FIELD_MARK_TEST_START_Y.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_mark_test_end_x).c_str(), strtail.c_str(), FIELD_MARK_TEST_END_X.c_str()); ups.push_back(buffer); sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", strhead.c_str(), to_string(m_mark_test_end_y).c_str(), strtail.c_str(), FIELD_MARK_TEST_END_Y.c_str()); ups.push_back(buffer); } void ScanTestCfg::SetScanTestCfg(stream::ScanTestCfg* cp) { cp->set_debugshape(m_debug_shape); cp->set_shapesize(m_shape_size); cp->set_shapesizemin(m_shape_size_min); cp->set_shape_size_max(m_shape_size_max); cp->set_laser_power(m_laser_power); cp->set_laser_power_min(m_laser_power_min); cp->set_laser_power_max(m_laser_power_max); cp->set_defocus(m_defocus); cp->set_defocus_min(m_defocus_min); cp->set_defocus_max(m_defocus_max); cp->set_is_cycle(m_is_cycle); cp->set_cross_x(m_cross_x); cp->set_cross_y(m_cross_y); cp->set_z_distance(m_z_distance); cp->set_isautoheatingscanner(m_IsAutoHeatingScanner); cp->set_autoheatingscannerminutes(m_AutoHeatingScannerMinutes); cp->set_autoheatingscannersize(m_AutoHeatingScannerSize); cp->set_autoheatingscannerspeed(m_AutoHeatingScannerSpeed); cp->set_mark_test_start_x(m_mark_test_start_x); cp->set_mark_test_start_y(m_mark_test_start_y); cp->set_mark_test_end_x(m_mark_test_end_x); cp->set_mark_test_end_y(m_mark_test_end_y); } void ScanTestCfg::Update(const ReadData& rd, const list& lst) { for (auto start = lst.begin(); start != lst.end(); ++start) { if (start->nameKey == "debug_shape") m_debug_shape = ConverType::TryToI(start->strValue); else if (start->nameKey == "shape_size") m_shape_size = ConverType::TryToI(start->strValue); else if (start->nameKey == "shape_size_min") m_shape_size_min = ConverType::TryToI(start->strValue); else if (start->nameKey == "shape_size_max") m_shape_size_max = ConverType::TryToI(start->strValue); else if (start->nameKey == "laser_power") m_laser_power = ConverType::TryToI(start->strValue); else if (start->nameKey == "laser_power_min") m_laser_power_min = ConverType::TryToI(start->strValue); else if (start->nameKey == "laser_power_max") m_laser_power_max = ConverType::TryToI(start->strValue); else if (start->nameKey == "defocus") m_defocus = ConverType::TryToD(start->strValue); else if (start->nameKey == "defocus_min") m_defocus_min = ConverType::TryToD(start->strValue); else if (start->nameKey == "defocus_max") m_defocus_max = ConverType::TryToD(start->strValue); else if (start->nameKey == "is_cycle") m_is_cycle = ConverType::TryToD(start->strValue); else if (start->nameKey == "cross_x") m_cross_x = ConverType::TryToD(start->strValue); else if (start->nameKey == "cross_y") m_cross_y = ConverType::TryToD(start->strValue); else if (start->nameKey == "z_distance") m_z_distance = ConverType::TryToD(start->strValue); else if (start->nameKey == "IsAutoHeatingScanner") m_IsAutoHeatingScanner = (bool)ConverType::TryToI(start->strValue); else if (start->nameKey == "AutoHeatingScannerMinutes") m_AutoHeatingScannerMinutes = (unsigned int)ConverType::TryToI(start->strValue); else if (start->nameKey == "AutoHeatingScannerSize") m_AutoHeatingScannerSize = (unsigned int)ConverType::TryToI(start->strValue); else if (start->nameKey == "AutoHeatingScannerSpeed") m_AutoHeatingScannerSpeed = ConverType::TryToD(start->strValue); else if (start->nameKey == "mark_test_start_x") m_mark_test_start_x = ConverType::TryToD(start->strValue); else if (start->nameKey == "mark_test_start_y") m_mark_test_start_y = ConverType::TryToD(start->strValue); else if (start->nameKey == "mark_test_end_x") m_mark_test_end_x = ConverType::TryToD(start->strValue); else if (start->nameKey == "mark_test_end_y") m_mark_test_end_y = ConverType::TryToD(start->strValue); } } string ScanTestCfg::CONFIG_NAME="ScanTest"; string ScanTestCfg::FIELD_DEBUG_SHAPE = "DebugShape"; string ScanTestCfg::FIELD_SHAPE_SIZE = "ShapeSize"; string ScanTestCfg::FIELD_SHAPE_SIZE_MIN = "ShapeSizeMin"; string ScanTestCfg::FIELD_SHAPE_SIZE_MAX = "ShapeSizeMax"; string ScanTestCfg::FIELD_LASER_POWER = "LaserPower"; string ScanTestCfg::FIELD_LASER_POWER_MIN = "LaserPowerMin"; string ScanTestCfg::FIELD_LASER_POWER_MAX = "LaserPowerMax"; string ScanTestCfg::FIELD_IS_CYCLE = "IsCycle"; string ScanTestCfg::FIELD_DEFOCUS="Defocus"; string ScanTestCfg::FIELD_DEFOCUS_MIN="DefocusMin"; string ScanTestCfg::FIELD_DEFOCUS_MAX="DefocusMax"; string ScanTestCfg::FIELD_CROSS_CENTER_X = "CorssCenterX"; string ScanTestCfg::FIELD_CROSS_CENTER_Y = "CorssCenterY"; string ScanTestCfg::FIELD_IS_AUTO_HEATING_SCANNER = "IsAutoHeatingScanner"; string ScanTestCfg::FIELD_AUTO_HEATING_SCANNER_MINUTES = "AutoHeatingScannerMinutes"; string ScanTestCfg::FIELD_AUTO_HEATING_SCANNER_SIZE = "AutoHeatingScannerSize"; string ScanTestCfg::FIELD_AUTO_HEATING_SCANNER_SPEED = "AutoHeatingScannerSpeed"; string ScanTestCfg::FIELD_MARK_TEST_START_X = "MarkTestStartX"; string ScanTestCfg::FIELD_MARK_TEST_START_Y = "MarkTestStartY"; string ScanTestCfg::FIELD_MARK_TEST_END_X = "MarkTestEndX"; string ScanTestCfg::FIELD_MARK_TEST_END_Y = "MarkTestEndY";