import QtQuick 2.0 import QtQuick.Controls 2.0 import TcpSocket 2.0 import BCIManager 2.0 Item { property int hitIndex: -1 property bool bStimulate: false property int responseTime: 10 property bool bTest: false property bool bConnect: false; property var brainTrainForm: null property string red: "#EE6352" property string green: "#41B962" property string yellow: "#F8C434" property int currentIndexTenHz: 0 property var imageFilesTenHz: [ "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R01.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R02.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R03.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R04.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R05.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R06.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R07.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R08.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R09.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R10.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R11.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R12.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R13.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R14.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R15.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R14.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R13.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R12.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R11.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R10.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R09.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R08.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R07.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R06.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R05.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R04.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R03.png", "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R02.png" ] property int currentIndexTwelevHz: 0 property var imageFilesTwelevHz: [ "qrc:/DependFile/Source/brainTrain/upTest2D/upper_stretch_R01.png", "qrc:/DependFile/Source/brainTrain/upTest2D/upper_stretch_R02.png", "qrc:/DependFile/Source/brainTrain/upTest2D/upper_stretch_R03.png", "qrc:/DependFile/Source/brainTrain/upTest2D/upper_stretch_R04.png", "qrc:/DependFile/Source/brainTrain/upTest2D/upper_stretch_R05.png", "qrc:/DependFile/Source/brainTrain/upTest2D/upper_stretch_R06.png", "qrc:/DependFile/Source/brainTrain/upTest2D/upper_stretch_R07.png" ] property int currentIndexFifteenHz: 0 property var imageFilesFifteenHz: [ "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R01.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R02.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R03.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R04.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R05.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R06.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R07.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R08.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R09.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R10.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R11.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R12.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R13.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R14.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R15.png", "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R16.png", ]; function startStimulate() { animationTenHz.start(); animationTwelveHz.start(); animationFifteenHz.start(); if(!bConnect) { clientSocket.connectToHost(); } clientSocket.writeBytes(getIntArr("1")); } function stopStimulate() { if(animationTenHz.running) { animationTenHz.stop(); flashingImageTenHz.opacity = 1; } if(animationTwelveHz.running) { animationTwelveHz.stop(); flashingImageTwelveHz.opacity = 1; } if(animationFifteenHz.running) { animationFifteenHz.stop(); flashingImageFifteenHz.opacity = 1; } } function clearHit() { if(hitIndex === 0) { ssvepTenHzTimer.stop(); imageTenHz.source = imageFilesTenHz[0]; }else if(hitIndex === 1) { ssvepTwelveHzTimer.stop(); imageTwelveHz.source = imageFilesTwelevHz[0]; }else if(hitIndex === 2) { ssvepFifteenHzTimer.stop(); imageFifteenHz.source = imageFilesFifteenHz[0]; } if(hitTimer.running) { hitTimer.stop(); } hitIndex = -1; } Timer { id: hitTimer interval: responseTime*1000; repeat: false onTriggered: { clearHit(); startStimulate(); } } Timer { id: connectTimer interval: 3*1000; onTriggered: { clientSocket.connected(); } } function ssvepHit(index) { if(!bStimulate) { return; } if(hitIndex !== -1) { return; } if(index === "0") { ssvepTenHzTimer.start(); hitTimer.start(); bci.startTrain(0,responseTime-1); }else if(index === "1") { ssvepTwelveHzTimer.start(); hitTimer.start(); bci.startTrain(1,responseTime-1); }else if(index === "2") { ssvepFifteenHzTimer.start(); hitTimer.start(); bci.startTrain(2,responseTime-1); }else { return; } hitIndex = index; } function getStr(intArr){ var str = ""; for(var i=0;i