From 560062626becb4d211a9948bf3008921129711cf Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Tue, 13 Dec 2016 01:29:33 +0900 Subject: move hvac app and hvac plugin to new repository $ qmake && make will generate package/hvac.wgt Change-Id: I67057f1f3b511a3af4a22aedd32f6614dc56b503 Signed-off-by: Tasuku Suzuki --- .gitignore | 1 + app/HVAC.qml | 137 +++++++ app/HeatDegree.qml | 55 +++ app/SeatHeatButton.qml | 78 ++++ app/app.pri | 12 + app/app.pro | 10 + app/config.tests/libhomescreen/libhomescreen.cpp | 8 + app/config.tests/libhomescreen/libhomescreen.pro | 5 + app/hvac.qrc | 7 + app/images/HMI_HVAC_Active.svg | 75 ++++ app/images/HMI_HVAC_AirDown_Active.svg | 121 ++++++ app/images/HMI_HVAC_AirDown_Inactive.svg | 69 ++++ app/images/HMI_HVAC_AirRight_Active.svg | 123 ++++++ app/images/HMI_HVAC_AirRight_Inactive.svg | 72 ++++ app/images/HMI_HVAC_AirUp_Active.svg | 126 ++++++ app/images/HMI_HVAC_AirUp_Inactive.svg | 75 ++++ app/images/HMI_HVAC_ChairIndicator_OFF.svg | 76 ++++ app/images/HMI_HVAC_ChairIndicator_One.svg | 71 ++++ app/images/HMI_HVAC_ChairIndicator_Two.svg | 77 ++++ app/images/HMI_HVAC_Circulation_Active.svg | 198 +++++++++ app/images/HMI_HVAC_Circulation_Inactive.svg | 87 ++++ app/images/HMI_HVAC_Fan_Icon.svg | 81 ++++ app/images/HMI_HVAC_Front_Active.svg | 111 +++++ app/images/HMI_HVAC_Front_Inactive.svg | 72 ++++ app/images/HMI_HVAC_Inactive.svg | 63 +++ app/images/HMI_HVAC_Left_Chair_OFF.svg | 87 ++++ app/images/HMI_HVAC_Left_Chair_ON.svg | 99 +++++ app/images/HMI_HVAC_Rear_Active.svg | 195 +++++++++ app/images/HMI_HVAC_Rear_Inactive.svg | 91 +++++ app/images/HMI_HVAC_Right_Chair_OFF.svg | 87 ++++ app/images/HMI_HVAC_Right_Chair_ON.svg | 100 +++++ app/images/images.qrc | 26 ++ app/main.cpp | 46 +++ binding/binding.pri | 6 + binding/binding.pro | 10 + binding/export.map | 1 + binding/hvac-demo-binding.c | 374 +++++++++++++++++ hvac.pro | 3 + package/config.xml | 11 + package/icon.svg | 489 +++++++++++++++++++++++ package/package.pro | 21 + 41 files changed, 3456 insertions(+) create mode 100644 .gitignore create mode 100644 app/HVAC.qml create mode 100644 app/HeatDegree.qml create mode 100644 app/SeatHeatButton.qml create mode 100644 app/app.pri create mode 100644 app/app.pro create mode 100644 app/config.tests/libhomescreen/libhomescreen.cpp create mode 100644 app/config.tests/libhomescreen/libhomescreen.pro create mode 100644 app/hvac.qrc create mode 100644 app/images/HMI_HVAC_Active.svg create mode 100644 app/images/HMI_HVAC_AirDown_Active.svg create mode 100644 app/images/HMI_HVAC_AirDown_Inactive.svg create mode 100644 app/images/HMI_HVAC_AirRight_Active.svg create mode 100644 app/images/HMI_HVAC_AirRight_Inactive.svg create mode 100644 app/images/HMI_HVAC_AirUp_Active.svg create mode 100644 app/images/HMI_HVAC_AirUp_Inactive.svg create mode 100644 app/images/HMI_HVAC_ChairIndicator_OFF.svg create mode 100644 app/images/HMI_HVAC_ChairIndicator_One.svg create mode 100644 app/images/HMI_HVAC_ChairIndicator_Two.svg create mode 100644 app/images/HMI_HVAC_Circulation_Active.svg create mode 100644 app/images/HMI_HVAC_Circulation_Inactive.svg create mode 100644 app/images/HMI_HVAC_Fan_Icon.svg create mode 100644 app/images/HMI_HVAC_Front_Active.svg create mode 100644 app/images/HMI_HVAC_Front_Inactive.svg create mode 100644 app/images/HMI_HVAC_Inactive.svg create mode 100644 app/images/HMI_HVAC_Left_Chair_OFF.svg create mode 100644 app/images/HMI_HVAC_Left_Chair_ON.svg create mode 100644 app/images/HMI_HVAC_Rear_Active.svg create mode 100644 app/images/HMI_HVAC_Rear_Inactive.svg create mode 100644 app/images/HMI_HVAC_Right_Chair_OFF.svg create mode 100644 app/images/HMI_HVAC_Right_Chair_ON.svg create mode 100644 app/images/images.qrc create mode 100644 app/main.cpp create mode 100644 binding/binding.pri create mode 100644 binding/binding.pro create mode 100644 binding/export.map create mode 100644 binding/hvac-demo-binding.c create mode 100644 hvac.pro create mode 100644 package/config.xml create mode 100644 package/icon.svg create mode 100644 package/package.pro diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..89f64c7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pro.* diff --git a/app/HVAC.qml b/app/HVAC.qml new file mode 100644 index 0000000..565b108 --- /dev/null +++ b/app/HVAC.qml @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2016 The Qt Company Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import QtQuick 2.6 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 +import AGL.Demo.Controls 1.0 + +ApplicationWindow { + id: root + + ColumnLayout { + anchors.fill: parent + anchors.topMargin: width / 10 + anchors.bottomMargin: width / 10 + RowLayout { + Layout.fillHeight: true + Layout.alignment: Qt.AlignHCenter + Image { + source: './images/HMI_HVAC_Fan_Icon.svg' + } + Item { + width: root.width * 0.8 + Slider { + id: fanSpeed + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + onValueChanged: { + console.debug('Fan', value) + } + } + Label { + anchors.left: fanSpeed.left + anchors.top: fanSpeed.bottom + font.pixelSize: 32 + text: 'FAN SPEED' + } + } + } + RowLayout { + Layout.fillHeight: true + Layout.fillWidth: true + Layout.alignment: Layout.Center + spacing: 20 + ColumnLayout { + Layout.fillWidth: true + spacing: 20 + SeatHeatButton { + id: leftSeat + side: 'Left' + } + HeatDegree { + enabled: leftSeat.headLevel > 0 + } + } + ColumnLayout { + Layout.fillWidth: true + spacing: 20 + ToggleButton { + onImage: './images/HMI_HVAC_Active.svg' + offImage: './images/HMI_HVAC_Inactive.svg' + Label { + anchors.centerIn: parent + color: parent.checked ? '#66FF99' : '#848286' + text: 'A/C' + font.pixelSize: parent.height / 3 + } + onCheckedChanged: { + console.debug('A/C', checked) + } + } + ToggleButton { + onImage: './images/HMI_HVAC_Active.svg' + offImage: './images/HMI_HVAC_Inactive.svg' + Label { + anchors.centerIn: parent + color: parent.checked ? '#66FF99' : '#848286' + text: 'AUTO' + font.pixelSize: parent.height / 3 + } + onCheckedChanged: { + console.debug('AUTO', checked) + } + } + ToggleButton { + onImage: './images/HMI_HVAC_Circulation_Active.svg' + offImage: './images/HMI_HVAC_Circulation_Inactive.svg' + onCheckedChanged: { + console.debug('Circulation', checked) + } + } + } + + ColumnLayout { + Layout.fillWidth: true + spacing: 20 + SeatHeatButton { + id: rightSeat + side: 'Right' + } + HeatDegree { + enabled: rightSeat.headLevel > 0 + } + } + } + + RowLayout { + Layout.fillHeight: true + Layout.alignment: Qt.AlignHCenter + spacing: root.width / 20 + Repeater { + model: ['AirDown', 'AirUp', 'AirRight', 'Rear', 'Front'] + ToggleButton { + onImage: './images/HMI_HVAC_%1_Active.svg'.arg(model.modelData) + offImage: './images/HMI_HVAC_%1_Inactive.svg'.arg(model.modelData) + onCheckedChanged: { + console.debug(model.modelData, checked) + } + } + } + } + } +} diff --git a/app/HeatDegree.qml b/app/HeatDegree.qml new file mode 100644 index 0000000..878a9d8 --- /dev/null +++ b/app/HeatDegree.qml @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2016 The Qt Company Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import QtQuick 2.6 +import QtQuick.Controls 2.0 + +ListView { + id: root + clip: true + width: 318 + height: 219 * 2 + 20 + spacing: 20 + opacity: enabled ? 1 : 0.5 + + property int degree: currentIndex > -1 ? model.get(currentIndex).value : -1 + model: ListModel { + Component.onCompleted: { + append({value: 15, modelData: 'LO'}) + for (var d = 16; d < 30; d++) { + append({value: d, modelData: d.toFixed(0) + '\u00b0'}) + } + append({value: 30, modelData: 'HI'}) + } + } + delegate: Label { + width: ListView.view.width + height: 219 + horizontalAlignment: Label.AlignHCenter + verticalAlignment: Label.AlignVCenter + text: model.modelData + font.pixelSize: height * 0.8 + color: (ListView.view.enabled && ListView.isCurrentItem) ? '#66FF99' : 'white' + } + + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + highlightRangeMode: ListView.StrictlyEnforceRange + highlight: Rectangle { + color: 'white' + opacity: 0.2 + } +} diff --git a/app/SeatHeatButton.qml b/app/SeatHeatButton.qml new file mode 100644 index 0000000..3495cf6 --- /dev/null +++ b/app/SeatHeatButton.qml @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2016 The Qt Company Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import QtQuick 2.6 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 +import AGL.Demo.Controls 1.0 + + +Item { + id: root + implicitWidth: 318 + implicitHeight: 219 + + property string side: 'Left' + property int headLevel: 0 + + Column { + id: background + anchors.centerIn: parent + Image { + id: chair + source: './images/HMI_HVAC_%1_Chair_OFF.svg'.arg(root.side) + states: [ + State { + when: root.headLevel > 0 + PropertyChanges { + target: chair + source: './images/HMI_HVAC_%1_Chair_ON.svg'.arg(root.side) + } + } + ] + } + Image { + id: indicator + width: 178 + height: 18 + source: './images/HMI_HVAC_ChairIndicator_OFF.svg' + states: [ + State { + when: root.headLevel === 1 + PropertyChanges { + target: indicator + source: './images/HMI_HVAC_ChairIndicator_One.svg' + } + }, + State { + when: root.headLevel === 2 + PropertyChanges { + target: indicator + source: './images/HMI_HVAC_ChairIndicator_Two.svg' + } + } + ] + } + + } + + MouseArea { + anchors.fill: parent + onClicked: { + root.headLevel = (root.headLevel + 1) % 3 + } + } +} diff --git a/app/app.pri b/app/app.pri new file mode 100644 index 0000000..014646f --- /dev/null +++ b/app/app.pri @@ -0,0 +1,12 @@ +TEMPLATE = app + +load(configure) +qtCompileTest(libhomescreen) + +config_libhomescreen { + CONFIG += link_pkgconfig + PKGCONFIG += homescreen + DEFINES += HAVE_LIBHOMESCREEN +} + +DESTDIR = $${OUT_PWD}/../package/root/bin diff --git a/app/app.pro b/app/app.pro new file mode 100644 index 0000000..2c81b9f --- /dev/null +++ b/app/app.pro @@ -0,0 +1,10 @@ +TARGET = hvac +QT = quickcontrols2 + +SOURCES = main.cpp + +RESOURCES += \ + hvac.qrc \ + images/images.qrc + +include(app.pri) diff --git a/app/config.tests/libhomescreen/libhomescreen.cpp b/app/config.tests/libhomescreen/libhomescreen.cpp new file mode 100644 index 0000000..d698b05 --- /dev/null +++ b/app/config.tests/libhomescreen/libhomescreen.cpp @@ -0,0 +1,8 @@ +#include + +int main(int argc,char **argv) +{ + LibHomeScreen libHomeScreen; + return 0; +} + diff --git a/app/config.tests/libhomescreen/libhomescreen.pro b/app/config.tests/libhomescreen/libhomescreen.pro new file mode 100644 index 0000000..eb4e8f3 --- /dev/null +++ b/app/config.tests/libhomescreen/libhomescreen.pro @@ -0,0 +1,5 @@ +SOURCES = libhomescreen.cpp + +CONFIG -= qt +CONFIG += link_pkgconfig +PKGCONFIG += homescreen diff --git a/app/hvac.qrc b/app/hvac.qrc new file mode 100644 index 0000000..03fbf7d --- /dev/null +++ b/app/hvac.qrc @@ -0,0 +1,7 @@ + + + HVAC.qml + SeatHeatButton.qml + HeatDegree.qml + + diff --git a/app/images/HMI_HVAC_Active.svg b/app/images/HMI_HVAC_Active.svg new file mode 100644 index 0000000..803a42e --- /dev/null +++ b/app/images/HMI_HVAC_Active.svg @@ -0,0 +1,75 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_HVAC_AirDown_Active.svg b/app/images/HMI_HVAC_AirDown_Active.svg new file mode 100644 index 0000000..68aebb3 --- /dev/null +++ b/app/images/HMI_HVAC_AirDown_Active.svg @@ -0,0 +1,121 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_HVAC_AirDown_Inactive.svg b/app/images/HMI_HVAC_AirDown_Inactive.svg new file mode 100644 index 0000000..a013f4b --- /dev/null +++ b/app/images/HMI_HVAC_AirDown_Inactive.svg @@ -0,0 +1,69 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_HVAC_AirRight_Active.svg b/app/images/HMI_HVAC_AirRight_Active.svg new file mode 100644 index 0000000..9ac6103 --- /dev/null +++ b/app/images/HMI_HVAC_AirRight_Active.svg @@ -0,0 +1,123 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_HVAC_AirRight_Inactive.svg b/app/images/HMI_HVAC_AirRight_Inactive.svg new file mode 100644 index 0000000..991a773 --- /dev/null +++ b/app/images/HMI_HVAC_AirRight_Inactive.svg @@ -0,0 +1,72 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_HVAC_AirUp_Active.svg b/app/images/HMI_HVAC_AirUp_Active.svg new file mode 100644 index 0000000..7428bd1 --- /dev/null +++ b/app/images/HMI_HVAC_AirUp_Active.svg @@ -0,0 +1,126 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_HVAC_AirUp_Inactive.svg b/app/images/HMI_HVAC_AirUp_Inactive.svg new file mode 100644 index 0000000..39e1fa1 --- /dev/null +++ b/app/images/HMI_HVAC_AirUp_Inactive.svg @@ -0,0 +1,75 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_HVAC_ChairIndicator_OFF.svg b/app/images/HMI_HVAC_ChairIndicator_OFF.svg new file mode 100644 index 0000000..1fcd17f --- /dev/null +++ b/app/images/HMI_HVAC_ChairIndicator_OFF.svg @@ -0,0 +1,76 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_HVAC_ChairIndicator_One.svg b/app/images/HMI_HVAC_ChairIndicator_One.svg new file mode 100644 index 0000000..c24fa8f --- /dev/null +++ b/app/images/HMI_HVAC_ChairIndicator_One.svg @@ -0,0 +1,71 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_HVAC_ChairIndicator_Two.svg b/app/images/HMI_HVAC_ChairIndicator_Two.svg new file mode 100644 index 0000000..042b87d --- /dev/null +++ b/app/images/HMI_HVAC_ChairIndicator_Two.svg @@ -0,0 +1,77 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_HVAC_Circulation_Active.svg b/app/images/HMI_HVAC_Circulation_Active.svg new file mode 100644 index 0000000..8a15033 --- /dev/null +++ b/app/images/HMI_HVAC_Circulation_Active.svg @@ -0,0 +1,198 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_HVAC_Circulation_Inactive.svg b/app/images/HMI_HVAC_Circulation_Inactive.svg new file mode 100644 index 0000000..9c7d43f --- /dev/null +++ b/app/images/HMI_HVAC_Circulation_Inactive.svg @@ -0,0 +1,87 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_HVAC_Fan_Icon.svg b/app/images/HMI_HVAC_Fan_Icon.svg new file mode 100644 index 0000000..2676ba1 --- /dev/null +++ b/app/images/HMI_HVAC_Fan_Icon.svg @@ -0,0 +1,81 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_HVAC_Front_Active.svg b/app/images/HMI_HVAC_Front_Active.svg new file mode 100644 index 0000000..2c873de --- /dev/null +++ b/app/images/HMI_HVAC_Front_Active.svg @@ -0,0 +1,111 @@ + + + +image/svg+xmlFRONT + \ No newline at end of file diff --git a/app/images/HMI_HVAC_Front_Inactive.svg b/app/images/HMI_HVAC_Front_Inactive.svg new file mode 100644 index 0000000..c5d9166 --- /dev/null +++ b/app/images/HMI_HVAC_Front_Inactive.svg @@ -0,0 +1,72 @@ + + + +image/svg+xmlFRONT + \ No newline at end of file diff --git a/app/images/HMI_HVAC_Inactive.svg b/app/images/HMI_HVAC_Inactive.svg new file mode 100644 index 0000000..b29a74f --- /dev/null +++ b/app/images/HMI_HVAC_Inactive.svg @@ -0,0 +1,63 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_HVAC_Left_Chair_OFF.svg b/app/images/HMI_HVAC_Left_Chair_OFF.svg new file mode 100644 index 0000000..1412266 --- /dev/null +++ b/app/images/HMI_HVAC_Left_Chair_OFF.svg @@ -0,0 +1,87 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_HVAC_Left_Chair_ON.svg b/app/images/HMI_HVAC_Left_Chair_ON.svg new file mode 100644 index 0000000..14faf49 --- /dev/null +++ b/app/images/HMI_HVAC_Left_Chair_ON.svg @@ -0,0 +1,99 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_HVAC_Rear_Active.svg b/app/images/HMI_HVAC_Rear_Active.svg new file mode 100644 index 0000000..7c67104 --- /dev/null +++ b/app/images/HMI_HVAC_Rear_Active.svg @@ -0,0 +1,195 @@ + + + +image/svg+xmlREAR + \ No newline at end of file diff --git a/app/images/HMI_HVAC_Rear_Inactive.svg b/app/images/HMI_HVAC_Rear_Inactive.svg new file mode 100644 index 0000000..574c541 --- /dev/null +++ b/app/images/HMI_HVAC_Rear_Inactive.svg @@ -0,0 +1,91 @@ + + + +image/svg+xmlREAR + \ No newline at end of file diff --git a/app/images/HMI_HVAC_Right_Chair_OFF.svg b/app/images/HMI_HVAC_Right_Chair_OFF.svg new file mode 100644 index 0000000..711a942 --- /dev/null +++ b/app/images/HMI_HVAC_Right_Chair_OFF.svg @@ -0,0 +1,87 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_HVAC_Right_Chair_ON.svg b/app/images/HMI_HVAC_Right_Chair_ON.svg new file mode 100644 index 0000000..319ef67 --- /dev/null +++ b/app/images/HMI_HVAC_Right_Chair_ON.svg @@ -0,0 +1,100 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/images.qrc b/app/images/images.qrc new file mode 100644 index 0000000..036c1f5 --- /dev/null +++ b/app/images/images.qrc @@ -0,0 +1,26 @@ + + + HMI_HVAC_AirDown_Active.svg + HMI_HVAC_AirDown_Inactive.svg + HMI_HVAC_AirRight_Active.svg + HMI_HVAC_AirRight_Inactive.svg + HMI_HVAC_AirUp_Active.svg + HMI_HVAC_AirUp_Inactive.svg + HMI_HVAC_ChairIndicator_OFF.svg + HMI_HVAC_ChairIndicator_One.svg + HMI_HVAC_ChairIndicator_Two.svg + HMI_HVAC_Circulation_Active.svg + HMI_HVAC_Circulation_Inactive.svg + HMI_HVAC_Fan_Icon.svg + HMI_HVAC_Front_Active.svg + HMI_HVAC_Front_Inactive.svg + HMI_HVAC_Left_Chair_OFF.svg + HMI_HVAC_Left_Chair_ON.svg + HMI_HVAC_Rear_Active.svg + HMI_HVAC_Rear_Inactive.svg + HMI_HVAC_Right_Chair_OFF.svg + HMI_HVAC_Right_Chair_ON.svg + HMI_HVAC_Active.svg + HMI_HVAC_Inactive.svg + + diff --git a/app/main.cpp b/app/main.cpp new file mode 100644 index 0000000..b2133f7 --- /dev/null +++ b/app/main.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2016 The Qt Company Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#ifdef HAVE_LIBHOMESCREEN +#include +#endif + +int main(int argc, char *argv[]) +{ +#ifdef HAVE_LIBHOMESCREEN + LibHomeScreen libHomeScreen; + + if (!libHomeScreen.renderAppToAreaAllowed(0, 1)) { + qWarning() << "renderAppToAreaAllowed is denied"; + return -1; + } +#endif + + QGuiApplication app(argc, argv); + + QQuickStyle::setStyle("AGL"); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/HVAC.qml"))); + + return app.exec(); +} + diff --git a/binding/binding.pri b/binding/binding.pri new file mode 100644 index 0000000..3448a56 --- /dev/null +++ b/binding/binding.pri @@ -0,0 +1,6 @@ +TEMPLATE = lib +CONFIG += plugin use_c_linker +CONFIG -= qt +QMAKE_CFLAGS += -Wextra -Wconversion -Wno-unused-parameter -Werror=maybe-uninitialized -Werror=implicit-function-declaration -ffunction-sections -fdata-sections -Wl,--as-needed -Wl,--gc-sections + +DESTDIR = $${OUT_PWD}/../package/root/lib diff --git a/binding/binding.pro b/binding/binding.pro new file mode 100644 index 0000000..73ab515 --- /dev/null +++ b/binding/binding.pro @@ -0,0 +1,10 @@ +TARGET = hvac-demo-binding + +SOURCES = hvac-demo-binding.c + +LIBS += -Wl,--version-script=$$PWD/export.map + +CONFIG += link_pkgconfig +PKGCONFIG += json-c afb-daemon + +include(binding.pri) diff --git a/binding/export.map b/binding/export.map new file mode 100644 index 0000000..52c1b4a --- /dev/null +++ b/binding/export.map @@ -0,0 +1 @@ +{ global: afbBindingV1*; local: *; }; diff --git a/binding/hvac-demo-binding.c b/binding/hvac-demo-binding.c new file mode 100644 index 0000000..fe20880 --- /dev/null +++ b/binding/hvac-demo-binding.c @@ -0,0 +1,374 @@ +/* + * Copyright (C) 2015, 2016 "IoT.bzh" + * Author "Romain Forlot" + * Author "Jose Bolo" + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#define CAN_DEV "vcan0" + +#define SIMULATE_HVAC + +static const struct afb_binding_interface *interface; + +// Initialize CAN hvac array that will be sent trough the socket +static struct { + const char *name; + uint8_t value; +} hvac_values[] = { + { "LeftTemperature", 21 }, + { "RightTemperature", 21 }, + { "Temperature", 21 }, + { "FanSpeed", 0 } +}; + +struct can_handler { + int socket; + struct sockaddr_can txAddress; +}; + +static struct can_handler can_handler = { .socket = -1 }; + +/*****************************************************************************************/ +/*****************************************************************************************/ +/** **/ +/** **/ +/** SECTION: HANDLE CAN DEVICE **/ +/** **/ +/** **/ +/*****************************************************************************************/ +/*****************************************************************************************/ + +static int open_can_dev() +{ +#if defined(SIMULATE_HVAC) + DEBUG(interface, "Defining can handler socket to 0 and return"); + can_handler.socket = 0; + return 0; +#else + struct ifreq ifr; + + can_handler.socket = socket(PF_CAN, SOCK_RAW, CAN_RAW); + if (can_handler.socket < 0) + { + ERROR(interface, "socket could not be created"); + } + else + { + // Attempts to open a socket to CAN bus + strcpy(ifr.ifr_name, CAN_DEV); + if(ioctl(can_handler.socket, SIOCGIFINDEX, &ifr) < 0) + { + ERROR(interface, "ioctl failed"); + } + else + { + can_handler.txAddress.can_family = AF_CAN; + can_handler.txAddress.can_ifindex = ifr.ifr_ifindex; + + // And bind it to txAddress + if (bind(can_handler.socket, (struct sockaddr *)&can_handler.txAddress, sizeof(can_handler.txAddress)) < 0) + { + ERROR(interface, "bind failed"); + } + else { + return 0; + } + } + close(can_handler.socket); + can_handler.socket = -1; + } + return -1; +#endif +} + +// Get original get temperature function from cpp hvacplugin code +static uint8_t to_can_temp(uint8_t value) +{ + int result = ((0xF0 - 0x10) / 15) * value - 16; + if (result < 0x10) + result = 0x10; + if (result > 0xF0) + result = 0xF0; + + return (uint8_t)result; +} + +static uint8_t read_temp_left_zone() +{ + return hvac_values[0].value; +} + +static uint8_t read_temp_right_zone() +{ + return hvac_values[1].value; +} + +static uint8_t read_temp() +{ + return (uint8_t)(((int)read_temp_left_zone() + (int)read_temp_right_zone()) >> 1); +} + +static uint8_t read_fanspeed() +{ + return hvac_values[3].value; +} + +static int write_can() +{ + struct can_frame txCanFrame; + int rc = 0; + + rc = can_handler.socket; + if (rc >= 0) + { + // Hardcoded can_id and dlc (data lenght code) + txCanFrame.can_id = 0x30; + txCanFrame.can_dlc = 8; + txCanFrame.data[0] = to_can_temp(read_temp_left_zone()); + txCanFrame.data[1] = to_can_temp(read_temp_right_zone()); + txCanFrame.data[2] = to_can_temp(read_temp()); + txCanFrame.data[3] = 0xf0; + txCanFrame.data[4] = read_fanspeed(); + txCanFrame.data[5] = 1; + txCanFrame.data[6] = 0; + txCanFrame.data[7] = 0; + +#if defined(SIMULATE_HVAC) + DEBUG(interface, "WRITING CAN: %d %d [%02x %02x %02x %02x %02x %02x %02x %02x]\n", + txCanFrame.can_id, txCanFrame.can_dlc, + txCanFrame.data[0], txCanFrame.data[1], txCanFrame.data[2], txCanFrame.data[3], + txCanFrame.data[4], txCanFrame.data[5], txCanFrame.data[6], txCanFrame.data[7]); +#else + rc = sendto(can_handler.socket, &txCanFrame, sizeof(struct can_frame), 0, + (struct sockaddr*)&can_handler.txAddress, sizeof(can_handler.txAddress)); + if (rc < 0) + { + ERROR(interface, "Sending can frame failed"); + } +#endif + } + else + { + ERROR(interface, "socket not initialized"); + } + return rc; +} + +/*****************************************************************************************/ +/*****************************************************************************************/ +/** **/ +/** **/ +/** SECTION: BINDING VERBS IMPLEMENTATION **/ +/** **/ +/** **/ +/*****************************************************************************************/ +/*****************************************************************************************/ + +/* + * @brief Get fan speed HVAC system + * + * @param struct afb_req : an afb request structure + * + */ +static void get_fanspeed(struct afb_req request) +{ + json_object *ret_json; + uint8_t fanspeed = read_fanspeed(); + + ret_json = json_object_new_object(); + json_object_object_add(ret_json, "FanSpeed", json_object_new_int(fanspeed)); + + afb_req_success(request, ret_json, NULL); +} + +/* + * @brief Read Consign right zone temperature for HVAC system + * + * @param struct afb_req : an afb request structure + * + */ +static void get_temp_right_zone(struct afb_req request) +{ + json_object *ret_json; + uint8_t temp = read_temp_right_zone(); + + ret_json = json_object_new_object(); + json_object_object_add(ret_json, "RightTemperature", json_object_new_int(temp)); + + afb_req_success(request, ret_json, NULL); +} + +/* + * @brief Read Consign left zone temperature for HVAC system + * + * @param struct afb_req : an afb request structure + * + */ +static void get_temp_left_zone(struct afb_req request) +{ + json_object *ret_json; + uint8_t temp = read_temp_left_zone(); + + ret_json = json_object_new_object(); + json_object_object_add(ret_json, "LeftTemperature", json_object_new_int(temp)); + + afb_req_success(request, ret_json, NULL); +} + +/* + * @brief Read all values + * + * @param struct afb_req : an afb request structure + * + */ +static void get(struct afb_req request) +{ + DEBUG(interface, "Getting all values"); + json_object *ret_json; + + ret_json = json_object_new_object(); + json_object_object_add(ret_json, "LeftTemperature", json_object_new_int(read_temp_left_zone())); + json_object_object_add(ret_json, "RightTemperature", json_object_new_int(read_temp_right_zone())); + json_object_object_add(ret_json, "FanSpeed", json_object_new_int(read_fanspeed())); + + afb_req_success(request, ret_json, NULL); +} + +/* + * @brief Set a component value using a json object retrieved from request + * + * @param struct afb_req : an afb request structure + * + */ +static void set(struct afb_req request) +{ + int i, rc, x, changed; + struct json_object *query, *val; + uint8_t values[sizeof hvac_values / sizeof *hvac_values]; + uint8_t saves[sizeof hvac_values / sizeof *hvac_values]; + + /* records initial values */ + DEBUG(interface, "Records initial values"); + i = (int)(sizeof hvac_values / sizeof *hvac_values); + while (i) { + i--; + values[i] = saves[i] = hvac_values[i].value; + } + + /* Loop getting arguments */ + query = afb_req_json(request); + changed = 0; + i = (int)(sizeof hvac_values / sizeof *hvac_values); + DEBUG(interface, "Looping for args. i: %d", i); + while (i) + { + i--; + DEBUG(interface, "Searching... query: %s, i: %d, comp: %s", json_object_to_json_string(query), i, hvac_values[i].name); + if (json_object_object_get_ex(query, hvac_values[i].name, &val)) + { + DEBUG(interface, "We got it. Tests if it is an int or not."); + if (!json_object_is_type(val, json_type_int)) + { + afb_req_fail_f(request, "bad-request", + "argument '%s' isn't integer", hvac_values[i].name); + return; + } + DEBUG(interface, "We get an 'int'. Hail for the int: %d", x); + x = json_object_get_int(val); + if (x < 0 || x > 255) + { + afb_req_fail_f(request, "bad-request", + "argument '%s' is out of bounds", hvac_values[i].name); + return; + } + if (values[i] != x) { + values[i] = (uint8_t)x; + changed = 1; + } + } + DEBUG(interface, "Not found !"); + } + + /* attemps to set new values */ + DEBUG(interface, "Diff: %d", changed); + if (changed) + { + i = (int)(sizeof hvac_values / sizeof *hvac_values); + while (i) { + i--; + hvac_values[i].value = values[i]; + } + rc = write_can(); + if (rc >= 0) + afb_req_success(request, NULL, NULL); + else { + /* restore initial values */ + i = (int)(sizeof hvac_values / sizeof *hvac_values); + while (i) { + i--; + hvac_values[i].value = saves[i]; + } + afb_req_fail(request, "error", "CAN error"); + } + } + else { + afb_req_success(request, NULL, "No changes"); + } +} + +// TODO: Have to change session management flag to AFB_SESSION_CHECK to use token auth +static const struct afb_verb_desc_v1 verbs[]= { + {"get_temp_left_zone" , AFB_SESSION_NONE, get_temp_left_zone , "Get the left zone temperature"}, + {"get_temp_right_zone" , AFB_SESSION_NONE, get_temp_right_zone , "Get the right zone temperature"}, + {"get_fanspeed" , AFB_SESSION_NONE, get_fanspeed , "Read fan speed"}, + {"get" , AFB_SESSION_NONE, get , "Read all values"}, + {"set" , AFB_SESSION_NONE, set , "Set a HVAC component value"}, + {NULL} +}; + +static const struct afb_binding binding_desc = { + .type = AFB_BINDING_VERSION_1, + .v1 = { + .info = "hvac service", + .prefix = "hvac", + .verbs = verbs + } +}; + +const struct afb_binding *afbBindingV1Register (const struct afb_binding_interface *itf) +{ + interface = itf; + + return &binding_desc; +} + +int afbBindingV1ServiceInit(struct afb_service service) +{ + return open_can_dev(); +} diff --git a/hvac.pro b/hvac.pro new file mode 100644 index 0000000..80f6d6c --- /dev/null +++ b/hvac.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS = app binding package +package.depends += app binding diff --git a/package/config.xml b/package/config.xml new file mode 100644 index 0000000..bd374b6 --- /dev/null +++ b/package/config.xml @@ -0,0 +1,11 @@ + + + HVAC + + + This is a demo application used to control and dialog with HVAC system + Romain Forlot <romain.forlot@iot.bzh> + APL 2.0 + + + diff --git a/package/icon.svg b/package/icon.svg new file mode 100644 index 0000000..411d130 --- /dev/null +++ b/package/icon.svg @@ -0,0 +1,489 @@ + + + +image/svg+xmlHVAC + \ No newline at end of file diff --git a/package/package.pro b/package/package.pro new file mode 100644 index 0000000..3ee8fa3 --- /dev/null +++ b/package/package.pro @@ -0,0 +1,21 @@ + +DISTFILES = icon.svg config.xml + +!equals($$_PRO_FILE_PWD_, $$OUT_PWD) { + copy_icon.target = $$OUT_PWD/root/icon.svg + copy_icon.depends = $$_PRO_FILE_PWD_/icon.svg + copy_icon.commands = $(COPY_FILE) \"$$replace(copy_icon.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_icon.target, /, $$QMAKE_DIR_SEP)\" + QMAKE_EXTRA_TARGETS += copy_icon + PRE_TARGETDEPS += $$copy_icon.target + + copy_config.target = $$OUT_PWD/root/config.xml + copy_config.depends = $$_PRO_FILE_PWD_/config.xml + copy_config.commands = $(COPY_FILE) \"$$replace(copy_config.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_config.target, /, $$QMAKE_DIR_SEP)\" + QMAKE_EXTRA_TARGETS += copy_config + PRE_TARGETDEPS += $$copy_config.target +} + +wgt.target = package +wgt.commands = wgtpkg-pack -f -o hvac.wgt root + +QMAKE_EXTRA_TARGETS += wgt -- cgit 1.2.3-korg