import QtQuick 2.3
import QtQuick.Layouts 1.1
import "../../commons/"
Core {
id: page
width: 400; height: 640
property int refreshRate: 3000;
property variant logicConnections;
property int initialized: 0;
logicConnections: [
{
"logicID":"0",
"logicDevice" : "0",
"logicParameter" : "Lua.KeyValue.ch.inside.values.day",
"logicLocal" : "vqml_setting_ch_inside_demand_t_day",
"logicDirection": "toDevice",
"logicRange" : ["-65535", "65535"],
"fastRead" : true
},
{
"logicID":"1",
"logicDevice" : "0",
"logicParameter" : "Lua.KeyValue.ch.inside.values.night",
"logicLocal" : "vqml_setting_ch_inside_demand_t_night",
"logicDirection": "toDevice",
"logicRange" : ["-65535", "65535"],
"fastRead" : true
},
{
"logicID":"2",
"logicDevice" : "0",
"logicParameter" : "MapperTemp.inside.output.t.value",
"logicLocal" : "vqml_input_logic_t_inside_value",
"logicDirection": "toDevice",
"logicRange" : ["-65535", "65535"],
"fastRead" : true
},
{
"logicID":"3",
"logicDevice" : "0",
"logicParameter" : "MapperTemp.inside.output.t.err",
"logicLocal" : "vqml_input_logic_t_inside_err",
"logicDirection": "toDevice",
"logicRange" : ["-65535", "65535"],
"fastRead" : true
},
{
"logicID":"4",
"logicDevice" : "0",
"logicParameter" : "Thermostat.ch.0.setting.t.demand",
"logicLocal" : "vqml_counter_ch_inside_demand_t",
"logicDirection": "toDevice",
"logicRange" : ["-65535", "65535"],
"fastRead" : true
},
{
"logicID":"5",
"logicDevice" : "0",
"logicParameter" : "MapperIO.do.ch.0.pump.output.value",
"logicLocal" : "vqml_output_logic_ch_pump",
"logicDirection": "toDevice",
"logicRange" : ["-65535", "65535"],
"fastRead" : true
}
];
property int vqml_setting_ch_inside_demand_t_day : -65535; // 0
property int vqml_setting_ch_inside_demand_t_night : -65535; // 1
property int vqml_input_logic_t_inside_value : -235; // 2
property int vqml_input_logic_t_inside_err : 0; // 2
property int vqml_counter_ch_inside_demand_t : 270; // 2
property int vqml_input_logic_di_window : 0; // 3
property int vqml_output_logic_ch_pump : 0; // 3
signal commitValue(int a_index, int a_value_1, int a_value_2, int a_value_3, int a_value_4)
/*
* Typy parametrów - opis w Core.qml
*
*/
function set_settingsListModel() {
settingsListModel.append({"param_title" : "Temperatura dzienna", "param_p_0" : "10;5;100;320;°C;1", "param_control" : "C_value_set_01", "param_qml" : ""}) // 0
settingsListModel.append({"param_title" : "Temperatura nocna", "param_p_0" : "10;5;100;320;°C;1", "param_control" : "C_value_set_01", "param_qml" : ""}) // 1
settingsListModel.append({"param_title" : "Temp. panująca/wymagana", "param_p_0" : "10;1;°C;thermometer_02.svg;thermometer_01.svg", "param_control" : "C_value_view_01", "param_qml" : ""}) // 2
settingsListModel.append({"param_title" : "Pompa", "param_p_0" : "arrow_red.svg;arrow_blue.svg;44;64;arrow_red.svg;arrow_blue.svg;44;64", "param_control" : "C_graphic_status_view_01", "param_qml" : ""}) // 3
prepareDynamicQMLs();
initialized = 1;
}
/*
* Zatwierdza zmienne qml - wysyła ich wartości do kontrolek stworzonych dynamicznie
* (sygnał dla kontrolki)
*/
function commitAllValues() {
commitValue(0, vqml_setting_ch_inside_demand_t_day, 65535, 0, 0);
commitValue(1, vqml_setting_ch_inside_demand_t_night, 65535, 0, 0);
commitValue(2, vqml_input_logic_t_inside_value, vqml_input_logic_t_inside_err, vqml_counter_ch_inside_demand_t, 0);
commitValue(3, vqml_output_logic_ch_pump, vqml_output_logic_ch_pump, 0, 0);
}
/*
* Nastąpiła zmiana ustawienia w kontrolce stworzonej dynamicznie -
* przypisanie zmiennej qml wartości z kontrolki
* (sygnał z kontrolki)
*/
function updateValue(a_index, a_value) {
switch (a_index) {
case 0:
vqml_setting_ch_inside_demand_t_day = a_value
eval("thisObject.changeLogicValue(0, " + a_value + ")")
break;
case 1:
vqml_setting_ch_inside_demand_t_night = a_value
eval("thisObject.changeLogicValue(1, " + a_value + ")")
break;
default:
}
}
/*
* Lista zgrupowanych parametrów nastawczych
*
* title: "Temperatura wewnętrzna" - nazwa grupy
* picture: "../../images/thermometer_01.svg" - ikona grupy
* setting_index: "0;1;2;3" - poszczególne indexy parametrów oddzielonych średnikiem, które mają być w ramach tej grupy
*
*/
ListModel {
id: settingsModel
ListElement {
title: "Pokój dzienny"
picture: "../../images/keychain.svg"
setting_index: "0;1;2;3"
}
}
function prepareDynamicQMLs() {
var tmp_str = "";
var tmp_title = "";
var tmp_p_0 = "";
var tmp_control = "";
var tmp_list_model_count = 0;
var i = 0;
tmp_list_model_count = settingsListModel.count;
for(i = 0; i < tmp_list_model_count; i++){
tmp_title = settingsListModel.get(i).param_title;
tmp_p_0 = settingsListModel.get(i).param_p_0;
tmp_control = settingsListModel.get(i).param_control;
tmp_str = generateQMLstring(tmp_control, i, tmp_title, tmp_p_0);
settingsListModel.setProperty(i, "param_qml", tmp_str);
}
}
function createSettings(a_setting_index, a_parent) {
var tmp_setting_index = a_setting_index.split(";");
var tmp_str = "";
if (tmp_setting_index.length > 0) {
for (var i=0; i<tmp_setting_index.length; i++) {
tmp_str = settingsListModel.get(tmp_setting_index[i]).param_qml;
var dynamicObject = Qt.createQmlObject(tmp_str, a_parent, 'content_object_' + i);
}
}
}
ListModel {
id: settingsListModel
}
Timer {
id: timer
interval: 1000
repeat: true
running: true
triggeredOnStart: true
onTriggered: commitAllValues()
}
Component {
id: settingDelegate
Item {
id: itm_setting
Component.onCompleted: {
if (!initialized) {
set_settingsListModel();
}
}
property real details_visible : 0
width: listView.width
height: 70
Rectangle {
id: rec_background
x: 2
y: 2
width: parent.width - x * 2
height: parent.height - y * 2
color: "lightgray"
border.color: "gray"
radius: 5
ColumnLayout {
id: columnlayout_setting
x: 3
y: 3
width: parent.width - x * 2
height: parent.height - y * 2
spacing: 10
RowLayout {
spacing: 10
Layout.fillHeight: true
Layout.maximumHeight: 130
Layout.fillWidth: true
Item {
id: itm_Icon
Layout.preferredWidth: 60
Layout.preferredHeight: 130
Layout.maximumHeight: columnlayout_setting.height
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
// Rectangle{
// color: 'lightblue'
// anchors.fill: parent
// }
Image {
source: picture
sourceSize.height: height
sourceSize.width: width
anchors.centerIn: parent
anchors.fill: parent
fillMode: Image.PreserveAspectFit
}
}
Item {
id: itm_title
Layout.fillWidth: true
Layout.fillHeight: true
// Rectangle{
// color: 'lightblue'
// anchors.fill: parent
// }
Text {
id: txt_title
anchors.fill: parent
text: title
elide: Text.ElideRight
wrapMode: Text.WordWrap
font.pixelSize: 22
clip: true
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
Image {
id: img_details_collapse
source: "../../images/close_01.svg"
sourceSize.height: height
sourceSize.width: width
height: 15
width: 30
y: parent.height - 5
//anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.rightMargin: 5
opacity: itm_setting.details_visible
}
}
MouseArea {
anchors.fill: parent
onClicked: (itm_setting.state == "") ? itm_setting.state = "Details" : itm_setting.state = ""
}
}
RowLayout {
Layout.fillWidth: true
Layout.fillHeight: true
spacing: 2
Item {
Layout.fillWidth: true
Layout.fillHeight: true
opacity: itm_setting.details_visible
Rectangle {
id: rec_details_background
x: 0
y: 0
width: parent.width - x * 2
height: parent.height - y * 2
color: "lightgray"
border.color: "gray"
radius: 5
}
Flickable {
id: flick_details
x: 2
y: 2
width: parent.width - x * 2
height: parent.height - y * 2
contentHeight: itm_setting_content.height
clip: true
Component.onCompleted: {
createSettings(setting_index, column_layout_settings)
}
Item {
id: itm_setting_content
width: parent.width
//height: content_height
height: column_layout_settings.implicitHeight
ColumnLayout{
id: column_layout_settings
x: 13
y: 5
width: parent.width - 2 * x
height: parent.height - 2 * y
spacing: 10
}
}
}
Image {
anchors.right: flick_details.right
anchors.top: flick_details.top
source: "../../images/moreUp.png"
opacity: flick_details.atYBeginning ? 0 : 1
}
Image {
anchors.right: flick_details.right
anchors.bottom: flick_details.bottom
source: "../../images/moreDown.png"
opacity: flick_details.atYEnd ? 0 : 1
}
// Rectangle{
// color: 'plum'
// anchors.fill: parent
// }
}
}
}
}
states: State {
name: "Details"
PropertyChanges { target: rec_background; color: "linen" }
PropertyChanges { target: itm_Icon; Layout.preferredWidth: 130 }
PropertyChanges { target: itm_setting; details_visible: 1}
PropertyChanges { target: itm_setting; height: listView.height }
// Move the list so that this item is at the top.
PropertyChanges { target: itm_setting.ListView.view; explicit: true; contentY: itm_setting.y }
// Disallow flicking while we're in detailed view
PropertyChanges { target: itm_setting.ListView.view; interactive: false }
}
transitions: Transition {
ParallelAnimation {
ColorAnimation { property: "color"; duration: 1000 }
NumberAnimation { duration: 300; properties: "details_visible,x,contentY,height,preferredWidth,width" }
}
}
}
}
ListView {
id: listView
anchors.fill: parent
model: settingsModel
delegate: settingDelegate
}
// Text {
// id: tmp_debug_text
// x: 5
// y: 5
// }
}