| | |
| | | if (type == -1) { |
| | | AppendLogLineRichStyled(msg, LOG_COLOR_ERROR); |
| | | } |
| | | if (type == 0) { |
| | | else if (type == 0) { |
| | | AppendLogLineRichStyled(msg, LOG_COLOR_SUCCESS); |
| | | } |
| | | else if (type == 1) { |
| | | AppendLogLineRichStyled(msg, LOG_COLOR_WARNING); |
| | | } |
| | | else { |
| | | else if (type == 2) { |
| | | AppendLogLineRichStyled(msg, LOG_COLOR_NORMAL); |
| | | } |
| | | }); |
| | |
| | | |
| | | // 设置 PLC 监听器的开始采集回调函数 |
| | | m_plcListener.SetStartCallback([this]() { |
| | | InitDataStorage(); |
| | | StartDataStorage(); |
| | | UpdateControlStatus(m_bConnected, m_bSaving); |
| | | if (!m_bConnected) { |
| | | ConnectToDevice(); |
| | | } |
| | | |
| | | if (InitDataStorage()) { |
| | | StartDataStorage(); |
| | | UpdateControlStatus(m_bConnected, m_bSaving); |
| | | } |
| | | }); |
| | | |
| | | // 设置 PLC 监听器的停止采集回调函数 |
| | |
| | | |
| | | // 设置 PLC 监听器的分析回调函数 |
| | | m_plcListener.SetAnalyzeCallback([this]() { |
| | | if (!m_bConnected) { |
| | | AppendLogLineRichStyled(_T("设备未连接,请先连接设备。"), LOG_COLOR_WARNING); |
| | | return std::array<double, 4>{ -1.0, -1.0, -1.0, -1.0 }; |
| | | } |
| | | |
| | | std::array<double, 4> result; |
| | | for (int i = 0; i < 4; ++i) { |
| | | result[i] = AnalyzeStoredData(i + 1); // OUT1 ~ OUT4 |