11/26
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import QtQuick 2.0
|
||||
import TcpSocket 2.0
|
||||
|
||||
Item {
|
||||
property int hitIndex: -1
|
||||
property bool bStimulate: false
|
||||
property int responseTime: 10*1000
|
||||
property bool bTest: true
|
||||
property bool bConnect: false;
|
||||
|
||||
property int currentIndexTenHz: 0
|
||||
property var imageFilesTenHz:
|
||||
@@ -65,6 +67,14 @@ Item {
|
||||
animationTenHz.start();
|
||||
animationTwelveHz.start();
|
||||
animationFifteenHz.start();
|
||||
if(!bConnect)
|
||||
{
|
||||
clientSocket.connectToHost();
|
||||
bConnect = true;
|
||||
}else
|
||||
{
|
||||
clientSocket.writeBytes(getIntArr("1"));
|
||||
}
|
||||
}
|
||||
|
||||
function stopStimulate()
|
||||
@@ -128,15 +138,15 @@ Item {
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(index === 0)
|
||||
if(index === "0")
|
||||
{
|
||||
ssvepTenHzTimer.start();
|
||||
hitTimer.start();
|
||||
}else if(index === 1)
|
||||
}else if(index === "1")
|
||||
{
|
||||
ssvepTwelveHzTimer.start();
|
||||
hitTimer.start();
|
||||
}else if(index === 2)
|
||||
}else if(index === "2")
|
||||
{
|
||||
ssvepFifteenHzTimer.start();
|
||||
hitTimer.start();
|
||||
@@ -147,6 +157,60 @@ Item {
|
||||
hitIndex = index;
|
||||
}
|
||||
|
||||
function getStr(intArr){
|
||||
var str = "";
|
||||
for(var i=0;i<intArr.length;i++)
|
||||
str += String.fromCharCode(intArr[i]);
|
||||
return str;
|
||||
}
|
||||
|
||||
function getIntArr(str){
|
||||
var ret = [];
|
||||
for(var i=0;i<str.length;i++)
|
||||
ret.push(str.charCodeAt(i));
|
||||
return ret;
|
||||
}
|
||||
|
||||
TcpSocket{
|
||||
id: clientSocket
|
||||
peer: "127.0.0.1"
|
||||
port: 8099
|
||||
onBytesReceived:
|
||||
{
|
||||
var cmd = getStr(bytes);
|
||||
console.info("Client received: " + cmd);
|
||||
if(cmd !== "0" && cmd !== "1" && cmd !== "2")
|
||||
{
|
||||
return;
|
||||
}
|
||||
ssvepHit(cmd);
|
||||
stopStimulate();
|
||||
|
||||
}
|
||||
onConnected:
|
||||
{
|
||||
console.info("Client socket connected");
|
||||
writeBytes(getIntArr("1"));
|
||||
}
|
||||
onDisconnected:
|
||||
{
|
||||
console.info("Client socket disconnected");
|
||||
bConnect = false;
|
||||
}
|
||||
onPeerChanged:
|
||||
{
|
||||
console.info("Client socket peer changed: " + peer);
|
||||
}
|
||||
onPortChanged:
|
||||
{
|
||||
console.info("Client socket port changed: " + port);
|
||||
}
|
||||
onError:
|
||||
{
|
||||
console.info("Client socket disconnected")
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 42
|
||||
|
||||
Reference in New Issue
Block a user