96 lines
2.3 KiB
QML
96 lines
2.3 KiB
QML
import QtQuick 2.0
|
|
|
|
Item {
|
|
id: startpadConn
|
|
height: 0
|
|
width: 0
|
|
opacity: 0
|
|
visible: false
|
|
|
|
signal pushed()
|
|
property bool connected: false
|
|
property var status: {'status': startpadConn.state, 'progress': get_progress()}
|
|
|
|
Timer {
|
|
//timer that refreshes the connection state to the buzzer
|
|
id: connectionRefreshTimer
|
|
running: root.state !== "RUNNING" && root.state !== "STARTING" && startpadConn.status !== "connecting"
|
|
repeat: false
|
|
interval: 1000
|
|
onTriggered: {
|
|
_cppStartpadConn.refresh()
|
|
if(!_cppStartpadConn.get("connected") && startpadConn.state !== "connecting"){
|
|
startpadConn.state = "disconnected"
|
|
}
|
|
|
|
connectionRefreshTimer.start()
|
|
}
|
|
}
|
|
|
|
Timer {
|
|
//timer that checks, if the button has been pushed
|
|
id: running_refresh_timer
|
|
running: root.state === "RUNNING"
|
|
repeat: false
|
|
interval: 1
|
|
|
|
onTriggered: {
|
|
if(_cppStartpadConn.buzzer_triggered()){
|
|
startpadConn.pushed()
|
|
|
|
}
|
|
if(root.state === "RUNNING" || root.state === "STARTING"){
|
|
running_refresh_timer.start()
|
|
}
|
|
}
|
|
}
|
|
|
|
Timer {
|
|
id: prog_refresh
|
|
running: startpadConn.state === "connecting"
|
|
interval: 1
|
|
repeat: true
|
|
onTriggered: {
|
|
startpadConn.status.progress = get_progress()
|
|
}
|
|
}
|
|
|
|
states: [
|
|
State {
|
|
name: "disconnected"
|
|
PropertyChanges {
|
|
target: startpadConn
|
|
}
|
|
},
|
|
State {
|
|
name: "connecting"
|
|
PropertyChanges {
|
|
target: startpadConn
|
|
}
|
|
},
|
|
State {
|
|
name: "connected"
|
|
PropertyChanges {
|
|
target: startpadConn
|
|
}
|
|
}
|
|
]
|
|
|
|
function connect(){
|
|
startpadConn.state = "connecting"
|
|
if(_cppStartpadConn.connect()){
|
|
startpadConn.state = "connected"
|
|
return(true)
|
|
}
|
|
else {
|
|
startpadConn.state = "disconnected"
|
|
return(false)
|
|
}
|
|
|
|
|
|
}
|
|
|
|
function get_progress(){
|
|
return(_cppStartpadConn.get("connection_progress"))
|
|
}
|
|
}
|