| | |
| | | #include "SGMeasurementDlg.h" |
| | | #include "afxdialogex.h" |
| | | #include "SGIF.h" |
| | | #include "Logger.h" |
| | | |
| | | #ifdef _DEBUG |
| | | #define new DEBUG_NEW |
| | |
| | | m_editLog.ReplaceSel(_T("")); // 删除 |
| | | } |
| | | |
| | | void CSGMeasurementDlg::AppendLogLineRichStyled(const CString& content, COLORREF color /*= RGB(0, 0, 0)*/) |
| | | void CSGMeasurementDlg::AppendLogLineRichStyled(const CString& strContent, COLORREF color /*= RGB(0, 0, 0)*/) |
| | | { |
| | | if (!::IsWindow(GetSafeHwnd()) || !::IsWindow(m_editLog.GetSafeHwnd())) { |
| | | return; |
| | |
| | | m_editLog.SetSelectionCharFormat(cfTime); |
| | | m_editLog.ReplaceSel(strTimestamp); |
| | | |
| | | // 生成日志级别标签 |
| | | CString strLevel; |
| | | if (color == LOG_COLOR_WARNING) { |
| | | strLevel = _T("[警告]"); |
| | | } |
| | | else if (color == LOG_COLOR_ERROR) { |
| | | strLevel = _T("[错误]"); |
| | | } |
| | | else if (color == LOG_COLOR_NORMAL) { |
| | | strLevel = _T("[信息]"); |
| | | } |
| | | else if (color == LOG_COLOR_SUCCESS) { |
| | | strLevel = _T("[成功]"); |
| | | } |
| | | else { |
| | | strLevel = _T("[未知]"); |
| | | } |
| | | |
| | | // 插入日志正文(传入颜色) |
| | | CHARFORMAT2 cfMsg = {}; |
| | | cfMsg.cbSize = sizeof(cfMsg); |
| | | cfMsg.dwMask = CFM_COLOR; |
| | | cfMsg.crTextColor = color; |
| | | m_editLog.SetSelectionCharFormat(cfMsg); |
| | | m_editLog.ReplaceSel(content + _T("\r\n")); |
| | | m_editLog.ReplaceSel(strLevel + strContent + _T("\r\n")); |
| | | |
| | | // 限制最大行数 |
| | | TrimRichEditLineLimit(100); |
| | | |
| | | // 拼接完整日志行 |
| | | CString strFullLogLine; |
| | | strFullLogLine.Format(_T("%s %s"), strLevel, strContent); |
| | | |
| | | // 写入日志文件 |
| | | LOG_LINE(strFullLogLine); |
| | | } |
| | | |
| | | void CSGMeasurementDlg::HighlightAllMatches(const CString& strSearch, COLORREF clrHighlight/* = RGB(255, 165, 0)*/) |
| | |
| | | return -1.0f; |
| | | } |
| | | |
| | | clock_t startClock = clock(); // 记录开始时间 |
| | | |
| | | std::vector<float> vecBuffer(m_nSavePointCount, 0.0f); |
| | | int nReceived = 0; |
| | | |
| | |
| | | CalcGlassOffset(vecGlass1, vecGlass2, fAvg1, fAvg2, fOffset); |
| | | } |
| | | |
| | | clock_t endClock = clock(); // 记录结束时间 |
| | | double dElapsedMs = 1000.0 * (endClock - startClock) / CLOCKS_PER_SEC; |
| | | |
| | | CString strElapsed; |
| | | strElapsed.Format(_T("AnalyzeStoredData 执行耗时:%.1f ms"), dElapsedMs); |
| | | AppendLogLineRichStyled(strElapsed, LOG_COLOR_SUCCESS); |
| | | |
| | | return fOffset; |
| | | } |
| | | |