implemented connectivity to startpad

This commit is contained in:
Dorian Zedler 2018-08-29 18:33:39 +02:00
parent 0661b3e515
commit 97d17618bf
4 changed files with 46 additions and 5 deletions

View file

@ -9,6 +9,7 @@
#include <QAuthenticator> #include <QAuthenticator>
#include <QDesktopServices> #include <QDesktopServices>
#include <QDateTime> #include <QDateTime>
#include <QtDebug>
typedef struct strReturnData{ typedef struct strReturnData{
int status_code; int status_code;

View file

@ -39,7 +39,7 @@ Item {
startpadConn.pushed() startpadConn.pushed()
} }
if(root.state === "RUNNING"){ if(root.state === "RUNNING" || root.state === "STARTING"){
running_refresh_timer.start() running_refresh_timer.start()
} }
} }

View file

@ -79,7 +79,16 @@ Window {
StartpadConn { StartpadConn {
id: startpadConn id: startpadConn
onPushed: {
console.log("startpad triggered")
var offset = _cppStartpadConn.get("offset")
var last_pressed = _cppStartpadConn.get("lastpressed")
var trigger_time = (last_pressed + offset)
root.last_run.react_time = trigger_time - root.startTime
if(trigger_time - root.startTime <= 0){
root.stop("false")
}
}
} }
Timer { Timer {
@ -167,6 +176,7 @@ Window {
onPlayingChanged: { onPlayingChanged: {
if(!playing && root.state==="STARTING"){ if(!playing && root.state==="STARTING"){
root.startTime = _cppBuzzerConn.get("currtime") root.startTime = _cppBuzzerConn.get("currtime")
console.log(root.startTime)
root.currTime = _cppBuzzerConn.get("currtime") root.currTime = _cppBuzzerConn.get("currtime")
time.text = ( ( root.currTime - root.startTime ) / 1000 ).toFixed(3) + " sec" time.text = ( ( root.currTime - root.startTime ) / 1000 ).toFixed(3) + " sec"
@ -210,6 +220,28 @@ Window {
} }
} }
} }
Label {
id: react_time
property int rtime: root.last_run.react_time
text: qsTr("reaction time (ms): ") + Math.round(rtime)
opacity: (root.state === "RUNNING" || root.sate === "STARTING" || root.state === "STOPPED") && rtime !== 0 ? 1:0
color: StyleSettings.textColor
anchors {
horizontalCenter: parent.horizontalCenter
top: time.bottom
topMargin: parent.height * 0.1
}
Timer {
running: root.state === "RUNNING" || root.sate === "STARTING" || root.state === "STOPPED"
repeat: true
interval: 1
onTriggered: {
react_time.rtime = root.last_run.react_time
}
}
}
} }
ConnectionIcon { ConnectionIcon {
@ -674,6 +706,7 @@ Window {
function reset(){ function reset(){
root.state = "IDLE" root.state = "IDLE"
root.last_run.react_time = 0
} }
} }
} }

View file

@ -105,8 +105,8 @@ int main(int argc, char *argv[])
#endif #endif
connectToDatabase(); connectToDatabase();
BuzzerConn * pBuzzerConn = new BuzzerConn(nullptr, QUrl("http://api.itsblue.de/test/buzzerem.php")); BuzzerConn * pBuzzerConn = new BuzzerConn(nullptr, QUrl("http://192.168.4.1"));
BuzzerConn * pStartpadConn = new BuzzerConn(nullptr, QUrl("http://api.itsblue.de/test/startpadem.php")); BuzzerConn * pStartpadConn = new BuzzerConn(nullptr, QUrl("http://192.168.4.2"));
AppSettings * pAppSettings = new AppSettings(); AppSettings * pAppSettings = new AppSettings();
//setup the sql storage model as a qml model //setup the sql storage model as a qml model
@ -129,5 +129,12 @@ int main(int argc, char *argv[])
engine.rootContext()->setContextProperty("_cppStartpadConn", pStartpadConn); engine.rootContext()->setContextProperty("_cppStartpadConn", pStartpadConn);
engine.rootContext()->setContextProperty("_cppAppSettings", pAppSettings); engine.rootContext()->setContextProperty("_cppAppSettings", pAppSettings);
return app.exec(); int iRet = 0;
iRet = app.exec();
delete pBuzzerConn;
delete pStartpadConn;
delete pAppSettings;
return iRet;
} }