/**
* Updates the CN0 versus Time plot data from a {@link GnssMeasurement}
*/
protected void updateCnoTab(GnssMeasurementsEvent event) {
long timeInSeconds =
TimeUnit.NANOSECONDS.toSeconds(event.getClock().getTimeNanos());
if (mInitialTimeSeconds < 0) {
mInitialTimeSeconds = timeInSeconds;
}
// Building the texts message in analysis text view
List<GnssMeasurement> measurements =
sortByCarrierToNoiseRatio(new ArrayList<>(event.getMeasurements()));
SpannableStringBuilder builder = new SpannableStringBuilder();
double currentAverage = 0;
if (measurements.size() >= NUMBER_OF_STRONGEST_SATELLITES) {
mAverageCn0 =
(mAverageCn0 * mMeasurementCount
+ (measurements.get(0).getCn0DbHz()
+ measurements.get(1).getCn0DbHz()
+ measurements.get(2).getCn0DbHz()
+ measurements.get(3).getCn0DbHz())
/ NUMBER_OF_STRONGEST_SATELLITES)
/ (++mMeasurementCount);
currentAverage =
(measurements.get(0).getCn0DbHz()
+ measurements.get(1).getCn0DbHz()
+ measurements.get(2).getCn0DbHz()
+ measurements.get(3).getCn0DbHz())
/ NUMBER_OF_STRONGEST_SATELLITES;
}
builder.append(getString(R.string.history_average_hint,
sDataFormat.format(mAverageCn0) + "\n"));
builder.append(getString(R.string.current_average_hint,
sDataFormat.format(currentAverage) + "\n"));
for (int i = 0; i < NUMBER_OF_STRONGEST_SATELLITES && i < measurements.size(); i++) {
int start = builder.length();
builder.append(
mDataSetManager.getConstellationPrefix(measurements.get(i).getConstellationType())
+ measurements.get(i).getSvid()
+ ": "
+ sDataFormat.format(measurements.get(i).getCn0DbHz())
+ "\n");
int end = builder.length();
builder.setSpan(
new ForegroundColorSpan(
mColorMap.getColor(
measurements.get(i).getSvid(), measurements.get(i).getConstellationType())),
start,
end,
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
}
builder.append(getString(R.string.satellite_number_sum_hint, measurements.size()));
mAnalysisView.setText(builder);
// Adding incoming data into Dataset
mLastTimeReceivedSeconds = timeInSeconds - mInitialTimeSeconds;
for (GnssMeasurement measurement : measurements) {
int constellationType = measurement.getConstellationType();
int svID = measurement.getSvid();
if (constellationType != GnssStatus.CONSTELLATION_UNKNOWN) {
mDataSetManager.addValue(
CN0_TAB,
constellationType,
svID,
mLastTimeReceivedSeconds,
measurement.getCn0DbHz());
}
}
mDataSetManager.fillInDiscontinuity(CN0_TAB, mLastTimeReceivedSeconds);
// Checks if the plot has reached the end of frame and resize
if (mLastTimeReceivedSeconds > mCurrentRenderer.getXAxisMax()) {
mCurrentRenderer.setXAxisMax(mLastTimeReceivedSeconds);
mCurrentRenderer.setXAxisMin(mLastTimeReceivedSeconds - TIME_INTERVAL_SECONDS);
}
mChartView.invalidate();
}
PlotFragment.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:gps-measurement-tools
作者:
评论列表
文章目录