소스 검색

修改生物反馈问题

[plg137200.] 1 년 전
부모
커밋
d08ecd756d

+ 4 - 4
src/main/index.js

@@ -55,11 +55,11 @@ let loadingWindow
 //设置访问路径
 //打包访问的路径
 
-let serveUrl = "./resources/exe"
-let serveUrlJar = '\\resources\\exe'
+// let serveUrl = "./resources/exe"
+// let serveUrlJar = '\\resources\\exe'
 //本地访问的路径
-// let serveUrl = "./exe"
-// let serveUrlJar = '\\exe'
+let serveUrl = "./exe"
+let serveUrlJar = '\\exe'
 /**
  * Set `__static` path to static files in production
  * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html

BIN
src/renderer/assets/newAnimation/lanya.png


BIN
src/renderer/assets/newAnimation/lanyaActive.png


+ 60 - 14
src/renderer/components/Animation.vue

@@ -1,7 +1,11 @@
 <template>
   <div class="main_right_height">
+    <div class="main_tab_double">
+      <el-button :class="{'xl_tab_active_button':singlePeople,'xl_tab_button':singlePeople==false}"  style='margin-right:50px' @click='singlePeople=true'>单人训练</el-button>
+      <el-button :class="{'xl_tab_active_button':singlePeople==false,'xl_tab_button':singlePeople}" @click='singlePeople=false'>双人训练</el-button>
+    </div>
     <div class="animation_main">
-      <div class="animation_k" @click='goPage("/menu/animationDes",4)'>
+      <div class="animation_k" @click="goPage('/menu/animationDes', 4)">
         <img
           class="animation_img_cla"
           src="../assets/newAnimation/baobaotong.png"
@@ -9,7 +13,7 @@
         <div class="animation_des">&nbsp;</div>
         <span class="animation_des_font">爆爆桶</span>
       </div>
-      <div class="animation_k" @click='goPage("/menu/animationDes",5)'>
+      <div class="animation_k" @click="goPage('/menu/animationDes', 5)">
         <img
           class="animation_img_cla"
           src="../assets/newAnimation/zhadan.png"
@@ -18,7 +22,7 @@
         <span class="animation_des_font">炸弹</span>
       </div>
 
-      <div class="animation_k" @click='goPage("/menu/animationDes",2)'>
+      <div class="animation_k" @click="goPage('/menu/animationDes', 2)">
         <img
           class="animation_img_cla"
           src="../assets/newAnimation/flower.png"
@@ -27,18 +31,18 @@
         <span class="animation_des_font">心之花</span>
       </div>
     </div>
-    <div class="animation_main_two" >
-      <div class="animation_k" @click='goPage("/menu/animationDes",1)'>
+    <div class="animation_main_two">
+      <div class="animation_k" @click="goPage('/menu/animationDes', 1)">
         <img class="animation_img_cla" src="../assets/newAnimation/fire.png" />
         <div class="animation_des">&nbsp;</div>
         <span class="animation_des_font">心灵之火</span>
       </div>
-      <div class="animation_k" @click='goPage("/menu/animationDes",3)'>
+      <div class="animation_k" @click="goPage('/menu/animationDes', 3)">
         <img class="animation_img_cla" src="../assets/newAnimation/cat.png" />
         <div class="animation_des">&nbsp;</div>
         <span class="animation_des_font">急速赛车</span>
       </div>
-      <div class="animation_k"  @click='goPage("/menu/animationDes",6)'>
+      <div class="animation_k" @click="goPage('/menu/animationDes', 6)">
         <img class="animation_img_cla" src="../assets/newAnimation/ball.png" />
         <div class="animation_des">&nbsp;</div>
         <span class="animation_des_font">漂浮球</span>
@@ -49,18 +53,21 @@
 <script>
 export default {
   data() {
-    return {};
+    return {
+      singlePeople:true
+    };
+  },
+  methods: {
+    goPage(val, typeName) {
+      this.$router.push({ path: val, query: { gameType: typeName,single:this.singlePeople} });
+    },
   },
-  methods:{
-    goPage(val,typeName){
-      this.$router.push({path:val,query:{gameType:typeName}})
-    }
-  }
 };
 </script>
 <style scoped>
+
 .animation_main {
-  margin-top: 14vh;
+  margin-top: 2vh;
   display: flex;
   flex-direction: row;
   justify-content: space-around;
@@ -116,4 +123,43 @@ export default {
   border-bottom-right-radius: 15px;
   justify-content: center;
 }
+.main_tab_double {
+ 
+  display: flex;
+  flex-direction: row;
+  justify-content: center;
+   margin-top: 10vh;
+}
+.xl_tab_button,.xl_tab_button:hover,.xl_tab_button:focus,.xl_tab_button:active {
+  background: #E4E4E4;
+  opacity: 1;
+  border-radius: 8px;
+  border: 1px solid #E4E4E4;
+  color: #000000;
+  font-weight: 700;
+  /* border-radius: 18px; */
+  /* font-size: 14px; */
+  padding-left: 40px;
+  padding-right: 40px;
+  padding-top:12px;
+  padding-bottom:12px;
+  font-family: PingFang SC;
+  font-weight: 400;
+}
+.xl_tab_active_button,.xl_tab_active_button:hover,.xl_tab_active_button:focus,.xl_tab_active_button:active{
+  background: #0FB577;
+  opacity: 1;
+  border-radius: 8px;
+  border: 1px solid #0FB577;
+  color: #ffffff;
+  font-weight: 700;
+  /* border-radius: 18px; */
+  /* font-size: 14px; */
+  padding-left: 40px;
+  padding-right: 40px;
+  padding-top:12px;
+  padding-bottom:12px;
+  font-family: PingFang SC;
+  font-weight: 400;
+}
 </style>

