|
@@ -11,125 +11,90 @@
|
|
|
</el-row> -->
|
|
|
<el-row>
|
|
|
<el-col :span="1"> </el-col>
|
|
|
- <el-col :span="22" class='select_class_animation'>
|
|
|
- <!-- <span class="desSty"> 游戏场景</span>
|
|
|
-
|
|
|
- <el-select
|
|
|
- class="selectSty"
|
|
|
- size="mini"
|
|
|
- v-model="gameScene"
|
|
|
- placeholder="请选择"
|
|
|
- @change="changeGame"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="item in optionsGame"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
+ <el-col :span="22">
|
|
|
+ <div class="select_class_animation">
|
|
|
+ <span class="desSty">选择设备</span>
|
|
|
+ <el-select
|
|
|
+ v-model="equipment"
|
|
|
+ placeholder="请选择"
|
|
|
+ class="selectSty"
|
|
|
+ size="medium"
|
|
|
+ @change="equipmentFun"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ class="select_option"
|
|
|
+ v-for="item in optionsEquipment"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+
|
|
|
+ <span class="desSty">游戏难度</span>
|
|
|
+ <el-select
|
|
|
+ v-model="gameDifficulty"
|
|
|
+ placeholder="请选择"
|
|
|
+ class="selectSty"
|
|
|
+ size="medium"
|
|
|
+ @change="gameDiffFun"
|
|
|
>
|
|
|
- </el-option>
|
|
|
- </el-select> -->
|
|
|
- <span class="desSty">选择设备</span>
|
|
|
- <el-select
|
|
|
- v-model="equipment"
|
|
|
- placeholder="请选择"
|
|
|
- class="selectSty"
|
|
|
- size="medium"
|
|
|
- @change="equipmentFun"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- class='select_option'
|
|
|
- v-for="item in optionsEquipment"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
+ <el-option
|
|
|
+ v-for="item in difficultyOptions"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+
|
|
|
+ <span class="desSty">游戏时间</span>
|
|
|
+ <el-select
|
|
|
+ v-model="gameTime"
|
|
|
+ placeholder="请选择"
|
|
|
+ class="selectSty"
|
|
|
+ size="medium"
|
|
|
+ @change="gameTimeFun"
|
|
|
>
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
-
|
|
|
- <span class="desSty">游戏难度</span>
|
|
|
- <el-select
|
|
|
- v-model="gameDifficulty"
|
|
|
- placeholder="请选择"
|
|
|
- class="selectSty"
|
|
|
- size="medium"
|
|
|
- @change="gameDiffFun"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="item in difficultyOptions"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
+ <el-option
|
|
|
+ v-for="item in timeOptions"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+
|
|
|
+ <div class="equipment_status">
|
|
|
+ <span class="desSty">设备未连接:</span>
|
|
|
+ <img
|
|
|
+ style="width: 14px; height: 20px"
|
|
|
+ src="../assets/newAnimation/lanya.png"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <span class="desSty">查看波形图</span>
|
|
|
+ <span
|
|
|
+ style="font-size: 12px"
|
|
|
+ v-show="equipment == '2' && pulseTimeNum < 180 && pulseTimeNum > 0"
|
|
|
+ >还剩{{ timeShow }}开始</span
|
|
|
>
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
-
|
|
|
- <span class="desSty">游戏时间</span>
|
|
|
- <el-select
|
|
|
- v-model="gameTime"
|
|
|
- placeholder="请选择"
|
|
|
- class="selectSty"
|
|
|
- size="medium"
|
|
|
- @change="gameTimeFun"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="item in timeOptions"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
+ <span
|
|
|
+ style="font-size: 12px"
|
|
|
+ v-show="buttonFlag == '结束' && gameTimeTimerFlag"
|
|
|
+ >{{ timeShow }}</span
|
|
|
>
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- <span
|
|
|
- style="font-size: 12px"
|
|
|
- v-show="equipment == '2' && pulseTimeNum < 180 && pulseTimeNum > 0"
|
|
|
- >还剩{{ timeShow }}开始</span
|
|
|
- >
|
|
|
- <span
|
|
|
- style="font-size: 12px"
|
|
|
- v-show="buttonFlag == '结束' && gameTimeTimerFlag"
|
|
|
- >{{ timeShow }}</span
|
|
|
- >
|
|
|
+ <div class="animation-middle-m"> </div>
|
|
|
+ <el-button
|
|
|
+ @click="startTest"
|
|
|
+ size="small"
|
|
|
+ class="xl_animation_button"
|
|
|
+ style="float: right; font-size: 12px"
|
|
|
+ >{{ buttonFlag }}</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
|
|
|
- <el-button
|
|
|
- @click="startTest"
|
|
|
- size="small"
|
|
|
- class="xl_animation_button"
|
|
|
- style="float: right; font-size: 12px"
|
|
|
- >{{ buttonFlag }}</el-button
|
|
|
- >
|
|
|
- <el-row>
|
|
|
- <!-- <el-col :span="4" style="text-align: left">
|
|
|
- 游戏场景
|
|
|
- <el-select
|
|
|
- v-model="value"
|
|
|
- placeholder="选择游戏场景"
|
|
|
- @change="changeGame"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="item in options"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
- >
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </el-col> -->
|
|
|
- <!-- <el-col :span="12">
|
|
|
- <span>请选择反馈指标</span>
|
|
|
- <el-select v-model="valueAttention" placeholder="请选择">
|
|
|
- <el-option
|
|
|
- v-for="item in optionsAttention"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
- >
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </el-col>
|
|
|
- style="display: block; height: 72vh; margin-top: 10px"
|
|
|
- -->
|
|
|
- </el-row>
|
|
|
+ <el-row> </el-row>
|
|
|
<el-row> </el-row>
|
|
|
<el-row>
|
|
|
<el-col :span="24">
|
|
@@ -164,6 +129,8 @@ const { ipcRenderer } = require("electron");
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
+ //是否是单个训练
|
|
|
+ singleFlag: true,
|
|
|
buttonDisable: true,
|
|
|
//脉搏开始前倒计时
|
|
|
pulseTimeNum: 180,
|
|
@@ -235,19 +202,71 @@ export default {
|
|
|
gameTimeTimer: null,
|
|
|
//是否显示的倒计时标志
|
|
|
gameTimeTimerFlag: false,
|
|
|
- //脉搏原始数据
|
|
|
+
|
|
|
+ //脑电变量
|
|
|
+ waveData: [],
|
|
|
+ // 全量
|
|
|
+ waveDataAll: [],
|
|
|
+
|
|
|
+ deltaDataFlag: [],
|
|
|
+ // 全量
|
|
|
+ deltaDataFlagAll: [],
|
|
|
+
|
|
|
+ deltaData: [],
|
|
|
+ // 全量
|
|
|
+ deltaDataAll: [],
|
|
|
+
|
|
|
+ thetaData: [],
|
|
|
+ // 全量
|
|
|
+ thetaDataAll: [],
|
|
|
+
|
|
|
+ lowAlphaData: [],
|
|
|
+ // 全量
|
|
|
+ lowAlphaDataAll: [],
|
|
|
+
|
|
|
+ highAlphaData: [],
|
|
|
+ // 全量
|
|
|
+ highAlphaDataAll: [],
|
|
|
+
|
|
|
+ lowBetaData: [],
|
|
|
+ // 全量
|
|
|
+ lowBetaDataAll: [],
|
|
|
+
|
|
|
+ highBetaData: [],
|
|
|
+ // 全量
|
|
|
+ highBetaDataAll: [],
|
|
|
+
|
|
|
+ lowGammaData: [],
|
|
|
+ // 全量
|
|
|
+ lowGammaDataAll: [],
|
|
|
+
|
|
|
+ midGammaData: [],
|
|
|
+ // 全量
|
|
|
+ midGammaDataAll: [],
|
|
|
+
|
|
|
+ noiseData: [],
|
|
|
+ // 全量
|
|
|
+ noiseDataAll: [],
|
|
|
+
|
|
|
+ attentionData: [],
|
|
|
+ // 全量
|
|
|
+ attentionDataAll: [],
|
|
|
+
|
|
|
+ meditationData: [],
|
|
|
+ // 全量
|
|
|
+ meditationDataAll: [],
|
|
|
+
|
|
|
+ focusNao: [],
|
|
|
+ // 全量
|
|
|
+ focusNaoAll: [],
|
|
|
};
|
|
|
},
|
|
|
- activated() {
|
|
|
- let that = this;
|
|
|
- setTimeout(() => {
|
|
|
- that.getSize();
|
|
|
- }, 5000);
|
|
|
- },
|
|
|
mounted() {
|
|
|
+ //添加监听接收到数据后开始驱动
|
|
|
+ //脑电监听
|
|
|
+
|
|
|
//进来之前得到传过来的参数
|
|
|
//调用切换场景的方法
|
|
|
-
|
|
|
let that = this;
|
|
|
let count = 0;
|
|
|
var k = 1;
|
|
@@ -262,129 +281,119 @@ export default {
|
|
|
}
|
|
|
flagAnimation = false;
|
|
|
});
|
|
|
-
|
|
|
- Utils.$on("fatigue", function (msg) {
|
|
|
- if (msg.status == "未连接") {
|
|
|
- that.eleFlag = "未连接";
|
|
|
- // that.resetData();
|
|
|
- //如果是未连接则点击按钮时提醒脑电未连接
|
|
|
- } else if (msg.status == "已连接") {
|
|
|
- that.eleFlag = "已连接";
|
|
|
- //已连接后处理得到的值
|
|
|
- let a = msg.attentionGame;
|
|
|
- let diff = 1;
|
|
|
- if (that.gameDifficulty == 1) {
|
|
|
- diff = 1.5;
|
|
|
- } else if (that.gameDifficulty == 2) {
|
|
|
- diff = 1.25;
|
|
|
- } else {
|
|
|
- diff = 1;
|
|
|
+ //设置定时器每秒定时器
|
|
|
+ // setInterval(() => {
|
|
|
+ // //当按钮开始时需要发送信息到
|
|
|
+ // //当按钮处于结束状态时
|
|
|
+ // if (that.buttonFlag == "结束") {
|
|
|
+ // //当前设备是选择的哪一个
|
|
|
+ // //如果选择的是脑电时
|
|
|
+ // //判断脑电是否连接
|
|
|
+ // //如果脑电连接则发送send(0)
|
|
|
+ // if (that.equipment == 1) {
|
|
|
+ // if (that.eleFlag == "未连接") {
|
|
|
+ // if (that.gameValue != 0) {
|
|
|
+ // that.send(0);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // if (that.pulseFlag == "未连接") {
|
|
|
+ // if (that.gameValue != 0) {
|
|
|
+ // that.send(0);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }, 1000);
|
|
|
+ setTimeout(() => {
|
|
|
+ that.getSize();
|
|
|
+ }, 5000);
|
|
|
+ setTimeout(() => {
|
|
|
+ that.changeGame(parseInt(that.$route.query.gameType));
|
|
|
+ }, 1000);
|
|
|
+ that.singleFlag = that.$route.query.single;
|
|
|
+ console.log(that.singleFlag);
|
|
|
+ ipcRenderer.on("accelerationData-message", (event, arg) => {
|
|
|
+ if (arg["_c"].size == 1) {
|
|
|
+ this.waveData.push(arg["_c"].get("rawWaveData"));
|
|
|
+ this.waveDataAll.push(arg["_c"].get("rawWaveData"));
|
|
|
+ if (this.waveData.length > 5120) {
|
|
|
+ this.waveData.shift();
|
|
|
}
|
|
|
- if (that.equipment === 1 && that.buttonFlag == "结束") {
|
|
|
- if (a == 0) {
|
|
|
- that.gameValue = 0;
|
|
|
- } else {
|
|
|
- that.gameValue = (a / 100) * diff;
|
|
|
+ } else {
|
|
|
+ if (arg["_c"].size == 11) {
|
|
|
+ // 当不为undefined时
|
|
|
+ let ll = 11;
|
|
|
+ // 获取长度
|
|
|
+ this.deltaDataFlag.push(arg["_c"].get("Delta"));
|
|
|
+ this.deltaDataFlagAll.push(arg["_c"].get("Delta"));
|
|
|
+ if (this.deltaDataFlag.length > ll) {
|
|
|
+ this.deltaDataFlag.shift();
|
|
|
}
|
|
|
- if (isNaN(that.gameValue)) {
|
|
|
- that.gameValue = 0;
|
|
|
+ this.noiseData.push(arg["_c"].get("Signal"));
|
|
|
+ this.noiseDataAll.push(arg["_c"].get("Signal"));
|
|
|
+ if (this.noiseData.length > ll) {
|
|
|
+ this.noiseData.shift();
|
|
|
}
|
|
|
- that.send(that.gameValue);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- Utils.$on("pulse", function (msg) {
|
|
|
- if (msg.status == "未连接") {
|
|
|
- that.pulseFlag = "未连接";
|
|
|
- // that.resetData();
|
|
|
- //假如脉搏是未连接的,点击开始按钮时提示脉搏未连接
|
|
|
- } else {
|
|
|
- that.pulseFlag = "已连接";
|
|
|
- //假如已经连接则判断返回的时间字段是多少
|
|
|
- //当前是否已连接如果已连接查看是否是脉搏如果是脉搏则判断3分钟是否已过
|
|
|
-
|
|
|
- that.waitTimePluse = msg.waitTime;
|
|
|
- if (msg.waitTime == 0) {
|
|
|
- //将指标写入文件
|
|
|
- console.log("------------------");
|
|
|
- // that.saveFileGame(JSON.stringify(msg.bbGame))
|
|
|
- // fs.appendFile(’./data1.txt’,‘hello\n’,(err)=>{
|
|
|
- // if(err) throw err;
|
|
|
- // console.log(‘写入成功’);
|
|
|
- // });
|
|
|
-
|
|
|
- let a = msg.pulseGame;
|
|
|
-
|
|
|
- // if (a > 30) {
|
|
|
- // a = 30;
|
|
|
- // }
|
|
|
- let diff = 1;
|
|
|
- if (that.gameDifficulty == 1) {
|
|
|
- diff = 1.5;
|
|
|
- } else if (that.gameDifficulty == 2) {
|
|
|
- diff = 1.25;
|
|
|
- } else {
|
|
|
- diff = 1;
|
|
|
+ this.attentionData.push(arg["_c"].get("Attention"));
|
|
|
+ this.attentionDataAll.push(arg["_c"].get("Attention"));
|
|
|
+ if (this.attentionData.length > ll) {
|
|
|
+ this.attentionData.shift();
|
|
|
}
|
|
|
- if (that.equipment === 2 && that.buttonFlag == "结束") {
|
|
|
- //如果a等于0时gameValue就等于0
|
|
|
- if (a == 0) {
|
|
|
- that.gameValue = 0;
|
|
|
- } else {
|
|
|
- that.gameValue = (a / 100) * diff * 2;
|
|
|
- }
|
|
|
-
|
|
|
- //当发现这个值是NAN时需要将值改为0
|
|
|
- if (isNaN(that.gameValue)) {
|
|
|
- that.gameValue = 0;
|
|
|
- }
|
|
|
-
|
|
|
- //当测试发现数据是NAN时
|
|
|
-
|
|
|
- that.send(that.gameValue);
|
|
|
+ this.meditationData.push(arg["_c"].get("Meditation"));
|
|
|
+ this.meditationDataAll.push(arg["_c"].get("Meditation"));
|
|
|
+ if (this.meditationData.length > ll) {
|
|
|
+ this.attentionData.shift();
|
|
|
}
|
|
|
- //发送信号的时候需要判断选择的难度
|
|
|
- //简单为现在的值乘以1
|
|
|
- //普通为现在的值乘以0.8
|
|
|
- //困难为现在的值乘以0.6
|
|
|
- } else {
|
|
|
- //假如已经连接了,但是不够3分钟点击按钮时进行提示
|
|
|
- //采集时间限制,倒计时三分钟
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- //设置定时器每秒定时器
|
|
|
- setInterval(() => {
|
|
|
- //当按钮开始时需要发送信息到
|
|
|
- //当按钮处于结束状态时
|
|
|
- if (that.buttonFlag == "结束") {
|
|
|
- //当前设备是选择的哪一个
|
|
|
- //如果选择的是脑电时
|
|
|
- //判断脑电是否连接
|
|
|
- //如果脑电连接则发送send(0)
|
|
|
- if (that.equipment == 1) {
|
|
|
- if (that.eleFlag == "未连接") {
|
|
|
- if (that.gameValue != 0) {
|
|
|
- that.send(0);
|
|
|
- }
|
|
|
+ this.thetaData.push(arg["_c"].get("Theta"));
|
|
|
+ this.thetaDataAll.push(arg["_c"].get("Theta"));
|
|
|
+ if (this.thetaData.length > ll) {
|
|
|
+ this.thetaData.shift();
|
|
|
}
|
|
|
- } else {
|
|
|
- if (that.pulseFlag == "未连接") {
|
|
|
- if (that.gameValue != 0) {
|
|
|
- that.send(0);
|
|
|
- }
|
|
|
+ this.lowAlphaData.push(arg["_c"].get("LowAlpha"));
|
|
|
+ this.lowAlphaDataAll.push(arg["_c"].get("LowAlpha"));
|
|
|
+ if (this.lowAlphaData.length > ll) {
|
|
|
+ this.lowAlphaData.shift();
|
|
|
+ }
|
|
|
+ this.highAlphaData.push(arg["_c"].get("HighAlpha"));
|
|
|
+ this.highAlphaDataAll.push(arg["_c"].get("HighAlpha"));
|
|
|
+ if (this.highAlphaData.length > ll) {
|
|
|
+ this.highAlphaData.shift();
|
|
|
+ }
|
|
|
+ this.lowBetaData.push(arg["_c"].get("LowBeta"));
|
|
|
+ this.lowBetaDataAll.push(arg["_c"].get("LowBeta"));
|
|
|
+ if (this.lowBetaData.length > ll) {
|
|
|
+ this.lowBetaData.shift();
|
|
|
+ }
|
|
|
+ this.highBetaData.push(arg["_c"].get("HighBeta"));
|
|
|
+ this.highBetaDataAll.push(arg["_c"].get("HighBeta"));
|
|
|
+ if (this.highBetaData.length > ll) {
|
|
|
+ this.highBetaData.shift();
|
|
|
+ }
|
|
|
+ this.lowGammaData.push(arg["_c"].get("LowGamma"));
|
|
|
+ this.lowGammaDataAll.push(arg["_c"].get("LowGamma"));
|
|
|
+ if (this.lowGammaData.length > ll) {
|
|
|
+ this.lowGammaData.shift();
|
|
|
+ }
|
|
|
+ this.midGammaData.push(arg["_c"].get("MiddleGamma"));
|
|
|
+ this.midGammaDataAll.push(arg["_c"].get("MiddleGamma"));
|
|
|
+ if (this.midGammaData.length > ll) {
|
|
|
+ this.midGammaData.shift();
|
|
|
+ }
|
|
|
+ this.focusNao.push(arg["_c"].get("Attention"));
|
|
|
+ this.focusNaoAll.push(arg["_c"].get("Attention"));
|
|
|
+ if (this.focusNao > ll) {
|
|
|
+ this.focusNao.shift();
|
|
|
+ }
|
|
|
+ // this.numEleDom = this.focusNaoAll.length.toString();
|
|
|
+ if (this.currentFlag) {
|
|
|
+ this.renderEegOne();
|
|
|
+ this.renderEegTwo();
|
|
|
+ this.renderEegThree();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }, 1000);
|
|
|
- setTimeout(() => {
|
|
|
- that.getSize();
|
|
|
- }, 5000);
|
|
|
- setTimeout(() => {
|
|
|
- that.changeGame(parseInt(that.$route.query.gameType));
|
|
|
- }, 1000);
|
|
|
- // that.changeGame(parseInt(that.$route.query.gameType));
|
|
|
+ });
|
|
|
},
|
|
|
methods: {
|
|
|
//保存文件
|
|
@@ -717,6 +726,11 @@ export default {
|
|
|
};
|
|
|
</script>
|
|
|
<style scoped>
|
|
|
+.equipment_status {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
.main_right_height {
|
|
|
height: 100vh !important;
|
|
|
display: block !important;
|
|
@@ -762,9 +776,17 @@ canvas {
|
|
|
}
|
|
|
.animation_fk {
|
|
|
}
|
|
|
-.select_option{
|
|
|
+.select_option {
|
|
|
font-size: 10px;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+.select_class_animation {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+.animation-middle-m {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ flex: 1;
|
|
|
+}
|
|
|
</style>
|