void OdroidReader::updateCurve(int row, int col) { if (col != 0) return; bool enable = ui->sensors->item(row,col)->checkState() == Qt::Checked; if (enable && graphs.at(row) == nullptr) { if (origcols.count() == 0) { ui->sensors->item(row,col)->setCheckState(Qt::Unchecked); return; } QColor color = origcols.takeFirst(); QCPGraph* graph = ui->globalPlot->addGraph(); DataSeries* series = data[rowMap[row]]; graph->setName(series->descriptor->name()); graph->setProperty("unit",series->descriptor->unit()); graph->setPen(color); graph->setData(series->getTimestamps(), series->getValues()); connect(series,&DataSeries::newValue,[graph,this](double time, double value) { graph->addData(time,value); ui->globalPlot->rescaleAxes(); ui->globalPlot->yAxis->scaleRange(1.2,ui->globalPlot->yAxis->range().center()); ui->globalPlot->replot(); }); graphs[row] = graph; ui->sensors->item(row,col)->setBackgroundColor(color); } else if (!enable && graphs.at(row) != nullptr){ disconnect(data.at(rowMap[row]),SIGNAL(newValue(double,double)),0,0); origcols.push_front(graphs.at(row)->pen().color()); ui->globalPlot->removeGraph(graphs.at(row)); graphs[row] = nullptr; ui->sensors->item(row,col)->setBackgroundColor(Qt::white); }
void MainWindow::onPacketParsed(Packet packet) { _packetsReceivedCount++; if(!packet.isCrcValid()) { _crcErrorCount++; } QString sourceId = ByteArrayUtils::toString(packet.sourceId()).replace(" 0x", "").replace("0x", ""); if(!_rssValues.contains(sourceId)) { _rssValues.insert(sourceId, QVector<double>()); _timestampValues.insert(sourceId, QVector<double>()); QCPGraph* deviceGraph = ui->plotWidget->addGraph(); deviceGraph->setScatterStyle(QCP::ssDisc); deviceGraph->setScatterSize(5); deviceGraph->setName(sourceId); ensureDistinctColors(); } _rssValues[sourceId].append(packet.rss()); _timestampValues[sourceId].append(packet.timestamp().toTime_t()); updatePlot(); updateStatus(); }
void ScatterWidget::addBaseLine(const PointD &p1, const PointD &p2, string legend) { QCPGraph *graph = NULL; int nG = ui->scatter->graphCount(); for(int j=0; j<nG; j++) { if(ui->scatter->graph(j)->name() == QString::fromStdString(legend)) { graph = ui->scatter->graph(j); break; } } if(!graph) { graph = ui->scatter->addGraph(); // ----------------------- Scatter Configuration --------------------------- graph->setName(QString::fromStdString(legend)); QColor color_ = colorManager.getNewDifferentColor(); graph->setPen(QPen(color_)); } QVector<double> keys, vals; keys << p1.x << p2.x; vals << p1.y << p2.y; graph->setData(keys, vals); }
void ScatterWidget::setData(const std::vector<PointD> &data, string legend) { QCPGraph *graph = NULL; int nG = ui->scatter->graphCount(); for(int i=0; i<nG; i++) { if(ui->scatter->graph(i)->name() == QString::fromStdString(legend)) { graph = ui->scatter->graph(i); break; } } if(!graph) { graph = ui->scatter->addGraph(); // ----------------------- Scatter Configuration --------------------------- graph->setName(QString::fromStdString(legend)); QColor color_ = colorManager.getNewDifferentColor(); graph->setPen(QPen(color_)); graph->setLineStyle(QCPGraph::lsNone); graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssPlusCircle, 4)); ui->scatter->legend->setVisible(true); } double min_x = INFINITY, min_y = INFINITY; double max_x = -INFINITY, max_y = -INFINITY; QVector<QCPGraphData> q_data(data.size()); for(unsigned int i=0; i<data.size(); i++) { q_data[i] = QCPGraphData(data[i].x, data[i].y); if(ui->recButton->isChecked()) { vector<double> vec2_double(2); vec2_double[0] = data[i].x; vec2_double[1] = data[i].y; vector<string> vec2_string(2); vec2_string[0] = legend + "_x"; vec2_string[1] = legend + "_y"; logger.addLogCsv(graph->dataCount(), vec2_string, vec2_double); } max_x = qMax(data[i].x, ui->scatter->xAxis->range().upper); min_x = qMin(data[i].x, ui->scatter->xAxis->range().lower); max_y = qMax(data[i].y, ui->scatter->yAxis->range().upper); min_y = qMin(data[i].y, ui->scatter->yAxis->range().lower); } graph->data()->set(q_data); ui->scatter->xAxis->setRange(min_x, max_x); ui->scatter->yAxis->setRange(min_y, max_y); ui->scatter->replot(); }
void ScatterWidget::addPacket(const ScatterPacket &packet) { QCPGraph *graph = NULL; int nG = ui->scatter->graphCount(); for(int i=0; i<nG; i++) { if(ui->scatter->graph(i)->name() == QString::fromStdString(packet.legend)) { graph = ui->scatter->graph(i); break; } } if(!graph) { graph = ui->scatter->addGraph(); // ----------------------- Scatter Configuration --------------------------- graph->setName(QString::fromStdString(packet.legend)); QColor color_ = colorManager.getNewDifferentColor(); graph->setPen(QPen(color_)); graph->setLineStyle(QCPGraph::lsNone); graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssPlusCircle, 4)); ui->scatter->legend->setVisible(true); } graph->addData(packet.point.x, packet.point.y); //if(packet.point.x > ui->scatter->xAxis->max) double max_x = qMax(packet.point.x, ui->scatter->xAxis->range().upper); double min_x = qMin(packet.point.x, ui->scatter->xAxis->range().lower); double max_y = qMax(packet.point.y, ui->scatter->yAxis->range().upper); double min_y = qMin(packet.point.y, ui->scatter->yAxis->range().lower); ui->scatter->xAxis->setRange(min_x, max_x); ui->scatter->yAxis->setRange(min_y, max_y); if(realTimePlot) ui->scatter->replot(); else ui->scatter->replot(QCustomPlot::rpQueuedReplot); if(ui->recButton->isChecked()) { vector<double> vec2_double(2); vec2_double[0] = packet.point.x; vec2_double[1] = packet.point.y; vector<string> vec2_string(2); vec2_string[0] = packet.legend + "_x"; vec2_string[1] = packet.legend + "_y"; logger.addLogCsv(graph->dataCount(), vec2_string, vec2_double); } }
QCPGraph* SensorDashboard::createGraph(const QString& name, const QColor& color) { QPen pen; pen.setBrush(color); QCPGraph *graph = mPlot->addGraph(); graph->setName(name); graph->setLineStyle(QCPGraph::lsLine); graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssNone)); graph->setPen(pen); return graph; }
void DataExplorer::updateDetails() { //qDebug() << "SELECT!"; ui->runPlot->clearPlottables(); QVector<QString> labels; QVector<double> ticks; int colid = 0; switch (ui->detailType->currentIndex()) { case 0: ui->runPlot->xAxis->setAutoTicks(true); ui->runPlot->xAxis->setAutoTickLabels(true); for (QCPAbstractPlottable *p : ui->selectEnvironment->selectedPlottables()) { int unitid = p->property("UID").toInt(); int envid = p->property("EID").toInt(); DataSeries v = exp->runs.keys().at(envid)->run(unitid,ui->runNo->value(),exp); QCPGraph *g = ui->runPlot->addGraph(); g->setName(v.descriptor->name()+" @ "+exp->runs.keys().at(envid)->label); g->setProperty("Unit",v.descriptor->unit()); g->setPen(origcols[colid++%origcols.size()]); g->setData(v.getTimestamps(),v.getValues()); } break; case 1: for (QCPAbstractPlottable *p : ui->selectEnvironment->selectedPlottables()) { int unitid = p->property("UID").toInt(); int envid = p->property("EID").toInt(); StatisticalSet vals = exp->runs.keys().at(envid)->integral(unitid,exp); QCPStatisticalBox* b = new QCPStatisticalBox(ui->runPlot->xAxis,ui->runPlot->yAxis); b->setData(colid,vals.min(),vals.quantile(0.25),vals.median(),vals.quantile(0.75),vals.max()); b->setProperty("StdDev",vals.getStdDev()); b->setProperty("avg",vals.avg()); b->setProperty("avgTime",vals.avgTime()); qWarning() << exp->data.at(unitid)->descriptor->name() << exp->runs.keys().at(envid)->label << vals.avg() << vals.avgTime() << vals.getStdDev(); ui->runPlot->addPlottable(b); labels.append(QString("%1 @ %2").arg(exp->data.at(unitid)->descriptor->name(),exp->runs.keys().at(envid)->label)); ticks.append(colid++); ui->runPlot->xAxis->setAutoTicks(false); ui->runPlot->xAxis->setAutoTickLabels(false); ui->runPlot->xAxis->setSubTickCount(0); ui->runPlot->xAxis->setTickLength(0, 4); ui->runPlot->xAxis->setTickLabelRotation(90); ui->runPlot->xAxis->setTickVector(ticks); ui->runPlot->xAxis->setTickVectorLabels(labels); } break; case 2: break; } ui->runPlot->rescaleAxes(); if (ui->axisFromZero->isChecked()) ui->runPlot->yAxis->setRangeLower(0); ui->runPlot->replot(); }
void SCTPGraphDialog::drawTSNGraph() { GList *listTSN = NULL,*tlist; tsn_t *tsn; guint8 type; guint32 tsnumber=0; if (direction == 1) { listTSN = g_list_last(selected_assoc->tsn1); } else { listTSN = g_list_last(selected_assoc->tsn2); } while (listTSN) { tsn = (tsn_t*) (listTSN->data); tlist = g_list_first(tsn->tsns); while (tlist) { type = ((struct chunk_header *)tlist->data)->type; if (type == SCTP_DATA_CHUNK_ID || type == SCTP_I_DATA_CHUNK_ID || type == SCTP_FORWARD_TSN_CHUNK_ID) { tsnumber = g_ntohl(((struct data_chunk_header *)tlist->data)->tsn); yt.append(tsnumber); xt.append(tsn->secs + tsn->usecs/1000000.0); ft.append(tsn->frame_number); } tlist = g_list_next(tlist); } listTSN = g_list_previous(listTSN); } QCPScatterStyle myScatter; myScatter.setShape(QCPScatterStyle::ssCircle); myScatter.setSize(3); int graphcount = ui->sctpPlot->graphCount(); // create graph and assign data to it: // Add TSN graph if (xt.size() > 0) { QCPGraph *gr = ui->sctpPlot->addGraph(); gr->setName(QString("TSN")); myScatter.setPen(QPen(Qt::black)); myScatter.setBrush(Qt::black); ui->sctpPlot->graph(graphcount)->setScatterStyle(myScatter); ui->sctpPlot->graph(graphcount)->setLineStyle(QCPGraph::lsNone); ui->sctpPlot->graph(graphcount)->setData(xt, yt); typeStrings.insert(graphcount, QString(tr("TSN"))); } }
void BodeWidget::addBodePlot(BodeData *data, const QString& name){ QCPGraph* dbGraph = dbPlot->addGraph(); QCPGraph* paGraph = paPlot->addGraph(); dbGraph->setData(data->at(0), data->at(1)); paGraph->setData(data->at(0), data->at(2)); dbGraph->setName(name); paGraph->setName(name); dbGraph->setPen(QPen(QColor::fromHsv(hue, 255, 255, 192))); paGraph->setPen(QPen(QColor::fromHsv(hue, 255, 255, 192))); paGraph->setVisible(false); dbGraph->rescaleAxes(); paGraph->rescaleAxes(); hue += 17; hue %= 360; this->paGraphMap[dbGraph] = paGraph; }
void RealTimePlot::updateChannel(int index) { Channel *chan = channels[index]; // Get parameters from channel QCPGraph *line = chan->getPtrGraphLine(); QCPGraph *marker = chan->getPtrGraphMarker(); QColor color = chan->getGraphColor(); // Set parameters of line graph line->setPen(QPen(color)); line->setLineStyle(QCPGraph::lsLine); line->setVisible(chan->getVisible(LINE)); // Set parameters of marker graph marker->setName(chan->getName()); marker->setPen(QPen(color)); marker->setLineStyle(QCPGraph::lsNone); marker->setScatterStyle(chan->getMarkerStyle()); marker->setVisible(chan->getVisible(MARKER)); }
void SCTPGraphArwndDialog::drawArwndGraph() { GList *listSACK = NULL, *tlist; struct sack_chunk_header *sack_header; struct nr_sack_chunk_header *nr_sack_header; tsn_t *tsn; guint8 type; guint32 arwnd=0; if (direction == 1) { listSACK = g_list_last(selected_assoc->sack1); startArwnd = selected_assoc->arwnd1; } else { listSACK = g_list_last(selected_assoc->sack2); startArwnd = selected_assoc->arwnd2; } while (listSACK) { tsn = (tsn_t*) (listSACK->data); tlist = g_list_first(tsn->tsns); while (tlist) { type = ((struct chunk_header *)tlist->data)->type; if (type == SCTP_SACK_CHUNK_ID) { sack_header =(struct sack_chunk_header *)tlist->data; arwnd = g_ntohl(sack_header->a_rwnd); } else if (type == SCTP_NR_SACK_CHUNK_ID) { nr_sack_header =(struct nr_sack_chunk_header *)tlist->data; arwnd = g_ntohl(nr_sack_header->a_rwnd); } ya.append(arwnd); xa.append(tsn->secs + tsn->usecs/1000000.0); fa.append(tsn->frame_number); tlist = g_list_next(tlist); } listSACK = g_list_previous(listSACK); } QCPScatterStyle myScatter; myScatter.setShape(QCPScatterStyle::ssCircle); myScatter.setSize(3); // create graph and assign data to it: // Add Arwnd graph if (xa.size() > 0) { QCPGraph *gr = ui->sctpPlot->addGraph(ui->sctpPlot->xAxis, ui->sctpPlot->yAxis); gr->setName(QString(tr("Arwnd"))); myScatter.setPen(QPen(Qt::red)); myScatter.setBrush(Qt::red); ui->sctpPlot->graph(0)->setScatterStyle(myScatter); ui->sctpPlot->graph(0)->setLineStyle(QCPGraph::lsNone); ui->sctpPlot->graph(0)->setData(xa, ya); } ui->sctpPlot->xAxis->setLabel(tr("time [secs]")); ui->sctpPlot->yAxis->setLabel(tr("Advertised Receiver Window [Bytes]")); // set axes ranges, so we see all data: QCPRange myXArwndRange(0, (selected_assoc->max_secs+1)); // QCPRange myXArwndRange(0, 1); QCPRange myYArwndRange(0, startArwnd); ui->sctpPlot->xAxis->setRange(myXArwndRange); ui->sctpPlot->yAxis->setRange(myYArwndRange); }
void Dialog::mkSensorModel() { QCPGraph * gr; QPen pn; double simTime = 60.0; double simStepTime = 0.1; double tempStart = 25.0; double tempCurrent = tempStart; double tempSet = 35.0; double tempDeltaPrev = 0.0; int normalFixDeep = 5; int steps = simTime / simStepTime; QVector<double> xTime(steps), yTemp(steps), yTempSet(steps); QVector<double> normalValues(normalFixDeep); normalValues.fill(0); QVector<double> tempLabels; for (int x=10; x<=50; x+=5) tempLabels.push_back(x); QVector<double> timeLabels; for (int x=0; x<=simTime; x+=5) timeLabels.push_back(x); for (int x=0; x<steps; x++) { // Calc new temp value double tempApply = 0.0; // No change double tempDelta = std::abs(tempCurrent - tempSet); double stepDir = (tempCurrent < tempSet) ? 1.0 : -1.0; if (0.1 < tempDelta) { if (tempDelta > 10) { tempApply = 0.19 * 1.0; } else { tempApply = 0.2 * (1.0 * (tempDelta/10.0) ); } // if (tempApply < 0.01) tempApply = 0.01; // qDebug() << tempApply; tempApply = tempApply * stepDir; // Calc normalzied value double lastSum = 0; for (int x=0; x<normalFixDeep; x++) lastSum += normalValues[x]; tempApply = (lastSum + tempApply) / ((double)normalFixDeep + 1.0); tempDeltaPrev = tempApply; tempCurrent = tempCurrent + tempApply; qDebug() << tempCurrent; } normalValues.push_back(tempApply); normalValues.pop_front(); xTime[x] = (double)x * simStepTime; if (10.0 == xTime[x]) tempSet = 40.0; if (40.0 == xTime[x]) tempSet = 30.0; yTempSet[x] = tempSet; yTemp[x] = tempCurrent; } gr = ui->plot->addGraph(); gr->setData(xTime, yTemp); pn.setColor(Qt::red); pn.setWidth(3); gr->setPen(pn); gr->setName("Реальное значение"); gr = ui->plot->addGraph(); gr->setData(xTime, yTempSet); pn.setColor(0x008080); pn.setWidth(1); pn.setStyle(Qt::DashLine); gr->setPen(pn); gr->setName("Конечное значение"); ui->plot->xAxis->setLabel("Время, сек"); ui->plot->xAxis->setRange(0, simTime); ui->plot->xAxis->setAutoTicks(false); ui->plot->xAxis->setTickVector(timeLabels); ui->plot->yAxis->setLabel("Температура, °C"); ui->plot->yAxis->setRange(20, 50); ui->plot->yAxis->setAutoTicks(false); ui->plot->yAxis->setTickVector(tempLabels); ui->plot->legend->setVisible(true); ui->plot->replot(); ui->plot->savePdf("graph-boiler.pdf", false, 800, 400); }
void Dialog::mkGraph() { QCPGraph * gr; QPen pn; QVector<double> timeLabels, tempLabels, drosselLabels; for (int x=0; x<mdl.simTime; x+=10) timeLabels.push_back(x); for (int x=0; x<=80; x+=5) tempLabels.push_back(x); for (int x=0; x<=120; x+=10) drosselLabels.push_back(x); gr = ui->plot->addGraph(); gr->setData(mdl.xTime, mdl.yTempOutput); pn.setColor(Qt::red); pn.setWidth(3); gr->setPen(pn); gr->setName("Реальное значение, °C"); gr = ui->plot->addGraph(); gr->setData(mdl.xTime, mdl.yTempSet); pn.setColor(0x0000FF); pn.setWidth(2); pn.setStyle(Qt::DotLine); gr->setPen(pn); gr->setName("Конечное значение, °C"); gr = ui->plot->addGraph(); gr->setData(mdl.xTime, mdl.yTempCurrent); pn.setColor(0x808000); pn.setWidth(2); pn.setStyle(Qt::SolidLine); gr->setPen(pn); gr->setName("Желаемая температура, °C"); gr = ui->plot->addGraph(0, ui->plot->yAxis2); gr->setData(mdl.xTime, mdl.yServoPos); pn.setColor(0x006600); pn.setWidth(2); pn.setStyle(Qt::DotLine); gr->setPen(pn); gr->setName("Дроссель, %"); gr = ui->plot->addGraph(0, ui->plot->yAxis2); gr->setData(mdl.xTime, mdl.yPressure); pn.setColor(0x800080); pn.setWidth(2); pn.setStyle(Qt::SolidLine); gr->setPen(pn); gr->setName("Сила нагрева, %"); ui->plot->xAxis->setLabel("Время, сек"); ui->plot->xAxis->setRange(0, mdl.simTime); ui->plot->xAxis->setAutoTicks(false); ui->plot->xAxis->setTickVector(timeLabels); //ui->plot->xAxis->setAutoTickCount(15); ui->plot->xAxis->setSubTickCount(10); ui->plot->yAxis->setLabel("Температура, °C"); ui->plot->yAxis->setRange(20, 80); ui->plot->yAxis->setAutoTicks(false); ui->plot->yAxis->setTickVector(tempLabels); ui->plot->yAxis->setSubTickCount(5); ui->plot->yAxis2->setLabel("Параметры, %"); ui->plot->yAxis2->setRange(0, 150); ui->plot->yAxis2->setVisible(true); ui->plot->yAxis2->setAutoTicks(false); ui->plot->yAxis2->setTickVector(drosselLabels); ui->plot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignLeft|Qt::AlignTop); ui->plot->legend->setVisible(true); mdl.reset(); mdl.tempCurrent = 40; mdl.pressureCoef = 1.0; repaintGraph("ideal"); /* mdl.reset(); mdl.simTime = 180; mdl.tempCurrent = 35; mdl.pressureCoef = 1.2; mdl.paramsChanged.push_back(ParamChange(20.0, 0, 40)); repaintGraph("hotrun"); mdl.reset(); mdl.tempCurrent = 35; mdl.pressureCoef = 1.2; mdl.paramsChanged.push_back(ParamChange(20.0, 0, 30)); repaintGraph("hotrun-low"); // return; mdl.reset(); mdl.tempCurrent = 45; mdl.pressureCoef = 0.5; mdl.paramsChanged.push_back(ParamChange(20.0, 0, 40)); mdl.paramsChanged.push_back(ParamChange(30.0, 1.2, 0)); repaintGraph("plow-hi"); mdl.reset(); mdl.tempCurrent = 45; mdl.pressureCoef = 0.5; mdl.paramsChanged.push_back(ParamChange(30.0, 0.8, 0)); repaintGraph("plow"); mdl.reset(); mdl.tempOutput = 40; mdl.tempCurrent = 30; mdl.paramsChanged.push_back(ParamChange(50.0, 0.8, 0)); repaintGraph("hotstart"); mdl.reset(); mdl.simTime = 180; mdl.tempCurrent = 30; mdl.paramsChanged.push_back(ParamChange(20.0, 0.8, 0)); mdl.paramsChanged.push_back(ParamChange(40.0, 0, 40)); mdl.paramsChanged.push_back(ParamChange(50.0, 0.9, 0)); mdl.paramsChanged.push_back(ParamChange(90.0, 1.1, 0)); mdl.paramsChanged.push_back(ParamChange(130.0, 1.0, 0)); repaintGraph("longrun"); // ui->plot->savePdf("graph-test.pdf", false, 800, 600); // qDebug() << QImageWriter::supportedImageFormats(); */ }
void SCTPGraphDialog::drawSACKGraph() { GList *listSACK = NULL, *tlist; guint16 gap_start=0, gap_end=0, nr, dup_nr; struct sack_chunk_header *sack_header; struct gaps *gap; tsn_t *tsn; guint8 type; guint32 tsnumber=0; guint32 minTSN; guint32 *dup_list; int i, j; if (direction == 1) { minTSN = selected_assoc->min_tsn1; listSACK = g_list_last(selected_assoc->sack1); } else { minTSN = selected_assoc->min_tsn2; listSACK = g_list_last(selected_assoc->sack2); } while (listSACK) { tsn = (tsn_t*) (listSACK->data); tlist = g_list_first(tsn->tsns); while (tlist) { type = ((struct chunk_header *)tlist->data)->type; if (type == SCTP_SACK_CHUNK_ID) { gIsSackChunkPresent = 1; sack_header =(struct sack_chunk_header *)tlist->data; nr=g_ntohs(sack_header->nr_of_gaps); tsnumber = g_ntohl(sack_header->cum_tsn_ack); dup_nr=g_ntohs(sack_header->nr_of_dups); if (nr>0) { // Gap Reports green gap = &sack_header->gaps[0]; for(i=0;i<nr; i++) { gap_start=g_ntohs(gap->start); gap_end = g_ntohs(gap->end); for (j=gap_start; j<=gap_end; j++) { yg.append(j+tsnumber); xg.append(tsn->secs + tsn->usecs/1000000.0); fg.append(tsn->frame_number); } if (i < nr-1) gap++; } } if (tsnumber>=minTSN) { // CumTSNAck red ys.append(tsnumber); xs.append(tsn->secs + tsn->usecs/1000000.0); fs.append(tsn->frame_number); } if (dup_nr > 0) { // Duplicates cyan dup_list = &sack_header->a_rwnd + 2 + nr; for (i = 0; i < dup_nr; i++) { tsnumber = g_ntohl(dup_list[i]); if (tsnumber >= minTSN) { yd.append(tsnumber); xd.append(tsn->secs + tsn->usecs/1000000.0); fd.append(tsn->frame_number); } } } } tlist = g_list_next(tlist); } listSACK = g_list_previous(listSACK); } QCPScatterStyle myScatter; myScatter.setShape(QCPScatterStyle::ssCircle); myScatter.setSize(3); int graphcount = ui->sctpPlot->graphCount(); // create graph and assign data to it: // Add SACK graph if (xs.size() > 0) { QCPGraph *gr = ui->sctpPlot->addGraph(); gr->setName(QString("SACK")); myScatter.setPen(QPen(Qt::red)); myScatter.setBrush(Qt::red); ui->sctpPlot->graph(graphcount)->setScatterStyle(myScatter); ui->sctpPlot->graph(graphcount)->setLineStyle(QCPGraph::lsNone); ui->sctpPlot->graph(graphcount)->setData(xs, ys); typeStrings.insert(graphcount, QString(tr("CumTSNAck"))); graphcount++; } // Add Gap Acks if (xg.size() > 0) { QCPGraph *gr = ui->sctpPlot->addGraph(); gr->setName(QString("GAP")); myScatter.setPen(QPen(Qt::green)); myScatter.setBrush(Qt::green); ui->sctpPlot->graph(graphcount)->setScatterStyle(myScatter); ui->sctpPlot->graph(graphcount)->setLineStyle(QCPGraph::lsNone); ui->sctpPlot->graph(graphcount)->setData(xg, yg); typeStrings.insert(graphcount, QString(tr("Gap Ack"))); graphcount++; } // Add NR Gap Acks if (xn.size() > 0) { QCPGraph *gr = ui->sctpPlot->addGraph(); gr->setName(QString("NR_GAP")); myScatter.setPen(QPen(Qt::blue)); myScatter.setBrush(Qt::blue); ui->sctpPlot->graph(graphcount)->setScatterStyle(myScatter); ui->sctpPlot->graph(graphcount)->setLineStyle(QCPGraph::lsNone); ui->sctpPlot->graph(graphcount)->setData(xn, yn); typeStrings.insert(graphcount, QString(tr("NR Gap Ack"))); graphcount++; } // Add Duplicates if (xd.size() > 0) { QCPGraph *gr = ui->sctpPlot->addGraph(); gr->setName(QString("DUP")); myScatter.setPen(QPen(Qt::cyan)); myScatter.setBrush(Qt::cyan); ui->sctpPlot->graph(graphcount)->setScatterStyle(myScatter); ui->sctpPlot->graph(graphcount)->setLineStyle(QCPGraph::lsNone); ui->sctpPlot->graph(graphcount)->setData(xd, yd); typeStrings.insert(graphcount, QString(tr("Duplicate Ack"))); } }
Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) : WiresharkDialog(parent, cf), ui(new Ui::Iax2AnalysisDialog), port_src_fwd_(0), port_dst_fwd_(0), port_src_rev_(0), port_dst_rev_(0) { ui->setupUi(this); setWindowSubtitle(tr("IAX2 Stream Analysis")); // XXX Use recent settings instead resize(parent.width() * 4 / 5, parent.height() * 4 / 5); ui->progressFrame->hide(); stream_ctx_menu_.addAction(ui->actionGoToPacket); stream_ctx_menu_.addAction(ui->actionNextProblem); stream_ctx_menu_.addSeparator(); stream_ctx_menu_.addAction(ui->actionSaveAudio); stream_ctx_menu_.addAction(ui->actionSaveForwardAudio); stream_ctx_menu_.addAction(ui->actionSaveReverseAudio); stream_ctx_menu_.addSeparator(); stream_ctx_menu_.addAction(ui->actionSaveCsv); stream_ctx_menu_.addAction(ui->actionSaveForwardCsv); stream_ctx_menu_.addAction(ui->actionSaveReverseCsv); stream_ctx_menu_.addSeparator(); stream_ctx_menu_.addAction(ui->actionSaveGraph); ui->forwardTreeWidget->installEventFilter(this); ui->forwardTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->forwardTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showStreamMenu(QPoint))); ui->reverseTreeWidget->installEventFilter(this); ui->reverseTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->reverseTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showStreamMenu(QPoint))); connect(ui->streamGraph, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(graphClicked(QMouseEvent*))); graph_ctx_menu_.addAction(ui->actionSaveGraph); QStringList header_labels; for (int i = 0; i < ui->forwardTreeWidget->columnCount(); i++) { header_labels << ui->forwardTreeWidget->headerItem()->text(i); } ui->reverseTreeWidget->setHeaderLabels(header_labels); memset(&src_fwd_, 0, sizeof(address)); memset(&dst_fwd_, 0, sizeof(address)); memset(&src_rev_, 0, sizeof(address)); memset(&dst_rev_, 0, sizeof(address)); QList<QCheckBox *> graph_cbs = QList<QCheckBox *>() << ui->fJitterCheckBox << ui->fDiffCheckBox << ui->rJitterCheckBox << ui->rDiffCheckBox; for (int i = 0; i < num_graphs_; i++) { QCPGraph *graph = ui->streamGraph->addGraph(); graph->setPen(QPen(ColorUtils::graph_colors_[i])); graph->setName(graph_cbs[i]->text()); graphs_ << graph; graph_cbs[i]->setChecked(true); graph_cbs[i]->setIcon(StockIcon::colorIcon(ColorUtils::graph_colors_[i], QPalette::Text)); } ui->streamGraph->xAxis->setLabel("Arrival Time"); ui->streamGraph->yAxis->setLabel("Value (ms)"); // We keep our temp files open for the lifetime of the dialog. The GTK+ // UI opens and closes at various points. QString tempname = QString("%1/wireshark_iax2_f").arg(QDir::tempPath()); fwd_tempfile_ = new QTemporaryFile(tempname, this); fwd_tempfile_->open(); tempname = QString("%1/wireshark_iax2_r").arg(QDir::tempPath()); rev_tempfile_ = new QTemporaryFile(tempname, this); rev_tempfile_->open(); if (fwd_tempfile_->error() != QFile::NoError || rev_tempfile_->error() != QFile::NoError) { err_str_ = tr("Unable to save RTP data."); ui->actionSaveAudio->setEnabled(false); ui->actionSaveForwardAudio->setEnabled(false); ui->actionSaveReverseAudio->setEnabled(false); } QMenu *save_menu = new QMenu(); save_menu->addAction(ui->actionSaveAudio); save_menu->addAction(ui->actionSaveForwardAudio); save_menu->addAction(ui->actionSaveReverseAudio); save_menu->addSeparator(); save_menu->addAction(ui->actionSaveCsv); save_menu->addAction(ui->actionSaveForwardCsv); save_menu->addAction(ui->actionSaveReverseCsv); save_menu->addSeparator(); save_menu->addAction(ui->actionSaveGraph); ui->buttonBox->button(QDialogButtonBox::Save)->setMenu(save_menu); const gchar *filter_text = "iax2 && (ip || ipv6)"; dfilter_t *sfcode; gchar *err_msg; if (!dfilter_compile(filter_text, &sfcode, &err_msg)) { QMessageBox::warning(this, tr("No IAX2 packets found"), QString("%1").arg(err_msg)); g_free(err_msg); close(); } if (!cap_file_.capFile() || !cap_file_.capFile()->current_frame) close(); frame_data *fdata = cap_file_.capFile()->current_frame; if (!cf_read_record(cap_file_.capFile(), fdata)) close(); epan_dissect_t edt; epan_dissect_init(&edt, cap_file_.capFile()->epan, TRUE, FALSE); epan_dissect_prime_dfilter(&edt, sfcode); epan_dissect_run(&edt, cap_file_.capFile()->cd_t, &cap_file_.capFile()->phdr, frame_tvbuff_new_buffer(fdata, &cap_file_.capFile()->buf), fdata, NULL); // This shouldn't happen (the menu item should be disabled) but check anyway if (!dfilter_apply_edt(sfcode, &edt)) { epan_dissect_cleanup(&edt); dfilter_free(sfcode); err_str_ = tr("Please select an IAX2 packet"); updateWidgets(); return; } dfilter_free(sfcode); /* ok, it is a IAX2 frame, so let's get the ip and port values */ COPY_ADDRESS(&(src_fwd_), &(edt.pi.src)); COPY_ADDRESS(&(dst_fwd_), &(edt.pi.dst)); port_src_fwd_ = edt.pi.srcport; port_dst_fwd_ = edt.pi.destport; /* assume the inverse ip/port combination for the reverse direction */ COPY_ADDRESS(&(src_rev_), &(edt.pi.dst)); COPY_ADDRESS(&(dst_rev_), &(edt.pi.src)); port_src_rev_ = edt.pi.destport; port_dst_rev_ = edt.pi.srcport; #if 0 /* check if it is Voice or MiniPacket */ bool ok; getIntFromProtoTree(edt.tree, "iax2", "iax2.call", &ok); if (!ok) { err_str_ = tr("Please select an IAX2 packet."); updateWidgets(); return; } #endif #ifdef IAX2_RTP_STREAM_CHECK rtpstream_tapinfot tapinfo; /* Register the tap listener */ memset(&tapinfo, 0, sizeof(rtpstream_tapinfot)); tapinfo.tap_data = this; tapinfo.mode = TAP_ANALYSE; // register_tap_listener_rtp_stream(&tapinfo, NULL); /* Scan for RTP streams (redissect all packets) */ rtpstream_scan(&tapinfo, cap_file_.capFile(), NULL); int num_streams = 0; GList *filtered_list = NULL; for (GList *strinfo_list = g_list_first(tapinfo.strinfo_list); strinfo_list; strinfo_list = g_list_next(strinfo_list)) { rtp_stream_info_t * strinfo = (rtp_stream_info_t*)(strinfo_list->data); << address_to_qstring(&strinfo->dest_addr) << address_to_qstring(&src_rev_) << address_to_qstring(&dst_rev_); if (ADDRESSES_EQUAL(&(strinfo->src_addr), &(src_fwd_)) && (strinfo->src_port == port_src_fwd_) && (ADDRESSES_EQUAL(&(strinfo->dest_addr), &(dst_fwd_))) && (strinfo->dest_port == port_dst_fwd_)) { ++num_streams; filtered_list = g_list_prepend(filtered_list, strinfo); } if (ADDRESSES_EQUAL(&(strinfo->src_addr), &(src_rev_)) && (strinfo->src_port == port_src_rev_) && (ADDRESSES_EQUAL(&(strinfo->dest_addr), &(dst_rev_))) && (strinfo->dest_port == port_dst_rev_)) { ++num_streams; filtered_list = g_list_append(filtered_list, strinfo); } }
void Widget::on_pushButtonLagra_clicked() { ui->widget->clearGraphs(); // Graphf* gf = new Graphf(); gf->setStartX(ui->lineEditLagraStart->text().toDouble()); gf->setFinishX(ui->lineEditLagraFinish->text().toDouble()); gf->setPointsCount((gf->finishX - gf->startX) * 10 + 1); gf->setStepY((gf->finishX - gf->startX) / (gf->points_count - 1)); gf->calcf(); QCPGraph *graph = ui->widget->addGraph(); graph->setData(gf->fX, gf->fY); graph->setPen(QPen(Qt::red, 1)); graph->setName("f(x)"); // // Lagra* l = new Lagra(ui->lineEditLagraPointsCount->text().toInt() + 1); l->calcF(gf); graph = ui->widget->addGraph(); graph->setData(gf->fX, l->result); graph->setPen(QPen(Qt::blue, 1)); graph->setName("L(x)"); // // QVector<double> Rt(gf->points_count); for (int i = 0; i < Rt.size(); i++) Rt[i] = qFabs(gf->fY[i] - l->result[i]); qDebug() << Rt; graph = ui->widget->addGraph(); graph->setData(gf->fX, Rt); graph->setPen(QPen(Qt::black, 1)); graph->setName("R(x)"); // // LagraRp* lrp = NULL; int unit_points = l->lX.size(); if (unit_points - 1 == 5) { lrp = new LagraRp(); lrp->calcRp(gf, l); graph = ui->widget->addGraph(); graph->setData(gf->fX, lrp->result); graph->setPen(QPen(Qt::green, 1)); graph->setName("Теоретическая погрешность"); } // ui->widget->xAxis->setRange(gf->startX, gf->finishX); ui->widget->yAxis->setRange(0, 10); ui->widget->replot(); /* Рисуем */ if (lrp != NULL) delete lrp; delete l; delete gf; }
QCPGraph* tva::postProc::vec2Chart( const postProc::policyChart& policy, const tva::opVecReal& opVx, const tva::vecReal& vy, QCustomPlot *plot ) { if (policy.needClear) { /*int n=*/ plot->clearGraphs(); } size_t size = vy.size(); tva::vecReal vx; // generate data: if (opVx.isSettled()) { vx = opVx.get(); } else { for (size_t i=0; i<size; ++i) { vx.push_back(i);//index } } //const auto& mx = vx_vy.first; //const auto& my = vx_vy.second; QVector<double> x, y; for (size_t i=0; i<size; ++i) { x.push_back(vx[i]);//index y.push_back(vy[i]);//value } // create graph and assign data to it: QCPGraph * graph; if (policy.leftAxis) { graph = plot->addGraph(); } else { graph = plot->addGraph(plot->xAxis, plot->yAxis2); plot->yAxis2->setVisible(true); } //auto * graph = plot->addPlottable(); {//set graph QPen graphPen; if (policy.lStyle.isSettled()) { graph->setLineStyle(policy.lStyle.get().style); graph->setScatterStyle(policy.lStyle.get().scatter); if (policy.lStyle.get().name.isSettled()) { graph->setName(policy.lStyle.get().name.get()); } if (policy.lStyle.get().color.isSettled()) { graphPen.setColor(policy.lStyle.get().color.get()); } else { graphPen.setColor(QColor(rand()%245+10, rand()%245+10, rand()%245+10)); } //graphPen.setWidthF(rand()/(double)RAND_MAX*2+1); } else { tva::chartSetup::lineStyle ls; graph->setLineStyle(ls.style); } graph->setPen(graphPen); } graph->setData(x, y); QCPAxis* xAxis= plot->xAxis; QCPAxis* yAxis;// = plot->yAxis; if (policy.leftAxis) { yAxis = plot->yAxis; } else { yAxis = plot->yAxis2; } if (policy.style.isSettled()) { plot->setTitle(policy.style.get().title); } tva::chartSetup::setupAxisesStyle(policy.style, xAxis, yAxis); // plot->replot(); return graph; }
void SCTPGraphByteDialog::drawBytesGraph() { GList *listTSN = NULL,*tlist; tsn_t *tsn; guint8 type; guint32 maxBytes; guint64 sumBytes = 0; if (direction == 1) { maxBytes = selected_assoc->n_data_bytes_ep1; listTSN = g_list_last(selected_assoc->tsn1); } else { maxBytes = selected_assoc->n_data_bytes_ep2; listTSN = g_list_last(selected_assoc->tsn2); } while (listTSN) { tsn = (tsn_t*) (listTSN->data); tlist = g_list_first(tsn->tsns); guint16 length; while (tlist) { type = ((struct chunk_header *)tlist->data)->type; if (type == SCTP_DATA_CHUNK_ID || type == SCTP_I_DATA_CHUNK_ID) { length = g_ntohs(((struct data_chunk_header *)tlist->data)->length); if (type == SCTP_DATA_CHUNK_ID) length -= DATA_CHUNK_HEADER_LENGTH; else length -= I_DATA_CHUNK_HEADER_LENGTH; sumBytes += length; yb.append(sumBytes); xb.append(tsn->secs + tsn->usecs/1000000.0); fb.append(tsn->frame_number); } tlist = g_list_next(tlist); } listTSN = g_list_previous(listTSN); } QCPScatterStyle myScatter; myScatter.setShape(QCPScatterStyle::ssCircle); myScatter.setSize(3); // create graph and assign data to it: // Add Bytes graph if (xb.size() > 0) { QCPGraph *gr = ui->sctpPlot->addGraph(ui->sctpPlot->xAxis, ui->sctpPlot->yAxis); gr->setName(QString(tr("Bytes"))); myScatter.setPen(QPen(Qt::red)); myScatter.setBrush(Qt::red); ui->sctpPlot->graph(0)->setScatterStyle(myScatter); ui->sctpPlot->graph(0)->setLineStyle(QCPGraph::lsNone); ui->sctpPlot->graph(0)->setData(xb, yb); } ui->sctpPlot->xAxis->setLabel(tr("time [secs]")); ui->sctpPlot->yAxis->setLabel(tr("Received Bytes")); // set axes ranges, so we see all data: QCPRange myXByteRange(0, (selected_assoc->max_secs+1)); QCPRange myYByteRange(0, maxBytes); ui->sctpPlot->xAxis->setRange(myXByteRange); ui->sctpPlot->yAxis->setRange(myYByteRange); }