修复波形文件补招优化波形匹配规则

This commit is contained in:
lnk
2026-06-12 15:31:06 +08:00
parent 3191422869
commit 7b60de7c76
3 changed files with 55 additions and 23 deletions

View File

@@ -3037,39 +3037,57 @@ bool extract_timestamp_from_cfg_file(const std::string& cfg_path, long long& sta
return start_tm > 0 && trig_tm > 0;
}
bool compare_qvvr_and_file(const std::string& cfg_path, std::vector<qvvr_data>& data_list,qvvr_data& matched_data) {
bool compare_qvvr_and_file(const std::string& cfg_path,
std::vector<qvvr_data>& data_list,
qvvr_data& matched_data) {
long long start_tm = 0;
long long trig_tm = 0;
// 提取 .cfg 文件中的时间戳
if (!extract_timestamp_from_cfg_file(cfg_path, start_tm, trig_tm)) {
std::cerr << "Failed to extract timestamp from cfg file: " << cfg_path << "\n";
return false;
}
//打印提取到的时间戳
std::cout << "[调试] 提取到的起始时间戳: " << start_tm << ", 触发时间戳: " << trig_tm << "\n";
std::cout << "[调试] 提取到的起始时间戳: " << start_tm
<< ", 触发时间戳: " << trig_tm << "\n";
// 遍历所有暂态事件,查找与 trig_tm 匹配的
for (auto& data : data_list) {
long long diff = static_cast<long long>(data.QVVR_time) - trig_tm;
const long long EIGHT_HOURS_MS = 8LL * 60 * 60 * 1000;
std::cout << "[调试] QVVR_time=" << data.QVVR_time
<< ", trig_tm=" << trig_tm
<< ", diff=" << diff << "\n";
std::vector<long long> candidates;
candidates.push_back(trig_tm); // 原始时间
candidates.push_back(trig_tm - EIGHT_HOURS_MS); // 减 8 小时
candidates.push_back(trig_tm + EIGHT_HOURS_MS); // 加 8 小时
if (std::abs(diff) <= 1) {
for (size_t i = 0; i < candidates.size(); ++i) {
long long cmp_tm = candidates[i];
data.is_pair = true; // 标记为已匹配
std::cout << "[调试] 开始匹配候选触发时间: " << cmp_tm
<< " offset_ms=" << (cmp_tm - trig_tm) << "\n";
matched_data = data; // 返回匹配到的事件
for (auto& data : data_list) {
long long diff =
static_cast<long long>(data.QVVR_time) - cmp_tm;
std::cout << "[调试] 匹配成功diff=" << diff << "\n";
std::cout << "[调试] QVVR_time=" << data.QVVR_time
<< ", cmp_tm=" << cmp_tm
<< ", diff=" << diff << "\n";
return true;
if (std::abs(diff) <= 1) {
data.is_pair = true;
matched_data = data;
std::cout << "[调试] 匹配成功cmp_tm=" << cmp_tm
<< ", offset_ms=" << (cmp_tm - trig_tm)
<< ", diff=" << diff << "\n";
return true;
}
}
}
std::cout << "[调试] 匹配失败,原始 trig_tm=" << trig_tm
<< ",已尝试 trig_tm、trig_tm-8h、trig_tm+8h\n";
return false;
}
@@ -5577,11 +5595,17 @@ void check_recall_file() {
}
//更新事件
// ★修改开始替换“assign_qvvr_file_list + update_qvvr_file_download(有锁)”
// 组装完整路径列表
std::vector<std::string> fullFilenames;
fullFilenames.reserve(front.required_files.size());
for (const auto& f : front.required_files) fullFilenames.push_back(f);
const std::string base_dir = std::string("download/") + sanitize(dev.addr_str);
for (const auto& remote_file : front.required_files) {
std::string fname = sanitize(extract_filename1(remote_file));
if (!fname.empty()) {
fullFilenames.push_back(base_dir + "/" + fname);
}
}
// 仅对“当前监测点”添加一组 qvvr_filefile_name=仅文件名,下载标记留到下行)
{

View File

@@ -38,7 +38,7 @@ AccessKey=rmqroot
SecretKey=001@#njcnmq
Topic_Test=lnk_Topic
Tag_Test=Test_Tag
Tag_Test=914b94563ca7f272c90ee8580ed6adc6
Key_Test=Test_Keys
Testflag=1
Testnum=0
@@ -48,7 +48,7 @@ TestList=
consumer=Group_consumer
ConsumerIpport=192.168.1.103:9876
ConsumerTopicRT=ask_real_data_topic
ConsumerTopicRT=ask_real_data_Topic
ConsumerTagRT=Test_Tag
ConsumerKeyRT=Test_Keys
ConsumerAccessKey=rmqroot
@@ -57,7 +57,7 @@ ConsumerChannel=
ConsumerTopicUD=control_Topic
ConsumerTagUD=Test_Tag
ConsumerKeyUD=Test_Keys
ConsumerTopicRC=recall_Topic
ConsumerTopicRC=ask_recall_Topic
ConsumerTagRC=Test_Tag
ConsumerKeyRC=Test_Keys
ConsumerTopicSET=process_Topic
@@ -75,6 +75,15 @@ CONNECTKey=Test_Keys
Heart_Beat_Topic=Heart_Beat_Topic
Heart_Beat_Tag=Test_Tag
Heart_Beat_Key=Test_Key
Topic_Reply_Topic=Topic_Reply_Topic
Topic_Reply_Topic=Reply_Topic
Topic_Reply_Tag=Test_Tag
Topic_Reply_Key=Test_Key
ConsumerTopicLOG=ask_log_Topic
ConsumerTagLOG=Test_Tag
ConsumerKeyLOG=Test_Keys
ConsumerTopicCLOUD=Cloud_Topic
ConsumerTagCLOUD=Cloud_Tag
ConsumerKeyCLOUD=Cloud_Keys
Cloud_Reply_Topic=Cloud_Reply_Topic
Cloud_Reply_Tag=Cloud_Reply_Tag
Cloud_Reply_Key=Cloud_Reply_Key

View File

@@ -1201,7 +1201,6 @@ void process_received_message(string mac, string id,const char* data, size_t len
//使用接口上送文件lnk20250826
std::string filename;
if(SendFileWebAuto(id, file_path, file_path, filename)){//如果是补招文件的下载则不会在这边上送
std::cout << "File upload success: " << filename << std::endl;
//通知文件上传
on_device_response_minimal(static_cast<int>(ResponseCode::OK), id, 0, static_cast<int>(DeviceState::READING_FILEDATA));