2024-03-26 10:33:00 +08:00
|
|
|
|
#include "RTC5Scanner.h"
|
|
|
|
|
#include "RTC5impl.hpp"
|
|
|
|
|
#include "../global.h"
|
|
|
|
|
#include "../SystemInfo.h"
|
|
|
|
|
#include "../Logger.h"
|
|
|
|
|
#include "../utils/MathHelper.h"
|
|
|
|
|
#include "../LanguageManager.h"
|
|
|
|
|
#include "../PLC/SignalService.h"
|
|
|
|
|
|
2024-05-15 13:38:34 +08:00
|
|
|
|
RTC5Scanner::RTC5Scanner(ScannerControlCfg* cfg,int scanIndex)
|
|
|
|
|
:Scanner(cfg), m_scanIndex(scanIndex)
|
2024-03-26 10:33:00 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//n_get_serial_number();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RTC5Scanner::~RTC5Scanner()
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::Uninit()
|
|
|
|
|
{
|
|
|
|
|
free_rtc5_dll();
|
|
|
|
|
DeleteCriticalSection(&m_SeqCS);
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-22 15:58:54 +08:00
|
|
|
|
bool RTC5Scanner::PreInit(unsigned int& card_count)
|
|
|
|
|
{
|
|
|
|
|
InitializeCriticalSection(&m_SeqCS);
|
|
|
|
|
for (int i = 1; i <= m_SeqCount; i++) {
|
|
|
|
|
GetLimitCodeV2(i);
|
|
|
|
|
}
|
|
|
|
|
InitMassLimitCode();
|
|
|
|
|
unsigned int error = 0;
|
|
|
|
|
|
|
|
|
|
if (g_isDebug)
|
|
|
|
|
{
|
|
|
|
|
srand(time(0));
|
|
|
|
|
vector<CardSerialPair> vec;
|
|
|
|
|
ConfigManager::GetInstance()->GetMachine()->GetDebugRTC(vec);
|
|
|
|
|
card_count = vec.size();
|
|
|
|
|
uint32_t sum = 0;
|
|
|
|
|
for (size_t i = 0; i < vec.size(); i++) {
|
|
|
|
|
m_CurrentSerio[i + 1] = vec[i].serialNo;
|
|
|
|
|
sum += vec[i].serialNo;
|
|
|
|
|
}
|
|
|
|
|
g_ScanSerial = (sum % 1000000);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error = init_rtc5_dll();
|
|
|
|
|
if (error != 0)
|
|
|
|
|
{
|
|
|
|
|
g_log->TraceError(_(u8"初始化振镜卡失败").c_str());
|
|
|
|
|
m_InitErrorInfos.push_back(_(u8"初始化振镜卡失败").c_str());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
card_count = rtc5_count_cards();
|
|
|
|
|
uint32_t sum = 0;
|
|
|
|
|
for (int i = 1; i <= card_count; i++) {
|
|
|
|
|
m_CurrentSerio[i] = n_get_serial_number(i);
|
|
|
|
|
sum += m_CurrentSerio[i];
|
|
|
|
|
}
|
|
|
|
|
g_ScanSerial = (sum % 1000000);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-26 10:33:00 +08:00
|
|
|
|
bool RTC5Scanner::Init()
|
|
|
|
|
{
|
|
|
|
|
//m_SeqBit.reset();
|
2024-05-22 15:58:54 +08:00
|
|
|
|
//int startIndex = (m_ScannerControlCfg->m_SeqNo - 1) * 6+1;
|
|
|
|
|
//int endIndex = m_ScannerControlCfg->m_SeqNo * 6+1;
|
2024-03-26 10:33:00 +08:00
|
|
|
|
//for (int i = startIndex; i < endIndex; i++) {
|
|
|
|
|
// m_SeqBit[i] = true;
|
|
|
|
|
//}
|
|
|
|
|
if ((m_ScannerControlCfg->m_SeqNo % 2) != 0) {
|
|
|
|
|
m_IsLeftScan = true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
m_IsLeftScan = false;
|
|
|
|
|
}
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
if (m_MachineCfg->m_IsIntelli) {
|
|
|
|
|
StartGetScanInfo();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
#endif
|
|
|
|
|
m_output_vfactor = 4095.0 / 10.0;
|
|
|
|
|
m_list_memory = 50 * 100 * 100;
|
|
|
|
|
|
2024-05-22 15:58:54 +08:00
|
|
|
|
|
2024-03-26 10:33:00 +08:00
|
|
|
|
//m_laser_control = (0x01 << 3) | (0x01 << 4); // Laser signals LOW active (Bits #3 and #4)
|
|
|
|
|
m_laser_control = 0;
|
|
|
|
|
unsigned int error = 0;
|
|
|
|
|
//n_stop_execution(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
error = n_load_program_file(m_ScannerControlCfg->m_ControlNo, g_AppPath.c_str());
|
|
|
|
|
if (error != 0) {
|
2024-05-22 15:58:54 +08:00
|
|
|
|
g_log->TraceError(g_LngManager->Log_LoadRTCFileError->ShowText());
|
|
|
|
|
m_InitErrorInfos.push_back(g_LngManager->Log_LoadRTCFileError->ShowText());
|
2024-03-26 10:33:00 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
char buffer[512];
|
|
|
|
|
sprintf_s(buffer, sizeof(buffer), "%sSLM%d.ct5", g_AppPath.c_str(), m_ScannerControlCfg->m_SeqNo);
|
|
|
|
|
string crtPath = string(buffer);
|
|
|
|
|
uint32_t dim = m_CorrectParamCfg->m_IsCorrectFile3D ? 3 : 2;
|
|
|
|
|
error = n_load_correction_file(m_ScannerControlCfg->m_ControlNo, crtPath.c_str(), 1, dim);
|
|
|
|
|
if (error != 0)
|
|
|
|
|
{
|
2024-05-22 15:58:54 +08:00
|
|
|
|
g_log->TraceError(g_LngManager->Log_LoadCorrectFileError->ShowText());
|
|
|
|
|
m_InitErrorInfos.push_back(g_LngManager->Log_LoadCorrectFileError->ShowText());
|
2024-03-26 10:33:00 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
n_select_cor_table(m_ScannerControlCfg->m_ControlNo, 1, 0);
|
|
|
|
|
n_reset_error(m_ScannerControlCfg->m_ControlNo, -1);
|
|
|
|
|
n_config_list(m_ScannerControlCfg->m_ControlNo, m_list_memory, m_list_memory);
|
|
|
|
|
n_set_laser_mode(m_ScannerControlCfg->m_ControlNo, 4);
|
|
|
|
|
//set_firstpulse_killer(FirstPulseKiller);
|
|
|
|
|
n_set_laser_control(m_ScannerControlCfg->m_ControlNo, m_laser_control);
|
|
|
|
|
unsigned int power = (unsigned int)(m_output_vfactor*m_ScanTestCfg->m_laser_power / 100 * 10.0);
|
|
|
|
|
|
|
|
|
|
double angle = m_CorrectParamCfg->m_scan_angle + m_CorrectParamCfg->m_fix_angle;
|
|
|
|
|
if (angle < 0.0) {
|
|
|
|
|
angle = angle + 360.0;
|
|
|
|
|
}
|
|
|
|
|
if (angle > 360.0) {
|
|
|
|
|
angle = angle - 360.0;
|
|
|
|
|
}
|
|
|
|
|
SetAngle(angle);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_CorrectParamCfg->m_IsCorrectFile3D) {
|
|
|
|
|
m_kfactor = n_get_head_para(m_ScannerControlCfg->m_ControlNo, 1, 1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
m_kfactor = m_CorrectParamCfg->m_FactorK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_zfactor = m_kfactor / 16.0;
|
|
|
|
|
m_workingdis = n_get_head_para(m_ScannerControlCfg->m_ControlNo, 1, 2);
|
|
|
|
|
m_xfactor = m_kfactor*m_CorrectParamCfg->m_xcorrect;
|
|
|
|
|
m_yfactor = m_kfactor*m_CorrectParamCfg->m_ycorrect;
|
|
|
|
|
unsigned int jumpDelay = m_ScanParamCfg->m_jump_delay / 10;
|
|
|
|
|
unsigned int markDelay = m_ScanParamCfg->m_scan_delay / 10;
|
|
|
|
|
unsigned int polygonDelay = m_ScanParamCfg->m_polygon_delay / 10;
|
|
|
|
|
long laserOnDealy = m_ScanParamCfg->m_laseron_delay * 2;
|
|
|
|
|
long laserOffDelay = m_ScanParamCfg->m_laseroff_delay * 2;
|
|
|
|
|
unsigned int edgeLevel = m_ScanParamCfg->m_edge_level / 10;
|
|
|
|
|
unsigned int minJumpDelay = m_ScanParamCfg->m_min_jump_delay / 10;
|
|
|
|
|
|
|
|
|
|
double markspeed = m_kfactor* m_ScanParamCfg->m_mark_speed / 1000.0;
|
|
|
|
|
double jumpspeed = m_kfactor* m_ScanParamCfg->m_jump_speed / 1000.0;
|
|
|
|
|
|
|
|
|
|
//float xoffset = m_CorrectParamCfg->m_xposfix*cos(m_Angle*MathHelper::m_PI / 180.0) - m_CorrectParamCfg->m_yposfix*sin(m_Angle*MathHelper::m_PI / 180.0);
|
|
|
|
|
// float yoffset = m_CorrectParamCfg->m_xposfix*sin(m_Angle*MathHelper::m_PI / 180.0) + m_CorrectParamCfg->m_yposfix*cos(m_Angle*MathHelper::m_PI / 180.0);
|
|
|
|
|
m_XOffsetAssist = m_CorrectParamCfg->m_xposfix*m_xfactor;
|
|
|
|
|
m_YOffsetAssist = m_CorrectParamCfg->m_yposfix*m_yfactor;
|
|
|
|
|
n_set_start_list(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
n_set_scanner_delays(m_ScannerControlCfg->m_ControlNo, jumpDelay, markDelay, polygonDelay);
|
|
|
|
|
n_set_laser_delays(m_ScannerControlCfg->m_ControlNo, laserOnDealy, laserOffDelay);
|
|
|
|
|
n_set_delay_mode_list(m_ScannerControlCfg->m_ControlNo, 1, 0, edgeLevel, minJumpDelay, (unsigned int)(m_ScanParamCfg->m_jump_length_limit*m_kfactor));
|
|
|
|
|
n_set_jump_speed(m_ScannerControlCfg->m_ControlNo, jumpspeed);
|
|
|
|
|
n_set_mark_speed(m_ScannerControlCfg->m_ControlNo, markspeed);
|
|
|
|
|
|
|
|
|
|
n_write_da_1_list(m_ScannerControlCfg->m_ControlNo, power);
|
|
|
|
|
n_set_defocus_list(m_ScannerControlCfg->m_ControlNo, 0);
|
|
|
|
|
//n_set_offset_list(m_ScannerControlCfg->m_ControlNo, 1, m_CorrectParamCfg->m_xposfix*m_xfactor, m_CorrectParamCfg->m_yposfix*m_yfactor, 1);
|
|
|
|
|
//n_set_offset_list(m_ScannerControlCfg->m_ControlNo, 1, xoffset*m_xfactor, yoffset*m_yfactor, 1);
|
|
|
|
|
UpdateSkyWriting(true);
|
|
|
|
|
n_set_end_of_list(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
ListExecute(1, true);
|
|
|
|
|
|
|
|
|
|
if (m_MachineCfg->m_IsIntelli) {
|
|
|
|
|
StartGetScanInfo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::GetInfo(vector<string>& ins)
|
|
|
|
|
{
|
|
|
|
|
char buffer[256];
|
|
|
|
|
sprintf_s(buffer, sizeof(buffer), "KFactor:%f\n", m_kfactor);
|
|
|
|
|
ins.push_back(buffer);
|
|
|
|
|
sprintf_s(buffer, sizeof(buffer), "XFactor:%f\n", m_xfactor);
|
|
|
|
|
ins.push_back(buffer);
|
|
|
|
|
sprintf_s(buffer, sizeof(buffer), "YFactor:%f\n", m_yfactor);
|
|
|
|
|
ins.push_back(buffer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::LoadList(unsigned int listid, bool wait)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (wait) {
|
|
|
|
|
while (!n_load_list(m_ScannerControlCfg->m_ControlNo, listid, 0)) {
|
|
|
|
|
Sleep(20);
|
|
|
|
|
if (BaseCtrl::IsStop()) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
n_load_list(m_ScannerControlCfg->m_ControlNo, listid, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::EndList()
|
|
|
|
|
{
|
|
|
|
|
n_set_end_of_list(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::AutoChangeList() {
|
|
|
|
|
n_auto_change(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::ListExecute(unsigned int listid, bool wait)
|
|
|
|
|
{
|
|
|
|
|
n_execute_list(m_ScannerControlCfg->m_ControlNo, listid);
|
|
|
|
|
unsigned int Busy(0), Pos(0);
|
|
|
|
|
if (wait) {
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
Sleep(10);
|
|
|
|
|
n_get_status(m_ScannerControlCfg->m_ControlNo, Busy, Pos);
|
|
|
|
|
if (BaseCtrl::IsStop()) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} while (Busy);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::AddVector(double startx, double starty, double endx, double endy)
|
|
|
|
|
{
|
|
|
|
|
double x1 = startx*m_xfactor + m_XOffsetAssist;
|
|
|
|
|
double y1 = starty*m_yfactor + m_YOffsetAssist;
|
|
|
|
|
double x2 = endx*m_xfactor + m_XOffsetAssist;
|
|
|
|
|
double y2 = endy*m_yfactor + m_YOffsetAssist;
|
|
|
|
|
|
|
|
|
|
double bitx1 = x1*cos(m_Radians) - y1*sin(m_Radians);
|
|
|
|
|
double bity1 = x1*sin(m_Radians) + y1*cos(m_Radians);
|
|
|
|
|
double bitx2 = x2*cos(m_Radians) - y2*sin(m_Radians);
|
|
|
|
|
double bity2 = x2*sin(m_Radians) + y2*cos(m_Radians);
|
|
|
|
|
|
|
|
|
|
long lstartx = lround(bitx1);
|
|
|
|
|
long lstarty = lround(bity1);
|
|
|
|
|
long lendx = lround(bitx2);
|
|
|
|
|
long lendy = lround(bity2);
|
|
|
|
|
n_jump_abs(m_ScannerControlCfg->m_ControlNo, lstartx, lstarty);
|
|
|
|
|
n_mark_abs(m_ScannerControlCfg->m_ControlNo, lendx, lendy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::JumpAbs(double x, double y)
|
|
|
|
|
{
|
|
|
|
|
double x1 = x*m_xfactor + m_XOffsetAssist;
|
|
|
|
|
double y1 = y*m_yfactor + m_YOffsetAssist;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double bitx1 = x1*cos(m_Radians) - y1*sin(m_Radians);
|
|
|
|
|
double bity1 = x1*sin(m_Radians) + y1*cos(m_Radians);
|
|
|
|
|
|
|
|
|
|
long lx = lround(bitx1);
|
|
|
|
|
long ly = lround(bity1);
|
|
|
|
|
n_jump_abs(m_ScannerControlCfg->m_ControlNo, lx, ly);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::MarkAbs(double x, double y)
|
|
|
|
|
{
|
|
|
|
|
double x1 = x*m_xfactor + m_XOffsetAssist;
|
|
|
|
|
double y1 = y*m_yfactor + m_YOffsetAssist;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double bitx1 = x1*cos(m_Radians) - y1*sin(m_Radians);
|
|
|
|
|
double bity1 = x1*sin(m_Radians) + y1*cos(m_Radians);
|
|
|
|
|
|
|
|
|
|
long lx = lround(bitx1);
|
|
|
|
|
long ly = lround(bity1);
|
|
|
|
|
n_mark_abs(m_ScannerControlCfg->m_ControlNo, lx, ly);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::WaitListFree()
|
|
|
|
|
{
|
|
|
|
|
unsigned int Busy(0), Pos(0);
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
Sleep(5);
|
|
|
|
|
n_get_status(m_ScannerControlCfg->m_ControlNo, Busy, Pos);
|
|
|
|
|
if (BaseCtrl::IsStop()) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} while (Busy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::ScanDebug()
|
|
|
|
|
{
|
|
|
|
|
SetAutoUpdateScanInfo(false);
|
|
|
|
|
Sleep(200);
|
|
|
|
|
unsigned int power = (unsigned int)(4095.0*m_PowerCompensateCfg->CalcPowerCompensate((float)m_ScanTestCfg->m_laser_power) / 100.0);
|
|
|
|
|
if (power > 4095)power = 4095;
|
|
|
|
|
double markspeed = m_kfactor*m_ScanParamCfg->m_mark_speed / 1000.0;
|
|
|
|
|
n_set_start_list(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
n_write_da_1_list(m_ScannerControlCfg->m_ControlNo, power);
|
|
|
|
|
n_set_mark_speed(m_ScannerControlCfg->m_ControlNo, markspeed);
|
|
|
|
|
if (m_CorrectParamCfg->m_IsDynamicFocus) {
|
|
|
|
|
long df = m_ScanTestCfg->m_defocus*m_zfactor;
|
|
|
|
|
n_set_defocus_list(m_ScannerControlCfg->m_ControlNo, df);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
n_set_defocus_list(m_ScannerControlCfg->m_ControlNo, 0);
|
|
|
|
|
}
|
|
|
|
|
n_set_end_of_list(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
ListExecute(1, true);
|
|
|
|
|
do {
|
|
|
|
|
ScanTestProc();
|
|
|
|
|
Sleep(20);
|
|
|
|
|
} while (m_ScanTestCfg->m_is_cycle && m_DebugFlag);
|
|
|
|
|
|
|
|
|
|
SetAutoUpdateScanInfo(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::ScanTestProc() {
|
|
|
|
|
|
|
|
|
|
int shapeSize = m_ScanTestCfg->m_shape_size;
|
|
|
|
|
switch (m_ScanTestCfg->m_debug_shape) {
|
|
|
|
|
case Cross: {
|
|
|
|
|
double tempx = m_ScanTestCfg->m_cross_x - (double)shapeSize / 2.0;
|
|
|
|
|
double tempy = m_ScanTestCfg->m_cross_y + (double)shapeSize / 2.0;
|
|
|
|
|
n_set_start_list(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
JumpAbs(tempx, m_ScanTestCfg->m_cross_y);
|
|
|
|
|
MarkAbs(tempx + shapeSize, m_ScanTestCfg->m_cross_y);
|
|
|
|
|
JumpAbs(m_ScanTestCfg->m_cross_x, tempy);
|
|
|
|
|
MarkAbs(m_ScanTestCfg->m_cross_x, tempy - shapeSize);
|
|
|
|
|
n_set_end_of_list(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
ListExecute(1, true);
|
|
|
|
|
}break;
|
|
|
|
|
case Square: {
|
|
|
|
|
float sqlength = (float)shapeSize / 2;
|
|
|
|
|
//double xoffset = m_ScanTestCfg->m_cross_x*cos(m_CorrectParamCfg->m_fix_angle*MathHelper::m_PI / 180.0) - m_ScanTestCfg->m_cross_y*sin(m_CorrectParamCfg->m_fix_angle*MathHelper::m_PI / 180.0);
|
|
|
|
|
//double yoffset = m_ScanTestCfg->m_cross_x*sin(m_CorrectParamCfg->m_fix_angle*MathHelper::m_PI / 180.0) + m_ScanTestCfg->m_cross_y*cos(m_CorrectParamCfg->m_fix_angle*MathHelper::m_PI / 180.0);
|
|
|
|
|
double xoffset = m_ScanTestCfg->m_cross_x;
|
|
|
|
|
double yoffset = m_ScanTestCfg->m_cross_y;
|
|
|
|
|
polygon square[] = {
|
|
|
|
|
-sqlength + xoffset, -sqlength + yoffset,
|
|
|
|
|
-sqlength + xoffset, sqlength + yoffset,
|
|
|
|
|
sqlength + xoffset, sqlength + yoffset,
|
|
|
|
|
sqlength + xoffset, -sqlength + yoffset,
|
|
|
|
|
-sqlength + xoffset, -sqlength + yoffset
|
|
|
|
|
};
|
|
|
|
|
int sqsize = (sizeof(square) / sizeof(polygon));
|
|
|
|
|
n_set_start_list(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
JumpAbs(square[0].xval, square[0].yval);
|
|
|
|
|
for (int i = 1; i < sqsize; i++) {
|
|
|
|
|
MarkAbs(square[i].xval, square[i].yval);
|
|
|
|
|
}
|
|
|
|
|
n_set_end_of_list(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
ListExecute(1, true);
|
|
|
|
|
}break;
|
|
|
|
|
case PointLaser: {
|
|
|
|
|
n_set_start_list(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
//n_set_defocus_list(m_ScannerControlCfg->m_ControlNo, 0);
|
|
|
|
|
JumpAbs(m_ScanTestCfg->m_cross_x, m_ScanTestCfg->m_cross_y);
|
|
|
|
|
n_set_end_of_list(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
ListExecute(1, true);
|
|
|
|
|
Sleep(200);
|
|
|
|
|
n_laser_signal_on(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
uint64_t tflag = GetTickCount64();
|
|
|
|
|
while (m_DebugFlag) {
|
|
|
|
|
Sleep(20);
|
|
|
|
|
uint64_t tnow = GetTickCount64();
|
|
|
|
|
unsigned int dif = tnow - tflag;
|
|
|
|
|
if (dif >= m_ExtCfg->m_TestEmissionTime) {
|
|
|
|
|
m_DebugFlag = false;
|
|
|
|
|
if (m_ScanTestCfg->m_is_cycle) {
|
|
|
|
|
m_ScanTestCfg->m_is_cycle = false;
|
|
|
|
|
}
|
|
|
|
|
//StopWork();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
n_laser_signal_off(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
}break;
|
|
|
|
|
case DefocusLenth: {
|
|
|
|
|
n_set_defocus(m_ScannerControlCfg->m_ControlNo, 0);
|
|
|
|
|
Sleep(100);
|
|
|
|
|
long zlength = n_get_z_distance(m_ScannerControlCfg->m_ControlNo, m_ScanTestCfg->m_cross_x*m_xfactor, m_ScanTestCfg->m_cross_y*m_yfactor, 0);
|
|
|
|
|
if (m_zfactor != 0.0) {
|
|
|
|
|
m_ScanTestCfg->m_z_distance = (double)zlength / m_zfactor;
|
|
|
|
|
}
|
|
|
|
|
}break;
|
|
|
|
|
case HLine:
|
|
|
|
|
{
|
|
|
|
|
double tempx = m_ScanTestCfg->m_cross_x - (double)shapeSize / 2.0;
|
|
|
|
|
//double tempy = m_ScanTestCfg->m_cross_x + (double)shapeSize / 2.0;
|
|
|
|
|
n_set_start_list(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
JumpAbs(tempx, m_ScanTestCfg->m_cross_y);
|
|
|
|
|
MarkAbs(tempx + shapeSize, m_ScanTestCfg->m_cross_y);
|
|
|
|
|
n_set_end_of_list(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
ListExecute(1, true);
|
|
|
|
|
|
|
|
|
|
}break;
|
|
|
|
|
case VLine:
|
|
|
|
|
{
|
|
|
|
|
double tempy = m_ScanTestCfg->m_cross_y + (double)shapeSize / 2.0;
|
|
|
|
|
n_set_start_list(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
JumpAbs(m_ScanTestCfg->m_cross_x, tempy);
|
|
|
|
|
MarkAbs(m_ScanTestCfg->m_cross_x, tempy - shapeSize);
|
|
|
|
|
n_set_end_of_list(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
ListExecute(1, true);
|
|
|
|
|
}break;
|
|
|
|
|
case MulPoints:
|
|
|
|
|
{
|
|
|
|
|
for (list<FixPointCfg*>::iterator it = m_ScannerControlCfg->m_FixPointWrapper.m_Cfgs.begin(); it != m_ScannerControlCfg->m_FixPointWrapper.m_Cfgs.end(); it++) {
|
|
|
|
|
FixPointCfg* cfg = (*it);
|
|
|
|
|
n_set_start_list(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
JumpAbs(cfg->m_PointX, cfg->m_PointY);
|
|
|
|
|
n_set_end_of_list(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
ListExecute(1, true);
|
|
|
|
|
n_laser_signal_on(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
uint64_t tflag = GetTickCount64();
|
|
|
|
|
while (m_DebugFlag) {
|
|
|
|
|
Sleep(5);
|
|
|
|
|
uint64_t tnow = GetTickCount64();
|
|
|
|
|
unsigned int dif = tnow - tflag;
|
|
|
|
|
if (dif >= cfg->m_Duration) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
n_laser_signal_off(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
if (!m_DebugFlag)break;
|
|
|
|
|
}
|
|
|
|
|
}break;
|
|
|
|
|
case MulJumpPoints:
|
|
|
|
|
{
|
|
|
|
|
while (m_DebugFlag) {
|
|
|
|
|
n_set_start_list(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
for (list<FixPointCfg*>::iterator it = m_ScannerControlCfg->m_FixPointWrapper.m_Cfgs.begin(); it != m_ScannerControlCfg->m_FixPointWrapper.m_Cfgs.end(); it++) {
|
|
|
|
|
FixPointCfg* cfg = (*it);
|
|
|
|
|
JumpAbs(cfg->m_PointX, cfg->m_PointY);
|
|
|
|
|
}
|
|
|
|
|
n_set_end_of_list(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
ListExecute(1, true);
|
|
|
|
|
Sleep(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}break;
|
|
|
|
|
case Vector:
|
|
|
|
|
{
|
|
|
|
|
n_set_start_list(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
JumpAbs(m_ScanTestCfg->m_mark_test_start_x, m_ScanTestCfg->m_mark_test_start_y);
|
|
|
|
|
MarkAbs(m_ScanTestCfg->m_mark_test_end_x, m_ScanTestCfg->m_mark_test_end_y);
|
|
|
|
|
n_set_end_of_list(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
ListExecute(1, true);
|
|
|
|
|
}break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::UpdateScanParamByCfg(ScanParamCfg* cfg)
|
|
|
|
|
{
|
|
|
|
|
if (!cfg)return;
|
|
|
|
|
unsigned int jumpDelay = cfg->m_jump_delay / 10;
|
|
|
|
|
unsigned int markDelay = cfg->m_scan_delay / 10;
|
|
|
|
|
unsigned int polygonDelay = cfg->m_polygon_delay / 10;
|
|
|
|
|
long laserOnDealy = cfg->m_laseron_delay * 2;
|
|
|
|
|
long laserOffDelay = cfg->m_laseroff_delay * 2;
|
|
|
|
|
unsigned int edgeLevel = cfg->m_edge_level / 10;
|
|
|
|
|
unsigned int minJumpDelay = cfg->m_min_jump_delay / 10;
|
|
|
|
|
double jumpspeed = m_kfactor* cfg->m_jump_speed / 1000.0;
|
|
|
|
|
|
|
|
|
|
n_set_scanner_delays(m_ScannerControlCfg->m_ControlNo, jumpDelay, markDelay, polygonDelay);
|
|
|
|
|
n_set_laser_delays(m_ScannerControlCfg->m_ControlNo, laserOnDealy, laserOffDelay);
|
|
|
|
|
n_set_delay_mode_list(m_ScannerControlCfg->m_ControlNo, 1, 1, edgeLevel, minJumpDelay, (unsigned int)(cfg->m_jump_length_limit*m_kfactor));
|
|
|
|
|
n_set_jump_speed(m_ScannerControlCfg->m_ControlNo, jumpspeed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::UpdateSetting()
|
|
|
|
|
{
|
|
|
|
|
SetAutoUpdateScanInfo(false);
|
|
|
|
|
Sleep(200);
|
|
|
|
|
/*ScanParamCfg* scanParam = ConfigManager::GetInstance()->GetScanParamCfg();
|
|
|
|
|
ScanTestCfg* scanTestCfg = ConfigManager::GetInstance()->GetScanTestCfg();*/
|
|
|
|
|
//LaserParamSetting* laserSetting = ConfigManager::GetInstance()->GetLaserParamSetting();
|
|
|
|
|
unsigned int jumpDelay = m_ScanParamCfg->m_jump_delay / 10;
|
|
|
|
|
unsigned int markDelay = m_ScanParamCfg->m_scan_delay / 10;
|
|
|
|
|
unsigned int polygonDelay = m_ScanParamCfg->m_polygon_delay / 10;
|
|
|
|
|
long laserOnDealy = m_ScanParamCfg->m_laseron_delay * 2;
|
|
|
|
|
long laserOffDelay = m_ScanParamCfg->m_laseroff_delay * 2;
|
|
|
|
|
unsigned int edgeLevel = m_ScanParamCfg->m_edge_level / 10;
|
|
|
|
|
unsigned int minJumpDelay = m_ScanParamCfg->m_min_jump_delay / 10;
|
|
|
|
|
unsigned int power = 4095.0* m_PowerCompensateCfg->CalcPowerCompensate((float)m_ScanTestCfg->m_laser_power) / 100.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double markspeed = m_kfactor*m_ScanParamCfg->m_mark_speed / 1000.0;
|
|
|
|
|
double jumpspeed = m_kfactor*m_ScanParamCfg->m_jump_speed / 1000.0;
|
|
|
|
|
n_write_da_x(m_ScannerControlCfg->m_ControlNo, 1, power); //设置功率
|
|
|
|
|
|
|
|
|
|
n_set_start_list(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
n_set_scanner_delays(m_ScannerControlCfg->m_ControlNo, jumpDelay, markDelay, polygonDelay);
|
|
|
|
|
//set_scanner_delays(m_jump_delay, m_mark_delay, m_polygon_delay);
|
|
|
|
|
n_set_laser_delays(m_ScannerControlCfg->m_ControlNo, laserOnDealy, laserOffDelay);
|
|
|
|
|
n_set_delay_mode_list(m_ScannerControlCfg->m_ControlNo, 1, 0, edgeLevel, minJumpDelay, m_ScanParamCfg->m_jump_length_limit*m_kfactor);
|
|
|
|
|
n_set_jump_speed(m_ScannerControlCfg->m_ControlNo, jumpspeed);
|
|
|
|
|
n_set_mark_speed(m_ScannerControlCfg->m_ControlNo, markspeed);
|
|
|
|
|
n_set_end_of_list(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
ListExecute(1, true);
|
|
|
|
|
SetAutoUpdateScanInfo(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::SetScanSpeed(double fvalue)
|
|
|
|
|
{
|
|
|
|
|
double speed = fvalue / 1000.0*m_kfactor;
|
|
|
|
|
n_set_mark_speed(m_ScannerControlCfg->m_ControlNo, speed);;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::SetPower(double watt)
|
|
|
|
|
{
|
|
|
|
|
unsigned int power = 4095.0*watt / 100;
|
|
|
|
|
if (power > 4095)power = 4095;
|
|
|
|
|
n_write_da_1_list(m_ScannerControlCfg->m_ControlNo, power);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool RTC5Scanner::StopWork() {
|
|
|
|
|
|
|
|
|
|
n_stop_execution(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::SetXyOffset(float x, float y) {
|
|
|
|
|
m_XOffsetAssist = x*m_xfactor;
|
|
|
|
|
m_YOffsetAssist = y*m_yfactor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::SetAngle(double angle) {
|
|
|
|
|
m_Angle = angle;
|
|
|
|
|
m_Radians = MathHelper::DegreesToRadians(m_Angle);
|
|
|
|
|
//n_set_angle(m_ScannerControlCfg->m_ControlNo, 1, angle, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::UpdateSkyWriting(bool islist)
|
|
|
|
|
{
|
|
|
|
|
long laserOnShift = 0;
|
|
|
|
|
unsigned int nprev = 0;
|
|
|
|
|
unsigned int npost = 0;
|
|
|
|
|
|
|
|
|
|
switch (m_SkyWritingCfg->m_Mode)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
laserOnShift = m_SkyWritingCfg->m_LaserOnShift * 2;
|
|
|
|
|
nprev = m_SkyWritingCfg->m_Nprev /10;
|
|
|
|
|
npost = m_SkyWritingCfg->m_Npost / 10;
|
|
|
|
|
if (islist)n_set_sky_writing_para_list(m_ScannerControlCfg->m_ControlNo, m_SkyWritingCfg->m_Timelag, laserOnShift, nprev, npost);
|
|
|
|
|
else n_set_sky_writing_para(m_ScannerControlCfg->m_ControlNo, m_SkyWritingCfg->m_Timelag, laserOnShift, nprev, npost);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
laserOnShift = m_SkyWritingCfg->m_LaserOnShift * 2;
|
|
|
|
|
nprev = m_SkyWritingCfg->m_Nprev / 10;
|
|
|
|
|
npost = m_SkyWritingCfg->m_Npost / 10;
|
|
|
|
|
if (islist) {
|
|
|
|
|
n_set_sky_writing_para_list(m_ScannerControlCfg->m_ControlNo, m_SkyWritingCfg->m_Timelag, laserOnShift, nprev, npost);
|
|
|
|
|
n_set_sky_writing_mode_list(m_ScannerControlCfg->m_ControlNo, 2);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
n_set_sky_writing_para(m_ScannerControlCfg->m_ControlNo, m_SkyWritingCfg->m_Timelag, laserOnShift, nprev, npost);
|
|
|
|
|
n_set_sky_writing_mode(m_ScannerControlCfg->m_ControlNo, 2);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
laserOnShift = m_SkyWritingCfg->m_LaserOnShift * 2;
|
|
|
|
|
nprev = m_SkyWritingCfg->m_Nprev / 10;
|
|
|
|
|
npost = m_SkyWritingCfg->m_Npost / 10;
|
|
|
|
|
if (islist) {
|
|
|
|
|
n_set_sky_writing_para_list(m_ScannerControlCfg->m_ControlNo, m_SkyWritingCfg->m_Timelag, laserOnShift, nprev, npost);
|
|
|
|
|
n_set_sky_writing_mode_list(m_ScannerControlCfg->m_ControlNo, 3);
|
|
|
|
|
n_set_sky_writing_limit_list(m_ScannerControlCfg->m_ControlNo, m_SkyWritingCfg->m_Limite);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
n_set_sky_writing_para(m_ScannerControlCfg->m_ControlNo, m_SkyWritingCfg->m_Timelag, laserOnShift, nprev, npost);
|
|
|
|
|
n_set_sky_writing_mode(m_ScannerControlCfg->m_ControlNo, 3);
|
|
|
|
|
n_set_sky_writing_limit(m_ScannerControlCfg->m_ControlNo, m_SkyWritingCfg->m_Limite);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 0:
|
|
|
|
|
default:
|
|
|
|
|
n_set_sky_writing_mode(m_ScannerControlCfg->m_ControlNo, 0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::SetSkyWritingEnable(bool benable, bool islist)
|
|
|
|
|
{
|
|
|
|
|
if (benable) {
|
|
|
|
|
UpdateSkyWriting(islist);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (islist) n_set_sky_writing_mode_list(m_ScannerControlCfg->m_ControlNo, 0);
|
|
|
|
|
else n_set_sky_writing_mode(m_ScannerControlCfg->m_ControlNo, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::SetDefocus(float value)
|
|
|
|
|
{
|
|
|
|
|
long ds = value*m_zfactor;
|
|
|
|
|
n_set_defocus_list(m_ScannerControlCfg->m_ControlNo, ds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::ListNop() {
|
|
|
|
|
|
|
|
|
|
n_list_nop(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::CheckAlarm()
|
|
|
|
|
{
|
|
|
|
|
if (!m_MachineCfg->m_IsIntelli)return;
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 1, CurrentOperationStateLowAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
int xlowstate = n_get_value(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
bool IsInternalVoltagesNormalX = (xlowstate & 0x20000) ? true : false;
|
|
|
|
|
bool IsCriticalErrorX = (xlowstate & 0x2000) ? false : true;
|
|
|
|
|
bool IsScannerAndServoBoradTempNormalX = (xlowstate & 0x8000) ? true : false;
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 2, CurrentOperationStateLowAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
int ylowstate = n_get_value(m_ScannerControlCfg->m_ControlNo, 2);
|
|
|
|
|
bool IsInternalVoltagesNormalY = (ylowstate & 0x20000) ? true : false;
|
|
|
|
|
bool IsCriticalErrorY = (ylowstate & 0x2000) ? false : true;
|
|
|
|
|
bool IsScannerAndServoBoradTempNormalY = (ylowstate & 0x8000) ? true : false;
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 1, StopEventCode);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
int xstopeven = n_get_value(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 2, StopEventCode);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
int ystopeven = n_get_value(m_ScannerControlCfg->m_ControlNo, 2);
|
|
|
|
|
|
|
|
|
|
bool isAlarm = false;
|
|
|
|
|
stringstream ss;
|
|
|
|
|
char buffer[256];
|
|
|
|
|
if (!IsInternalVoltagesNormalX) {
|
2024-05-22 15:58:54 +08:00
|
|
|
|
sprintf_s(buffer, sizeof(buffer), u8"%s:%d x%s\n", g_LngManager->SLog_ScannerNo->ShowText(), m_ScannerControlCfg->m_SeqNo, g_LngManager->Alarm_InteriorVoltageError->ShowText());
|
2024-03-26 10:33:00 +08:00
|
|
|
|
ss << buffer;
|
|
|
|
|
isAlarm = true;
|
|
|
|
|
}
|
|
|
|
|
if (!IsInternalVoltagesNormalY) {
|
2024-05-22 15:58:54 +08:00
|
|
|
|
sprintf_s(buffer, sizeof(buffer), u8"%s:%d y%s\n", g_LngManager->SLog_ScannerNo->ShowText(), m_ScannerControlCfg->m_SeqNo, g_LngManager->Alarm_InteriorVoltageError->ShowText());
|
2024-03-26 10:33:00 +08:00
|
|
|
|
ss << buffer;
|
|
|
|
|
isAlarm = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsCriticalErrorX) {
|
2024-05-22 15:58:54 +08:00
|
|
|
|
sprintf_s(buffer, sizeof(buffer), u8"%s:%d x%s\n", g_LngManager->SLog_ScannerNo->ShowText(), m_ScannerControlCfg->m_SeqNo, g_LngManager->Alarm_InteriorCriticalError->ShowText());
|
2024-03-26 10:33:00 +08:00
|
|
|
|
ss << buffer;
|
|
|
|
|
isAlarm = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsCriticalErrorY) {
|
2024-05-22 15:58:54 +08:00
|
|
|
|
sprintf_s(buffer, sizeof(buffer), u8"%s:%d y%s\n", g_LngManager->SLog_ScannerNo->ShowText(), m_ScannerControlCfg->m_SeqNo, g_LngManager->Alarm_InteriorCriticalError->ShowText());
|
2024-03-26 10:33:00 +08:00
|
|
|
|
ss << buffer;
|
|
|
|
|
isAlarm = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsScannerAndServoBoradTempNormalX) {
|
2024-05-22 15:58:54 +08:00
|
|
|
|
sprintf_s(buffer, sizeof(buffer), u8"%s:%d x%s\n", g_LngManager->SLog_ScannerNo->ShowText(), m_ScannerControlCfg->m_SeqNo, g_LngManager->Alarm_InteriorTempError->ShowText());
|
2024-03-26 10:33:00 +08:00
|
|
|
|
ss << buffer;
|
|
|
|
|
isAlarm = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsScannerAndServoBoradTempNormalY) {
|
2024-05-22 15:58:54 +08:00
|
|
|
|
sprintf_s(buffer, sizeof(buffer), u8"%s:%d y%s\n", g_LngManager->SLog_ScannerNo->ShowText(), m_ScannerControlCfg->m_SeqNo, g_LngManager->Alarm_InteriorTempError->ShowText());
|
2024-03-26 10:33:00 +08:00
|
|
|
|
ss << buffer;
|
|
|
|
|
isAlarm = true;
|
|
|
|
|
}
|
|
|
|
|
bool sbx = false;
|
|
|
|
|
bool sby = false;
|
|
|
|
|
string strx = IntelliScanState::GetStopEventInfo(xstopeven, sbx);
|
|
|
|
|
string stry = IntelliScanState::GetStopEventInfo(ystopeven, sby);
|
|
|
|
|
if (sbx)
|
|
|
|
|
{
|
2024-05-22 15:58:54 +08:00
|
|
|
|
sprintf_s(buffer, sizeof(buffer), u8"%s:%d x%s\n", g_LngManager->SLog_ScannerNo->ShowText(), m_ScannerControlCfg->m_SeqNo, strx.c_str());
|
2024-03-26 10:33:00 +08:00
|
|
|
|
ss << buffer;
|
|
|
|
|
isAlarm = true;
|
|
|
|
|
}
|
|
|
|
|
if (sby)
|
|
|
|
|
{
|
2024-05-22 15:58:54 +08:00
|
|
|
|
sprintf_s(buffer, sizeof(buffer), u8"%s:%d y%s\n", g_LngManager->SLog_ScannerNo->ShowText(), m_ScannerControlCfg->m_SeqNo, stry.c_str());
|
2024-03-26 10:33:00 +08:00
|
|
|
|
ss << buffer;
|
|
|
|
|
isAlarm = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isAlarm)
|
|
|
|
|
{
|
|
|
|
|
m_AlarmCfgWrapper->m_ScannerInteriorAlarm->m_AlarmInfo = ss.str().c_str();
|
|
|
|
|
SignalService::GetInstance().SetAlarm(m_AlarmCfgWrapper->m_ScannerInteriorAlarm, true);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
m_AlarmCfgWrapper->m_ScannerInteriorAlarm->m_AlarmInfo = "";
|
|
|
|
|
SignalService::GetInstance().SetAlarm(m_AlarmCfgWrapper->m_ScannerInteriorAlarm, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::UpdateScannerInfo()
|
|
|
|
|
{
|
|
|
|
|
if (!m_MachineCfg->m_IsIntelli)return;
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 1, ActualPositionAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
long xap = n_get_value(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 1, SetPositionAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
long xsp = n_get_value(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 1, PositionErrorAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
long xpe = n_get_value(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 1, ScanStatusAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
int xsta = n_get_value(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
// long xsta = n_get_value(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 1, GalvanometerScannerTempAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
float xgst = (float)n_get_value(m_ScannerControlCfg->m_ControlNo, 1) / 160.0f;
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 1, ServoBoardTempAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
float xsbt = (float)n_get_value(m_ScannerControlCfg->m_ControlNo, 1) / 160.0f;
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 1, CurrentOperationStateLowAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
int xlowstate = n_get_value(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 1, CurrentOperationStateHighAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
int xhighstate = n_get_value(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 1, StopEventCode);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
int xstopeven = n_get_value(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 2, ActualPositionAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
long yap = n_get_value(m_ScannerControlCfg->m_ControlNo, 2);
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 2, SetPositionAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
long ysp = n_get_value(m_ScannerControlCfg->m_ControlNo, 2);
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 2, PositionErrorAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
long ype = n_get_value(m_ScannerControlCfg->m_ControlNo, 2);
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 2, ScanStatusAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
int ysta = n_get_value(m_ScannerControlCfg->m_ControlNo, 2);
|
|
|
|
|
//long ysta = n_get_value(m_ScannerControlCfg->m_ControlNo, 2);
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 2, GalvanometerScannerTempAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
float ygst = (float)n_get_value(m_ScannerControlCfg->m_ControlNo, 2) / 160.0f;
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 2, ServoBoardTempAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
float ysbt = (float)n_get_value(m_ScannerControlCfg->m_ControlNo, 2) / 160.0f;
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 2, CurrentOperationStateLowAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
int ylowstate = n_get_value(m_ScannerControlCfg->m_ControlNo, 2);
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 2, CurrentOperationStateHighAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
int yhighstate = n_get_value(m_ScannerControlCfg->m_ControlNo, 2);
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 1, 2, StopEventCode);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
int ystopeven = n_get_value(m_ScannerControlCfg->m_ControlNo, 2);
|
|
|
|
|
|
|
|
|
|
EnterCriticalSection(&m_ScannerInfoCS);
|
2024-05-15 13:38:34 +08:00
|
|
|
|
m_ScanState.m_X.m_ActualPosition->SetValue(xap);
|
|
|
|
|
m_ScanState.m_Y.m_ActualPosition->SetValue(yap);
|
|
|
|
|
m_ScanState.m_X.m_SetPosition->SetValue(xsp);// / m_xfactor - m_CorrectParamCfg->m_xposfix / m_xfactor;
|
|
|
|
|
m_ScanState.m_Y.m_SetPosition->SetValue(ysp);// / m_yfactor - m_CorrectParamCfg->m_xposfix / m_yfactor;
|
|
|
|
|
m_ScanState.m_X.m_PositionError->SetValue(xpe);// / m_xfactor;
|
|
|
|
|
m_ScanState.m_Y.m_PositionError->SetValue(ype);// / m_yfactor;
|
2024-03-26 10:33:00 +08:00
|
|
|
|
bitset<32> xstaBit(xsta);
|
|
|
|
|
bitset<32> ystaBit(ysta);
|
2024-05-15 13:38:34 +08:00
|
|
|
|
m_ScanState.m_X.m_GalvanometerScannerTempOK->SetValue(xstaBit[18]);
|
|
|
|
|
m_ScanState.m_Y.m_GalvanometerScannerTempOK->SetValue(ystaBit[18]);
|
|
|
|
|
m_ScanState.m_X.m_GalvanometerScannerTemp->SetValue(xgst);
|
|
|
|
|
m_ScanState.m_Y.m_GalvanometerScannerTemp->SetValue(ygst);
|
|
|
|
|
m_ScanState.m_X.m_ServoBoardTemp->SetValue(xsbt);
|
|
|
|
|
m_ScanState.m_Y.m_ServoBoardTemp->SetValue(ysbt);
|
2024-03-26 10:33:00 +08:00
|
|
|
|
|
|
|
|
|
bitset<32> xlowstateBit(xlowstate);
|
2024-05-15 13:38:34 +08:00
|
|
|
|
m_ScanState.m_X.m_IsAllControlParametersValid->SetValue(xlowstateBit[8]);
|
|
|
|
|
m_ScanState.m_X.m_IsScannerReachedCriticalEdgePos->SetValue(!xlowstateBit[9]);
|
|
|
|
|
m_ScanState.m_X.m_IsADConverterSuccessfullyInit->SetValue(xlowstateBit[10]);
|
|
|
|
|
m_ScanState.m_X.m_IsScanSystemTempOverLimit->SetValue(!xlowstateBit[11]);
|
|
|
|
|
m_ScanState.m_X.m_IsExternalPowderLow->SetValue(!xlowstateBit[12]);
|
|
|
|
|
m_ScanState.m_X.m_IsCriticalError->SetValue(!xlowstateBit[13]);
|
|
|
|
|
m_ScanState.m_X.m_IsBootingProcessCompleted->SetValue(xlowstateBit[14]);
|
|
|
|
|
m_ScanState.m_X.m_IsScannerAndServoBoradTempNormal->SetValue(xlowstateBit[15]);
|
|
|
|
|
m_ScanState.m_X.m_IsPositionErrorNormalRange->SetValue(xlowstateBit[16]);
|
|
|
|
|
m_ScanState.m_X.m_IsInternalVoltagesNormal->SetValue(xlowstateBit[17]);
|
|
|
|
|
m_ScanState.m_X.m_IsGalvanometerScannerHeaterOutputStageOn->SetValue(xlowstateBit[18]);
|
|
|
|
|
m_ScanState.m_X.m_IsGalvanometerScannerOutputStageOn->SetValue(xlowstateBit[19]);
|
2024-03-26 10:33:00 +08:00
|
|
|
|
|
|
|
|
|
bitset<32> ylowstateBit(ylowstate);
|
2024-05-15 13:38:34 +08:00
|
|
|
|
m_ScanState.m_Y.m_IsAllControlParametersValid->SetValue(ylowstateBit[8]);
|
|
|
|
|
m_ScanState.m_Y.m_IsScannerReachedCriticalEdgePos->SetValue(!ylowstateBit[9]);
|
|
|
|
|
m_ScanState.m_Y.m_IsADConverterSuccessfullyInit->SetValue(ylowstateBit[10]);
|
|
|
|
|
m_ScanState.m_Y.m_IsScanSystemTempOverLimit->SetValue(!ylowstateBit[11]);
|
|
|
|
|
m_ScanState.m_Y.m_IsExternalPowderLow->SetValue(!ylowstateBit[12]);
|
|
|
|
|
m_ScanState.m_Y.m_IsCriticalError->SetValue(!ylowstateBit[13]);
|
|
|
|
|
m_ScanState.m_Y.m_IsBootingProcessCompleted->SetValue(ylowstateBit[14]);
|
|
|
|
|
m_ScanState.m_Y.m_IsScannerAndServoBoradTempNormal->SetValue(ylowstateBit[15]);
|
|
|
|
|
m_ScanState.m_Y.m_IsPositionErrorNormalRange->SetValue(ylowstateBit[16]);
|
|
|
|
|
m_ScanState.m_Y.m_IsInternalVoltagesNormal->SetValue(ylowstateBit[17]);
|
|
|
|
|
m_ScanState.m_Y.m_IsGalvanometerScannerHeaterOutputStageOn->SetValue(ylowstateBit[18]);
|
|
|
|
|
m_ScanState.m_Y.m_IsGalvanometerScannerOutputStageOn->SetValue(ylowstateBit[19]);
|
2024-03-26 10:33:00 +08:00
|
|
|
|
|
|
|
|
|
bitset<32> xhighstateBit(xhighstate);
|
2024-05-15 13:38:34 +08:00
|
|
|
|
m_ScanState.m_X.m_IsGalvanometerScannerOperationTempNormal->SetValue(xhighstateBit[13]);
|
|
|
|
|
m_ScanState.m_X.m_IsServoBoradOperationTempNormal->SetValue(xhighstateBit[14]);
|
|
|
|
|
m_ScanState.m_X.m_IsAGCVoltageOK->SetValue(xhighstateBit[15]);
|
|
|
|
|
m_ScanState.m_X.m_IsDSPCoreVoltageOK->SetValue(xhighstateBit[16]);
|
|
|
|
|
m_ScanState.m_X.m_IsDSPIOVoltageOK->SetValue(xhighstateBit[17]);
|
|
|
|
|
m_ScanState.m_X.m_IsAnalogSetionVoltageOK->SetValue(xhighstateBit[18]);
|
|
|
|
|
m_ScanState.m_X.m_IsADConverterVoltageOK->SetValue(xhighstateBit[19]);
|
2024-03-26 10:33:00 +08:00
|
|
|
|
|
|
|
|
|
bitset<32> yhighstateBit(yhighstate);
|
2024-05-15 13:38:34 +08:00
|
|
|
|
m_ScanState.m_Y.m_IsGalvanometerScannerOperationTempNormal->SetValue(yhighstateBit[13]);
|
|
|
|
|
m_ScanState.m_Y.m_IsServoBoradOperationTempNormal->SetValue(yhighstateBit[14]);
|
|
|
|
|
m_ScanState.m_Y.m_IsAGCVoltageOK->SetValue(yhighstateBit[15]);
|
|
|
|
|
m_ScanState.m_Y.m_IsDSPCoreVoltageOK->SetValue(yhighstateBit[16]);
|
|
|
|
|
m_ScanState.m_Y.m_IsDSPIOVoltageOK->SetValue(yhighstateBit[17]);
|
|
|
|
|
m_ScanState.m_Y.m_IsAnalogSetionVoltageOK->SetValue(yhighstateBit[18]);
|
|
|
|
|
m_ScanState.m_Y.m_IsADConverterVoltageOK->SetValue(yhighstateBit[19]);
|
2024-03-26 10:33:00 +08:00
|
|
|
|
time(&m_ScanStateUpdateTime);
|
2024-05-15 13:38:34 +08:00
|
|
|
|
m_ScanState.m_ScanStateUpdateTime->SetValue(to_string(m_ScanStateUpdateTime));
|
|
|
|
|
|
|
|
|
|
m_ScanState.m_X.m_LowState->SetValue(xlowstate);
|
|
|
|
|
m_ScanState.m_X.m_HighState->SetValue(xhighstate);
|
|
|
|
|
m_ScanState.m_Y.m_LowState->SetValue(ylowstate);
|
|
|
|
|
m_ScanState.m_Y.m_HighState->SetValue(yhighstate);
|
|
|
|
|
m_ScanState.m_X.m_StopEven->SetValue(xstopeven);
|
|
|
|
|
m_ScanState.m_Y.m_StopEven->SetValue(ystopeven);
|
2024-03-26 10:33:00 +08:00
|
|
|
|
LeaveCriticalSection(&m_ScannerInfoCS);
|
|
|
|
|
|
|
|
|
|
if (m_ScannerControlCfg->m_ScanCfgWrapper.m_CorrectParamCfg.m_IsDynamicFocus) {
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 2, 1, ServoBoardTempAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
float ysbtz = (float)n_get_value(m_ScannerControlCfg->m_ControlNo, 4) / 160.0f;
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 2, 1, PDSupplyVoltageAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
float pdsv = (float)n_get_value(m_ScannerControlCfg->m_ControlNo, 4) / 1600.0f;
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 2, 1, DSPCoreSupplyVoltageAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
float dspcsv = (float)n_get_value(m_ScannerControlCfg->m_ControlNo, 4) / 1600.0f;
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 2, 1, DSPIOVoltageAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
float dspiov = (float)n_get_value(m_ScannerControlCfg->m_ControlNo, 4) / 1600.0f;
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 2, 1, AnalogSectionVoltageAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
float asv = (float)n_get_value(m_ScannerControlCfg->m_ControlNo, 4) / 1600.0f;
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 2, 1, ADConverterSupplyVoltageAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
float adcsv = (float)n_get_value(m_ScannerControlCfg->m_ControlNo, 4) / 1600.0f;
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 2, 1, PDSupplyCurrentAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
float pdsc = (float)n_get_value(m_ScannerControlCfg->m_ControlNo, 4) / 16.0f;
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 2, 1, CurrentOperationStateLowAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
int ylowstatez = n_get_value(m_ScannerControlCfg->m_ControlNo, 4);
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 2, 1, CurrentOperationStateHighAddr);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
int yhighstatez = n_get_value(m_ScannerControlCfg->m_ControlNo, 4);
|
|
|
|
|
|
|
|
|
|
n_control_command(m_ScannerControlCfg->m_ControlNo, 2, 1, StopEventCode);
|
|
|
|
|
Sleep(2);
|
|
|
|
|
int zstopeven = n_get_value(m_ScannerControlCfg->m_ControlNo, 4);
|
|
|
|
|
|
|
|
|
|
EnterCriticalSection(&m_ScannerInfoCS);
|
2024-05-15 13:38:34 +08:00
|
|
|
|
m_ScanState.m_Focus.m_ServoBoardTemp->SetValue(ysbtz);
|
|
|
|
|
m_ScanState.m_Focus.m_PDSupplyVoltage->SetValue(pdsv);
|
|
|
|
|
m_ScanState.m_Focus.m_DSPCoreSupplyVoltage->SetValue(dspcsv);
|
|
|
|
|
m_ScanState.m_Focus.m_DSPIOVoltage->SetValue(dspiov);
|
|
|
|
|
m_ScanState.m_Focus.m_AnalogSectionVoltage->SetValue(asv);
|
|
|
|
|
m_ScanState.m_Focus.m_ADConverterSupplyVoltage->SetValue(adcsv);
|
|
|
|
|
m_ScanState.m_Focus.m_PDSupplyCurrent->SetValue(pdsc);
|
2024-03-26 10:33:00 +08:00
|
|
|
|
|
|
|
|
|
bitset<32> ylowstatezBit(ylowstatez);
|
2024-05-15 13:38:34 +08:00
|
|
|
|
m_ScanState.m_Focus.m_IsAllControlParametersValid->SetValue(ylowstatezBit[8]);
|
|
|
|
|
m_ScanState.m_Focus.m_IsScannerReachedCriticalEdgePos->SetValue(!ylowstatezBit[9]);
|
|
|
|
|
m_ScanState.m_Focus.m_IsADConverterSuccessfullyInit->SetValue(ylowstatezBit[10]);
|
|
|
|
|
m_ScanState.m_Focus.m_IsScanSystemTempOverLimit->SetValue(!ylowstatezBit[11]);
|
|
|
|
|
m_ScanState.m_Focus.m_IsExternalPowderLow->SetValue(!ylowstatezBit[12]);
|
|
|
|
|
m_ScanState.m_Focus.m_IsCriticalError->SetValue(!ylowstatezBit[13]);
|
|
|
|
|
m_ScanState.m_Focus.m_IsBootingProcessCompleted->SetValue(ylowstatezBit[14]);
|
|
|
|
|
m_ScanState.m_Focus.m_IsScannerAndServoBoradTempNormal->SetValue(ylowstatezBit[15]);
|
|
|
|
|
m_ScanState.m_Focus.m_IsPositionErrorNormalRange->SetValue(ylowstatezBit[16]);
|
|
|
|
|
m_ScanState.m_Focus.m_IsInternalVoltagesNormal->SetValue(ylowstatezBit[17]);
|
|
|
|
|
m_ScanState.m_Focus.m_IsGalvanometerScannerHeaterOutputStageOn->SetValue(ylowstatezBit[18]);
|
|
|
|
|
m_ScanState.m_Focus.m_IsGalvanometerScannerOutputStageOn->SetValue(ylowstatezBit[19]);
|
2024-03-26 10:33:00 +08:00
|
|
|
|
|
|
|
|
|
bitset<32> yhighstatezBit(yhighstatez);
|
2024-05-15 13:38:34 +08:00
|
|
|
|
m_ScanState.m_Focus.m_IsGalvanometerScannerOperationTempNormal->SetValue(yhighstatezBit[13]);
|
|
|
|
|
m_ScanState.m_Focus.m_IsServoBoradOperationTempNormal->SetValue(yhighstatezBit[14]);
|
|
|
|
|
m_ScanState.m_Focus.m_IsAGCVoltageOK->SetValue(yhighstatezBit[15]);
|
|
|
|
|
m_ScanState.m_Focus.m_IsDSPCoreVoltageOK->SetValue(yhighstatezBit[16]);
|
|
|
|
|
m_ScanState.m_Focus.m_IsDSPIOVoltageOK->SetValue(yhighstatezBit[17]);
|
|
|
|
|
m_ScanState.m_Focus.m_IsAnalogSetionVoltageOK->SetValue(yhighstatezBit[18]);
|
|
|
|
|
m_ScanState.m_Focus.m_IsADConverterVoltageOK->SetValue(yhighstatezBit[19]);
|
|
|
|
|
|
|
|
|
|
m_ScanState.m_Focus.m_LowState->SetValue(ylowstatez);
|
|
|
|
|
m_ScanState.m_Focus.m_HighState->SetValue(yhighstatez);
|
|
|
|
|
m_ScanState.m_Focus.m_StopEven->SetValue(zstopeven);
|
2024-03-26 10:33:00 +08:00
|
|
|
|
LeaveCriticalSection(&m_ScannerInfoCS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::ScannerInfoRun()
|
|
|
|
|
{
|
|
|
|
|
int updateFlag = 0;
|
|
|
|
|
while (m_InfoRunFlag) {
|
|
|
|
|
if (!m_ScannerIO->IsActive()) {
|
|
|
|
|
int flag = 0;
|
|
|
|
|
while (m_InfoRunFlag && flag < 10) {
|
|
|
|
|
Sleep(200);
|
|
|
|
|
flag++;
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!m_IsAutoInfo) {
|
|
|
|
|
int flag = 0;
|
|
|
|
|
while (m_InfoRunFlag && (!m_IsAutoInfo) && (flag < 20)) {
|
|
|
|
|
Sleep(100);
|
|
|
|
|
flag++;
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (updateFlag % 10 == 0) {
|
|
|
|
|
UpdateScannerInfo();
|
2024-05-15 13:38:34 +08:00
|
|
|
|
m_ScanState.SendToClients(XYSCANSTATE, "_" + to_string(m_scanIndex));
|
2024-03-26 10:33:00 +08:00
|
|
|
|
}
|
|
|
|
|
updateFlag++;
|
|
|
|
|
if (updateFlag > 1000) { updateFlag = 0; }
|
|
|
|
|
Sleep(100);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::HeatingScannerRun()
|
|
|
|
|
{
|
|
|
|
|
SetAutoUpdateScanInfo(false);
|
|
|
|
|
Sleep(300);
|
|
|
|
|
float sqlength = (float)m_ScannerControlCfg->m_ScanCfgWrapper.m_ScanTestCfg.m_AutoHeatingScannerSize / 2;
|
|
|
|
|
//double xoffset = m_ScanTestCfg->m_cross_x*cos(m_CorrectParamCfg->m_angle*MathHelper::m_PI / 180.0) - m_ScanTestCfg->m_cross_y*sin(m_CorrectParamCfg->m_angle*MathHelper::m_PI / 180.0);
|
|
|
|
|
// double yoffset = m_ScanTestCfg->m_cross_x*sin(m_CorrectParamCfg->m_angle*MathHelper::m_PI / 180.0) + m_ScanTestCfg->m_cross_y*cos(m_CorrectParamCfg->m_angle*MathHelper::m_PI / 180.0);
|
|
|
|
|
polygon square[] = {
|
|
|
|
|
-sqlength, -sqlength ,
|
|
|
|
|
-sqlength, sqlength,
|
|
|
|
|
sqlength, sqlength ,
|
|
|
|
|
sqlength, -sqlength,
|
|
|
|
|
-sqlength, -sqlength
|
|
|
|
|
};
|
|
|
|
|
double markspeed = m_kfactor* m_ScannerControlCfg->m_ScanCfgWrapper.m_ScanTestCfg.m_AutoHeatingScannerSpeed / 1000.0;
|
|
|
|
|
int sqsize = (sizeof(square) / sizeof(polygon));
|
|
|
|
|
n_set_start_list(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
n_set_mark_speed(m_ScannerControlCfg->m_ControlNo, markspeed);
|
|
|
|
|
JumpAbs(square[0].xval, square[0].yval);
|
|
|
|
|
n_set_end_of_list(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
ListExecute(1, true);
|
|
|
|
|
Sleep(100);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
n_set_start_list(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
for (int i = 1; i < sqsize; i++) {
|
|
|
|
|
MarkAbs(square[i].xval, square[i].yval);
|
|
|
|
|
}
|
|
|
|
|
n_set_end_of_list(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t tbegin = GetTickCount64();
|
|
|
|
|
unsigned int Busy(0), Pos(0);
|
2024-05-22 15:58:54 +08:00
|
|
|
|
while (m_HeatingScannerRunFlag && BaseCtrl::IsHeatingScanner()) {
|
2024-03-26 10:33:00 +08:00
|
|
|
|
uint64_t tnow = GetTickCount64();
|
|
|
|
|
if (tnow - tbegin > (m_ScannerControlCfg->m_ScanCfgWrapper.m_ScanTestCfg.m_AutoHeatingScannerMinutes * 60 * 1000)) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
n_get_status(m_ScannerControlCfg->m_ControlNo, Busy, Pos);
|
|
|
|
|
if (!Busy) {
|
|
|
|
|
n_execute_list(m_ScannerControlCfg->m_ControlNo, 1);
|
|
|
|
|
}
|
2024-05-22 15:58:54 +08:00
|
|
|
|
Sleep(10);
|
2024-03-26 10:33:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
n_stop_execution(m_ScannerControlCfg->m_ControlNo);
|
|
|
|
|
SetAutoUpdateScanInfo(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTC5Scanner::ResetDefocus()
|
|
|
|
|
{
|
|
|
|
|
n_set_defocus(m_ScannerControlCfg->m_ControlNo, 0);
|
|
|
|
|
}
|