import QtQuick 2.0

Item {
    id: buzzerConn
    height: 0
    width: 0
    opacity: 0
    visible: false

    signal pushed()

    Timer {
        //timer that refreshes the connection state to the buzzer
        id: connectionRefreshTimer
        running: root.state !== "RUNNING" && root.state !== "STARTING"
        repeat: false
        interval: 1000
        onTriggered: {
            _cppBuzzerConn.refresh()
            connectionRefreshTimer.start()
        }
    }

    Timer {
        id: running_refresh_timer
        running: root.state === "RUNNING"
        repeat: false
        interval: 1

        onTriggered: {
            if(_cppBuzzerConn.buzzer_triggered()){
                buzzerConn.pushed()

            }
            if(root.state === "RUNNING"){
                running_refresh_timer.start()
            }
        }
    }

}
