diff --git a/ChannelItem.h b/ChannelItem.h index b6cbad5..592dc97 100644 --- a/ChannelItem.h +++ b/ChannelItem.h @@ -8,6 +8,7 @@ extern QVector> phaseVector; extern QVector> channelAllan; +extern QVector> channelAllenSigma; namespace Ui { class ChannelItem; diff --git a/ChannelItem.h b/ChannelItem.h index b6cbad5..592dc97 100644 --- a/ChannelItem.h +++ b/ChannelItem.h @@ -8,6 +8,7 @@ extern QVector> phaseVector; extern QVector> channelAllan; +extern QVector> channelAllenSigma; namespace Ui { class ChannelItem; diff --git a/DataProcessAlgorithm.cpp b/DataProcessAlgorithm.cpp index 7d7fd39..5947a07 100644 --- a/DataProcessAlgorithm.cpp +++ b/DataProcessAlgorithm.cpp @@ -36,26 +36,31 @@ { int i = 0; double tau0 = 1; //tau0是基本采样间隔,由计数器或比相仪的最小采样间隔决定,最小为1s - double sum = 0.0; double allan[2] = {0.0}; + double *y = new double[3]; double tau_2 = pow(d * tau0, 2); //pow是计算x的y次幂 int logd = log10(d); + double sum = channelAllenSigma[index][logd]; + for (int j = 3; j > 0; j--) { i = aN - 2*d - j; double v2 = phaseVector[index][i+2*d].at(1).toDouble(); double v1 = phaseVector[index][i+d].at(1).toDouble(); double v0 = phaseVector[index][i].at(1).toDouble(); - double sigma = pow(v2 - 2 * v1 + v0, 2); + y[3 - j] = pow(v2 - 2 * v1 + v0, 2); - sum = channelAllenSigma[index][logd] + sigma; - channelAllenSigma[index][logd] = sum; + sum += y[3 - j]; } + channelAllenSigma[index][logd] += y[0]; + allan[0] = sum/(2*tau_2*(aN-2*d)); //delta的平方 allan[1] = sqrt(sum/(2*tau_2*(aN-2*d))); //delta + delete[] y; + return allan[1]; } diff --git a/ChannelItem.h b/ChannelItem.h index b6cbad5..592dc97 100644 --- a/ChannelItem.h +++ b/ChannelItem.h @@ -8,6 +8,7 @@ extern QVector> phaseVector; extern QVector> channelAllan; +extern QVector> channelAllenSigma; namespace Ui { class ChannelItem; diff --git a/DataProcessAlgorithm.cpp b/DataProcessAlgorithm.cpp index 7d7fd39..5947a07 100644 --- a/DataProcessAlgorithm.cpp +++ b/DataProcessAlgorithm.cpp @@ -36,26 +36,31 @@ { int i = 0; double tau0 = 1; //tau0是基本采样间隔,由计数器或比相仪的最小采样间隔决定,最小为1s - double sum = 0.0; double allan[2] = {0.0}; + double *y = new double[3]; double tau_2 = pow(d * tau0, 2); //pow是计算x的y次幂 int logd = log10(d); + double sum = channelAllenSigma[index][logd]; + for (int j = 3; j > 0; j--) { i = aN - 2*d - j; double v2 = phaseVector[index][i+2*d].at(1).toDouble(); double v1 = phaseVector[index][i+d].at(1).toDouble(); double v0 = phaseVector[index][i].at(1).toDouble(); - double sigma = pow(v2 - 2 * v1 + v0, 2); + y[3 - j] = pow(v2 - 2 * v1 + v0, 2); - sum = channelAllenSigma[index][logd] + sigma; - channelAllenSigma[index][logd] = sum; + sum += y[3 - j]; } + channelAllenSigma[index][logd] += y[0]; + allan[0] = sum/(2*tau_2*(aN-2*d)); //delta的平方 allan[1] = sqrt(sum/(2*tau_2*(aN-2*d))); //delta + delete[] y; + return allan[1]; } diff --git a/PhaseWindow.cpp b/PhaseWindow.cpp index 59201e9..99a2108 100644 --- a/PhaseWindow.cpp +++ b/PhaseWindow.cpp @@ -258,6 +258,8 @@ for (int i = 0; i < phaseVector.size(); i++) { phaseVector[i].clear(); + channelAllan[i].clear(); +// channelAllenSigma[i].clear(); } // 发送结束指令