+ 261 - 239
src/renderer/components/AnimationDes.vue

@@ -11,125 +11,90 @@
     </el-row> -->
     <el-row>
       <el-col :span="1"> &nbsp; </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>&nbsp;
+          <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>
+          &nbsp;&nbsp;&nbsp;&nbsp;
+          <span class="desSty">游戏难度</span>&nbsp;
+          <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>
+          &nbsp;&nbsp;&nbsp;&nbsp;
+          <span class="desSty">游戏时间</span>&nbsp;
+          <el-select
+            v-model="gameTime"
+            placeholder="请选择"
+            class="selectSty"
+            size="medium"
+            @change="gameTimeFun"
           >
-          </el-option>
-        </el-select>
-        &nbsp;&nbsp;
-        <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>
+          &nbsp;&nbsp;&nbsp;&nbsp;
+          <div class="equipment_status">
+            <span class="desSty">设备未连接:</span>
+            <img
+              style="width: 14px; height: 20px"
+              src="../assets/newAnimation/lanya.png"
+            />
+          </div>
+          &nbsp;&nbsp;&nbsp;&nbsp;
+          <span class="desSty">查看波形图</span>
+          <span
+            style="font-size: 12px"
+            v-show="equipment == '2' && pulseTimeNum < 180 && pulseTimeNum > 0"
+            >还剩{{ timeShow }}开始</span
           >
-          </el-option>
-        </el-select>
-        &nbsp;&nbsp;
-        <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">&nbsp;</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>&nbsp;&nbsp;&nbsp;&nbsp;
-            <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>

+ 1 - 1
src/renderer/components/Electrical.vue

@@ -334,7 +334,7 @@ export default {
           this.meditationData.push(arg["_c"].get("Meditation"));
           this.meditationDataAll.push(arg["_c"].get("Meditation"));
           if (this.meditationData.length > ll) {
-            this.attentionData.shift();
+            this.meditationData.shift();
           }
           this.thetaData.push(arg["_c"].get("Theta"));
           this.thetaDataAll.push(arg["_c"].get("Theta"));