void MainWindow::displayTemperature(QCustomPlot *customPlot) { QPen pen; int temp; // give the axes some labels: customPlot->xAxis->setLabel("Samples"); customPlot->yAxis->setLabel("Temperature (°C)"); // set axes ranges, so we see all data: customPlot->xAxis->setRange(0, SAMPLE_STORE_SIZE); customPlot->yAxis->setRange(0, CUSTOMPLOT_YAXIS_RANGE); customPlot->legend->setVisible(true); pen.setWidth(1); currentTempsensorIndex = 0; for (uint zone = 0; zone < thermaldInterface.getZoneCount(); zone++) { zoneInformationType *zone_info = thermaldInterface.getZone(zone); if (!zone_info) continue; pen.setColor(colors[zone % colors.count()]); int sensor_cnt_per_zone = thermaldInterface.getSensorCountForZone(zone); if (sensor_cnt_per_zone <= 0) break; pen.setStyle(Qt::SolidLine); for (int cnt = 0; cnt < sensor_cnt_per_zone; cnt++) { QString sensor_type; QString sensor_name; sensorZoneInformationType sensor_info; if (thermaldInterface.getSensorTypeForZone(zone, cnt, sensor_type) < 0) continue; sensor_name.append(zone_info->name); sensor_name.append(":"); sensor_name.append(sensor_type); ui->customPlot->addGraph(); ui->customPlot->graph(currentTempsensorIndex)->setName(sensor_name); ui->customPlot->graph(currentTempsensorIndex)->setPen(pen); current_sample_index[currentTempsensorIndex] = 0; sensor_info.index = thermaldInterface.getSensorIndex(sensor_type); sensor_info.display_name = sensor_name; sensor_info.sensor_name = sensor_type; sensor_info.zone = zone; sensor_types.append(sensor_info); currentTempsensorIndex++; } pen.setStyle(Qt::DashLine); // Draw a dashed horz line for each min valid trip temperature QVector<QCPItemLine *> these_trips; uint trip_count = thermaldInterface.getTripCountForZone(zone); if (trip_count > 0) { for (uint trip = 0; trip < trip_count; trip++){ QCPItemLine *line = new QCPItemLine(customPlot); customPlot->addItem(line); temp = thermaldInterface.getTripTempForZone(zone, trip); line->start->setCoords(0, temp); line->end->setCoords(SAMPLE_STORE_SIZE - 1, temp); line->setPen(pen); if (temp == thermaldInterface.getLowestValidTripTempForZone(zone)) { line->setVisible(true); thermaldInterface.setTripVisibility(zone, trip, true); } else { line->setVisible(false); thermaldInterface.setTripVisibility(zone, trip, false); } these_trips.append(line); } trips.append(these_trips); } } // Now display sensors which are not part of any zone. Users can use this and assign to some zone for (uint i = 0; i < thermaldInterface.getSensorCount(); ++i) { sensorInformationType info; QString name; bool found = false; name = thermaldInterface.getSensorName(i); if (!name.isEmpty()){ // search if this is already registered as part of a zone sensor for (int j = 0; j < sensor_types.count(); ++j) { sensorZoneInformationType sensor_info = sensor_types[j]; if (name == sensor_info.sensor_name) { found = true; break; } } if (!found) { sensorZoneInformationType sensor_info; QString sensor_name; sensor_name.append("UKWN:"); sensor_name.append(name); ui->customPlot->addGraph(); ui->customPlot->graph(currentTempsensorIndex)->setName(sensor_name); ui->customPlot->graph(currentTempsensorIndex)->setPen(pen); current_sample_index[currentTempsensorIndex] = 0; sensor_info.index = thermaldInterface.getSensorIndex(name); sensor_info.display_name = sensor_name; sensor_info.sensor_name = name; sensor_info.zone = -1; sensor_types.append(sensor_info); currentTempsensorIndex++; } } } sensor_visibility = new bool[sensor_types.count()]; sensor_temp = new QLabel[sensor_types.count()]; connect(&tempUpdateTimer, SIGNAL(timeout()), this, SLOT(updateTemperatureDataSlot())); tempUpdateTimer.start(temp_poll_interval); }