fix the bug when there are three wave time slices in one eigen interval and modify version from 5.2 to 5.3

This commit is contained in:
pandx 2025-01-09 12:00:54 +08:00
parent 15582c4c49
commit a7ae340c01
4 changed files with 31 additions and 18 deletions

View File

@ -14,7 +14,7 @@ int GlobalConfig::LinkStatus_G = 0;
int GlobalConfig::LinkCount = 0;
int GlobalConfig::net0Status = 1;
std::string GlobalConfig::Version = "5.2";
std::string GlobalConfig::Version = "5.3";
std::string GlobalConfig::MacAddr_G = "";
std::string GlobalConfig::MacAddr_G2 = "";
std::string GlobalConfig::IpAddr_G = "";

View File

@ -142,7 +142,7 @@ private:
int seconds_in_current_eigen_slice_; // 相对特征值发送间隔的秒数
bool ts_in_eigen_slice_; // 时间位于特征值发送窗口中
int nth_eigen_slice_; // 如果ts_in_eigen_slice_是真的话此值表明是第几个特征值窗口
bool nth_wave_slice_; // 如果ts_in_eigen_slice_是假的话此值表明是第几个波形窗口
int nth_wave_slice_; // 如果ts_in_eigen_slice_是假的话此值表明是第几个波形窗口
int current_request_;
};

View File

@ -12,6 +12,14 @@ int UpgradeCfg::ReadCfg(std::map<int, UpgradeInfo> &upgrade) {
zlog_info(zbt, "[UpgradeCfg] no such file");
return 0;
}
upgrade_file.seekg(0, std::ios::end);
std::streampos file_size = upgrade_file.tellg();
if (file_size > 256000) {
zlog_error(zct, "upgrade file exception, will remove it");
ClearCfg();
return 1;
}
upgrade_file.seekg(0, std::ios::beg);
Json::Reader reader;
Json::Value root;
@ -51,6 +59,11 @@ int UpgradeCfg::ReadCfg(std::map<int, UpgradeInfo> &upgrade) {
}
int UpgradeCfg::WriteCfg(std::map<int, UpgradeInfo> &upgrade) {
if (upgrade.size() == 0) {
ClearCfg();
return 0;
}
Json::Value root;
for (auto item : upgrade) {
Json::Value upgrade_item;

View File

@ -33,12 +33,12 @@ WaveFeatureSetting::WaveFeatureSetting() {
global_feature_.short_addr = 0;
for (size_t i = 0; i < v.size(); ++i) {
if (i == 0) {
global_feature_.x = v[i].asInt();
global_feature_.x = v.get(i, 0).asInt();
} else if (i == 1) {
global_feature_.y = v[i].asInt();
global_feature_.y = v.get(i, 0).asInt();
} else if (i == 2) {
global_feature_.z = v[i].asInt();
}
global_feature_.z = v.get(i, 0).asInt();
}
}
} else {
short_addr = strtol(key.c_str(), &end_ptr, 16);
@ -46,12 +46,12 @@ WaveFeatureSetting::WaveFeatureSetting() {
FeatureEntryPrivateCfg item;
for (size_t i = 0; i < v.size(); ++i) {
if (i == 0) {
item.x = v[i].asInt();
item.x = v.get(i, 0).asInt();
} else if (i == 1) {
item.y = v[i].asInt();
item.y = v.get(i, 0).asInt();
} else if (i == 2) {
item.z = v[i].asInt();
}
item.z = v.get(i, 0).asInt();
}
}
eigen_map_[short_addr] = item;
}
@ -85,12 +85,12 @@ WaveFeatureSetting::WaveFeatureSetting() {
global_wave_.short_addr = 0;
for (size_t i = 0; i < v.size(); ++i) {
if (i == 0) {
global_wave_.x = v[i].asInt();
global_wave_.x = v.get(i, 0).asInt();
} else if (i == 1) {
global_wave_.y = v[i].asInt();
global_wave_.y = v.get(i, 0).asInt();
} else if (i == 2) {
global_wave_.z = v[i].asInt();
}
global_wave_.z = v.get(i, 0).asInt();
}
}
} else {
short_addr = strtol(key.c_str(), &end_ptr, 16);
@ -98,12 +98,12 @@ WaveFeatureSetting::WaveFeatureSetting() {
FeatureEntryPrivateCfg item;
for (size_t i = 0; i < v.size(); ++i) {
if (i == 0) {
item.x = v[i].asInt();
item.x = v.get(i, 0).asInt();
} else if (i == 1) {
item.y = v[i].asInt();
item.y = v.get(i, 0).asInt();
} else if (i == 2) {
item.z = v[i].asInt();
}
item.z = v.get(i, 0).asInt();
}
}
wave_map_[short_addr] = item;