Browse Source

修改生物反馈素材联调

plg 1 year ago
parent
commit
1b281d96a9

+ 2 - 1
src/main/index.js

@@ -92,7 +92,8 @@ function createLoadingWindow() {   //加载页面窗口
     // allowRunningInsecureContent:true,
     webPreferences: {
       contextIsolation: false, // 设置此项为false后,才可在渲染进程中使用electron api
-      nodeIntegration: true
+      nodeIntegration: true,
+      partition:String(+new Date())   //每次都以隐私窗口打开
     }
   })
 

+ 37 - 31
src/renderer/components/AnimationDes.vue

@@ -388,7 +388,7 @@ export default {
       focusNaoAll: [],
       // urlThreeP: "../../../static/candle/index.html",
       // urlThreeP: __static + "/candle/index.html",
-      urlThreeP: "../../../static/long/index.html",
+      urlThreeP: "../../../static/loong_1/index.html",
       // urlThreeP: __static + "/balance/index.html",
       // pubSrc: "../../../static",
       pubsrc: __static,
@@ -427,6 +427,8 @@ export default {
 
       //新增已选列表变量
       isSelectedList: [],
+      //单人驱动动画的变量
+      attentionAnimation: 0,
     };
   },
   mounted() {
@@ -488,6 +490,7 @@ export default {
     //进入生物反馈页面扫描设备
     // this.queryScan();
     that.listTimeFlag = setInterval(that.connectList, 2000);
+    that.listTimeFlag = setInterval(that.sendAtten, 1000);
   },
   beforeDestroy() {
     clearTimeout(this.mergeTimeFlag);
@@ -504,6 +507,14 @@ export default {
   },
   destroyed() {},
   methods: {
+    //单人人向传输数据
+    sendAtten() {
+      // this.attentionAnimation = Math.random();
+      // console.log(this.attentionAnimation);
+      let val = this.attentionAnimation;
+      let a = parseFloat(val/100)
+      this.send(a);
+    },
     rssiFor(val) {
       if (val == 0) {
         return "";
@@ -640,11 +651,9 @@ export default {
             if (this.noiseData.length > ll) {
               this.noiseData.shift();
             }
-            if (this.equipment == 1 && this.linkStatus && this.buttonFlag == "结束") {
-              this.send(Math.random() * 10);
-            }
 
-            //先设为随机数
+            //记录脑电指标
+            this.attentionAnimation = arg["_c"].get("Attention");
 
             this.attentionData.push(arg["_c"].get("Attention"));
             this.attentionDataAll.push(arg["_c"].get("Attention"));
@@ -855,7 +864,7 @@ export default {
     initWebsocket() {
       // const wsuri = "ws://192.168.1.103:8000/ws?uid=client&to_uid=server";
       // const wsuri = "ws://localhost:8000/ws?uid=client&to_uid=server";
-      const wsuri = "ws://192.168.1.2:8000/ws?uid=client&to_uid=server";
+      const wsuri = "ws://192.168.1.13:8000/ws?uid=client&to_uid=server";
       this.websock = new WebSocket(wsuri);
       this.websock.onmessage = this.websocketonmessage;
       this.websock.onopen = this.websocketonopen;
@@ -879,13 +888,7 @@ export default {
       let that = this;
       //数据接收
       const redata = JSON.parse(e.data);
-      // console.log(redata);
-      // if(redata.content == "设备连接成功"){
-      //   console.log(redata);
-      // }
-      // if(redata.content == "设备连接失败"){
-      //   console.log(redata);
-      // }
+  
 
       if (
         redata.content != "开启扫描成功" &&
@@ -952,10 +955,10 @@ export default {
                   //当心电为5分钟的数据时
                   // 100*60*5
                   // 30000
-                  if(that.userLink.ecgAllList.length==30000){
+                  if (that.userLink.ecgAllList.length == 30000) {
                     let a = that.userLink.ecgAllList.toString();
-                    console.log(a)
-                    fs.writeFileSync('./aaaaa.txt',a)
+                    console.log(a);
+                    fs.writeFileSync("./aaaaa.txt", a);
                   }
 
                   that.userLink.ecgSectionList.push(tmp);
@@ -1005,7 +1008,7 @@ export default {
                 }
               }
               that.isSelectedList = JSON.parse(JSON.stringify(listBarring));
-              console.log(that.isSelectedList);
+   
               that.connectedData = JSON.parse(JSON.stringify(listBarring));
 
               //   that.userLink.mac
@@ -1026,8 +1029,7 @@ export default {
               //listBarring  将值赋值给已选列表的值
               //判断当前是脑电吗
             } else if (redata.msgType == "disConnect") {
-              console.log("------------------------------------");
-              console.log(dataLin);
+     
               let mac = dataLin.m;
               let list = JSON.parse(JSON.stringify(that.connectedData));
               let list1 = [];
@@ -1047,14 +1049,11 @@ export default {
               }
               that.isSelectedList = JSON.parse(JSON.stringify(listLin1));
 
-              console.log("断开连接后已选列表进行变化");
-              console.log(that.connectedData);
               if (that.userLink.mac == mac) {
                 that.linkStatus = false;
                 that.userLink.mac = "";
               }
             } else if (redata.msgType == "connect") {
-              console.log(dataLin);
               //设备正在等待
               //设备连接成功
               if (dataLin.state == "SUCCESS") {
@@ -1542,8 +1541,9 @@ export default {
       this.$refs.unityIframe.contentWindow.changeSize(width, height);
     },
     send(val) {
-      // this.$refs.unityIframe.contentWindow.Bloomsize(val);
-      this.$refs.unityIframe.contentWindow.CallUnity();
+      
+      this.$refs.unityIframe.contentWindow.Bloomsize(val);
+      // this.$refs.unityIframe.contentWindow.CallUnity();
     },
     // btt() {
     //   let that = this;
@@ -1562,27 +1562,32 @@ export default {
         case 1:
           //this.urlThreeP = this.pubSrc + "/candle/index.html";
           // this.urlThreeP = pubSrc+ + "/candle/index.html";
-          this.urlThreeP = __static + "/long/index.html";
+          this.urlThreeP = "../../../static/loong_1/index.html";
+          // this.urlThreeP = __static + "/long/index.html";
           this.delayTime();
           break;
         case 2:
+           this.urlThreeP = "../../../static/mabenpao/index.html";
           // this.urlThreeP = this.pubSrc + "/flower/index.html";
-          this.urlThreeP = __static + "/mabenpao/index.html";
+          //this.urlThreeP = __static + "/mabenpao/index.html";
           this.delayTime();
           break;
         case 3:
+          this.urlThreeP = "../../../static/tianqi/index.html";
           // this.urlThreeP = this.pubSrc + "/car/index.html";
-          this.urlThreeP = __static + "/tianqi/index.html";
+          //this.urlThreeP = __static + "/tianqi/index.html";
           this.delayTime();
           break;
         case 4:
           // this.urlThreeP = this.pubSrc + "/baobaotong/index.html";
-          this.urlThreeP = __static + "/yanhua/index.html";
+          this.urlThreeP = "../../../static/yanhua/index.html";
+          //this.urlThreeP = __static + "/yanhua/index.html";
           this.delayTime();
           break;
         case 5:
+          this.urlThreeP = "../../../static/saiche/index.html";
           // this.urlThreeP = this.pubSrc + "/bomb/index.html";
-          this.urlThreeP = __static + "/saiche/index.html";
+          // this.urlThreeP = __static + "/saiche/index.html";
           this.delayTime();
           break;
         case 6:
@@ -1591,8 +1596,9 @@ export default {
           this.delayTime();
           break;
         default:
-          // this.urlThreeP = this.pubSrc + "/candle/index.html";
-          this.urlThreeP = __static + "/candle/index.html";
+          this.urlThreeP = "../../../static/loong_1/index.html";
+        // this.urlThreeP = this.pubSrc + "/candle/index.html";
+        // this.urlThreeP = __static + "/candle/index.html";
       }
       this.gameScene = val;
       this.flag = this.gameScene;

+ 2 - 4
src/renderer/components/AnimationDouble.vue

@@ -945,6 +945,7 @@ export default {
 
             // this.send(Math.random()*10)
             // console.log(arg["_c"].get("Attention")/100)
+            this.attentionAnimation=arg["_c"].get("Attention");
             this.attentionData.push(arg["_c"].get("Attention"));
             this.attentionDataAll.push(arg["_c"].get("Attention"));
             if (this.attentionData.length > ll) {
@@ -1040,9 +1041,6 @@ export default {
 
             //先设为随机数
 
-            // this.send(Math.random()*10)
-            // console.log(arg["_c"].get("Attention")/100)
-            this.attentionAnimation=arg["_c"].get("Attention")
             this.attentionDataSecond.push(arg["_c"].get("Attention"));
             this.attentionDataAllSecond.push(arg["_c"].get("Attention"));
             if (this.attentionDataSecond.length > ll) {
@@ -1409,7 +1407,7 @@ export default {
     //列表出现后点击连接并打开数据如果有数据才算成功
     //初始化websocket
     initWebsocket() {
-      const wsuri = "ws://192.168.1.2:8000/ws?uid=client&to_uid=server";
+      const wsuri = "ws://192.168.1.13:8000/ws?uid=client&to_uid=server";
       // const wsuri = "ws://localhost:8000/ws?uid=client&to_uid=server";
       this.websock = new WebSocket(wsuri);
       this.websock.onmessage = this.websocketonmessage;

+ 1 - 1
src/utils/http.js

@@ -14,7 +14,7 @@ axios.defaults.baseURL = global.dev;
 // 创建一个 Axios 实例并设置 baseURL 适应不同服务器的baseUrl
 const apiInstance = axios.create({
   // baseURL: 'http://localhost:8000/'
-  baseURL: 'http://192.168.1.2:8000/'
+  baseURL: 'http://192.168.1.13:8000/'
 });
 
 // axios.defaults.baseURL = "/api";

+ 0 - 0
static/long/Build/Longfeixing.data → static/loong_1/Build/Longfeixing.data


+ 0 - 0
static/long/Build/Longfeixing.framework.js → static/loong_1/Build/Longfeixing.framework.js


+ 0 - 0
static/long/Build/Longfeixing.loader.js → static/loong_1/Build/Longfeixing.loader.js


+ 0 - 0
static/long/Build/Longfeixing.wasm → static/loong_1/Build/Longfeixing.wasm


+ 0 - 0
static/long/ServiceWorker.js → static/loong_1/ServiceWorker.js


+ 0 - 0
static/long/TemplateData/favicon.ico → static/loong_1/TemplateData/favicon.ico


+ 0 - 0
static/long/TemplateData/icons/unity-logo-dark.png → static/loong_1/TemplateData/icons/unity-logo-dark.png


+ 0 - 0
static/long/TemplateData/icons/unity-logo-light.png → static/loong_1/TemplateData/icons/unity-logo-light.png


+ 0 - 0
static/long/TemplateData/progress-bar-empty-dark.png → static/loong_1/TemplateData/progress-bar-empty-dark.png


+ 0 - 0
static/long/TemplateData/progress-bar-empty-light.png → static/loong_1/TemplateData/progress-bar-empty-light.png


+ 0 - 0
static/long/TemplateData/progress-bar-full-dark.png → static/loong_1/TemplateData/progress-bar-full-dark.png


+ 0 - 0
static/long/TemplateData/progress-bar-full-light.png → static/loong_1/TemplateData/progress-bar-full-light.png


+ 0 - 0
static/long/TemplateData/style.css → static/loong_1/TemplateData/style.css


+ 0 - 0
static/long/TemplateData/unity-logo-dark.png → static/loong_1/TemplateData/unity-logo-dark.png


+ 0 - 0
static/long/TemplateData/unity-logo-light.png → static/loong_1/TemplateData/unity-logo-light.png


+ 11 - 2
static/long/index.html → static/loong_1/index.html

@@ -104,15 +104,24 @@
         // alert(message);
       });
     };
-
     function changeSize(width, height) {
       canvas.style.width = width + 'px';
       canvas.style.height = height + 'px';
     }
     function Bloomsize(concentration) {
-      gameInstance.SendMessage("dropal", "Fireworklocity", concentration);
+      console.log(concentration)
+   
+
+      this.gameInstance.SendMessage("dropal", "Fireworklocity", concentration);
       // gameInstance.SendMessage("baobaotong", "concentrationControl", concentration);
     }
+    // setInterval(() => {
+
+    //   let a = Math.random()
+    //   console.log(a)
+    //   Bloomsize(a)
+
+    // }, 1000);
 
     document.body.appendChild(script);
   </script>

+ 0 - 0
static/long/manifest.webmanifest → static/loong_1/manifest.webmanifest


+ 1 - 1
static/mabenpao/index.html

@@ -110,7 +110,7 @@
       canvas.style.height = height + 'px';
     }
     function Bloomsize(concentration) {
-      gameInstance.SendMessage("run", "Fireworklocity", concentration);
+      this.gameInstance.SendMessage("run", "Fireworklocity", concentration);
       // gameInstance.SendMessage("baobaotong", "concentrationControl", concentration);
     }
     document.body.appendChild(script);

+ 1 - 0
static/piaofuqiu/index.html

@@ -115,6 +115,7 @@
         function Bloomsize(buoyancy) {
             this.gameInstance.SendMessage("piaofuqiu", "buoyancyControl", buoyancy);
         }
+        
         // function buoyancyControl(buoyancy) {
         //     this.gameInstance.SendMessage("piaofuqiu", "buoyancyControl", buoyancy);
         // }

+ 102 - 98
static/run/index.html

@@ -1,116 +1,120 @@
 <!DOCTYPE html>
 <html lang="en-us">
-  <head>
-    <meta charset="utf-8">
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-    <title>Unity WebGL Player | Balance</title>
-    <link rel="shortcut icon" href="TemplateData/favicon.ico">
-    <link rel="stylesheet" href="TemplateData/style.css">
-    <link rel="manifest" href="manifest.webmanifest">
-  </head>
-  <body>
-    <div id="unity-container">
-      <canvas id="unity-canvas" width=960 height=600 tabindex="-1"></canvas>
-      <div id="unity-loading-bar">
-        <div id="unity-logo"></div>
-        <div id="unity-progress-bar-empty">
-          <div id="unity-progress-bar-full"></div>
-        </div>
+
+<head>
+  <meta charset="utf-8">
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+  <title>Unity WebGL Player | Balance</title>
+  <link rel="shortcut icon" href="TemplateData/favicon.ico">
+  <link rel="stylesheet" href="TemplateData/style.css">
+  <link rel="manifest" href="manifest.webmanifest">
+</head>
+
+<body>
+  <div id="unity-container">
+    <canvas id="unity-canvas" width=960 height=600 tabindex="-1"></canvas>
+    <div id="unity-loading-bar">
+      <div id="unity-logo"></div>
+      <div id="unity-progress-bar-empty">
+        <div id="unity-progress-bar-full"></div>
       </div>
-      <div id="unity-warning"> </div>
     </div>
-    <script>
-      window.addEventListener("load", function () {
-        if ("serviceWorker" in navigator) {
-          navigator.serviceWorker.register("ServiceWorker.js");
-        }
-      });
+    <div id="unity-warning"> </div>
+  </div>
+  <script>
+    window.addEventListener("load", function () {
+      if ("serviceWorker" in navigator) {
+        navigator.serviceWorker.register("ServiceWorker.js");
+      }
+    });
 
-      var container = document.querySelector("#unity-container");
-      var canvas = document.querySelector("#unity-canvas");
-      var loadingBar = document.querySelector("#unity-loading-bar");
-      var progressBarFull = document.querySelector("#unity-progress-bar-full");
-      var warningBanner = document.querySelector("#unity-warning");
+    var container = document.querySelector("#unity-container");
+    var canvas = document.querySelector("#unity-canvas");
+    var loadingBar = document.querySelector("#unity-loading-bar");
+    var progressBarFull = document.querySelector("#unity-progress-bar-full");
+    var warningBanner = document.querySelector("#unity-warning");
 
-      // Shows a temporary message banner/ribbon for a few seconds, or
-      // a permanent error message on top of the canvas if type=='error'.
-      // If type=='warning', a yellow highlight color is used.
-      // Modify or remove this function to customize the visually presented
-      // way that non-critical warnings and error messages are presented to the
-      // user.
-      function unityShowBanner(msg, type) {
-        function updateBannerVisibility() {
-          warningBanner.style.display = warningBanner.children.length ? 'block' : 'none';
-        }
-        var div = document.createElement('div');
-        div.innerHTML = msg;
-        warningBanner.appendChild(div);
-        if (type == 'error') div.style = 'background: red; padding: 10px;';
-        else {
-          if (type == 'warning') div.style = 'background: yellow; padding: 10px;';
-          setTimeout(function() {
-            warningBanner.removeChild(div);
-            updateBannerVisibility();
-          }, 5000);
-        }
-        updateBannerVisibility();
+    // Shows a temporary message banner/ribbon for a few seconds, or
+    // a permanent error message on top of the canvas if type=='error'.
+    // If type=='warning', a yellow highlight color is used.
+    // Modify or remove this function to customize the visually presented
+    // way that non-critical warnings and error messages are presented to the
+    // user.
+    function unityShowBanner(msg, type) {
+      function updateBannerVisibility() {
+        warningBanner.style.display = warningBanner.children.length ? 'block' : 'none';
+      }
+      var div = document.createElement('div');
+      div.innerHTML = msg;
+      warningBanner.appendChild(div);
+      if (type == 'error') div.style = 'background: red; padding: 10px;';
+      else {
+        if (type == 'warning') div.style = 'background: yellow; padding: 10px;';
+        setTimeout(function () {
+          warningBanner.removeChild(div);
+          updateBannerVisibility();
+        }, 5000);
       }
+      updateBannerVisibility();
+    }
 
-      var buildUrl = "Build";
-      var loaderUrl = buildUrl + "/run.loader.js";
-      var config = {
-        dataUrl: buildUrl + "/run.data",
-        frameworkUrl: buildUrl + "/run.framework.js",
-        codeUrl: buildUrl + "/run.wasm",
-        streamingAssetsUrl: "StreamingAssets",
-        companyName: "DefaultCompany",
-        productName: "Balance",
-        productVersion: "0.1",
-        showBanner: unityShowBanner,
-      };
+    var buildUrl = "Build";
+    var loaderUrl = buildUrl + "/run.loader.js";
+    var config = {
+      dataUrl: buildUrl + "/run.data",
+      frameworkUrl: buildUrl + "/run.framework.js",
+      codeUrl: buildUrl + "/run.wasm",
+      streamingAssetsUrl: "StreamingAssets",
+      companyName: "DefaultCompany",
+      productName: "Balance",
+      productVersion: "0.1",
+      showBanner: unityShowBanner,
+    };
 
-      // By default Unity keeps WebGL canvas render target size matched with
-      // the DOM size of the canvas element (scaled by window.devicePixelRatio)
-      // Set this to false if you want to decouple this synchronization from
-      // happening inside the engine, and you would instead like to size up
-      // the canvas DOM size and WebGL render target sizes yourself.
-      // config.matchWebGLToCanvasSize = false;
+    // By default Unity keeps WebGL canvas render target size matched with
+    // the DOM size of the canvas element (scaled by window.devicePixelRatio)
+    // Set this to false if you want to decouple this synchronization from
+    // happening inside the engine, and you would instead like to size up
+    // the canvas DOM size and WebGL render target sizes yourself.
+    // config.matchWebGLToCanvasSize = false;
 
-      if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
-        // Mobile device style: fill the whole browser client area with the game canvas:
-        var meta = document.createElement('meta');
-        meta.name = 'viewport';
-        meta.content = 'width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, shrink-to-fit=yes';
-        document.getElementsByTagName('head')[0].appendChild(meta);
-      }
+    if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
+      // Mobile device style: fill the whole browser client area with the game canvas:
+      var meta = document.createElement('meta');
+      meta.name = 'viewport';
+      meta.content = 'width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, shrink-to-fit=yes';
+      document.getElementsByTagName('head')[0].appendChild(meta);
+    }
 
-      loadingBar.style.display = "block";
+    loadingBar.style.display = "block";
 
-      var script = document.createElement("script");
-      script.src = loaderUrl;
-      script.onload = () => {
-        createUnityInstance(canvas, config, (progress) => {
-          progressBarFull.style.width = 100 * progress + "%";
-        }).then((unityInstance) => {
-          loadingBar.style.display = "none";
-          // fullscreenButton.onclick = () => {
-          //   unityInstance.SetFullscreen(1);
-          // };
-          this.gameInstance = unityInstance;
-          //gameInstance.SendMessage("Runvelocity","Firstvelocity","10.00,20.00");
-        }).catch((message) => {
-          alert(message);
-        });
-      };
-      function changeSize(width, height) {
+    var script = document.createElement("script");
+    script.src = loaderUrl;
+    script.onload = () => {
+      createUnityInstance(canvas, config, (progress) => {
+        progressBarFull.style.width = 100 * progress + "%";
+      }).then((unityInstance) => {
+        loadingBar.style.display = "none";
+        // fullscreenButton.onclick = () => {
+        //   unityInstance.SetFullscreen(1);
+        // };
+        this.gameInstance = unityInstance;
+        //gameInstance.SendMessage("Runvelocity","Firstvelocity","10.00,20.00");
+      }).catch((message) => {
+        alert(message);
+      });
+    };
+    function changeSize(width, height) {
       canvas.style.width = width + 'px';
       canvas.style.height = height + 'px';
     }
     function Bloomsize(concentration) {
-      gameInstance.SendMessage("Runvelocity", "Firstvelocity", concentration);
+      this.gameInstance.SendMessage("Runvelocity", "Firstvelocity", concentration);
       // gameInstance.SendMessage("baobaotong", "concentrationControl", concentration);
     }
-      document.body.appendChild(script);
-    </script>
-  </body>
-</html>
+
+    document.body.appendChild(script);
+  </script>
+</body>
+
+</html>

+ 3 - 1
static/saiche/index.html

@@ -109,9 +109,11 @@
       canvas.style.height = height + 'px';
     }
     function Bloomsize(concentration) {
-      gameInstance.SendMessage("car", "Fireworklocity", concentration);
+      console.log(concentration)
+      this.gameInstance.SendMessage("car", "Fireworklocity", concentration);
       // gameInstance.SendMessage("baobaotong", "concentrationControl", concentration);
     }
+
     document.body.appendChild(script);
   </script>
 </body>

+ 2 - 1
static/tianping/index.html

@@ -109,7 +109,8 @@
       canvas.style.height = height + 'px';
     }
     function Bloomsize(concentration) {
-      gameInstance.SendMessage("Tianping", "Balance", concentration);
+      console.log(concentration)
+      this.gameInstance.SendMessage("Tianping", "Balance", concentration);
       // gameInstance.SendMessage("baobaotong", "concentrationControl", concentration);
     }
     document.body.appendChild(script);

+ 1 - 1
static/tianqi/index.html

@@ -107,7 +107,7 @@
       canvas.style.height = height + 'px';
     }
     function Bloomsize(concentration) {
-      gameInstance.SendMessage("Ambience", "Fireworklocity", concentration);
+      this.gameInstance.SendMessage("Ambience", "Fireworklocity", concentration);
       // gameInstance.SendMessage("baobaotong", "concentrationControl", concentration);
     }
       document.body.appendChild(script);

+ 2 - 1
static/yanhua/index.html

@@ -109,7 +109,8 @@
       canvas.style.height = height + 'px';
     }
     function Bloomsize(concentration) {
-      gameInstance.SendMessage("Fireworks", "Fireworklocity", concentration);
+      console.log(concentration)
+      this.gameInstance.SendMessage("Fireworks", "Fireworklocity", concentration);
       // gameInstance.SendMessage("baobaotong", "concentrationControl", concentration);
     }
     document.body.appendChild(script);