|
@@ -0,0 +1,3546 @@
|
|
|
+<template>
|
|
|
+ <div class="main_right_height">
|
|
|
+ <TopDes :flag="true" topDesFont="生物反馈记录"></TopDes>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="1"> </el-col>
|
|
|
+ <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
|
|
|
+ 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
|
|
|
+ v-for="item in timeOptions"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </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-col>
|
|
|
+ <el-col :span="1"> </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="1"> </el-col>
|
|
|
+ <el-col :span="22">
|
|
|
+ <div class="select_class_animation" style="margin-top: 10px">
|
|
|
+ <div class="equipment_status">
|
|
|
+ <div class="desSty">用户编号:</div>
|
|
|
+ <div class="desSty">{{ userLink.num }}</div>
|
|
|
+
|
|
|
+ <span
|
|
|
+ class="desSty"
|
|
|
+ v-show="userLink.linkStatus"
|
|
|
+ :style="{ color: userLink.linkStatus ? '#0FB577' : '#000000' }"
|
|
|
+ >设备已连接:</span
|
|
|
+ >
|
|
|
+ <span class="desSty" v-show="!userLink.linkStatus"
|
|
|
+ >设备未连接:</span
|
|
|
+ >
|
|
|
+ <img
|
|
|
+ v-show="!userLink.linkStatus"
|
|
|
+ @click="openTableFun(1)"
|
|
|
+ style="width: 14px; height: 20px; color: #ffffff"
|
|
|
+ src="../assets/newAnimation/lanya.png"
|
|
|
+ />
|
|
|
+ <img
|
|
|
+ v-show="userLink.linkStatus"
|
|
|
+ @click="openTableFun(1)"
|
|
|
+ style="width: 14px; height: 20px; color: #ffffff"
|
|
|
+ src="../assets/newAnimation/lanyaActive.png"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <span
|
|
|
+ class="desSty"
|
|
|
+ @click="viewEchartsFun(1)"
|
|
|
+ :style="{ color: userLink.linkStatus ? '#0FB577' : '#000000' }"
|
|
|
+ >查看波形图</span
|
|
|
+ >
|
|
|
+
|
|
|
+ <div class="equipment_status">
|
|
|
+ <div class="desSty">用户编号:</div>
|
|
|
+ <div class="desSty">{{ userTwoLink.num }}</div>
|
|
|
+
|
|
|
+ <span
|
|
|
+ class="desSty"
|
|
|
+ v-show="userTwoLink.linkStatus"
|
|
|
+ :style="{ color: userTwoLink.linkStatus ? '#0FB577' : '#000000' }"
|
|
|
+ >设备已连接:</span
|
|
|
+ >
|
|
|
+ <span class="desSty" v-show="!userTwoLink.linkStatus"
|
|
|
+ >设备未连接:</span
|
|
|
+ >
|
|
|
+ <img
|
|
|
+ v-show="!userTwoLink.linkStatus"
|
|
|
+ @click="openTableFun(2)"
|
|
|
+ style="width: 14px; height: 20px; color: #ffffff"
|
|
|
+ src="../assets/newAnimation/lanya.png"
|
|
|
+ />
|
|
|
+ <img
|
|
|
+ v-show="userTwoLink.linkStatus"
|
|
|
+ @click="openTableFun(2)"
|
|
|
+ style="width: 14px; height: 20px; color: #ffffff"
|
|
|
+ src="../assets/newAnimation/lanyaActive.png"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <span
|
|
|
+ class="desSty"
|
|
|
+ @click="viewEchartsFun(2)"
|
|
|
+ :style="{ color: userTwoLink.linkStatus ? '#0FB577' : '#000000' }"
|
|
|
+ >查看波形图</span
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1"> </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="1"> </el-col>
|
|
|
+ <el-col :span="22">
|
|
|
+ <div
|
|
|
+ class="flood-plan-page"
|
|
|
+ ref="animationFlow"
|
|
|
+ style="display: block; height: 72vh; margin-top: 10px"
|
|
|
+ >
|
|
|
+ <iframe
|
|
|
+ scrolling="no"
|
|
|
+ :src="urlThreeP"
|
|
|
+ ref="unityIframe"
|
|
|
+ frameborder="0"
|
|
|
+ :width="widthIframe"
|
|
|
+ :height="heightIframe"
|
|
|
+ >
|
|
|
+ </iframe>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1"> </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-dialog title="提示" :visible.sync="tableVisible" width="60%" center>
|
|
|
+ <span>
|
|
|
+ <el-table
|
|
|
+ :data="mergeData"
|
|
|
+ style="width: 100%; max-height: 400px; overflow-y: auto"
|
|
|
+ :header-cell-style="{
|
|
|
+ background: '#66B497',
|
|
|
+ color: '#FFFFFF',
|
|
|
+ 'letter-spacing': '4px',
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <el-table-column prop="rssi" align="center" label="信号强度">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="deviceType"
|
|
|
+ align="center"
|
|
|
+ label="类型"
|
|
|
+ :formatter="typeFormatter"
|
|
|
+ >
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="userNum" align="center" label="已绑用户">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="mac" align="center" label="mac">
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column label="操作" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button
|
|
|
+ :disabled="buttonLinkFlag"
|
|
|
+ class="xl_d_button"
|
|
|
+ size="mini"
|
|
|
+ slot="reference"
|
|
|
+ @click="linkJudge(scope.row, scope.row.connent)"
|
|
|
+ >
|
|
|
+ <span v-if="scope.row.connent">断开连接</span
|
|
|
+ ><span v-if="!scope.row.connent">连接</span></el-button
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </span>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="tableVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="tableVisible = false"
|
|
|
+ >确 定</el-button
|
|
|
+ >
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ <!-- 用户选择框 -->
|
|
|
+ <el-dialog
|
|
|
+ title="选择连接用户"
|
|
|
+ :visible.sync="userVisible"
|
|
|
+ width="50%"
|
|
|
+ center
|
|
|
+ >
|
|
|
+ <span>
|
|
|
+ <el-input
|
|
|
+ style="width: 180px; margin-bottom: 10px"
|
|
|
+ placeholder="请输入搜索内容"
|
|
|
+ v-model="nameSearch"
|
|
|
+ prefix-icon="el-icon-search"
|
|
|
+ @input="searchUser"
|
|
|
+ size="small"
|
|
|
+ >
|
|
|
+ </el-input>
|
|
|
+ <el-table
|
|
|
+ :data="userData"
|
|
|
+ style="width: 100%; max-height: 300px; overflow-y: auto"
|
|
|
+ :header-cell-style="{
|
|
|
+ background: '#66B497',
|
|
|
+ color: '#FFFFFF',
|
|
|
+ 'letter-spacing': '4px',
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <el-table-column>
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-radio v-model="selectUserRadio" :label="scope.row.identifier"
|
|
|
+ > </el-radio
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="userName" align="center" label="姓名">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="identifier" align="center" label="编号">
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <p align="center" style="margin-bottom: 40px">
|
|
|
+ <el-pagination
|
|
|
+ @size-change="handleSizeChange"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ :current-page="pageNum"
|
|
|
+ :page-size="pageSize"
|
|
|
+ layout="total, prev, pager, next, jumper"
|
|
|
+ :total="totolSize"
|
|
|
+ >
|
|
|
+ </el-pagination>
|
|
|
+ </p>
|
|
|
+ </span>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="userVisible = false">取 消</el-button>
|
|
|
+ <!-- <el-button type="primary" @click="userVisible = false">确 定</el-button> -->
|
|
|
+ <el-button type="primary" @click="userComfirm">确 定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ <el-dialog
|
|
|
+ title="查看波形图"
|
|
|
+ :visible.sync="echartsVisible"
|
|
|
+ width="90%"
|
|
|
+ center
|
|
|
+ >
|
|
|
+ <span>
|
|
|
+ <div class="outPage" v-show="equipment == '1'">
|
|
|
+ <div id="eegOne" class="naoOneClass"></div>
|
|
|
+ </div>
|
|
|
+ <div class="outPage" v-show="equipment == '1'">
|
|
|
+ <div id="eegTwo" class="naoOneClass"></div>
|
|
|
+ </div>
|
|
|
+ <div class="outThreePage" v-show="equipment == '1'">
|
|
|
+ <div id="eegThree" class="naoOneClass"></div>
|
|
|
+ </div>
|
|
|
+ <div class="outPage" v-show="equipment == '2'">
|
|
|
+ <div id="ecgOne" class="naoOneClass" style="height: 500px"></div>
|
|
|
+ </div>
|
|
|
+ </span>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="echartsVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="echartsVisible = false"
|
|
|
+ >确 定</el-button
|
|
|
+ >
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!-- //第二个人的渲染图 -->
|
|
|
+ <el-dialog
|
|
|
+ title="查看波形图"
|
|
|
+ :visible.sync="echartsSecondVisible"
|
|
|
+ width="90%"
|
|
|
+ center
|
|
|
+ >
|
|
|
+ <span>
|
|
|
+ <div class="outPage" v-show="equipment == '1'">
|
|
|
+ <div id="eegOneSecond" class="naoOneClass"></div>
|
|
|
+ </div>
|
|
|
+ <div class="outPage" v-show="equipment == '1'">
|
|
|
+ <div id="eegTwoSecond" class="naoOneClass"></div>
|
|
|
+ </div>
|
|
|
+ <div class="outThreePage" v-show="equipment == '1'">
|
|
|
+ <div id="eegThreeSecond" class="naoOneClass"></div>
|
|
|
+ </div>
|
|
|
+ <div class="outPage" v-show="equipment == '2'">
|
|
|
+ <div id="ecgTwo" class="naoOneClass" style="height: 500px"></div>
|
|
|
+ </div>
|
|
|
+ </span>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="echartsSecondVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="echartsSecondVisible = false"
|
|
|
+ >确 定</el-button
|
|
|
+ >
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+//一个弹出框显示脑电或心电的显示图,外边显示脑电设备状态
|
|
|
+// 查看选择设备的状态,判断波形是哪个?
|
|
|
+import * as echarts from "echarts";
|
|
|
+import Utils from "./util.js";
|
|
|
+const fs = require("fs");
|
|
|
+const { ipcRenderer } = require("electron");
|
|
|
+const RingBuffer = require("ringbufferjs");
|
|
|
+// import RingBuffer from 'ringbufferjs'
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ activeName: "first",
|
|
|
+ //echarts渲染标志
|
|
|
+ echartsVisible: false,
|
|
|
+ echartsOne: null,
|
|
|
+ echartsTwo: null,
|
|
|
+ echartsThree: null,
|
|
|
+ //第二个人的图渲染标志
|
|
|
+ echartsSecondVisible: false,
|
|
|
+ echartsOneSecond: null,
|
|
|
+ echartsTwoSecond: null,
|
|
|
+ echartsThreeSecond: null,
|
|
|
+
|
|
|
+ //心电1连接对象
|
|
|
+ echartsEcg: null,
|
|
|
+ //心电2连接对象
|
|
|
+ echartsEcgTwo: null,
|
|
|
+
|
|
|
+ optionOne: null,
|
|
|
+ optionTwo: null,
|
|
|
+ optionThree: null,
|
|
|
+ //第二个用户的脑电
|
|
|
+ optionOneSecond: null,
|
|
|
+ optionTwoSecond: null,
|
|
|
+ optionThreeSecond: null,
|
|
|
+ //心电1 option
|
|
|
+ optionEcg: null,
|
|
|
+ //心电2 option
|
|
|
+ optionEcgTwo: null,
|
|
|
+ //打开设备进行选择的列表
|
|
|
+ openTableFlag: "",
|
|
|
+ scanData: [],
|
|
|
+ connectedData: [],
|
|
|
+ websock: null,
|
|
|
+ tableVisible: false,
|
|
|
+ linkIndex: null,
|
|
|
+ //是否是单个训练
|
|
|
+ singleFlag: true,
|
|
|
+ buttonDisable: true,
|
|
|
+ //脉搏开始前倒计时
|
|
|
+ pulseTimeNum: 180,
|
|
|
+ pulseTime: null,
|
|
|
+ gameValue: 0,
|
|
|
+ timeShow: "",
|
|
|
+ buttonFlag: "开始",
|
|
|
+ //脑电是否连接的状态
|
|
|
+ eleFlag: "未连接",
|
|
|
+ //脉搏是否连接的状态
|
|
|
+ pulseFlag: "未连接",
|
|
|
+ widthIframe: 900,
|
|
|
+ heightIframe: 600,
|
|
|
+ urlThreeP: "../../../static/candle/index.html",
|
|
|
+ // urlThreeP: __static + "/candle/index.html",
|
|
|
+ flag: 1,
|
|
|
+ //游戏场景
|
|
|
+ gameScene: 1,
|
|
|
+ optionsGame: [
|
|
|
+ {
|
|
|
+ value: 1,
|
|
|
+ label: "心灵之火",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 2,
|
|
|
+ label: "心之花",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 3,
|
|
|
+ label: "急速赛车",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 4,
|
|
|
+ label: "爆爆桶",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 5,
|
|
|
+ label: "炸弹",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 6,
|
|
|
+ label: "漂浮球",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ //设备选择
|
|
|
+ equipment: 1,
|
|
|
+ optionsEquipment: [
|
|
|
+ { value: 1, label: "脑电" },
|
|
|
+ { value: 2, label: "心电" },
|
|
|
+ ],
|
|
|
+ //游戏难度
|
|
|
+ gameDifficulty: 1,
|
|
|
+ difficultyOptions: [
|
|
|
+ { value: 1, label: "简单" },
|
|
|
+ { value: 2, label: "普通" },
|
|
|
+ { value: 3, label: "困难" },
|
|
|
+ ],
|
|
|
+ //游戏时间
|
|
|
+ gameTimeReserve: 180,
|
|
|
+ gameTime: 1,
|
|
|
+ timeOptions: [
|
|
|
+ { value: 1, label: "三分钟" },
|
|
|
+ { value: 2, label: "五分钟" },
|
|
|
+ { value: 3, label: "十分钟" },
|
|
|
+ ],
|
|
|
+ waitTimePluse: 0,
|
|
|
+ testTime: 0,
|
|
|
+ gameTimeTimer: null,
|
|
|
+ //是否显示的倒计时标志
|
|
|
+ gameTimeTimerFlag: false,
|
|
|
+
|
|
|
+ //用户1的脑电变量//脑电变量
|
|
|
+ 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: [],
|
|
|
+ pubSrc: "../../../static",
|
|
|
+ // pubsrc:__static
|
|
|
+ userLink: {
|
|
|
+ num: "",
|
|
|
+ mac: "",
|
|
|
+ linkStatus: false,
|
|
|
+ ecgAllList: [], //心电数据部分
|
|
|
+ ecgSectionList: [], //心电数据全部
|
|
|
+ //开始脑电各个部分的数据
|
|
|
+ },
|
|
|
+ userTwoLink: {
|
|
|
+ num: "",
|
|
|
+ mac: "",
|
|
|
+ linkStatus: false,
|
|
|
+ ecgAllList: [], //心电数据部分
|
|
|
+ ecgSectionList: [], //心电数据全部
|
|
|
+ //开始脑电各个部分的数据
|
|
|
+ },
|
|
|
+ //用户2的脑电变量//脑电变量
|
|
|
+ waveDataSecond: [],
|
|
|
+ // 全量
|
|
|
+ waveDataAllSecond: [],
|
|
|
+
|
|
|
+ deltaDataFlagSecond: [],
|
|
|
+ // 全量
|
|
|
+ deltaDataFlagAllSecond: [],
|
|
|
+
|
|
|
+ deltaDataSecond: [],
|
|
|
+ // 全量
|
|
|
+ deltaDataAllSecond: [],
|
|
|
+
|
|
|
+ thetaDataSecond: [],
|
|
|
+ // 全量
|
|
|
+ thetaDataAllSecond: [],
|
|
|
+
|
|
|
+ lowAlphaDataSecond: [],
|
|
|
+ // 全量
|
|
|
+ lowAlphaDataAllSecond: [],
|
|
|
+
|
|
|
+ highAlphaDataSecond: [],
|
|
|
+ // 全量
|
|
|
+ highAlphaDataAllSecond: [],
|
|
|
+
|
|
|
+ lowBetaDataSecond: [],
|
|
|
+ // 全量
|
|
|
+ lowBetaDataAllSecond: [],
|
|
|
+
|
|
|
+ highBetaDataSecond: [],
|
|
|
+ // 全量
|
|
|
+ highBetaDataAllSecond: [],
|
|
|
+
|
|
|
+ lowGammaDataSecond: [],
|
|
|
+ // 全量
|
|
|
+ lowGammaDataAllSecond: [],
|
|
|
+
|
|
|
+ midGammaDataSecond: [],
|
|
|
+ // 全量
|
|
|
+ midGammaDataAllSecond: [],
|
|
|
+
|
|
|
+ noiseDataSecond: [],
|
|
|
+ // 全量
|
|
|
+ noiseDataAllSecond: [],
|
|
|
+
|
|
|
+ attentionDataSecond: [],
|
|
|
+ // 全量
|
|
|
+ attentionDataAllSecond: [],
|
|
|
+
|
|
|
+ meditationDataSecond: [],
|
|
|
+ // 全量
|
|
|
+ meditationDataAllSecond: [],
|
|
|
+
|
|
|
+ focusNaoSecond: [],
|
|
|
+ // 全量
|
|
|
+ focusNaoAllSecond: [],
|
|
|
+ //定时器标志
|
|
|
+ listTimeFlagSecond: null,
|
|
|
+ //是否已连接的标志
|
|
|
+ //单人
|
|
|
+
|
|
|
+ //标志等待点击开始按钮后,打开定时器开始渲染
|
|
|
+ timeSendFlag: null,
|
|
|
+ //优化显示列表进行防抖
|
|
|
+ listShaking: true,
|
|
|
+ listTmp: [],
|
|
|
+ //合并的定时器
|
|
|
+ mergeTimeFlag: null,
|
|
|
+ mergeData: [],
|
|
|
+ //连接按钮flag
|
|
|
+ buttonLinkFlag: false,
|
|
|
+ //按钮状态
|
|
|
+ disabledTimeFlag: null,
|
|
|
+ //用户列表
|
|
|
+ userData: [],
|
|
|
+ //用户分页
|
|
|
+ pageNum: 1,
|
|
|
+ //每页多少条
|
|
|
+ pageSize: 10,
|
|
|
+ //总条数
|
|
|
+ totolSize: 10,
|
|
|
+ //用户搜索姓名
|
|
|
+ nameSearch: "",
|
|
|
+ //选择用户
|
|
|
+ selectUserRadio: "",
|
|
|
+ //选择用户的窗口
|
|
|
+ userVisible: false,
|
|
|
+ //一个标志标志着点击的是哪个用户的设备连接
|
|
|
+ //当数值等于1时代表选择的是用户用户1的选择
|
|
|
+ userDeviceFlag: null,
|
|
|
+ //获取当前选择设备的连接状态和值
|
|
|
+ currentSingle: {},
|
|
|
+ //当前设备的连接状态
|
|
|
+ currentFlag: false,
|
|
|
+
|
|
|
+ //间隔长度
|
|
|
+ intervalLength: 500,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ //获取当前用户num
|
|
|
+ // RingBuffer=null;
|
|
|
+ //添加监听接收到数据后开始驱动
|
|
|
+ //脑电监听
|
|
|
+
|
|
|
+ //进来之前得到传过来的参数
|
|
|
+ //调用切换场景的方法
|
|
|
+ let that = this;
|
|
|
+
|
|
|
+ //进入当前页面需要关闭掉所有连接的设备
|
|
|
+ that.disconnectDevice();
|
|
|
+
|
|
|
+ let count = 0;
|
|
|
+ var k = 1;
|
|
|
+ var flagAnimation = true;
|
|
|
+ window.addEventListener("resize", function () {
|
|
|
+ // that.getSize();
|
|
|
+ if (flagAnimation) {
|
|
|
+ setTimeout(() => {
|
|
|
+ that.getSize();
|
|
|
+ //判断当前是脑电还是心电
|
|
|
+ if (that.equipment == "1") {
|
|
|
+ if (that.echartsVisible) {
|
|
|
+ that.echartsOne.resize();
|
|
|
+ that.echartsTwo.resize();
|
|
|
+ that.echartsThree.resize();
|
|
|
+ }
|
|
|
+ if (that.echartsSecondVisible) {
|
|
|
+ that.echartsOneSecond.resize();
|
|
|
+ that.echartsTwoSecond.resize();
|
|
|
+ that.echartsThreeSecond.resize();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (that.equipment == "2") {
|
|
|
+ if (that.echartsVisible) {
|
|
|
+ that.echartsEcg.resize();
|
|
|
+ }
|
|
|
+ if (that.echartsSecondVisible) {
|
|
|
+ that.echartsEcgTwo.resize();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ flagAnimation = true;
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
+ flagAnimation = false;
|
|
|
+ });
|
|
|
+ setTimeout(() => {
|
|
|
+ that.getSize();
|
|
|
+ }, 5000);
|
|
|
+ setTimeout(() => {
|
|
|
+ that.changeGame(parseInt(that.$route.query.gameType));
|
|
|
+ console.log(that.$route.query.gameType);
|
|
|
+ }, 2000);
|
|
|
+ that.singleFlag = that.$route.query.single;
|
|
|
+ console.log(that.singleFlag);
|
|
|
+
|
|
|
+ ipcRenderer.on("accelerationData-message", this.acceptNao);
|
|
|
+ this.initWebsocket();
|
|
|
+ //当点击开始时调用方法开发发送游戏数据
|
|
|
+ //上来就查询已连接列表
|
|
|
+ that.listTimeFlag = setInterval(that.connectList, 2000);
|
|
|
+ //根据扫描列表和已连接列表看看哪些是重复的//重复的就是已连接的
|
|
|
+ that.mergeTimeFlag = setInterval(that.mergeDataFun, 1000);
|
|
|
+ },
|
|
|
+ destroyed() {
|
|
|
+ clearTimeout(this.mergeTimeFlag);
|
|
|
+ clearTimeout(this.disabledTimeFlag);
|
|
|
+ clearInterval(this.timeSendFlag);
|
|
|
+ clearInterval(this.listTimeFlag);
|
|
|
+ console.log(ipcRenderer);
|
|
|
+ this.websock.close(1000);
|
|
|
+ //清除特定的监听的ipcRenderer
|
|
|
+ ipcRenderer.removeListener("accelerationData-message", this.acceptNao);
|
|
|
+ this.disconnectDevice();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ //合并数据
|
|
|
+ mergeDataFun() {
|
|
|
+ let that = this;
|
|
|
+ let scanDataTmp = JSON.stringify(this.scanData);
|
|
|
+ let scanDataTmpFin = JSON.parse(scanDataTmp);
|
|
|
+ let list = [];
|
|
|
+ for (let i = 0; i < scanDataTmpFin.length; i++) {
|
|
|
+ let obj = {
|
|
|
+ rssi: "",
|
|
|
+ name: "",
|
|
|
+ mac: "",
|
|
|
+ connent: false,
|
|
|
+ deviceType: "",
|
|
|
+ userNum: "",
|
|
|
+ };
|
|
|
+ obj.rssi = scanDataTmpFin[i].rssi;
|
|
|
+ obj.name = scanDataTmpFin[i].name;
|
|
|
+ obj.mac = scanDataTmpFin[i].mac;
|
|
|
+ obj.connent = false;
|
|
|
+ obj.deviceType = scanDataTmpFin[i].deviceType;
|
|
|
+ list.push(obj);
|
|
|
+ }
|
|
|
+ //判断某个
|
|
|
+ //先取出与扫描列表显示不一样的
|
|
|
+
|
|
|
+ //循环list
|
|
|
+ //与已选列表进行对比,如果已选列表中有重复
|
|
|
+
|
|
|
+ //已选列表必定显示
|
|
|
+ //如果已选列表为空
|
|
|
+
|
|
|
+ //已连接列表中应该全部显示+扫描列表与已选列表不重复的mac的则为全部的
|
|
|
+
|
|
|
+ //先将扫描列表与已选列表全部格式化合并为一个数组
|
|
|
+ //先查已选列表中在扫描列表中没有的----
|
|
|
+
|
|
|
+ //然后最后将其加入扫描列表
|
|
|
+ //然后查询已选列表中在扫描列表中有的
|
|
|
+
|
|
|
+ //已选列表
|
|
|
+ let connectedDataTmp = JSON.stringify(this.connectedData);
|
|
|
+ let connectedDataTmpFin = JSON.parse(connectedDataTmp);
|
|
|
+ //不包含的列表
|
|
|
+ let listBarring = [];
|
|
|
+ for (let i = 0; i < connectedDataTmpFin.length; i++) {
|
|
|
+ let flag = false;
|
|
|
+ for (let j = 0; j < list.length; j++) {
|
|
|
+ if (connectedDataTmpFin[i].mac == list[j].mac) {
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!flag) {
|
|
|
+ listBarring.push(connectedDataTmpFin[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (let i = 0; i < list.length; i++) {
|
|
|
+ for (let j = 0; j < connectedDataTmpFin.length; j++) {
|
|
|
+ if (list[i].mac == connectedDataTmpFin[j].mac) {
|
|
|
+ list[i].connent = true;
|
|
|
+ list[i].rssi = connectedDataTmpFin[j].rssi;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //然后合并两个数组
|
|
|
+
|
|
|
+ let listFin = list.concat(listBarring);
|
|
|
+
|
|
|
+ //判断当前选择的是脑电还是心电
|
|
|
+ let currentDeviceList = [];
|
|
|
+ if (this.equipment == "1") {
|
|
|
+ //当是脑电时
|
|
|
+ for (let i = 0; i < listFin.length; i++) {
|
|
|
+ if (listFin[i].deviceType == "0") {
|
|
|
+ currentDeviceList.push(listFin[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (let i = 0; i < listFin.length; i++) {
|
|
|
+ if (listFin[i].deviceType == "1") {
|
|
|
+ currentDeviceList.push(listFin[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (let k = 0; k < currentDeviceList.length; k++) {
|
|
|
+ if (
|
|
|
+ that.userLink.mac !== "" &&
|
|
|
+ that.userLink.mac == currentDeviceList[k].mac
|
|
|
+ ) {
|
|
|
+ currentDeviceList[k].userNum = that.userLink.num;
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ that.userTwoLink.mac !== "" &&
|
|
|
+ that.userTwoLink.mac == currentDeviceList[k].mac
|
|
|
+ ) {
|
|
|
+ currentDeviceList[k].userNum = that.userTwoLink.num;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //将数组其他选项
|
|
|
+ // console.log(listFin);
|
|
|
+ this.mergeData = currentDeviceList;
|
|
|
+ //将将列表表现得多一点 用于测试列表溢出
|
|
|
+ // let obj = {
|
|
|
+ // rssi: "2",
|
|
|
+ // name: "2",
|
|
|
+ // mac: "2",
|
|
|
+ // connent: false,
|
|
|
+ // deviceType: "2",
|
|
|
+ // userNum: "2",
|
|
|
+ // };
|
|
|
+ // for (let i = 0; i < 10; i++) {
|
|
|
+ // this.mergeData.push(obj);
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ //用户选择点击确定
|
|
|
+ userComfirm() {
|
|
|
+ //点击的是哪个用户选怎设备
|
|
|
+ console.log(this.userDeviceFlag);
|
|
|
+ console.log(this.selectUserRadio);
|
|
|
+ if (this.selectUserRadio !== "") {
|
|
|
+ //判断是哪个用户
|
|
|
+ if (this.userDeviceFlag == 1) {
|
|
|
+ //则第一个用户的编号则是当前选择用户的
|
|
|
+ this.userLink.num = this.selectUserRadio;
|
|
|
+ } else {
|
|
|
+ this.userTwoLink.num = this.selectUserRadio;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let value = JSON.parse(JSON.stringify(this.currentSingle));
|
|
|
+ if (this.currentFlag) {
|
|
|
+ //buttonLinkFlag
|
|
|
+ this.disconnectEquipment(value);
|
|
|
+ } else {
|
|
|
+ //调用连接的时候需要知道选的是哪个用户的
|
|
|
+ //打开连接的时候需要弹出用户选择框进行选择用户
|
|
|
+ this.linkFun(value);
|
|
|
+ }
|
|
|
+ this.userVisible = false;
|
|
|
+ //判断绑定的用户是选择的哪个
|
|
|
+ // if(){
|
|
|
+
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ searchUser() {
|
|
|
+ this.pageNum = 1;
|
|
|
+ this.queryUser();
|
|
|
+ },
|
|
|
+ //选择用户
|
|
|
+ queryUser() {
|
|
|
+ let that = this;
|
|
|
+ that.$http.post(
|
|
|
+ `v1/user/find`,
|
|
|
+ {
|
|
|
+ pageNum: that.pageNum,
|
|
|
+ pageSize: that.pageSize,
|
|
|
+ startDate: "",
|
|
|
+ endDate: "",
|
|
|
+ userName: that.nameSearch,
|
|
|
+ role: 0,
|
|
|
+ },
|
|
|
+ (res) => {
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ that.userData = res.data.data.content;
|
|
|
+ that.totolSize = res.data.data.totalElements;
|
|
|
+ } else {
|
|
|
+ this.$message.error("访问服务器失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ handleSizeChange(val) {
|
|
|
+ this.queryUser();
|
|
|
+ },
|
|
|
+ handleCurrentChange(val) {
|
|
|
+ this.pageNum = val;
|
|
|
+ this.queryUser();
|
|
|
+
|
|
|
+ // this.pageNum = val;
|
|
|
+ // this.queryList();
|
|
|
+ },
|
|
|
+ //脑电图渲染
|
|
|
+ acceptNao(event, data) {
|
|
|
+ let arg = data.arg;
|
|
|
+ let mac = data.mac;
|
|
|
+ if (this.userLink.mac == mac) {
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ } 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();
|
|
|
+ }
|
|
|
+ this.noiseData.push(arg["_c"].get("Signal"));
|
|
|
+ this.noiseDataAll.push(arg["_c"].get("Signal"));
|
|
|
+ if (this.noiseData.length > ll) {
|
|
|
+ this.noiseData.shift();
|
|
|
+ }
|
|
|
+ // console.log(arg["_c"].get("Attention") / 100);
|
|
|
+ // console.log(Math.random() * 10);
|
|
|
+ if (
|
|
|
+ this.equipment == 1 &&
|
|
|
+ // this.linkStatus &&
|
|
|
+ this.buttonFlag == "结束"
|
|
|
+ ) {
|
|
|
+ this.send(Math.random() * 10);
|
|
|
+ }
|
|
|
+
|
|
|
+ //先设为随机数
|
|
|
+
|
|
|
+ // this.send(Math.random()*10)
|
|
|
+ // console.log(arg["_c"].get("Attention")/100)
|
|
|
+ this.attentionData.push(arg["_c"].get("Attention"));
|
|
|
+ this.attentionDataAll.push(arg["_c"].get("Attention"));
|
|
|
+ if (this.attentionData.length > ll) {
|
|
|
+ this.attentionData.shift();
|
|
|
+ }
|
|
|
+ this.meditationData.push(arg["_c"].get("Meditation"));
|
|
|
+ this.meditationDataAll.push(arg["_c"].get("Meditation"));
|
|
|
+ if (this.meditationData.length > ll) {
|
|
|
+ this.meditationData.shift();
|
|
|
+ }
|
|
|
+ this.thetaData.push(arg["_c"].get("Theta"));
|
|
|
+ this.thetaDataAll.push(arg["_c"].get("Theta"));
|
|
|
+ if (this.thetaData.length > ll) {
|
|
|
+ this.thetaData.shift();
|
|
|
+ }
|
|
|
+ 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.echartsVisible) {
|
|
|
+ console.log(this.attentionDataAll.length);
|
|
|
+ this.renderEegOne();
|
|
|
+ this.renderEegTwo();
|
|
|
+ this.renderEegThree();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //第二个用户的数据渲染
|
|
|
+ if (this.userTwoLink.mac == mac) {
|
|
|
+ if (arg["_c"].size == 1) {
|
|
|
+ this.waveDataSecond.push(arg["_c"].get("rawWaveData"));
|
|
|
+ this.waveDataAllSecond.push(arg["_c"].get("rawWaveData"));
|
|
|
+ if (this.waveDataSecond.length > 5120) {
|
|
|
+ this.waveDataSecond.shift();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (arg["_c"].size == 11) {
|
|
|
+ // 当不为undefined时
|
|
|
+ let ll = 11;
|
|
|
+ // 获取长度
|
|
|
+ this.deltaDataFlagSecond.push(arg["_c"].get("Delta"));
|
|
|
+ this.deltaDataFlagAllSecond.push(arg["_c"].get("Delta"));
|
|
|
+ if (this.deltaDataFlagSecond.length > ll) {
|
|
|
+ this.deltaDataFlagSecond.shift();
|
|
|
+ }
|
|
|
+ this.noiseDataSecond.push(arg["_c"].get("Signal"));
|
|
|
+ this.noiseDataAllSecond.push(arg["_c"].get("Signal"));
|
|
|
+ if (this.noiseDataSecond.length > ll) {
|
|
|
+ this.noiseDataSecond.shift();
|
|
|
+ }
|
|
|
+ // console.log(arg["_c"].get("Attention") / 100);
|
|
|
+ // console.log(Math.random() * 10);
|
|
|
+ if (
|
|
|
+ this.equipment == 1 &&
|
|
|
+ // this.linkStatus &&
|
|
|
+ this.buttonFlag == "结束"
|
|
|
+ ) {
|
|
|
+ this.send(Math.random() * 10);
|
|
|
+ }
|
|
|
+
|
|
|
+ //先设为随机数
|
|
|
+
|
|
|
+ // this.send(Math.random()*10)
|
|
|
+ // console.log(arg["_c"].get("Attention")/100)
|
|
|
+ this.attentionDataSecond.push(arg["_c"].get("Attention"));
|
|
|
+ this.attentionDataAllSecond.push(arg["_c"].get("Attention"));
|
|
|
+ if (this.attentionDataSecond.length > ll) {
|
|
|
+ this.attentionDataSecond.shift();
|
|
|
+ }
|
|
|
+ this.meditationDataSecond.push(arg["_c"].get("Meditation"));
|
|
|
+ this.meditationDataAllSecond.push(arg["_c"].get("Meditation"));
|
|
|
+ if (this.meditationDataSecond.length > ll) {
|
|
|
+ this.meditationDataSecond.shift();
|
|
|
+ }
|
|
|
+ this.thetaDataSecond.push(arg["_c"].get("Theta"));
|
|
|
+ this.thetaDataAllSecond.push(arg["_c"].get("Theta"));
|
|
|
+ if (this.thetaDataSecond.length > ll) {
|
|
|
+ this.thetaDataSecond.shift();
|
|
|
+ }
|
|
|
+ this.lowAlphaDataSecond.push(arg["_c"].get("LowAlpha"));
|
|
|
+ this.lowAlphaDataAllSecond.push(arg["_c"].get("LowAlpha"));
|
|
|
+ if (this.lowAlphaDataSecond.length > ll) {
|
|
|
+ this.lowAlphaDataSecond.shift();
|
|
|
+ }
|
|
|
+ this.highAlphaDataSecond.push(arg["_c"].get("HighAlpha"));
|
|
|
+ this.highAlphaDataAllSecond.push(arg["_c"].get("HighAlpha"));
|
|
|
+ if (this.highAlphaDataSecond.length > ll) {
|
|
|
+ this.highAlphaDataSecond.shift();
|
|
|
+ }
|
|
|
+ this.lowBetaDataSecond.push(arg["_c"].get("LowBeta"));
|
|
|
+ this.lowBetaDataAllSecond.push(arg["_c"].get("LowBeta"));
|
|
|
+ if (this.lowBetaDataSecond.length > ll) {
|
|
|
+ this.lowBetaDataSecond.shift();
|
|
|
+ }
|
|
|
+ this.highBetaDataSecond.push(arg["_c"].get("HighBeta"));
|
|
|
+ this.highBetaDataAllSecond.push(arg["_c"].get("HighBeta"));
|
|
|
+ if (this.highBetaDataSecond.length > ll) {
|
|
|
+ this.highBetaDataSecond.shift();
|
|
|
+ }
|
|
|
+ this.lowGammaDataSecond.push(arg["_c"].get("LowGamma"));
|
|
|
+ this.lowGammaDataAllSecond.push(arg["_c"].get("LowGamma"));
|
|
|
+ if (this.lowGammaDataSecond.length > ll) {
|
|
|
+ this.lowGammaDataSecond.shift();
|
|
|
+ }
|
|
|
+ this.midGammaDataSecond.push(arg["_c"].get("MiddleGamma"));
|
|
|
+ this.midGammaDataAllSecond.push(arg["_c"].get("MiddleGamma"));
|
|
|
+ if (this.midGammaDataSecond.length > ll) {
|
|
|
+ this.midGammaDataSecond.shift();
|
|
|
+ }
|
|
|
+ this.focusNaoSecond.push(arg["_c"].get("Attention"));
|
|
|
+ this.focusNaoAllSecond.push(arg["_c"].get("Attention"));
|
|
|
+ if (this.focusNaoSecond > ll) {
|
|
|
+ this.focusNaoSecond.shift();
|
|
|
+ }
|
|
|
+ // this.numEleDom = this.focusNaoAll.length.toString();
|
|
|
+ if (this.echartsSecondVisible) {
|
|
|
+ //console.log(this.attentionDataAllSecond.length);
|
|
|
+ this.renderEegOneSecond();
|
|
|
+ this.renderEegTwoSecond();
|
|
|
+ this.renderEegThreeSecond();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ viewEchartsFun(val) {
|
|
|
+ if (val == 1) {
|
|
|
+ this.echartsVisible = true;
|
|
|
+ } else {
|
|
|
+ this.echartsSecondVisible = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ //先判断选择的是哪个设备
|
|
|
+ //如果是脑电的话,需要判断是用户1还是用户2
|
|
|
+ //如果是心电的话,需要判断是用户1还是用户2
|
|
|
+ if (this.equipment == "1") {
|
|
|
+ if (val == 1) {
|
|
|
+ if (this.echartsOne == null) {
|
|
|
+ this.echartsOne = echarts.init(document.getElementById("eegOne"));
|
|
|
+ this.echartsTwo = echarts.init(document.getElementById("eegTwo"));
|
|
|
+ this.echartsThree = echarts.init(
|
|
|
+ document.getElementById("eegThree")
|
|
|
+ );
|
|
|
+ this.renderEegOne();
|
|
|
+ this.renderEegTwo();
|
|
|
+ this.renderEegThree();
|
|
|
+ setTimeout(() => {
|
|
|
+ this.echartsOne.resize();
|
|
|
+ this.echartsTwo.resize();
|
|
|
+ this.echartsThree.resize();
|
|
|
+ }, 1000);
|
|
|
+ } else {
|
|
|
+ this.echartsOne.resize();
|
|
|
+ this.echartsTwo.resize();
|
|
|
+ this.echartsThree.resize();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (this.echartsOneSecond == null) {
|
|
|
+ this.echartsOneSecond = echarts.init(
|
|
|
+ document.getElementById("eegOneSecond")
|
|
|
+ );
|
|
|
+ this.echartsTwoSecond = echarts.init(
|
|
|
+ document.getElementById("eegTwoSecond")
|
|
|
+ );
|
|
|
+ this.echartsThreeSecond = echarts.init(
|
|
|
+ document.getElementById("eegThreeSecond")
|
|
|
+ );
|
|
|
+ this.renderEegOneSecond();
|
|
|
+ this.renderEegTwoSecond();
|
|
|
+ this.renderEegThreeSecond();
|
|
|
+ setTimeout(() => {
|
|
|
+ this.echartsOneSecond.resize();
|
|
|
+ this.echartsTwoSecond.resize();
|
|
|
+ this.echartsThreeSecond.resize();
|
|
|
+ }, 1000);
|
|
|
+ } else {
|
|
|
+ this.echartsOneSecond.resize();
|
|
|
+ this.echartsTwoSecond.resize();
|
|
|
+ this.echartsThreeSecond.resize();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (val == 1) {
|
|
|
+ if (this.echartsEcg == null) {
|
|
|
+ this.echartsEcg = echarts.init(document.getElementById("ecgOne"));
|
|
|
+ this.renderEcgOne();
|
|
|
+ setTimeout(() => {
|
|
|
+ this.echartsEcg.resize();
|
|
|
+ }, 1000);
|
|
|
+ } else {
|
|
|
+ this.echartsEcg.resize();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (this.echartsEcgTwo == null) {
|
|
|
+ this.echartsEcgTwo = echarts.init(
|
|
|
+ document.getElementById("ecgTwo")
|
|
|
+ );
|
|
|
+ this.renderEcgTwo();
|
|
|
+ setTimeout(() => {
|
|
|
+ this.echartsEcgTwo.resize();
|
|
|
+ }, 1000);
|
|
|
+ } else {
|
|
|
+ this.echartsEcgTwo.resize();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 先调用
|
|
|
+ }, 2000);
|
|
|
+ },
|
|
|
+ //状态切换
|
|
|
+ linkJudge(val, flag) {
|
|
|
+ //打开用户
|
|
|
+ this.currentSingle = val;
|
|
|
+ this.currentFlag = flag;
|
|
|
+ //当前设备已连接时
|
|
|
+ if (flag) {
|
|
|
+ this.userVisible = false;
|
|
|
+ this.disconnectEquipment(val);
|
|
|
+ } else {
|
|
|
+ this.userVisible = true;
|
|
|
+ }
|
|
|
+ //当前设备的连接状态
|
|
|
+ //当前设备的连接状态
|
|
|
+ //获取当前用户的val 和flag
|
|
|
+ //查询用户
|
|
|
+ this.queryUser();
|
|
|
+ // if (flag) {
|
|
|
+ // //buttonLinkFlag
|
|
|
+ // this.disconnectEquipment(val);
|
|
|
+ // } else {
|
|
|
+ // //打开连接的时候需要弹出用户选择框进行选择用户
|
|
|
+ // this.linkFun(val);
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ //进行解析脑电数据
|
|
|
+
|
|
|
+ linkFun(val) {
|
|
|
+ console.log(val);
|
|
|
+ let that = this;
|
|
|
+ that.buttonLinkFlag = true;
|
|
|
+ that.$http.postTmp(
|
|
|
+ `/v1/device/connection`,
|
|
|
+ {
|
|
|
+ chip: 0 + "",
|
|
|
+ mac: val.mac,
|
|
|
+ addrType: "public",
|
|
|
+ filterName: val.deviceType,
|
|
|
+ },
|
|
|
+ (res) => {
|
|
|
+ that.disableStatus();
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ // this.linkIndex = index;
|
|
|
+ //如果是脑电的话直接调用打开数据接口
|
|
|
+ //如果是心电需要先调用写入输入数据-发送指令接口
|
|
|
+
|
|
|
+ if (val.deviceType == "1") {
|
|
|
+ this.writeData(val);
|
|
|
+ if (that.userDeviceFlag == 1) {
|
|
|
+ that.userLink.mac = val.mac;
|
|
|
+ } else {
|
|
|
+ that.userTwoLink.mac = val.mac;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //判断脑电设备
|
|
|
+
|
|
|
+ //脑电的情况下
|
|
|
+ //记录下当前mac,
|
|
|
+ if (that.userDeviceFlag == 1) {
|
|
|
+ that.userLink.mac = val.mac;
|
|
|
+ } else {
|
|
|
+ that.userTwoLink.mac = val.mac;
|
|
|
+ }
|
|
|
+ //然后调用已连接列表确定改mac是否存在在列表中,如果已存在则表示该设备已连接
|
|
|
+
|
|
|
+ // that.openData();
|
|
|
+ // this.$message.success("设备连接成功");
|
|
|
+ }
|
|
|
+ // that.tableData = res.data;
|
|
|
+ // that.totolSize = res.data.totalElements;
|
|
|
+ } else {
|
|
|
+ // this.$message.error("访问服务器失败!");
|
|
|
+ this.$message.error(res.data.message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ //写入数据--发送指令
|
|
|
+ writeData(val) {
|
|
|
+ let that = this;
|
|
|
+ let userName = sessionStorage.getItem("name");
|
|
|
+ that.$http.postTmp(
|
|
|
+ `/v1/device/write/data`,
|
|
|
+ { mac: val.mac, userName: userName },
|
|
|
+ (res) => {
|
|
|
+ // that.openData();
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ } else {
|
|
|
+ this.$message.error("访问服务器失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ //打开数据接口
|
|
|
+ // openData() {
|
|
|
+ // let that = this;
|
|
|
+ // that.$http.getTmp(`/v1/device/open/notify`, {}, (res) => {
|
|
|
+ // if (res.code == 200) {
|
|
|
+ // //打开数据接口
|
|
|
+ // // that.tableData = res.data;
|
|
|
+ // // that.totolSize = res.data.totalElements;
|
|
|
+ // } else {
|
|
|
+ // this.$message.error("访问服务器失败!");
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // },
|
|
|
+ disableStatus() {
|
|
|
+ let that = this;
|
|
|
+ this.disabledTimeFlag = setTimeout(() => {
|
|
|
+ this.buttonLinkFlag = false;
|
|
|
+ }, 1500);
|
|
|
+ },
|
|
|
+ //断开连接的脑电
|
|
|
+ disconnectEquipment(val) {
|
|
|
+ let that = this;
|
|
|
+ that.buttonLinkFlag = true;
|
|
|
+ that.$http.getTmp(`v1/device/${val.mac}/disconnect`, {}, (res) => {
|
|
|
+ that.disableStatus();
|
|
|
+ if (res.code == 200) {
|
|
|
+ //关闭连接的时候看是不是当前绑定的mac与用户的mac是否相同
|
|
|
+ //如果相同则 连接标志变为false;
|
|
|
+ //如果不同则不变
|
|
|
+ if (that.userLink.mac == val.mac) {
|
|
|
+ that.userLink.linkStatus = false;
|
|
|
+ that.userLink.mac = "";
|
|
|
+ }
|
|
|
+ if (that.userTwoLink.mac == val.mac) {
|
|
|
+ that.userTwoLink.linkStatus = false;
|
|
|
+ that.userTwoLink.mac = "";
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //查询连接列表
|
|
|
+ connectList() {
|
|
|
+ let that = this;
|
|
|
+ that.$http.getTmp(`v1/device/connected`, {}, (res) => {
|
|
|
+ // console.log(res)
|
|
|
+ //判断当前的列表是否存在该用户已点击的列表
|
|
|
+ if (res.code == 200) {
|
|
|
+ if (res.data) {
|
|
|
+ if (res.data) {
|
|
|
+ let list = [];
|
|
|
+ for (let i = 0; i < res.data.length; i++) {
|
|
|
+ let obj = {
|
|
|
+ rssi: "",
|
|
|
+ name: "",
|
|
|
+ mac: "",
|
|
|
+ connent: false,
|
|
|
+ deviceType: "",
|
|
|
+ };
|
|
|
+ obj.rssi = "";
|
|
|
+ obj.name = res.data[i].Name;
|
|
|
+ obj.mac = res.data[i].MAC;
|
|
|
+ obj.connent = true;
|
|
|
+ obj.deviceType = res.data[i].DeviceType;
|
|
|
+ obj.userNum = "";
|
|
|
+ list.push(obj);
|
|
|
+ }
|
|
|
+ that.connectedData = list;
|
|
|
+ // console.log(list);
|
|
|
+ if (list.length == 0) {
|
|
|
+ //表示未连接
|
|
|
+ that.userLink.linkStatus = false;
|
|
|
+ that.userTwoLink.linkStatus = false;
|
|
|
+ } else {
|
|
|
+ //标识已连接
|
|
|
+ for (let k = 0; k < list.length; k++) {
|
|
|
+ if (
|
|
|
+ that.userLink.mac !== "" &&
|
|
|
+ that.userLink.mac == list[k].mac
|
|
|
+ ) {
|
|
|
+ that.userLink.linkStatus = true;
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ that.userTwoLink.mac !== "" &&
|
|
|
+ that.userTwoLink.mac == list[k].mac
|
|
|
+ ) {
|
|
|
+ that.userTwoLink.linkStatus = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ that.connectedData = [];
|
|
|
+ }
|
|
|
+ //打开数据接口
|
|
|
+ // that.tableData = res.data;
|
|
|
+ // that.totolSize = res.data.totalElements;
|
|
|
+ } else {
|
|
|
+ // this.$message.error("访问服务器失败!");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ typeFormatter(val) {
|
|
|
+ // console.log(val.deviceType)
|
|
|
+ if (val.deviceType == "1") {
|
|
|
+ return "心电";
|
|
|
+ } else {
|
|
|
+ return "脑电";
|
|
|
+ }
|
|
|
+ },
|
|
|
+ openTableFun(val) {
|
|
|
+ this.userDeviceFlag = val;
|
|
|
+ this.tableVisible = true;
|
|
|
+ },
|
|
|
+ //进来后先连接websocket
|
|
|
+ //连上后进行扫描
|
|
|
+ //扫描以后出现列表
|
|
|
+ //列表出现后点击连接并打开数据如果有数据才算成功
|
|
|
+ //初始化websocket
|
|
|
+ initWebsocket() {
|
|
|
+ // const wsuri = "ws://192.168.2.101: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;
|
|
|
+ this.websock.onopen = this.websocketonopen;
|
|
|
+ this.websock.onerror = this.websocketonerror;
|
|
|
+ this.websock.onclose = this.websocketclose;
|
|
|
+ },
|
|
|
+ websocketonopen() {
|
|
|
+ //连接建立之后执行send方法发送数据
|
|
|
+ let actions = { test: "12345" };
|
|
|
+ this.websocketsend(JSON.stringify(actions));
|
|
|
+ },
|
|
|
+ websocketonerror() {
|
|
|
+ //连接建立失败重连
|
|
|
+ this.initWebSocket();
|
|
|
+ },
|
|
|
+ websocketsend(Data) {
|
|
|
+ //数据发送
|
|
|
+ this.websock.send(Data);
|
|
|
+ },
|
|
|
+ websocketonmessage(e) {
|
|
|
+ let that = this;
|
|
|
+ //数据接收
|
|
|
+ const redata = JSON.parse(e.data);
|
|
|
+ if (redata.content != "Successful connection to socket service") {
|
|
|
+ //首先判断是否redata.content是否是未定义
|
|
|
+ // console.log(redata.content)
|
|
|
+ if (redata.hasOwnProperty("content")) {
|
|
|
+ let dataLin = JSON.parse(redata.content);
|
|
|
+ if (redata.msgType == "device") {
|
|
|
+ // let dataLin = JSON.parse(redata.content);
|
|
|
+ let list = [];
|
|
|
+ for (var key in dataLin) {
|
|
|
+ let a = {
|
|
|
+ mac: dataLin[key]["MAC"],
|
|
|
+ name: dataLin[key].Name,
|
|
|
+ rssi: dataLin[key].Rssi,
|
|
|
+ deviceType: dataLin[key].DeviceType,
|
|
|
+ chip: dataLin[key].Chip,
|
|
|
+ };
|
|
|
+ that.changeList(a);
|
|
|
+ }
|
|
|
+ //获取到很多数据,取每秒最大的包含量
|
|
|
+ } else if (redata.msgType == "eegData") {
|
|
|
+ // let dataLin = JSON.parse(redata.content);
|
|
|
+ // console.log(dataLin);
|
|
|
+
|
|
|
+ ///先判断第一个用户是否有mac---有mac代表已连接
|
|
|
+ if (that.userLink.mac !== "" && that.userLink.mac == dataLin.id) {
|
|
|
+ ipcRenderer.send("asynchronoushrv-naoData", {
|
|
|
+ value: dataLin.value,
|
|
|
+ mac: dataLin.id,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ that.userTwoLink.mac !== "" &&
|
|
|
+ that.userTwoLink.mac == dataLin.id
|
|
|
+ ) {
|
|
|
+ ipcRenderer.send("asynchronoushrv-naoTwoData", {
|
|
|
+ value: dataLin.value,
|
|
|
+ mac: dataLin.id,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //判断第二个用户的mac是否有,有则代表已连接 --
|
|
|
+ } else if (redata.msgType == "ecgData") {
|
|
|
+ // console.log(dataLin)
|
|
|
+ //判断该数据对应的mac是否是当前绑定过用户的
|
|
|
+ //判断当前是否是绑定该用户的数据,是的话进行用户处理
|
|
|
+ //接到数据进行处理
|
|
|
+ // console.log(dataLin);
|
|
|
+ //当该用户的mac与id相同时,取这个数据
|
|
|
+ // console.log(dataLin.id === that.userLink.mac);
|
|
|
+ //用户1
|
|
|
+ if (that.userLink.mac !== "" && dataLin.id === that.userLink.mac) {
|
|
|
+ let list = dataLin.value.split(",");
|
|
|
+ // console.log(list)
|
|
|
+ list.forEach((item) => {
|
|
|
+ let tmp = parseInt(item);
|
|
|
+ that.userLink.ecgAllList.push(tmp);
|
|
|
+ that.userLink.ecgSectionList.push(tmp);
|
|
|
+ if (that.userLink.ecgSectionList.length > that.intervalLength) {
|
|
|
+ that.userLink.ecgSectionList.shift();
|
|
|
+ }
|
|
|
+ if (that.userLink.ecgAllList.length % 100 == 0) {
|
|
|
+ // console.log(that.ecgAllList.length);
|
|
|
+ if (that.echartsVisible && that.equipment == "2") {
|
|
|
+ that.renderEcgOne();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //用户2
|
|
|
+ if (
|
|
|
+ that.userTwoLink.mac !== "" &&
|
|
|
+ dataLin.id === that.userTwoLink.mac
|
|
|
+ ) {
|
|
|
+ let list = dataLin.value.split(",");
|
|
|
+ list.forEach((item) => {
|
|
|
+ let tmp = parseInt(item);
|
|
|
+ that.userTwoLink.ecgAllList.push(tmp);
|
|
|
+ that.userTwoLink.ecgSectionList.push(tmp);
|
|
|
+ if (that.userTwoLink.ecgSectionList.length > 500) {
|
|
|
+ that.userTwoLink.ecgSectionList.shift();
|
|
|
+ }
|
|
|
+ if (that.userTwoLink.ecgAllList.length % 100 == 0) {
|
|
|
+ // console.log(that.ecgAllList.length);
|
|
|
+ if (that.echartsSecondVisible) {
|
|
|
+ that.renderEcgTwo();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //处理数据让其变化最慢
|
|
|
+ //这个是最大的扫描列表
|
|
|
+ changeList(obj) {
|
|
|
+ // console.log(obj);
|
|
|
+ let that = this;
|
|
|
+ that.listTmp.push(obj);
|
|
|
+ let arrayStr = JSON.stringify(that.listTmp);
|
|
|
+ let array = JSON.parse(arrayStr);
|
|
|
+ //取list中不相同的
|
|
|
+ // console.log(array)
|
|
|
+ // array = array.reduce(function (item, next) {
|
|
|
+ // obj[next.MAC] ? "" : (obj[next.MAC] = true && item.push(next));
|
|
|
+ // return item;
|
|
|
+ // }, []);
|
|
|
+ //循环数组arr
|
|
|
+ //设置储存不一样的数组
|
|
|
+ var newArr = new Array();
|
|
|
+ var flag = false;
|
|
|
+ for (var i = 0; i < array.length; i++) {
|
|
|
+ for (var j = 0; j < newArr.length; j++) {
|
|
|
+ if (array[i].mac == newArr[j].mac) {
|
|
|
+ newArr[j] = array[i];
|
|
|
+ flag = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!flag) {
|
|
|
+ newArr.push(array[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // newArr=JSON.parse(newArr)
|
|
|
+ // let newArr = {}
|
|
|
+ // array.forEach(item => {
|
|
|
+ // newArr[item.MAC] = item
|
|
|
+ // })
|
|
|
+ that.listTmp = JSON.parse(JSON.stringify(newArr));
|
|
|
+ // console.log(JSON.stringify(newArr));
|
|
|
+ //listTmp即使最大扫描列表
|
|
|
+ that.scanData = newArr;
|
|
|
+
|
|
|
+ //目前无法知道当前设备是脑电还是脉搏
|
|
|
+
|
|
|
+ // listShaking:false,
|
|
|
+
|
|
|
+ //判断标志是true或false
|
|
|
+ // if (that.listShaking) {
|
|
|
+ // let flagTime = setTimeout(() => {
|
|
|
+ // that.listShaking = true;
|
|
|
+ // let arrayStr = JSON.stringify(that.listTmp);
|
|
|
+ // let array = JSON.parse(arrayStr);
|
|
|
+ // //取list中不相同的
|
|
|
+ // console.log(array)
|
|
|
+ // // array = array.reduce(function (item, next) {
|
|
|
+ // // obj[next.MAC] ? "" : (obj[next.MAC] = true && item.push(next));
|
|
|
+ // // return item;
|
|
|
+ // // }, []);
|
|
|
+ // //循环数组arr
|
|
|
+ // //设置储存不一样的数组
|
|
|
+ // var newArr = new Array();
|
|
|
+ // var flag = false;
|
|
|
+ // for (var i = 0; i < array.length; i++) {
|
|
|
+ // for (var j = 0; j < newArr.length; j++) {
|
|
|
+ // if (array[i].mac == newArr[j].mac) {
|
|
|
+ // newArr[j] = array[i];
|
|
|
+ // flag = true;
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (!flag) {
|
|
|
+ // newArr.push(array[i]);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // // newArr=JSON.parse(newArr)
|
|
|
+ // // let newArr = {}
|
|
|
+ // // array.forEach(item => {
|
|
|
+ // // newArr[item.MAC] = item
|
|
|
+ // // })
|
|
|
+ // that.listTmp = JSON.parse(JSON.stringify(newArr));
|
|
|
+ // console.log(JSON.stringify(newArr));
|
|
|
+ // //listTmp即使最大扫描列表
|
|
|
+ // that.scanData = newArr;
|
|
|
+ // //当前扫描列表
|
|
|
+ // clearTimeout(flagTime);
|
|
|
+ // }, 1000);
|
|
|
+ // }
|
|
|
+ // that.listShaking = false;
|
|
|
+ },
|
|
|
+ websocketclose(e) {
|
|
|
+ if (e.code == 1005) {
|
|
|
+ this.initWebsocket();
|
|
|
+ } else {
|
|
|
+ console.log("断开连接", e);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //保存文件
|
|
|
+ saveFileGame(val) {
|
|
|
+ fs.appendFile("D:\\pulseGame.txt", val + "@", (err) => {
|
|
|
+ if (err) {
|
|
|
+ console.error("Error writing to file:", err);
|
|
|
+ } else {
|
|
|
+ // console.log("Content appended successfully to file");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //切换选项时需要清空数据
|
|
|
+ clearDataFun() {
|
|
|
+ //1.首先清楚所有定时器
|
|
|
+ clearInterval(this.pulseTime);
|
|
|
+ clearInterval(this.gameTimeTimer);
|
|
|
+ //2.计时的时间
|
|
|
+ this.pulseTimeNum = 180;
|
|
|
+ //3.重置开始的按钮
|
|
|
+ this.buttonFlag = "开始";
|
|
|
+ this.gameTimeTimerFlag = false;
|
|
|
+ //4.重置数据
|
|
|
+ this.resetData();
|
|
|
+ },
|
|
|
+
|
|
|
+ resetData() {
|
|
|
+ this.send(0);
|
|
|
+ this.buttonFlag = "开始";
|
|
|
+ if (this.gameTime == 1) {
|
|
|
+ this.gameTimeReserve = 180;
|
|
|
+ this.timeShow = "03:00";
|
|
|
+ } else if (this.gameTime == 2) {
|
|
|
+ this.gameTimeReserve = 300;
|
|
|
+ this.timeShow = "05:00";
|
|
|
+ } else if (this.gameTime == 3) {
|
|
|
+ this.gameTimeReserve = 600;
|
|
|
+ this.timeShow = "10:00";
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //格式化倒计时格式
|
|
|
+ formatterTimeFun(val) {
|
|
|
+ let min = Math.floor(val / 60);
|
|
|
+ min = this.formatterSs(min);
|
|
|
+ let ss = val % 60;
|
|
|
+ ss = this.formatterSs(ss);
|
|
|
+ return min + ":" + ss;
|
|
|
+ },
|
|
|
+ formatterSs(val) {
|
|
|
+ if (val < 10) {
|
|
|
+ return "0" + val;
|
|
|
+ } else {
|
|
|
+ return val + "";
|
|
|
+ }
|
|
|
+ },
|
|
|
+ gameTimeFun(val) {
|
|
|
+ this.clearDataFun();
|
|
|
+ if (val == 1) {
|
|
|
+ this.gameTimeReserve = 180;
|
|
|
+ } else if (val == 2) {
|
|
|
+ this.gameTimeReserve = 300;
|
|
|
+ } else if (val == 3) {
|
|
|
+ this.gameTimeReserve = 600;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //当设备更换时需要初始化动画数值为0
|
|
|
+ //并且按钮初始化为开始状态
|
|
|
+ //倒计时时间也变为最初始化
|
|
|
+ //定时3分钟倒计时方法
|
|
|
+ // threeReserve(){
|
|
|
+
|
|
|
+ // },
|
|
|
+ gameDiffFun() {
|
|
|
+ this.clearDataFun();
|
|
|
+ },
|
|
|
+ equipmentFun(val) {
|
|
|
+ //先判断当选择的设备是否连接
|
|
|
+ //如果已连接,则继续测试
|
|
|
+ //如果未连接则提示连接设备
|
|
|
+ //先判断脑电
|
|
|
+ this.clearDataFun();
|
|
|
+ this.send(0);
|
|
|
+ // this.userLink.linkStatus = false;
|
|
|
+ // this.userTwoLink.linkStatus = false;
|
|
|
+ this.resetData();
|
|
|
+ this.disconnectDevice();
|
|
|
+ //切换完成后将已连接的设备调用断开的接口
|
|
|
+ //或退出当前页面时---
|
|
|
+
|
|
|
+ //设备切换以后将设备未连接的状态显示出来
|
|
|
+
|
|
|
+ //结束测试
|
|
|
+ },
|
|
|
+
|
|
|
+ //断开所有设备的操作
|
|
|
+ disconnectDevice() {
|
|
|
+ let that = this;
|
|
|
+ that.$http.getTmp(`v1/device/connected`, {}, (res) => {
|
|
|
+ // console.log(res)
|
|
|
+ //判断当前的列表是否存在该用户已点击的列表
|
|
|
+ if (res.code == 200) {
|
|
|
+ if (res.data) {
|
|
|
+ if (res.data) {
|
|
|
+ let list = [];
|
|
|
+ for (let i = 0; i < res.data.length; i++) {
|
|
|
+ let obj = {
|
|
|
+ rssi: "",
|
|
|
+ name: "",
|
|
|
+ mac: "",
|
|
|
+ connent: false,
|
|
|
+ deviceType: "",
|
|
|
+ };
|
|
|
+ obj.rssi = "";
|
|
|
+ obj.name = res.data[i].Name;
|
|
|
+ obj.mac = res.data[i].MAC;
|
|
|
+ obj.connent = true;
|
|
|
+ obj.deviceType = res.data[i].DeviceType;
|
|
|
+ obj.userNum = "";
|
|
|
+ list.push(obj);
|
|
|
+ }
|
|
|
+ that.connectedData = list;
|
|
|
+ // console.log(list);
|
|
|
+ if (list.length == 0) {
|
|
|
+ //表示未连接
|
|
|
+ that.userLink.linkStatus = false;
|
|
|
+ that.userTwoLink.linkStatus = false;
|
|
|
+ } else {
|
|
|
+ //标识已连接
|
|
|
+ for (let k = 0; k < list.length; k++) {
|
|
|
+ //调用断开设备的方法
|
|
|
+ that.disconnectEquipment(list[k]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ that.connectedData = [];
|
|
|
+ }
|
|
|
+ //打开数据接口
|
|
|
+ // that.tableData = res.data;
|
|
|
+ // that.totolSize = res.data.totalElements;
|
|
|
+ } else {
|
|
|
+ // this.$message.error("访问服务器失败!");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //需要先判断代码是否点击开始测试按钮了
|
|
|
+ //如果点击开始测试按钮了//才能发送信号到游戏
|
|
|
+ //定时器方法进行倒计时
|
|
|
+ //这是脉搏点击开始的倒计时
|
|
|
+ //倒计时结束以后进行3分钟或5分钟倒计时或十分钟倒计时
|
|
|
+ //然后自动结束
|
|
|
+ timeFun1() {
|
|
|
+ let that = this;
|
|
|
+
|
|
|
+ clearInterval(that.pulseTime);
|
|
|
+ that.pulseTimeNum = 180;
|
|
|
+ that.pulseTime = setInterval(() => {
|
|
|
+ that.timeShow = that.formatterTimeFun(that.pulseTimeNum);
|
|
|
+ that.pulseTimeNum--;
|
|
|
+ if (that.pulseTimeNum == 0) {
|
|
|
+ // that.buttonDisable = false;
|
|
|
+ //将状态改为结束
|
|
|
+ // this.buttonFlag = "结束";
|
|
|
+ clearInterval(that.pulseTime);
|
|
|
+ //倒计时开始后需要
|
|
|
+ that.timeCom();
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ },
|
|
|
+ getGameSence(val) {
|
|
|
+ console.log(val);
|
|
|
+ let gameName = "";
|
|
|
+ switch (val) {
|
|
|
+ case "1":
|
|
|
+ gameName = "心灵之火";
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ gameName = "心之花";
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ gameName = "急速赛车";
|
|
|
+ break;
|
|
|
+ case "4":
|
|
|
+ gameName = "爆爆桶";
|
|
|
+ break;
|
|
|
+ case "5":
|
|
|
+ gameName = "炸弹";
|
|
|
+ break;
|
|
|
+ case "6":
|
|
|
+ gameName = "漂浮球";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ console.log(gameName);
|
|
|
+ return gameName;
|
|
|
+ },
|
|
|
+ //获取游戏难度
|
|
|
+ getGameDiff(val) {
|
|
|
+ if (val == 1) {
|
|
|
+ return "简单";
|
|
|
+ }
|
|
|
+ if (val == 2) {
|
|
|
+ return "普通";
|
|
|
+ }
|
|
|
+ if (val == 3) {
|
|
|
+ return "困难";
|
|
|
+ }
|
|
|
+ },
|
|
|
+ formatterGameTime(val) {
|
|
|
+ if (val == "1") {
|
|
|
+ return "3分钟";
|
|
|
+ }
|
|
|
+ if (val == "2") {
|
|
|
+ return "5分钟";
|
|
|
+ }
|
|
|
+ if (val == "3") {
|
|
|
+ return "10分钟";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ },
|
|
|
+ //获取当前时间
|
|
|
+ getCurrentTimeFun() {
|
|
|
+ let data = new Date();
|
|
|
+ let year = this.formatterDate(data.getFullYear());
|
|
|
+ let month = this.formatterDate(data.getMonth() + 1);
|
|
|
+ let day = this.formatterDate(data.getDate());
|
|
|
+ let hour = this.formatterDate(data.getHours());
|
|
|
+ let minutes = this.formatterDate(data.getMinutes());
|
|
|
+ let seconds = this.formatterDate(data.getSeconds());
|
|
|
+ let microseconds = this.formatterMill(data.getMilliseconds());
|
|
|
+ return (
|
|
|
+ year +
|
|
|
+ "年" +
|
|
|
+ month +
|
|
|
+ "月" +
|
|
|
+ day +
|
|
|
+ "日" +
|
|
|
+ hour +
|
|
|
+ "时" +
|
|
|
+ minutes +
|
|
|
+ "分" +
|
|
|
+ seconds +
|
|
|
+ "秒" +
|
|
|
+ microseconds
|
|
|
+ );
|
|
|
+ },
|
|
|
+ //格式化两位数的时间数据
|
|
|
+ formatterDate(val) {
|
|
|
+ if (val < 10) {
|
|
|
+ return "0" + val;
|
|
|
+ } else {
|
|
|
+ return val;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //格式化毫秒数据
|
|
|
+ formatterMill(val) {
|
|
|
+ if (val < 10) {
|
|
|
+ return "00" + val;
|
|
|
+ } else if (val < 100) {
|
|
|
+ return "0" + val;
|
|
|
+ } else {
|
|
|
+ return val;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ timeCom() {
|
|
|
+ let that = this;
|
|
|
+ //有个标志显示当前的倒计时的状态
|
|
|
+ this.gameTimeTimerFlag = true;
|
|
|
+ //获取当前选择的是几分钟
|
|
|
+ //当选择的是3分钟时
|
|
|
+ //this.gameTimeReserve
|
|
|
+ this.gameTimeTimer = setInterval(() => {
|
|
|
+ this.timeShow = this.formatterTimeFun(this.gameTimeReserve);
|
|
|
+ this.gameTimeReserve--;
|
|
|
+ if (this.gameTimeReserve == 0) {
|
|
|
+ clearInterval(this.gameTimeTimer);
|
|
|
+ //当倒计时为0
|
|
|
+ //按钮状态改为结束
|
|
|
+ this.gameTimeTimerFlag = false;
|
|
|
+ this.buttonFlag = "开始";
|
|
|
+ if (this.equipment == 1) {
|
|
|
+ // 保存脑电数据
|
|
|
+ //参数进行保存
|
|
|
+ let params = {
|
|
|
+ type: "2", //1表示是单人模式 2代表是双人模式
|
|
|
+ num: [{ num: that.userLink.num }, { num: that.userTwoLink.num }], //个人编号
|
|
|
+ gameScene: that.getGameSence(that.$route.query.gameType), //游戏场景
|
|
|
+ equipmentType: "脑电", //设备类型
|
|
|
+ gameDifficulty: that.getGameDiff(that.gameDifficulty), //游戏难度
|
|
|
+ gameTime: that.formatterGameTime(that.gameTime), //游戏时间
|
|
|
+ // animationSourceList: that.animationSourceList, //原始数据
|
|
|
+ // fileName: "-",
|
|
|
+ // animationTarget: "", //指标数据
|
|
|
+ saveTime: that.getCurrentTimeFun(), //保存数据的时间
|
|
|
+ };
|
|
|
+ //调用保存数据的方法
|
|
|
+ that.saveAnimation(params);
|
|
|
+ }
|
|
|
+ if (this.equipment == 2) {
|
|
|
+ // 保存心电数据
|
|
|
+ //参数进行保存
|
|
|
+ let params = {
|
|
|
+ type: "2", //1表示是单人模式 2代表是双人模式
|
|
|
+ num: [{ num: that.userLink.num }, { num: that.userTwoLink.num }], //个人编号
|
|
|
+ gameScene: that.getGameSence(that.$route.query.gameType), //游戏场景
|
|
|
+ equipmentType: "心电", //设备类型
|
|
|
+ gameDifficulty: that.getGameDiff(that.gameDifficulty), //游戏难度
|
|
|
+ gameTime: that.formatterGameTime(that.gameTime), //游戏时间
|
|
|
+ // animationSourceList: that.animationSourceList, //原始数据
|
|
|
+ // fileName: "-",
|
|
|
+ // animationTarget: "", //指标数据
|
|
|
+ saveTime: that.getCurrentTimeFun(), //保存数据的时间
|
|
|
+ };
|
|
|
+ //调用保存数据的方法
|
|
|
+ that.saveAnimation(params);
|
|
|
+ }
|
|
|
+ this.resetData();
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ },
|
|
|
+ //保存游戏数据
|
|
|
+ saveAnimation(params) {
|
|
|
+ console.log(params);
|
|
|
+ console.log("游戏和数据保存");
|
|
|
+ },
|
|
|
+ startTest() {
|
|
|
+ //首先先判断是脑电还是脉搏
|
|
|
+ if (this.buttonFlag == "开始") {
|
|
|
+ if (this.equipment == 1) {
|
|
|
+ //如果是脑电.则需要判断脑电是否连接
|
|
|
+ if (this.userLink.linkStatus && this.userTwoLink.linkStatus) {
|
|
|
+ this.buttonFlag = "结束";
|
|
|
+ this.clearNaoData();
|
|
|
+ this.timeCom();
|
|
|
+ } else {
|
|
|
+ this.$message.warning("请先连接脑电设备");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //如果是脉搏,则需要判断脉搏是否是连接
|
|
|
+ if (this.userLink.linkStatus && this.userTwoLink.linkStatus) {
|
|
|
+ //如果是脉搏已连接
|
|
|
+ //点击了开始按钮
|
|
|
+ //则开始倒计时3分钟
|
|
|
+ this.timeFun1();
|
|
|
+ //清空心电数据
|
|
|
+ this.userLink.ecgAllList = [];
|
|
|
+ this.userLink.ecgSectionList = [];
|
|
|
+ this.userTwoLink.ecgAllList = [];
|
|
|
+ this.userTwoLink.ecgSectionList = [];
|
|
|
+ this.buttonFlag = "结束";
|
|
|
+ } else {
|
|
|
+ this.$message.warning("请先连接心电设备");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //改变按钮状态
|
|
|
+ this.clearDataFun();
|
|
|
+ this.resetData();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ clearNaoData() {
|
|
|
+ //清空第一个数组的数据
|
|
|
+ this.waveDataAll = [];
|
|
|
+ this.waveData = [];
|
|
|
+ //开始测试时需要清空所有数据,从头开始渲染
|
|
|
+ this.deltaDataFlagAll = [];
|
|
|
+ this.deltaDataFlag = [];
|
|
|
+
|
|
|
+ this.thetaDataAll = [];
|
|
|
+ this.thetaData = [];
|
|
|
+
|
|
|
+ this.lowAlphaDataAll = [];
|
|
|
+ this.lowAlphaData = [];
|
|
|
+
|
|
|
+ this.highAlphaDataAll = [];
|
|
|
+ this.highAlphaData = [];
|
|
|
+
|
|
|
+ this.lowBetaDataAll = [];
|
|
|
+ this.lowBetaData = [];
|
|
|
+
|
|
|
+ this.highBetaDataAll = [];
|
|
|
+ this.highBetaData = [];
|
|
|
+
|
|
|
+ this.lowGammaDataAll = [];
|
|
|
+ this.lowGammaData = [];
|
|
|
+
|
|
|
+ this.midGammaDataAll = [];
|
|
|
+ this.midGammaData = [];
|
|
|
+
|
|
|
+ this.noiseDataAll = [];
|
|
|
+ this.noiseData = [];
|
|
|
+
|
|
|
+ this.attentionDataAll = [];
|
|
|
+ this.attentionData = [];
|
|
|
+
|
|
|
+ this.meditationData = [];
|
|
|
+ this.meditationDataAll = [];
|
|
|
+
|
|
|
+ this.focusNaoAll = [];
|
|
|
+ this.focusNao = [];
|
|
|
+
|
|
|
+ //第二个用户数组的数据
|
|
|
+ this.waveDataSecond = [];
|
|
|
+ // 全量
|
|
|
+ this.waveDataAllSecond = [];
|
|
|
+
|
|
|
+ this.deltaDataFlagSecond = [];
|
|
|
+ // 全量
|
|
|
+ this.deltaDataFlagAllSecond = [];
|
|
|
+
|
|
|
+ this.deltaDataSecond = [];
|
|
|
+ // 全量
|
|
|
+ this.deltaDataAllSecond = [];
|
|
|
+
|
|
|
+ this.thetaDataSecond = [];
|
|
|
+ // 全量
|
|
|
+ this.thetaDataAllSecond = [];
|
|
|
+
|
|
|
+ this.lowAlphaDataSecond = [];
|
|
|
+ // 全量
|
|
|
+ this.lowAlphaDataAllSecond = [];
|
|
|
+
|
|
|
+ this.highAlphaDataSecond = [];
|
|
|
+ // 全量
|
|
|
+ this.highAlphaDataAllSecond = [];
|
|
|
+
|
|
|
+ this.lowBetaDataSecond = [];
|
|
|
+ // 全量
|
|
|
+ this.lowBetaDataAllSecond = [];
|
|
|
+
|
|
|
+ this.highBetaDataSecond = [];
|
|
|
+ // 全量
|
|
|
+ this.highBetaDataAllSecond = [];
|
|
|
+
|
|
|
+ this.lowGammaDataSecond = [];
|
|
|
+ // 全量
|
|
|
+ this.lowGammaDataAllSecond = [];
|
|
|
+
|
|
|
+ this.midGammaDataSecond = [];
|
|
|
+ // 全量
|
|
|
+ this.midGammaDataAllSecond = [];
|
|
|
+
|
|
|
+ this.noiseDataSecond = [];
|
|
|
+ // 全量
|
|
|
+ this.noiseDataAllSecond = [];
|
|
|
+
|
|
|
+ this.attentionDataSecond = [];
|
|
|
+ // 全量
|
|
|
+ this.attentionDataAllSecond = [];
|
|
|
+
|
|
|
+ this.meditationDataSecond = [];
|
|
|
+ // 全量
|
|
|
+ this.meditationDataAllSecond = [];
|
|
|
+
|
|
|
+ this.focusNaoSecond = [];
|
|
|
+ // 全量
|
|
|
+ this.focusNaoAllSecond = [];
|
|
|
+ },
|
|
|
+ setUrl() {},
|
|
|
+ getSize() {
|
|
|
+ let width = this.$refs.animationFlow.clientWidth;
|
|
|
+ let height = this.$refs.animationFlow.clientHeight - 20;
|
|
|
+ this.widthIframe = width;
|
|
|
+ this.heightIframe = height + 20;
|
|
|
+ this.changeSize(width, height);
|
|
|
+ },
|
|
|
+ changeSize(width, height) {
|
|
|
+ this.$refs.unityIframe.contentWindow.changeSize(width, height);
|
|
|
+ },
|
|
|
+ send(val) {
|
|
|
+ this.$refs.unityIframe.contentWindow.Bloomsize(val);
|
|
|
+ },
|
|
|
+ // btt() {
|
|
|
+ // let that = this;
|
|
|
+ // this.$refs.unityvueFlower.message("flower", "enableCamera", "true");
|
|
|
+ // },
|
|
|
+ delayTime() {
|
|
|
+ let that = this;
|
|
|
+ setTimeout(() => {
|
|
|
+ that.getSize();
|
|
|
+ }, 5000);
|
|
|
+ },
|
|
|
+ changeGame(val) {
|
|
|
+ console.log(val);
|
|
|
+ this.clearDataFun();
|
|
|
+ switch (val) {
|
|
|
+ case 1:
|
|
|
+ this.urlThreeP = this.pubSrc + "/candle/index.html";
|
|
|
+ // this.urlThreeP = pubSrc+ + "/candle/index.html";
|
|
|
+ this.delayTime();
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ this.urlThreeP = this.pubSrc + "/flower/index.html";
|
|
|
+ // this.urlThreeP = __static + "/flower/index.html";
|
|
|
+ this.delayTime();
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ this.urlThreeP = this.pubSrc + "/car/index.html";
|
|
|
+ // this.urlThreeP = __static + "/car/index.html";
|
|
|
+ this.delayTime();
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ this.urlThreeP = this.pubSrc + "/baobaotong/index.html";
|
|
|
+ // this.urlThreeP = __static + "/baobaotong/index.html";
|
|
|
+ this.delayTime();
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ this.urlThreeP = this.pubSrc + "/bomb/index.html";
|
|
|
+ // this.urlThreeP = __static + "/bomb/index.html";
|
|
|
+ this.delayTime();
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ this.urlThreeP = this.pubSrc + "/piaofuqiu/index.html";
|
|
|
+ // this.urlThreeP = __static + "/piaofuqiu/index.html";
|
|
|
+ this.delayTime();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ this.urlThreeP = this.pubSrc + "/candle/index.html";
|
|
|
+ // this.urlThreeP = __static + "/candle/index.html";
|
|
|
+ }
|
|
|
+ this.gameScene = val;
|
|
|
+ this.flag = this.gameScene;
|
|
|
+ },
|
|
|
+
|
|
|
+ chlz() {
|
|
|
+ this.sendUnity(Math.round(Math.random() * 100));
|
|
|
+ },
|
|
|
+ sendUnity(val) {
|
|
|
+ let a = val / 100;
|
|
|
+ this.$refs.unityvue.message("littlefire", "sssize", a);
|
|
|
+ },
|
|
|
+ goBack() {
|
|
|
+ this.$router.go(-1);
|
|
|
+ },
|
|
|
+ //心电1
|
|
|
+ renderEcgOne() {
|
|
|
+ let that = this;
|
|
|
+ let sarr = [];
|
|
|
+ // 当全量小于等于10时 显示1-10
|
|
|
+ if (that.userLink.ecgAllList.length <= that.intervalLength) {
|
|
|
+ for (let i = 0; i <= that.intervalLength; i++) {
|
|
|
+ // i = i.toFixed(3);
|
|
|
+ sarr.push(i.toString());
|
|
|
+ }
|
|
|
+ } else if (that.userLink.ecgAllList.length > that.intervalLength) {
|
|
|
+ for (
|
|
|
+ let i = that.userLink.ecgAllList.length - that.intervalLength;
|
|
|
+ i < that.userLink.ecgAllList.length;
|
|
|
+ i++
|
|
|
+ ) {
|
|
|
+ sarr.push(i.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ let dataEcg = JSON.parse(JSON.stringify(that.userLink.ecgSectionList));
|
|
|
+
|
|
|
+ let min = Math.min(...dataEcg);
|
|
|
+
|
|
|
+ let dataEcgFin = [];
|
|
|
+ for (let i = 0; i < dataEcg.length; i++) {
|
|
|
+ dataEcgFin.push(dataEcg[i] - min);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.optionEcg = {
|
|
|
+ animation: false,
|
|
|
+ title: {
|
|
|
+ text: "心电信号",
|
|
|
+ subtext: "",
|
|
|
+ left: "center",
|
|
|
+ align: "right",
|
|
|
+ x: "center",
|
|
|
+ y: "bottom",
|
|
|
+ },
|
|
|
+ grid: {
|
|
|
+ bottom: 80,
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ data: ["ECG"],
|
|
|
+ // left: 10,
|
|
|
+ },
|
|
|
+ xAxis: [
|
|
|
+ {
|
|
|
+ name: "秒(s)",
|
|
|
+ type: "category",
|
|
|
+ boundaryGap: false,
|
|
|
+ axisLine: { onZero: false },
|
|
|
+ splitLine: { show: true },
|
|
|
+ data: sarr,
|
|
|
+ axisLabel: {
|
|
|
+ interval: 99,
|
|
|
+ formatter: function (value, index) {
|
|
|
+ // console.log(value);
|
|
|
+ // console.log(index);
|
|
|
+
|
|
|
+ let a = parseInt(value);
|
|
|
+ // a = Math.round(a / 120);
|
|
|
+
|
|
|
+ return a / 100;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ yAxis: [
|
|
|
+ {
|
|
|
+ name: "",
|
|
|
+ type: "value",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+
|
|
|
+ name: "ECG",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ data: dataEcgFin,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+
|
|
|
+ this.echartsEcg.setOption(this.optionEcg);
|
|
|
+ },
|
|
|
+ //心电2
|
|
|
+ renderEcgTwo() {
|
|
|
+ let that = this;
|
|
|
+ let sarr = [];
|
|
|
+ // 当全量小于等于10时 显示1-10
|
|
|
+ if (that.userTwoLink.ecgAllList.length <= that.intervalLength) {
|
|
|
+ for (let i = 0; i <= that.intervalLength; i++) {
|
|
|
+ // i = i.toFixed(3);
|
|
|
+ sarr.push(i.toString());
|
|
|
+ }
|
|
|
+ } else if (that.userTwoLink.ecgAllList.length > that.intervalLength) {
|
|
|
+ for (
|
|
|
+ let i = that.userTwoLink.ecgAllList.length - that.intervalLength;
|
|
|
+ i < that.userTwoLink.ecgAllList.length;
|
|
|
+ i++
|
|
|
+ ) {
|
|
|
+ sarr.push(i.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ let dataEcg = JSON.parse(JSON.stringify(that.userTwoLink.ecgSectionList));
|
|
|
+
|
|
|
+ let min = Math.min(...dataEcg);
|
|
|
+
|
|
|
+ let dataEcgFin = [];
|
|
|
+ for (let i = 0; i < dataEcg.length; i++) {
|
|
|
+ dataEcgFin.push(dataEcg[i] - min);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.optionEcgTwo = {
|
|
|
+ animation: false,
|
|
|
+ title: {
|
|
|
+ text: "心电信号",
|
|
|
+ subtext: "",
|
|
|
+ left: "center",
|
|
|
+ align: "right",
|
|
|
+ x: "center",
|
|
|
+ y: "bottom",
|
|
|
+ },
|
|
|
+ grid: {
|
|
|
+ bottom: 80,
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ data: ["ECG"],
|
|
|
+ // left: 10,
|
|
|
+ },
|
|
|
+ xAxis: [
|
|
|
+ {
|
|
|
+ name: "秒(s)",
|
|
|
+ type: "category",
|
|
|
+ boundaryGap: false,
|
|
|
+ axisLine: { onZero: false },
|
|
|
+ splitLine: { show: true },
|
|
|
+ data: sarr,
|
|
|
+ axisLabel: {
|
|
|
+ interval: 99,
|
|
|
+ formatter: function (value, index) {
|
|
|
+ console.log(value);
|
|
|
+ let a = parseInt(value);
|
|
|
+ // a = Math.round(a / 100);
|
|
|
+ // if(a%100==0){
|
|
|
+ // return value;
|
|
|
+ // }
|
|
|
+ return a / 100;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ // axisLabel: {
|
|
|
+ // interval: 512,
|
|
|
+ // formatter: function (value, index) {
|
|
|
+ // // 当当前value除以1000为整数是
|
|
|
+ // // console.log(value);
|
|
|
+ // // 将value转化为int类型
|
|
|
+ // let a = parseInt(value);
|
|
|
+ // a = Math.round(a / 512);
|
|
|
+ // // if (a %510 == 0) {
|
|
|
+ // // // if ((a / 1000) % 2 == 0) {
|
|
|
+ // // // return a / 1000;
|
|
|
+ // // // }
|
|
|
+ // // return a / 1000;
|
|
|
+ // // }
|
|
|
+ // return a;
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ yAxis: [
|
|
|
+ {
|
|
|
+ name: "",
|
|
|
+ type: "value",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+
|
|
|
+ name: "ECG",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ data: dataEcgFin,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+
|
|
|
+ this.echartsEcgTwo.setOption(this.optionEcgTwo);
|
|
|
+ },
|
|
|
+ //脑电1
|
|
|
+ renderEegOne() {
|
|
|
+ let sarr = [];
|
|
|
+ // 当全量小于等于10时 显示1-10
|
|
|
+ if (this.focusNaoAll.length <= 10) {
|
|
|
+ for (let i = 0; i <= 10; i++) {
|
|
|
+ // i = i.toFixed(3);
|
|
|
+ sarr.push(i.toString());
|
|
|
+ }
|
|
|
+ } else if (this.focusNaoAll.length > 10) {
|
|
|
+ for (
|
|
|
+ let i = this.focusNaoAll.length - 10;
|
|
|
+ i < this.focusNaoAll.length;
|
|
|
+ i++
|
|
|
+ ) {
|
|
|
+ sarr.push(i.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.optionOne = {
|
|
|
+ animation: false,
|
|
|
+ title: {
|
|
|
+ text: "频谱成分",
|
|
|
+ subtext: "",
|
|
|
+ left: "center",
|
|
|
+ align: "right",
|
|
|
+ x: "center",
|
|
|
+ y: "bottom",
|
|
|
+ },
|
|
|
+ grid: {
|
|
|
+ bottom: 80,
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ data: [
|
|
|
+ "Delta",
|
|
|
+ "Theta",
|
|
|
+ "Low Alpha",
|
|
|
+ "High Alpha",
|
|
|
+ "Low Beta",
|
|
|
+ "High Beta",
|
|
|
+ "Low Gamma",
|
|
|
+ "Mid Gamma",
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ xAxis: [
|
|
|
+ {
|
|
|
+ name: "秒(s)",
|
|
|
+ type: "category",
|
|
|
+ boundaryGap: false,
|
|
|
+ axisLine: { onZero: false },
|
|
|
+ splitLine: { show: true },
|
|
|
+ data: sarr,
|
|
|
+ axisLabel: {
|
|
|
+ // interval: 999,
|
|
|
+ formatter: function (value, index) {
|
|
|
+ let a = parseInt(value);
|
|
|
+ if (a % 1000 == 0) {
|
|
|
+ if ((a / 1000) % 2 == 0) {
|
|
|
+ return a / 1000;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return value;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ yAxis: [
|
|
|
+ {
|
|
|
+ name: "",
|
|
|
+ type: "value",
|
|
|
+ // max: 500,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Delta",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.deltaData,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Theta",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.thetaData,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Low Alpha",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.lowAlphaData,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "High Alpha",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.highAlphaData,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Low Beta",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.lowBetaData,
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "High Beta",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.highBetaData,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Low Gamma",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.lowGammaData,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Mid Gamma",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.midGammaData,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ this.echartsOne.setOption(this.optionOne);
|
|
|
+ },
|
|
|
+ renderEegTwo() {
|
|
|
+ let sarr = [];
|
|
|
+ // 当全量小于等于10时 显示1-10
|
|
|
+ if (this.focusNaoAll.length <= 10) {
|
|
|
+ for (let i = 0; i <= 10; i++) {
|
|
|
+ // i = i.toFixed(3);
|
|
|
+ sarr.push(i.toString());
|
|
|
+ }
|
|
|
+ } else if (this.focusNaoAll.length > 10) {
|
|
|
+ for (
|
|
|
+ let i = this.focusNaoAll.length - 10;
|
|
|
+ i < this.focusNaoAll.length;
|
|
|
+ i++
|
|
|
+ ) {
|
|
|
+ sarr.push(i.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.optionTwo = {
|
|
|
+ animation: false,
|
|
|
+ title: {
|
|
|
+ text: "注意力指标",
|
|
|
+ subtext: "",
|
|
|
+ left: "center",
|
|
|
+ align: "right",
|
|
|
+ x: "center",
|
|
|
+ y: "bottom",
|
|
|
+ },
|
|
|
+ grid: {
|
|
|
+ bottom: 80,
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ data: ["Noise", "Attention", "Medition"],
|
|
|
+ // left: 10,
|
|
|
+ },
|
|
|
+ xAxis: [
|
|
|
+ {
|
|
|
+ name: "秒(s)",
|
|
|
+ type: "category",
|
|
|
+ boundaryGap: false,
|
|
|
+ axisLine: { onZero: false },
|
|
|
+ splitLine: { show: true },
|
|
|
+ data: sarr,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ yAxis: [
|
|
|
+ {
|
|
|
+ name: "秒(s)",
|
|
|
+ type: "value",
|
|
|
+ // max: 500,
|
|
|
+ },
|
|
|
+ // {
|
|
|
+ // name: "秒(s)",
|
|
|
+ // nameLocation: "start",
|
|
|
+ // // max: 5,
|
|
|
+ // type: "value",
|
|
|
+ // inverse: false,
|
|
|
+ // },
|
|
|
+ ],
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Noise",
|
|
|
+ type: "line",
|
|
|
+ yAxisIndex: 0,
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.noiseData,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Attention",
|
|
|
+ type: "line",
|
|
|
+ yAxisIndex: 0,
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.attentionData,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Medition",
|
|
|
+ type: "line",
|
|
|
+ yAxisIndex: 0,
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.meditationData,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ this.echartsTwo.setOption(this.optionTwo);
|
|
|
+ },
|
|
|
+ renderEegThree() {
|
|
|
+ let sarr = [];
|
|
|
+ // 当全量小于等于10时 显示1-10
|
|
|
+ if (this.waveDataAll.length <= 5120) {
|
|
|
+ for (let i = 0; i <= 5120; i++) {
|
|
|
+ // i = i.toFixed(3);
|
|
|
+ sarr.push(i.toString());
|
|
|
+ }
|
|
|
+ } else if (this.waveDataAll.length > 5120) {
|
|
|
+ for (
|
|
|
+ let i = this.waveDataAll.length - 5120;
|
|
|
+ i < this.waveDataAll.length;
|
|
|
+ i++
|
|
|
+ ) {
|
|
|
+ sarr.push(i.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.optionThree = {
|
|
|
+ animation: false,
|
|
|
+ title: {
|
|
|
+ text: "原始信号",
|
|
|
+ subtext: "",
|
|
|
+ left: "center",
|
|
|
+ align: "right",
|
|
|
+ x: "center",
|
|
|
+ y: "bottom",
|
|
|
+ },
|
|
|
+ grid: {
|
|
|
+ bottom: 80,
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ data: ["RAW Wave"],
|
|
|
+ // left: 10,
|
|
|
+ },
|
|
|
+ xAxis: [
|
|
|
+ {
|
|
|
+ name: "秒(s)",
|
|
|
+ type: "category",
|
|
|
+ boundaryGap: false,
|
|
|
+ axisLine: { onZero: false },
|
|
|
+ splitLine: { show: true },
|
|
|
+ data: sarr,
|
|
|
+ axisLabel: {
|
|
|
+ interval: 512,
|
|
|
+ formatter: function (value, index) {
|
|
|
+ // 当当前value除以1000为整数是
|
|
|
+ // console.log(value);
|
|
|
+ // 将value转化为int类型
|
|
|
+ let a = parseInt(value);
|
|
|
+ a = Math.round(a / 512);
|
|
|
+ // if (a %510 == 0) {
|
|
|
+ // // if ((a / 1000) % 2 == 0) {
|
|
|
+ // // return a / 1000;
|
|
|
+ // // }
|
|
|
+ // return a / 1000;
|
|
|
+ // }
|
|
|
+ return a;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ yAxis: [
|
|
|
+ {
|
|
|
+ name: "",
|
|
|
+ type: "value",
|
|
|
+ // max: 500,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+
|
|
|
+ name: "RAW Wave",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ data: this.waveData,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ this.echartsThree.setOption(this.optionThree);
|
|
|
+ },
|
|
|
+ //脑电2
|
|
|
+ renderEegOneSecond() {
|
|
|
+ let sarr = [];
|
|
|
+ // 当全量小于等于10时 显示1-10
|
|
|
+ if (this.focusNaoAllSecond.length <= 10) {
|
|
|
+ for (let i = 0; i <= 10; i++) {
|
|
|
+ // i = i.toFixed(3);
|
|
|
+ sarr.push(i.toString());
|
|
|
+ }
|
|
|
+ } else if (this.focusNaoAllSecond.length > 10) {
|
|
|
+ for (
|
|
|
+ let i = this.focusNaoAllSecond.length - 10;
|
|
|
+ i < this.focusNaoAllSecond.length;
|
|
|
+ i++
|
|
|
+ ) {
|
|
|
+ sarr.push(i.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.optionOneSecond = {
|
|
|
+ animation: false,
|
|
|
+ title: {
|
|
|
+ text: "频谱成分",
|
|
|
+ subtext: "",
|
|
|
+ left: "center",
|
|
|
+ align: "right",
|
|
|
+ x: "center",
|
|
|
+ y: "bottom",
|
|
|
+ },
|
|
|
+ grid: {
|
|
|
+ bottom: 80,
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ data: [
|
|
|
+ "Delta",
|
|
|
+ "Theta",
|
|
|
+ "Low Alpha",
|
|
|
+ "High Alpha",
|
|
|
+ "Low Beta",
|
|
|
+ "High Beta",
|
|
|
+ "Low Gamma",
|
|
|
+ "Mid Gamma",
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ xAxis: [
|
|
|
+ {
|
|
|
+ name: "秒(s)",
|
|
|
+ type: "category",
|
|
|
+ boundaryGap: false,
|
|
|
+ axisLine: { onZero: false },
|
|
|
+ splitLine: { show: true },
|
|
|
+ data: sarr,
|
|
|
+ axisLabel: {
|
|
|
+ // interval: 999,
|
|
|
+ formatter: function (value, index) {
|
|
|
+ let a = parseInt(value);
|
|
|
+ if (a % 1000 == 0) {
|
|
|
+ if ((a / 1000) % 2 == 0) {
|
|
|
+ return a / 1000;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return value;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ yAxis: [
|
|
|
+ {
|
|
|
+ name: "",
|
|
|
+ type: "value",
|
|
|
+ // max: 500,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Delta",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.deltaDataSecond,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Theta",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.thetaDataSecond,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Low Alpha",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.lowAlphaDataSecond,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "High Alpha",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.highAlphaDataSecond,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Low Beta",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.lowBetaDataSecond,
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "High Beta",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.highBetaDataSecond,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Low Gamma",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.lowGammaDataSecond,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Mid Gamma",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.midGammaDataSecond,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ this.echartsOneSecond.setOption(this.optionOneSecond);
|
|
|
+ },
|
|
|
+ renderEegTwoSecond() {
|
|
|
+ let sarr = [];
|
|
|
+ // 当全量小于等于10时 显示1-10
|
|
|
+ if (this.focusNaoAllSecond.length <= 10) {
|
|
|
+ for (let i = 0; i <= 10; i++) {
|
|
|
+ // i = i.toFixed(3);
|
|
|
+ sarr.push(i.toString());
|
|
|
+ }
|
|
|
+ } else if (this.focusNaoAllSecond.length > 10) {
|
|
|
+ for (
|
|
|
+ let i = this.focusNaoAllSecond.length - 10;
|
|
|
+ i < this.focusNaoAllSecond.length;
|
|
|
+ i++
|
|
|
+ ) {
|
|
|
+ sarr.push(i.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.optionTwoSecond = {
|
|
|
+ animation: false,
|
|
|
+ title: {
|
|
|
+ text: "注意力指标",
|
|
|
+ subtext: "",
|
|
|
+ left: "center",
|
|
|
+ align: "right",
|
|
|
+ x: "center",
|
|
|
+ y: "bottom",
|
|
|
+ },
|
|
|
+ grid: {
|
|
|
+ bottom: 80,
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ data: ["Noise", "Attention", "Medition"],
|
|
|
+ // left: 10,
|
|
|
+ },
|
|
|
+ xAxis: [
|
|
|
+ {
|
|
|
+ name: "秒(s)",
|
|
|
+ type: "category",
|
|
|
+ boundaryGap: false,
|
|
|
+ axisLine: { onZero: false },
|
|
|
+ splitLine: { show: true },
|
|
|
+ data: sarr,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ yAxis: [
|
|
|
+ {
|
|
|
+ name: "秒(s)",
|
|
|
+ type: "value",
|
|
|
+ // max: 500,
|
|
|
+ },
|
|
|
+ // {
|
|
|
+ // name: "秒(s)",
|
|
|
+ // nameLocation: "start",
|
|
|
+ // // max: 5,
|
|
|
+ // type: "value",
|
|
|
+ // inverse: false,
|
|
|
+ // },
|
|
|
+ ],
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Noise",
|
|
|
+ type: "line",
|
|
|
+ yAxisIndex: 0,
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.noiseDataSecond,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Attention",
|
|
|
+ type: "line",
|
|
|
+ yAxisIndex: 0,
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.attentionDataSecond,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+ name: "Medition",
|
|
|
+ type: "line",
|
|
|
+ yAxisIndex: 0,
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ focus: "series",
|
|
|
+ },
|
|
|
+ markArea: {
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.3,
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/10\n7:00",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ xAxis: "2009/9/20\n7:00",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ data: this.meditationDataSecond,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ this.echartsTwoSecond.setOption(this.optionTwoSecond);
|
|
|
+ },
|
|
|
+ renderEegThreeSecond() {
|
|
|
+ let sarr = [];
|
|
|
+ // 当全量小于等于10时 显示1-10
|
|
|
+ if (this.waveDataAllSecond.length <= 5120) {
|
|
|
+ for (let i = 0; i <= 5120; i++) {
|
|
|
+ // i = i.toFixed(3);
|
|
|
+ sarr.push(i.toString());
|
|
|
+ }
|
|
|
+ } else if (this.waveDataAllSecond.length > 5120) {
|
|
|
+ for (
|
|
|
+ let i = this.waveDataAllSecond.length - 5120;
|
|
|
+ i < this.waveDataAllSecond.length;
|
|
|
+ i++
|
|
|
+ ) {
|
|
|
+ sarr.push(i.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.optionThreeSecond = {
|
|
|
+ animation: false,
|
|
|
+ title: {
|
|
|
+ text: "原始信号",
|
|
|
+ subtext: "",
|
|
|
+ left: "center",
|
|
|
+ align: "right",
|
|
|
+ x: "center",
|
|
|
+ y: "bottom",
|
|
|
+ },
|
|
|
+ grid: {
|
|
|
+ bottom: 80,
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ data: ["RAW Wave"],
|
|
|
+ // left: 10,
|
|
|
+ },
|
|
|
+ xAxis: [
|
|
|
+ {
|
|
|
+ name: "秒(s)",
|
|
|
+ type: "category",
|
|
|
+ boundaryGap: false,
|
|
|
+ axisLine: { onZero: false },
|
|
|
+ splitLine: { show: true },
|
|
|
+ data: sarr,
|
|
|
+ axisLabel: {
|
|
|
+ interval: 512,
|
|
|
+ formatter: function (value, index) {
|
|
|
+ // 当当前value除以1000为整数是
|
|
|
+ // console.log(value);
|
|
|
+ // 将value转化为int类型
|
|
|
+ let a = parseInt(value);
|
|
|
+ a = Math.round(a / 512);
|
|
|
+ // if (a %510 == 0) {
|
|
|
+ // // if ((a / 1000) % 2 == 0) {
|
|
|
+ // // return a / 1000;
|
|
|
+ // // }
|
|
|
+ // return a / 1000;
|
|
|
+ // }
|
|
|
+ return a;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ yAxis: [
|
|
|
+ {
|
|
|
+ name: "",
|
|
|
+ type: "value",
|
|
|
+ // max: 500,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ showSymbol: false,
|
|
|
+
|
|
|
+ name: "RAW Wave",
|
|
|
+ type: "line",
|
|
|
+
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ data: this.waveDataSecond,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ this.echartsThreeSecond.setOption(this.optionThreeSecond);
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style scoped>
|
|
|
+.equipment_status {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+.main_right_height {
|
|
|
+ height: 100vh !important;
|
|
|
+ display: block !important;
|
|
|
+ overflow-y: auto !important;
|
|
|
+ background: #ffffff;
|
|
|
+}
|
|
|
+canvas {
|
|
|
+ /* width: 100%;
|
|
|
+ height: 100%; */
|
|
|
+}
|
|
|
+.main-unity {
|
|
|
+ margin-top: 10px;
|
|
|
+}
|
|
|
+</style>
|
|
|
+<style>
|
|
|
+.footer {
|
|
|
+ text-align: center;
|
|
|
+}
|
|
|
+.fullscreen {
|
|
|
+ margin-top: 25px !important;
|
|
|
+
|
|
|
+ text-align: center !important;
|
|
|
+ display: none !important;
|
|
|
+}
|
|
|
+.musicTitle {
|
|
|
+ display: block;
|
|
|
+ font-size: 18px;
|
|
|
+ color: #57acbb;
|
|
|
+ margin-bottom: 5px;
|
|
|
+}
|
|
|
+.flood-plan-page {
|
|
|
+ /* margin-top:20px; */
|
|
|
+}
|
|
|
+.selectSty {
|
|
|
+ width: 100px;
|
|
|
+ font-size: 14px;
|
|
|
+}
|
|
|
+.desSty {
|
|
|
+ font-size: 12px;
|
|
|
+ font-family: Source Han Sans CN-Regular, Source Han Sans CN;
|
|
|
+ font-weight: 500;
|
|
|
+ /* color: #0f0f0f; */
|
|
|
+}
|
|
|
+.animation_fk {
|
|
|
+}
|
|
|
+.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;
|
|
|
+}
|
|
|
+.naoOneClass {
|
|
|
+ width: 100%;
|
|
|
+ height: 30vh;
|
|
|
+ width: 100%;
|
|
|
+}
|
|
|
+</style>
|