解决bug,优化波形接收需要补发的逻辑,version 5.6
This commit is contained in:
parent
402a7d6604
commit
47707a4758
@ -577,6 +577,7 @@ std::string JsonData::JsonCmd_Cgi_59(Param_59 ¶m) {
|
||||
" LAG(timestamp) OVER (ORDER BY timestamp) AS prev_timestamp "
|
||||
" FROM %s"
|
||||
") "
|
||||
|
||||
"SELECT timestamp, "
|
||||
" prev_timestamp, "
|
||||
" timestamp - prev_timestamp AS interval_seconds "
|
||||
@ -894,7 +895,7 @@ std::string JsonData::JsonCmd_Cgi_62(Param_62 ¶m){
|
||||
if (nSize > 0) {
|
||||
char szTableName[100] = {0x00}, whereCon[256] = {0x00},selectCon[100] = {0x00};
|
||||
if (param.mMode == 1){
|
||||
sprintf(selectCon," dataNodeNo,channelID,timeStamp,sendMsg,nodeResend ");
|
||||
sprintf(selectCon," dataNodeNo,channelID,timeStamp,sendMsg,sendMsg,nodeResend ");
|
||||
sprintf(szTableName,"t_data_%s",param.MeasurementID.c_str());
|
||||
}else{
|
||||
sprintf(selectCon," * ");
|
||||
@ -903,14 +904,14 @@ std::string JsonData::JsonCmd_Cgi_62(Param_62 ¶m){
|
||||
|
||||
if(param.straxis == ""){
|
||||
if (param.mMode == 1){
|
||||
sprintf(whereCon, " channelID like '%%%s%%' and timeStamp < '%s' and timeStamp > '%s' ", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
|
||||
sprintf(whereCon, " channelID like '%s-X' and timeStamp < '%s' and timeStamp > '%s' ", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
|
||||
}else{
|
||||
sprintf(whereCon, " data_nodeno like '%%%s%%' and timeStamp < '%s' and timeStamp > '%s' ", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (param.mMode == 1){
|
||||
sprintf(whereCon, " channelID = '%s-%s' and timeStamp < '%s' and timeStamp > '%s' ", param.MeasurementID.c_str(),param.straxis.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
|
||||
sprintf(whereCon, " channelID = '%s-X' and timeStamp < '%s' and timeStamp > '%s' ", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
|
||||
}else{
|
||||
sprintf(whereCon, " data_nodeno = '%s-%s' and timeStamp < '%s' and timeStamp > '%s' ", param.MeasurementID.c_str(),param.straxis.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
|
||||
}
|
||||
@ -946,15 +947,15 @@ std::string JsonData::JsonCmd_Cgi_62(Param_62 ¶m){
|
||||
if(param.straxis == "")
|
||||
{
|
||||
if (param.mMode == 1){
|
||||
sprintf(whereCon, " channelID like '%%%s%%' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
|
||||
sprintf(whereCon, " channelID like '%s-X' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
|
||||
}else{
|
||||
sprintf(whereCon, " data_nodeno like '%%%s%%' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
|
||||
}
|
||||
}else{
|
||||
if (param.mMode == 1){
|
||||
sprintf(whereCon, " channelID = '%s-%s' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(),param.straxis.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
|
||||
sprintf(whereCon, " channelID = '%s-X' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
|
||||
}else{
|
||||
sprintf(whereCon, "data_nodeno = %s-%s' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(),param.straxis.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
|
||||
sprintf(whereCon, "data_nodeno = '%s-%s' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(),param.straxis.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
|
||||
}
|
||||
}
|
||||
array_t vecRes;
|
||||
|
||||
@ -14,7 +14,7 @@ int GlobalConfig::LinkStatus_G = 0;
|
||||
int GlobalConfig::LinkCount = 0;
|
||||
int GlobalConfig::net0Status = 1;
|
||||
|
||||
std::string GlobalConfig::Version = "5.5";
|
||||
std::string GlobalConfig::Version = "5.6";
|
||||
std::string GlobalConfig::MacAddr_G = "";
|
||||
std::string GlobalConfig::MacAddr_G2 = "";
|
||||
std::string GlobalConfig::IpAddr_G = "";
|
||||
|
||||
@ -210,7 +210,7 @@ long SensorScheduler::CalcNextTimestamp(int id, uint16_t short_addr) {
|
||||
if (wave_slice_iter != sensor_id_nth_slice_.end()) {
|
||||
if (nth_wave_slice > wave_slice_iter->second) {
|
||||
if (success_set_.count(short_addr) == 0 && !RetransferWave(short_addr)) {
|
||||
zlog_warn(zct, "[Nxt] [%d] add it to patch set", short_addr);
|
||||
zlog_warn(zct, "[Nxt] [%d:%x] add it to patch set", id, short_addr);
|
||||
patch_set_.insert(short_addr);
|
||||
}
|
||||
}
|
||||
@ -250,7 +250,7 @@ long SensorScheduler::CalcNextTimestamp(int id, uint16_t short_addr) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (MissedWave(short_addr)) {
|
||||
} else if (!MissedWave(short_addr)) {
|
||||
for (int i = 0; i < wave_slice_num_per_eigen_interval_; ++i) {
|
||||
if (slice_sensor_id_[i+forward_wave_slice_num] == 0) {
|
||||
// 判断此空闲位置是否被占用
|
||||
@ -307,6 +307,7 @@ int SensorScheduler::GetNextDuration(int short_addr) {
|
||||
SensorScheduler::SensorScheduler() {
|
||||
support_modification_ = true;
|
||||
std::ifstream schedule_file(SCHEDULE_CONFIG);
|
||||
bool configed = false;
|
||||
if (schedule_file.good()) {
|
||||
zlog_info(zbt, "exist configuration file");
|
||||
Json::Reader reader;
|
||||
@ -314,13 +315,14 @@ SensorScheduler::SensorScheduler() {
|
||||
if (!reader.parse(schedule_file, root, false)) {
|
||||
zlog_error(zbt, "invalid format, fail to parse %s", SCHEDULE_CONFIG);
|
||||
schedule_file.close();
|
||||
return;
|
||||
goto init_config;
|
||||
}
|
||||
schedule_file.close();
|
||||
if (!root.isObject()) {
|
||||
zlog_error(zbt, "invalid format, not an object: %s", SCHEDULE_CONFIG);
|
||||
return;
|
||||
goto init_config;
|
||||
}
|
||||
configed = true;
|
||||
start_timestamp_ = std::stol(root["schedule_start_timestamp"].asString());
|
||||
start_ts_str_ = root["schedule_start_time"].asString();
|
||||
long current_ts = GetLocalTs();
|
||||
@ -362,28 +364,12 @@ SensorScheduler::SensorScheduler() {
|
||||
int rest_duration = eigen_value_send_interval_ - eigen_value_slice_total_seconds_;
|
||||
wave_slice_num_per_eigen_interval_ = rest_duration / wave_form_send_duration_;
|
||||
seconds_per_wave_slice_ = rest_duration / wave_slice_num_per_eigen_interval_;
|
||||
} else {
|
||||
zlog_info(zbt, "use default configuration");
|
||||
int eigen_value_send_interval = 300;
|
||||
int wave_form_send_interval = 7200;
|
||||
int eigen_value_send_duration = 6;
|
||||
int wave_form_send_duration = 50;
|
||||
int max_sensor_num = 32;
|
||||
|
||||
// int eigen_value_send_interval = 120;
|
||||
// int wave_form_send_interval = 240;
|
||||
// int eigen_value_send_duration = 6;
|
||||
// int wave_form_send_duration = 40;
|
||||
// int max_sensor_num = 4;
|
||||
std::string error_msg;
|
||||
Config(eigen_value_send_interval,
|
||||
wave_form_send_interval,
|
||||
eigen_value_send_duration,
|
||||
wave_form_send_duration,
|
||||
max_sensor_num,
|
||||
error_msg);
|
||||
}
|
||||
|
||||
init_config:
|
||||
if (!configed) {
|
||||
UseDefaultConfig();
|
||||
}
|
||||
short_addr_map_.clear();
|
||||
ShortAddrCfg::ReadCfg(short_addr_map_);
|
||||
|
||||
@ -811,3 +797,25 @@ void SensorScheduler::CleanIdleOccupiedSet(long ts) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SensorScheduler::UseDefaultConfig() {
|
||||
zlog_info(zbt, "use default configuration");
|
||||
int eigen_value_send_interval = 300;
|
||||
int wave_form_send_interval = 7200;
|
||||
int eigen_value_send_duration = 6;
|
||||
int wave_form_send_duration = 50;
|
||||
int max_sensor_num = 32;
|
||||
|
||||
// int eigen_value_send_interval = 120;
|
||||
// int wave_form_send_interval = 240;
|
||||
// int eigen_value_send_duration = 6;
|
||||
// int wave_form_send_duration = 40;
|
||||
// int max_sensor_num = 4;
|
||||
std::string error_msg;
|
||||
Config(eigen_value_send_interval,
|
||||
wave_form_send_interval,
|
||||
eigen_value_send_duration,
|
||||
wave_form_send_duration,
|
||||
max_sensor_num,
|
||||
error_msg);
|
||||
}
|
||||
|
||||
@ -104,6 +104,7 @@ public:
|
||||
private:
|
||||
void UpdateUpgradeInfo(int id);
|
||||
void CleanIdleOccupiedSet(long ts);
|
||||
void UseDefaultConfig();
|
||||
|
||||
// user config
|
||||
int eigen_value_send_interval_;
|
||||
|
||||
@ -1115,11 +1115,11 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
|
||||
strChannelID = strMeasurementID + "-Z";
|
||||
wave_error_z = true;
|
||||
}
|
||||
if(scheduler::instance().WaveError(wave_shortAddr) < 0){
|
||||
|
||||
zlog_error(zct, "WaveError error ShortAddr :%s", strShortAddr.c_str());
|
||||
sprintf(insertSql, "'%s','%s','%s',%d,'%d','%s' ", strChannelID.c_str(),strShortAddr.c_str(),localtimestamp,bytesRead,0,error_msg.c_str());
|
||||
sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql);
|
||||
}
|
||||
|
||||
|
||||
JsonData jd;
|
||||
jd.JsonCmd_32(strMeasurementID,1,1,strChannelID,error_msg);
|
||||
@ -1157,11 +1157,11 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
|
||||
strChannelID = strMeasurementID + "-Z";
|
||||
wave_error_z = true;
|
||||
}
|
||||
if(scheduler::instance().WaveError(wave_shortAddr) < 0){
|
||||
|
||||
zlog_error(zct, "WaveError error ShortAddr :%s", strShortAddr.c_str());
|
||||
sprintf(insertSql, "'%s','%s','%s',%d,'%d','%s' ", strChannelID.c_str(),strShortAddr.c_str(),localtimestamp,bytesRead,0,error_msg.c_str());
|
||||
sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql);
|
||||
}
|
||||
|
||||
JsonData jd;
|
||||
jd.JsonCmd_32(strMeasurementID,1,1,strChannelID,error_msg);
|
||||
continue;
|
||||
|
||||
@ -776,6 +776,7 @@ void Uart::DealWave() {
|
||||
wave_trans_ = false;
|
||||
return;
|
||||
}
|
||||
strShortAddr = res[30];
|
||||
strLongAddr = res[0];
|
||||
strMeasurementID = res[44];
|
||||
if (0 == strLongAddr.length()) {
|
||||
@ -783,34 +784,7 @@ void Uart::DealWave() {
|
||||
wave_trans_ = false;
|
||||
return;
|
||||
}
|
||||
if (m_waveCountX > 0 || m_waveCountY > 0 || m_waveCountZ > 0){
|
||||
char localtimestamp[32] = {0};
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
char insertSql[100] = {0x00};
|
||||
char whereCon[50] = {0x00};
|
||||
sprintf(whereCon, "MeasurementID='%s'",strMeasurementID.c_str());
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
if (m_waveCountX > 0)
|
||||
{
|
||||
sprintf(insertSql, "'%s-X','%02x%02x','%s',0,'1','%s' ", strMeasurementID.c_str(),(wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,localtimestamp,"");
|
||||
sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql);
|
||||
}
|
||||
if (m_waveCountY > 0)
|
||||
{
|
||||
sprintf(insertSql, "'%s-Y','%02x%02x','%s',0,'1','%s' ", strMeasurementID.c_str(),(wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,localtimestamp,"");
|
||||
sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql);
|
||||
}
|
||||
if (m_waveCountZ > 0)
|
||||
{
|
||||
sprintf(insertSql, "'%s-Z','%02x%02x','%s',0,'1','%s' ", strMeasurementID.c_str(),(wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,localtimestamp,"");
|
||||
sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql);
|
||||
}
|
||||
scheduler::instance().WaveSuccess(wave_shortAddr);
|
||||
}else{
|
||||
if(scheduler::instance().WaveError(wave_shortAddr) < 0){
|
||||
zlog_error(zct, "wave size is 0,shortAddr %02x%02x", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string ran = "";
|
||||
int n = 0;
|
||||
@ -854,7 +828,50 @@ void Uart::DealWave() {
|
||||
g_VecWaveDataZ.clear();
|
||||
VecWaveDataZ.clear();
|
||||
}
|
||||
char localtimestamp[32] = {0};
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
char insertSql[100] = {0x00};
|
||||
char whereCon[50] = {0x00};
|
||||
sprintf(whereCon, "MeasurementID='%s'",strMeasurementID.c_str());
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
if (vecDataX.size() > 0)
|
||||
{
|
||||
sprintf(insertSql, "'%s-X','%02x%02x','%s',0,'1','%s' ", strMeasurementID.c_str(),(wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,localtimestamp,"");
|
||||
sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql);
|
||||
}
|
||||
if (vecDataY.size() > 0)
|
||||
{
|
||||
sprintf(insertSql, "'%s-Y','%02x%02x','%s',0,'1','%s' ", strMeasurementID.c_str(),(wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,localtimestamp,"");
|
||||
sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql);
|
||||
}
|
||||
if (vecDataZ.size() > 0)
|
||||
{
|
||||
sprintf(insertSql, "'%s-Z','%02x%02x','%s',0,'1','%s' ", strMeasurementID.c_str(),(wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,localtimestamp,"");
|
||||
sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql);
|
||||
}
|
||||
zlog_warn(zct,"waveCountX = %d, waveCountY = %d, waveCountZ = %d", vecDataX.size() , vecDataY.size(), vecDataZ.size());
|
||||
zlog_warn(zct,"CountX = %d, CountY = %d, CountZ = %d", g_mapCompress[strShortAddr].CountX , g_mapCompress[strShortAddr].CountY, g_mapCompress[strShortAddr].CountZ);
|
||||
if ((vecDataX.size() <= 0 && g_mapCompress[strShortAddr].CountX > 0) ||
|
||||
(vecDataY.size() <= 0 && g_mapCompress[strShortAddr].CountY > 0) ||
|
||||
(vecDataZ.size() <= 0 && g_mapCompress[strShortAddr].CountZ > 0))
|
||||
{
|
||||
scheduler::instance().WaveError(wave_shortAddr);
|
||||
}else if ((vecDataX.size() > 0 && g_mapCompress[strShortAddr].CountX > 0) ||
|
||||
(vecDataY.size() > 0 && g_mapCompress[strShortAddr].CountY > 0) ||
|
||||
(vecDataZ.size() > 0 && g_mapCompress[strShortAddr].CountZ > 0))
|
||||
{
|
||||
scheduler::instance().WaveSuccess(wave_shortAddr);
|
||||
}
|
||||
|
||||
g_mapCompress[strShortAddr].CountX = 0;
|
||||
g_mapCompress[strShortAddr].CountY = 0;
|
||||
g_mapCompress[strShortAddr].CountZ = 0;
|
||||
g_mapCompress[strShortAddr].compressChannelX = 0;
|
||||
g_mapCompress[strShortAddr].compressChannelY = 0;
|
||||
g_mapCompress[strShortAddr].compressChannelZ = 0;
|
||||
std::vector<float>().swap(vecDataX);
|
||||
std::vector<float>().swap(vecDataY);
|
||||
std::vector<float>().swap(vecDataZ);
|
||||
wave_trans_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user