add nicer graphs
parent
0bc40fc696
commit
2fafd06038
|
|
@ -133,7 +133,7 @@ void DeviceManager::getSupportedDevicesResponse(const QVariantMap ¶ms)
|
|||
QVariantList deviceClassList = params.value("params").toMap().value("deviceClasses").toList();
|
||||
foreach (QVariant deviceClassVariant, deviceClassList) {
|
||||
DeviceClass *deviceClass = JsonTypes::unpackDeviceClass(deviceClassVariant.toMap(), Engine::instance()->deviceManager()->deviceClasses());
|
||||
// qDebug() << "Server has device class:" << deviceClass->name() << deviceClass->id();
|
||||
qDebug() << "Server has device class:" << deviceClass->name() << deviceClass->id();
|
||||
m_deviceClasses->addDeviceClass(deviceClass);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ void UpnpDiscovery::writeDiscoveryPacket()
|
|||
"MX:2\r\n"
|
||||
"ST: ssdp:all\r\n\r\n");
|
||||
|
||||
qDebug() << "sending discovery packet";
|
||||
writeDatagram(ssdpSearchMessage, m_host, m_port);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ TARGET=guh-control
|
|||
include(../guh-control.pri)
|
||||
|
||||
|
||||
QT += qml quick quickcontrols2 websockets svg
|
||||
QT += qml quick quickcontrols2 websockets svg charts
|
||||
|
||||
INCLUDEPATH += $$top_srcdir/libguh-common
|
||||
LIBS += -L$$top_builddir/libguh-common/ -lguh-common
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ void ValueLogsProxyModel::logsReply(const QVariantMap &data)
|
|||
} else {
|
||||
continue;
|
||||
}
|
||||
LogEntry *entry = new LogEntry(startTime().addSecs(stepSize * i).addSecs(stepSize * .5), avg, this);
|
||||
LogEntry *entry = new LogEntry(startTime().addSecs(stepSize * i)/*.addSecs(stepSize * .5)*/, avg, this);
|
||||
m_list.append(entry);
|
||||
|
||||
// qDebug() << "**" << m_minimumValue << entry->value();
|
||||
|
|
|
|||
|
|
@ -43,5 +43,23 @@ Page {
|
|||
onClicked: settings.returnToHome = checked
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: "Graph style"
|
||||
}
|
||||
RadioButton {
|
||||
checked: settings.graphStyle === "bars"
|
||||
text: "Bars"
|
||||
onClicked: settings.graphStyle = "bars"
|
||||
}
|
||||
RadioButton {
|
||||
checked: settings.graphStyle === "bezier"
|
||||
text: "Lines"
|
||||
onClicked: settings.graphStyle = "bezier"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ Item {
|
|||
property var model: null
|
||||
|
||||
property color color: "grey"
|
||||
property string mode: "bezier" // "bezier" or "bars"
|
||||
|
||||
Connections {
|
||||
target: model
|
||||
|
|
@ -107,8 +108,13 @@ Item {
|
|||
|
||||
paintGrid(ctx)
|
||||
enumerate(ctx)
|
||||
// paintWifis(ctx, canvas.selectedIndex)
|
||||
paintGraph(ctx)
|
||||
|
||||
if (root.mode == "bezier") {
|
||||
paintGraph(ctx)
|
||||
} else {
|
||||
paintBars(ctx)
|
||||
}
|
||||
|
||||
ctx.restore();
|
||||
|
||||
}
|
||||
|
|
@ -170,8 +176,8 @@ Item {
|
|||
// enumerate Y axis
|
||||
|
||||
var lastTextX = -1;
|
||||
for (var i = 0; i < model.count - 1; i++) {
|
||||
var x = contentWidth / (model.count - 1) * i;
|
||||
for (var i = 0; i < model.count; i++) {
|
||||
var x = contentWidth / (model.count) * i;
|
||||
if (x < lastTextX) continue;
|
||||
|
||||
var label = model.get(i).dayString
|
||||
|
|
@ -310,6 +316,37 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
function paintBars(ctx) {
|
||||
if (model.count <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
var tempInterval = (maxTemp - minTemp) / sections;
|
||||
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.lineWidth = 2;
|
||||
var graphStroke = root.color;
|
||||
var grapFill = Qt.rgba(root.color.r, root.color.g, root.color.b, .2);
|
||||
|
||||
ctx.strokeStyle = graphStroke;
|
||||
ctx.fillStyle = grapFill;
|
||||
|
||||
|
||||
for (var i = 0; i < model.count; i++) {
|
||||
ctx.beginPath();
|
||||
var value = model.get(i).value;
|
||||
var x = contentWidth / (model.count) * i;
|
||||
var y = contentHeight - (value - minTemp) / tempInterval * pps;
|
||||
|
||||
var slotWidth = contentWidth / model.count
|
||||
ctx.rect(x,y, slotWidth - 5, contentHeight - y)
|
||||
ctx.fillRect(x,y, slotWidth - 5, contentHeight - y);
|
||||
ctx.stroke();
|
||||
ctx.fill();
|
||||
ctx.closePath();
|
||||
}
|
||||
}
|
||||
|
||||
function hourToX(hour) {
|
||||
var entries = root.day.count;
|
||||
return canvas.contentWidth / entries * hour
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import QtQuick 2.5
|
|||
import QtQuick.Controls 2.1
|
||||
import QtQuick.Controls.Material 2.1
|
||||
import QtQuick.Layouts 1.3
|
||||
//import QtCharts 2.1
|
||||
import "../components"
|
||||
import Guh 1.0
|
||||
|
||||
|
|
@ -25,19 +24,6 @@ CustomViewBase {
|
|||
onAverageChanged: updateTimer.start()
|
||||
onStartTimeChanged: updateTimer.start();
|
||||
|
||||
onBusyChanged: {
|
||||
if (!busy) {
|
||||
|
||||
// lineSeries1.clear()
|
||||
// splineSeries.clear()
|
||||
// print("---", axisX.min, axisX.max)
|
||||
// for (var i = 0; i < logsModel.count; i++) {
|
||||
// print("adding", logsModel.get(i).timestamp, logsModel.get(i).value)
|
||||
// lineSeries1.append(logsModel.get(i).timestamp, logsModel.get(i).value)
|
||||
// splineSeries.append(logsModel.get(i).timestamp, logsModel.get(i).value)
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
|
|
@ -78,6 +64,8 @@ CustomViewBase {
|
|||
property date startTime: {
|
||||
var date = new Date();
|
||||
date.setHours(new Date().getHours() - 6)
|
||||
date.setMinutes(0)
|
||||
date.setSeconds(0)
|
||||
return date;
|
||||
}
|
||||
}
|
||||
|
|
@ -87,6 +75,8 @@ CustomViewBase {
|
|||
property date startTime: {
|
||||
var date = new Date();
|
||||
date.setHours(new Date().getHours() - 24);
|
||||
date.setMinutes(0)
|
||||
date.setSeconds(0)
|
||||
return date;
|
||||
}
|
||||
}
|
||||
|
|
@ -96,6 +86,9 @@ CustomViewBase {
|
|||
property date startTime: {
|
||||
var date = new Date();
|
||||
date.setDate(new Date().getDate() - 7);
|
||||
date.setHours(0)
|
||||
date.setMinutes(0)
|
||||
date.setSeconds(0)
|
||||
return date;
|
||||
}
|
||||
}
|
||||
|
|
@ -105,72 +98,9 @@ CustomViewBase {
|
|||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 200
|
||||
model: logsModel
|
||||
mode: settings.graphStyle
|
||||
color: app.interfaceToColor(root.interfaceName)
|
||||
}
|
||||
|
||||
// ChartView {
|
||||
// id: chartView
|
||||
// Layout.fillWidth: true
|
||||
// Layout.preferredHeight: 300
|
||||
// animationOptions: ChartView.SeriesAnimations
|
||||
// theme: ChartView.ChartThemeQt
|
||||
// backgroundColor: Material.background
|
||||
// property bool openGL: false
|
||||
// property bool openGLSupported: true
|
||||
// onOpenGLChanged: {
|
||||
// if (openGLSupported) {
|
||||
// series("signal 1").useOpenGL = openGL;
|
||||
// series("signal 2").useOpenGL = openGL;
|
||||
// }
|
||||
// }
|
||||
// Component.onCompleted: {
|
||||
// if (!series("signal 1").useOpenGL) {
|
||||
// openGLSupported = false
|
||||
// openGL = false
|
||||
// }
|
||||
// }
|
||||
|
||||
// ValueAxis {
|
||||
// id: axisY1
|
||||
// min: logsModel.minimumValue - 1
|
||||
// max: logsModel.maximumValue + 1
|
||||
// }
|
||||
|
||||
// DateTimeAxis {
|
||||
// id: axisX
|
||||
// min: logsModel.startTime
|
||||
// max: logsModel.endTime
|
||||
// format: {
|
||||
// switch (logsModel.average) {
|
||||
// case ValueLogsProxyModel.AverageMinute:
|
||||
// case ValueLogsProxyModel.AverageHourly:
|
||||
// case ValueLogsProxyModel.AverageQuarterHour:
|
||||
// return "hh:mm"
|
||||
// }
|
||||
// return "ddd<br> dd.MM.<br>hh:mm"
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// AreaSeries {
|
||||
// axisX: axisX
|
||||
// axisY: axisY1
|
||||
// borderWidth: 0
|
||||
// name: app.interfaceToString(interfaceName)
|
||||
// borderColor: app.interfaceToColor(interfaceName)
|
||||
// color: Qt.rgba(borderColor.r, borderColor.g, borderColor.b, .4)
|
||||
// useOpenGL: chartView.openGL
|
||||
// upperSeries: LineSeries {
|
||||
// id: lineSeries1
|
||||
// }
|
||||
// }
|
||||
// SplineSeries {
|
||||
// id: splineSeries
|
||||
// axisX: axisX
|
||||
// axisY: axisY1
|
||||
// width: 3
|
||||
// color: app.interfaceToColor(interfaceName)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ ApplicationWindow {
|
|||
property string lastConnectedHost: ""
|
||||
property bool fullscreen: false
|
||||
property bool returnToHome: false
|
||||
property string graphStyle: "bars"
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
|
|
@ -90,6 +91,10 @@ ApplicationWindow {
|
|||
id: discovery
|
||||
}
|
||||
|
||||
// ZeroconfDiscovery {
|
||||
// id: discovery
|
||||
// }
|
||||
|
||||
Connections {
|
||||
target: Qt.application
|
||||
enabled: Engine.jsonRpcClient.connected && settings.returnToHome
|
||||
|
|
@ -163,10 +168,6 @@ ApplicationWindow {
|
|||
return "grey";
|
||||
}
|
||||
|
||||
// ZeroconfDiscovery {
|
||||
// id: discovery
|
||||
// }
|
||||
|
||||
Component {
|
||||
id: invalidVersionComponent
|
||||
Popup {
|
||||
|
|
|
|||
Loading…
Reference in New Issue