AnimationDes.vue 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364
  1. <template>
  2. <div class="main_right_height">
  3. <TopDes :flag="true" topDesFont="生物反馈记录"></TopDes>
  4. <!-- <el-row>
  5. <el-col :span="1">&nbsp;</el-col>
  6. <el-col :span="22">
  7. <span class="musicTitle">生物反馈</span>
  8. <el-divider></el-divider>
  9. </el-col>
  10. <el-col :span="1">&nbsp;</el-col>
  11. </el-row> -->
  12. <el-row>
  13. <el-col :span="1"> &nbsp; </el-col>
  14. <el-col :span="22">
  15. <div class="select_class_animation">
  16. <span class="desSty">选择设备</span>&nbsp;
  17. <el-select
  18. v-model="equipment"
  19. placeholder="请选择"
  20. class="selectSty"
  21. size="medium"
  22. @change="equipmentFun"
  23. >
  24. <el-option
  25. class="select_option"
  26. v-for="item in optionsEquipment"
  27. :key="item.value"
  28. :label="item.label"
  29. :value="item.value"
  30. >
  31. </el-option>
  32. </el-select>
  33. &nbsp;&nbsp;&nbsp;&nbsp;
  34. <span class="desSty">游戏难度</span>&nbsp;
  35. <el-select
  36. v-model="gameDifficulty"
  37. placeholder="请选择"
  38. class="selectSty"
  39. size="medium"
  40. @change="gameDiffFun"
  41. >
  42. <el-option
  43. v-for="item in difficultyOptions"
  44. :key="item.value"
  45. :label="item.label"
  46. :value="item.value"
  47. >
  48. </el-option>
  49. </el-select>
  50. &nbsp;&nbsp;&nbsp;&nbsp;
  51. <span class="desSty">游戏时间</span>&nbsp;
  52. <el-select
  53. v-model="gameTime"
  54. placeholder="请选择"
  55. class="selectSty"
  56. size="medium"
  57. @change="gameTimeFun"
  58. >
  59. <el-option
  60. v-for="item in timeOptions"
  61. :key="item.value"
  62. :label="item.label"
  63. :value="item.value"
  64. >
  65. </el-option>
  66. </el-select>
  67. &nbsp;&nbsp;&nbsp;&nbsp;
  68. <div class="equipment_status">
  69. <span
  70. class="desSty"
  71. v-show="linkStatus"
  72. :style="{ color: linkStatus ? '#0FB577' : '#000000' }"
  73. >设备已连接:</span
  74. >
  75. <span class="desSty" v-show="!linkStatus">设备未连接:</span>
  76. <img
  77. v-show="!linkStatus"
  78. @click="openTableFun"
  79. style="width: 14px; height: 20px; color: #ffffff"
  80. src="../assets/newAnimation/lanya.png"
  81. />
  82. <img
  83. v-show="linkStatus"
  84. @click="openTableFun"
  85. style="width: 14px; height: 20px; color: #ffffff"
  86. src="../assets/newAnimation/lanyaActive.png"
  87. />
  88. </div>
  89. &nbsp;&nbsp;&nbsp;&nbsp;
  90. <span
  91. class="desSty"
  92. @click="viewEchartsFun"
  93. :style="{ color: linkStatus ? '#0FB577' : '#000000' }"
  94. >查看波形图</span
  95. >
  96. &nbsp;&nbsp;&nbsp;&nbsp;
  97. <span
  98. style="font-size: 12px"
  99. v-show="equipment == '2' && pulseTimeNum < 180 && pulseTimeNum > 0"
  100. >还剩{{ timeShow }}开始</span
  101. >
  102. <span
  103. style="font-size: 12px"
  104. v-show="buttonFlag == '结束' && gameTimeTimerFlag"
  105. >{{ timeShow }}</span
  106. >
  107. <div class="animation-middle-m">&nbsp;</div>
  108. <el-button
  109. @click="startTest"
  110. size="small"
  111. class="xl_animation_button"
  112. style="float: right; font-size: 12px"
  113. >{{ buttonFlag }}</el-button
  114. >
  115. </div>
  116. <el-row> </el-row>
  117. <el-row> </el-row>
  118. <el-row>
  119. <el-col :span="24">
  120. <div
  121. class="flood-plan-page"
  122. ref="animationFlow"
  123. style="display: block; height: 72vh; margin-top: 10px"
  124. >
  125. <iframe
  126. scrolling="no"
  127. :src="urlThreeP"
  128. ref="unityIframe"
  129. frameborder="0"
  130. :width="widthIframe"
  131. :height="heightIframe"
  132. >
  133. </iframe>
  134. </div>
  135. </el-col>
  136. </el-row>
  137. </el-col>
  138. <el-col :span="1"> &nbsp; </el-col>
  139. </el-row>
  140. <el-dialog title="提示" :visible.sync="tableVisible" width="60%" center>
  141. <span>
  142. <el-table
  143. :data="mergeData"
  144. style="width: 100%; height: 400px"
  145. :header-cell-style="{
  146. background: '#66B497',
  147. color: '#FFFFFF',
  148. 'letter-spacing': '4px',
  149. }"
  150. >
  151. <el-table-column prop="rssi" align="center" label="信号强度">
  152. </el-table-column>
  153. <el-table-column
  154. prop="deviceType"
  155. align="center"
  156. label="类型"
  157. :formatter="typeFormatter"
  158. >
  159. </el-table-column>
  160. <!-- <el-table-column
  161. prop="Name"
  162. :formatter="nameFormatter"
  163. align="center"
  164. label="类型"
  165. >
  166. </el-table-column> -->
  167. <el-table-column prop="userNum" align="center" label="已绑用户">
  168. </el-table-column>
  169. <el-table-column prop="mac" align="center" label="mac">
  170. </el-table-column>
  171. <el-table-column label="操作" align="center">
  172. <template slot-scope="scope">
  173. <el-button
  174. :disabled="buttonLinkFlag"
  175. class="xl_d_button"
  176. size="mini"
  177. slot="reference"
  178. @click="linkJudge(scope.$index, scope.row, scope.row.connent)"
  179. >
  180. <span v-if="scope.row.connent">断开连接</span
  181. ><span v-if="!scope.row.connent">连接</span></el-button
  182. >
  183. </template>
  184. </el-table-column>
  185. </el-table>
  186. </span>
  187. <span slot="footer" class="dialog-footer">
  188. <el-button @click="tableVisible = false">取 消</el-button>
  189. <el-button type="primary" @click="tableVisible = false"
  190. >确 定</el-button
  191. >
  192. </span>
  193. </el-dialog>
  194. <el-dialog
  195. title="查看波形图"
  196. :visible.sync="echartsVisible"
  197. width="90%"
  198. center
  199. >
  200. <span>
  201. <div class="outPage" v-show="equipment == '1'">
  202. <div id="eegOne" class="naoOneClass"></div>
  203. </div>
  204. <div class="outPage" v-show="equipment == '1'">
  205. <div id="eegTwo" class="naoOneClass"></div>
  206. </div>
  207. <div class="outThreePage" v-show="equipment == '1'">
  208. <div id="eegThree" class="naoOneClass"></div>
  209. </div>
  210. <div class="outPage" v-show="equipment == '2'">
  211. <div id="ecgOne" class="naoOneClass" style="height: 500px"></div>
  212. </div>
  213. </span>
  214. <span slot="footer" class="dialog-footer">
  215. <el-button @click="echartsVisible = false">取 消</el-button>
  216. <el-button type="primary" @click="echartsVisible = false"
  217. >确 定</el-button
  218. >
  219. </span>
  220. </el-dialog>
  221. </div>
  222. </template>
  223. <script>
  224. //一个弹出框显示脑电或心电的显示图,外边显示脑电设备状态
  225. // 查看选择设备的状态,判断波形是哪个?
  226. import * as echarts from "echarts";
  227. import Utils from "./util.js";
  228. const fs = require("fs");
  229. const { ipcRenderer } = require("electron");
  230. const RingBuffer = require("ringbufferjs");
  231. // import RingBuffer from 'ringbufferjs'
  232. export default {
  233. data() {
  234. return {
  235. activeName: "first",
  236. //echarts渲染标志
  237. echartsVisible: false,
  238. echartsOne: null,
  239. echartsTwo: null,
  240. echartsThree: null,
  241. //心电连接对象
  242. echartsEcg: null,
  243. optionOne: null,
  244. optionTwo: null,
  245. optionThree: null,
  246. //心电option
  247. optionEcg: null,
  248. //打开设备进行选择的列表
  249. openTableFlag: "",
  250. scanData: [],
  251. connectedData: [],
  252. websock: null,
  253. tableVisible: false,
  254. linkIndex: null,
  255. //是否是单个训练
  256. singleFlag: true,
  257. buttonDisable: true,
  258. //脉搏开始前倒计时
  259. pulseTimeNum: 180,
  260. pulseTime: null,
  261. gameValue: 0,
  262. timeShow: "",
  263. buttonFlag: "开始",
  264. //脑电是否连接的状态
  265. eleFlag: "未连接",
  266. //脉搏是否连接的状态
  267. pulseFlag: "未连接",
  268. widthIframe: 900,
  269. heightIframe: 600,
  270. flag: 1,
  271. //游戏场景
  272. gameScene: 1,
  273. optionsGame: [
  274. {
  275. value: 1,
  276. label: "心灵之火",
  277. },
  278. {
  279. value: 2,
  280. label: "心之花",
  281. },
  282. {
  283. value: 3,
  284. label: "急速赛车",
  285. },
  286. {
  287. value: 4,
  288. label: "爆爆桶",
  289. },
  290. {
  291. value: 5,
  292. label: "炸弹",
  293. },
  294. {
  295. value: 6,
  296. label: "漂浮球",
  297. },
  298. ],
  299. //设备选择
  300. equipment: 1,
  301. optionsEquipment: [
  302. { value: 1, label: "脑电" },
  303. { value: 2, label: "心电" },
  304. ],
  305. //游戏难度
  306. gameDifficulty: 1,
  307. difficultyOptions: [
  308. { value: 1, label: "简单" },
  309. { value: 2, label: "普通" },
  310. { value: 3, label: "困难" },
  311. ],
  312. //游戏时间
  313. gameTimeReserve: 180,
  314. gameTime: 1,
  315. timeOptions: [
  316. { value: 1, label: "三分钟" },
  317. { value: 2, label: "五分钟" },
  318. { value: 3, label: "十分钟" },
  319. ],
  320. waitTimePluse: 0,
  321. testTime: 0,
  322. gameTimeTimer: null,
  323. //是否显示的倒计时标志
  324. gameTimeTimerFlag: false,
  325. //脑电变量
  326. waveData: [],
  327. // 全量
  328. waveDataAll: [],
  329. deltaDataFlag: [],
  330. // 全量
  331. deltaDataFlagAll: [],
  332. deltaData: [],
  333. // 全量
  334. deltaDataAll: [],
  335. thetaData: [],
  336. // 全量
  337. thetaDataAll: [],
  338. lowAlphaData: [],
  339. // 全量
  340. lowAlphaDataAll: [],
  341. highAlphaData: [],
  342. // 全量
  343. highAlphaDataAll: [],
  344. lowBetaData: [],
  345. // 全量
  346. lowBetaDataAll: [],
  347. highBetaData: [],
  348. // 全量
  349. highBetaDataAll: [],
  350. lowGammaData: [],
  351. // 全量
  352. lowGammaDataAll: [],
  353. midGammaData: [],
  354. // 全量
  355. midGammaDataAll: [],
  356. noiseData: [],
  357. // 全量
  358. noiseDataAll: [],
  359. attentionData: [],
  360. // 全量
  361. attentionDataAll: [],
  362. meditationData: [],
  363. // 全量
  364. meditationDataAll: [],
  365. focusNao: [],
  366. // 全量
  367. focusNaoAll: [],
  368. // urlThreeP: "../../../static/candle/index.html",
  369. urlThreeP: __static + "/candle/index.html",
  370. // pubSrc: "../../../static",
  371. pubsrc: __static,
  372. userLink: {
  373. num: "",
  374. mac: "",
  375. ecgAllList: [], //心电数据部分
  376. ecgSectionList: [], //心电数据全部
  377. //开始脑电各个部分的数据
  378. },
  379. userTwoLink: {
  380. num: "",
  381. mac: "",
  382. ecgAllList: [], //心电数据部分
  383. ecgSectionList: [], //心电数据全部
  384. //开始脑电各个部分的数据
  385. },
  386. //定时器标志
  387. listTimeFlag: null,
  388. //是否已连接的标志
  389. //单人
  390. linkStatus: false,
  391. //标志等待点击开始按钮后,打开定时器开始渲染
  392. timeSendFlag: null,
  393. //优化显示列表进行防抖
  394. listShaking: true,
  395. listTmp: [],
  396. //合并的定时器
  397. mergeTimeFlag: null,
  398. mergeData: [],
  399. //连接按钮flag
  400. buttonLinkFlag: false,
  401. //按钮状态
  402. disabledTimeFlag: null,
  403. intervalLength: 500,
  404. };
  405. },
  406. mounted() {
  407. //获取当前用户num
  408. this.userLink.num = sessionStorage.getItem("num");
  409. // RingBuffer=null;
  410. //添加监听接收到数据后开始驱动
  411. //脑电监听
  412. //进来之前得到传过来的参数
  413. //调用切换场景的方法
  414. let that = this;
  415. this.disconnectDevice();
  416. let count = 0;
  417. var k = 1;
  418. var flagAnimation = true;
  419. window.addEventListener("resize", function () {
  420. // that.getSize();
  421. if (flagAnimation) {
  422. setTimeout(() => {
  423. console.log("窗口变化了,需要调整");
  424. that.getSize();
  425. //当前是脑电时,且打开的窗口是第一个用户时
  426. if (that.equipment == "1") {
  427. if (that.echartsVisible) {
  428. that.echartsOne.resize();
  429. that.echartsTwo.resize();
  430. that.echartsThree.resize();
  431. }
  432. }
  433. if (that.equipment == "2") {
  434. if (that.echartsVisible) {
  435. that.echartsEcg.resize();
  436. }
  437. }
  438. flagAnimation = true;
  439. }, 1000);
  440. }
  441. flagAnimation = false;
  442. });
  443. setTimeout(() => {
  444. that.getSize();
  445. }, 5000);
  446. setTimeout(() => {
  447. that.changeGame(parseInt(that.$route.query.gameType));
  448. console.log(that.$route.query.gameType);
  449. }, 2000);
  450. that.singleFlag = that.$route.query.single;
  451. console.log(that.singleFlag);
  452. ipcRenderer.on("accelerationData-message", this.acceptNao);
  453. this.initWebsocket();
  454. //当点击开始时调用方法开发发送游戏数据
  455. //上来就查询已连接列表
  456. that.listTimeFlag = setInterval(that.connectList, 2000);
  457. //根据扫描列表和已连接列表看看哪些是重复的//重复的就是已连接的
  458. that.mergeTimeFlag = setInterval(that.mergeDataFun, 1000);
  459. },
  460. destroyed() {
  461. clearTimeout(this.mergeTimeFlag);
  462. clearTimeout(this.disabledTimeFlag);
  463. clearInterval(this.timeSendFlag);
  464. clearInterval(this.listTimeFlag);
  465. console.log(ipcRenderer);
  466. this.websock.close(1000);
  467. ipcRenderer.removeListener("accelerationData-message", this.acceptNao);
  468. //清除特定的监听的ipcRenderer
  469. //ipcRenderer
  470. this.disconnectDevice();
  471. },
  472. methods: {
  473. //合并数据
  474. mergeDataFun() {
  475. let that = this;
  476. let scanDataTmp = JSON.stringify(this.scanData);
  477. let scanDataTmpFin = JSON.parse(scanDataTmp);
  478. let list = [];
  479. for (let i = 0; i < scanDataTmpFin.length; i++) {
  480. let obj = {
  481. rssi: "",
  482. name: "",
  483. mac: "",
  484. connent: false,
  485. deviceType: "",
  486. userNum: "",
  487. };
  488. obj.rssi = scanDataTmpFin[i].rssi;
  489. obj.name = scanDataTmpFin[i].name;
  490. obj.mac = scanDataTmpFin[i].mac;
  491. obj.connent = false;
  492. obj.deviceType = scanDataTmpFin[i].deviceType;
  493. list.push(obj);
  494. }
  495. //判断某个
  496. //先取出与扫描列表显示不一样的
  497. //循环list
  498. //与已选列表进行对比,如果已选列表中有重复
  499. //已选列表必定显示
  500. //如果已选列表为空
  501. //已连接列表中应该全部显示+扫描列表与已选列表不重复的mac的则为全部的
  502. //先将扫描列表与已选列表全部格式化合并为一个数组
  503. //先查已选列表中在扫描列表中没有的----
  504. //然后最后将其加入扫描列表
  505. //然后查询已选列表中在扫描列表中有的
  506. //已选列表
  507. let connectedDataTmp = JSON.stringify(this.connectedData);
  508. let connectedDataTmpFin = JSON.parse(connectedDataTmp);
  509. //不包含的列表
  510. let listBarring = [];
  511. for (let i = 0; i < connectedDataTmpFin.length; i++) {
  512. let flag = false;
  513. for (let j = 0; j < list.length; j++) {
  514. if (connectedDataTmpFin[i].mac == list[j].mac) {
  515. flag = true;
  516. }
  517. }
  518. if (!flag) {
  519. listBarring.push(connectedDataTmpFin[i]);
  520. }
  521. }
  522. for (let i = 0; i < list.length; i++) {
  523. for (let j = 0; j < connectedDataTmpFin.length; j++) {
  524. if (list[i].mac == connectedDataTmpFin[j].mac) {
  525. list[i].connent = true;
  526. list[i].rssi = connectedDataTmpFin[j].rssi;
  527. }
  528. }
  529. }
  530. //然后合并两个数组
  531. let listFin = list.concat(listBarring);
  532. //判断当前选择的是脑电还是心电
  533. let currentDeviceList = [];
  534. if (this.equipment == "1") {
  535. //当是脑电时
  536. for (let i = 0; i < listFin.length; i++) {
  537. if (listFin[i].deviceType == "0") {
  538. currentDeviceList.push(listFin[i]);
  539. }
  540. }
  541. } else {
  542. for (let i = 0; i < listFin.length; i++) {
  543. if (listFin[i].deviceType == "1") {
  544. currentDeviceList.push(listFin[i]);
  545. }
  546. }
  547. }
  548. for (let k = 0; k < currentDeviceList.length; k++) {
  549. if (
  550. that.userLink.mac !== "" &&
  551. that.userLink.mac == currentDeviceList[k].mac
  552. ) {
  553. currentDeviceList[k].userNum = that.userLink.num;
  554. }
  555. }
  556. //将数组其他选项
  557. // console.log(listFin);
  558. this.mergeData = currentDeviceList;
  559. },
  560. //脑电图渲染
  561. acceptNao(event, data) {
  562. let arg = data.arg;
  563. let mac = data.mac;
  564. if (this.userLink.mac == mac) {
  565. if (arg["_c"].size == 1) {
  566. this.waveData.push(arg["_c"].get("rawWaveData"));
  567. this.waveDataAll.push(arg["_c"].get("rawWaveData"));
  568. if (this.waveData.length > 5120) {
  569. this.waveData.shift();
  570. }
  571. } else {
  572. if (arg["_c"].size == 11) {
  573. // 当不为undefined时
  574. let ll = 11;
  575. // 获取长度
  576. this.deltaDataFlag.push(arg["_c"].get("Delta"));
  577. this.deltaDataFlagAll.push(arg["_c"].get("Delta"));
  578. if (this.deltaDataFlag.length > ll) {
  579. this.deltaDataFlag.shift();
  580. }
  581. this.noiseData.push(arg["_c"].get("Signal"));
  582. this.noiseDataAll.push(arg["_c"].get("Signal"));
  583. if (this.noiseData.length > ll) {
  584. this.noiseData.shift();
  585. }
  586. // console.log(arg["_c"].get("Attention") / 100);
  587. // console.log(Math.random() * 10);
  588. if (
  589. this.equipment == 1 &&
  590. this.linkStatus &&
  591. this.buttonFlag == "结束"
  592. ) {
  593. this.send(Math.random() * 10);
  594. }
  595. //先设为随机数
  596. // this.send(Math.random()*10)
  597. // console.log(arg["_c"].get("Attention")/100)
  598. this.attentionData.push(arg["_c"].get("Attention"));
  599. this.attentionDataAll.push(arg["_c"].get("Attention"));
  600. if (this.attentionData.length > ll) {
  601. this.attentionData.shift();
  602. }
  603. console.log(this.attentionDataAll.length);
  604. this.meditationData.push(arg["_c"].get("Meditation"));
  605. this.meditationDataAll.push(arg["_c"].get("Meditation"));
  606. if (this.meditationData.length > ll) {
  607. this.meditationData.shift();
  608. }
  609. this.thetaData.push(arg["_c"].get("Theta"));
  610. this.thetaDataAll.push(arg["_c"].get("Theta"));
  611. if (this.thetaData.length > ll) {
  612. this.thetaData.shift();
  613. }
  614. this.lowAlphaData.push(arg["_c"].get("LowAlpha"));
  615. this.lowAlphaDataAll.push(arg["_c"].get("LowAlpha"));
  616. if (this.lowAlphaData.length > ll) {
  617. this.lowAlphaData.shift();
  618. }
  619. this.highAlphaData.push(arg["_c"].get("HighAlpha"));
  620. this.highAlphaDataAll.push(arg["_c"].get("HighAlpha"));
  621. if (this.highAlphaData.length > ll) {
  622. this.highAlphaData.shift();
  623. }
  624. this.lowBetaData.push(arg["_c"].get("LowBeta"));
  625. this.lowBetaDataAll.push(arg["_c"].get("LowBeta"));
  626. if (this.lowBetaData.length > ll) {
  627. this.lowBetaData.shift();
  628. }
  629. this.highBetaData.push(arg["_c"].get("HighBeta"));
  630. this.highBetaDataAll.push(arg["_c"].get("HighBeta"));
  631. if (this.highBetaData.length > ll) {
  632. this.highBetaData.shift();
  633. }
  634. this.lowGammaData.push(arg["_c"].get("LowGamma"));
  635. this.lowGammaDataAll.push(arg["_c"].get("LowGamma"));
  636. if (this.lowGammaData.length > ll) {
  637. this.lowGammaData.shift();
  638. }
  639. this.midGammaData.push(arg["_c"].get("MiddleGamma"));
  640. this.midGammaDataAll.push(arg["_c"].get("MiddleGamma"));
  641. if (this.midGammaData.length > ll) {
  642. this.midGammaData.shift();
  643. }
  644. this.focusNao.push(arg["_c"].get("Attention"));
  645. this.focusNaoAll.push(arg["_c"].get("Attention"));
  646. if (this.focusNao > ll) {
  647. this.focusNao.shift();
  648. }
  649. // this.numEleDom = this.focusNaoAll.length.toString();
  650. if (this.echartsVisible) {
  651. // console.log(this.attentionDataAll.length);
  652. this.renderEegOne();
  653. this.renderEegTwo();
  654. this.renderEegThree();
  655. }
  656. }
  657. }
  658. }
  659. },
  660. viewEchartsFun() {
  661. this.echartsVisible = true;
  662. setTimeout(() => {
  663. if (this.equipment == "1") {
  664. if (this.echartsOne == null) {
  665. this.echartsOne = echarts.init(document.getElementById("eegOne"));
  666. this.echartsTwo = echarts.init(document.getElementById("eegTwo"));
  667. this.echartsThree = echarts.init(
  668. document.getElementById("eegThree")
  669. );
  670. this.renderEegOne();
  671. this.renderEegTwo();
  672. this.renderEegThree();
  673. setTimeout(() => {
  674. this.echartsOne.resize();
  675. this.echartsTwo.resize();
  676. this.echartsThree.resize();
  677. }, 1000);
  678. } else {
  679. this.echartsOne.resize();
  680. this.echartsTwo.resize();
  681. this.echartsThree.resize();
  682. }
  683. }
  684. if (this.equipment == "2") {
  685. if (this.echartsEcg == null) {
  686. this.echartsEcg = echarts.init(document.getElementById("ecgOne"));
  687. this.renderEcgOne();
  688. setTimeout(() => {
  689. this.echartsEcg.resize();
  690. }, 1000);
  691. } else {
  692. this.echartsEcg.resize();
  693. }
  694. }
  695. // 先调用
  696. }, 2000);
  697. },
  698. //状态切换
  699. linkJudge(index, val, flag) {
  700. if (flag) {
  701. //buttonLinkFlag
  702. this.disconnectEquipment(val);
  703. } else {
  704. this.linkFun(index, val);
  705. }
  706. },
  707. //进行解析脑电数据
  708. linkFun(index, val) {
  709. console.log(val);
  710. let that = this;
  711. that.buttonLinkFlag = true;
  712. that.$http.postTmp(
  713. `/v1/device/connection`,
  714. {
  715. chip: val.deviceType,
  716. mac: val.mac,
  717. addrType: "public",
  718. filterName: val.deviceType,
  719. },
  720. (res) => {
  721. that.disableStatus();
  722. if (res.data.code == 200) {
  723. // this.linkIndex = index;
  724. //如果是脑电的话直接调用打开数据接口
  725. //如果是心电需要先调用写入输入数据-发送指令接口
  726. if (val.deviceType == "1") {
  727. this.writeData(val);
  728. that.userLink.mac = val.mac;
  729. } else {
  730. //判断脑电设备
  731. //脑电的情况下
  732. //记录下当前mac,
  733. that.userLink.mac = val.mac;
  734. //然后调用已连接列表确定改mac是否存在在列表中,如果已存在则表示该设备已连接
  735. // that.openData();
  736. // this.$message.success("设备连接成功");
  737. }
  738. // that.tableData = res.data;
  739. // that.totolSize = res.data.totalElements;
  740. } else {
  741. // this.$message.error("访问服务器失败!");
  742. this.$message.error(res.data.message);
  743. }
  744. }
  745. );
  746. },
  747. //写入数据--发送指令
  748. writeData(val) {
  749. let that = this;
  750. let userName = sessionStorage.getItem("name");
  751. that.$http.postTmp(
  752. `/v1/device/write/data`,
  753. { mac: val.mac, userName: userName },
  754. (res) => {
  755. // that.openData();
  756. if (res.data.code == 200) {
  757. } else {
  758. this.$message.error("访问服务器失败!");
  759. }
  760. }
  761. );
  762. },
  763. //打开数据接口
  764. // openData() {
  765. // let that = this;
  766. // that.$http.getTmp(`/v1/device/open/notify`, {}, (res) => {
  767. // if (res.code == 200) {
  768. // //打开数据接口
  769. // // that.tableData = res.data;
  770. // // that.totolSize = res.data.totalElements;
  771. // } else {
  772. // this.$message.error("访问服务器失败!");
  773. // }
  774. // });
  775. // },
  776. disableStatus() {
  777. let that = this;
  778. this.disabledTimeFlag = setTimeout(() => {
  779. this.buttonLinkFlag = false;
  780. }, 1500);
  781. },
  782. //断开连接的脑电
  783. disconnectEquipment(val) {
  784. let that = this;
  785. that.buttonLinkFlag = true;
  786. that.$http.getTmp(`v1/device/${val.mac}/disconnect`, {}, (res) => {
  787. that.disableStatus();
  788. if (res.code == 200) {
  789. //关闭连接的时候看是不是当前绑定的mac与用户的mac是否相同
  790. //如果相同则 连接标志变为false;
  791. //如果不同则不变
  792. if (that.userLink.mac == val.mac) {
  793. that.linkStatus = false;
  794. that.userLink.mac = "";
  795. }
  796. //打开数据接口
  797. // that.tableData = res.data;
  798. // that.totolSize = res.data.totalElements;
  799. } else {
  800. this.$message.error(res.message);
  801. }
  802. });
  803. },
  804. //查询连接列表
  805. connectList() {
  806. let that = this;
  807. that.$http.getTmp(`v1/device/connected`, {}, (res) => {
  808. // console.log(res)
  809. //判断当前的列表是否存在该用户已点击的列表
  810. if (res.code == 200) {
  811. if (res.data) {
  812. if (res.data) {
  813. let list = [];
  814. for (let i = 0; i < res.data.length; i++) {
  815. let obj = {
  816. rssi: "",
  817. name: "",
  818. mac: "",
  819. connent: false,
  820. deviceType: "",
  821. };
  822. obj.rssi = "";
  823. obj.name = res.data[i].Name;
  824. obj.mac = res.data[i].MAC;
  825. obj.connent = true;
  826. obj.deviceType = res.data[i].DeviceType;
  827. obj.userNum = "";
  828. list.push(obj);
  829. }
  830. that.connectedData = list;
  831. // console.log(list);
  832. if (list.length == 0) {
  833. //表示未连接
  834. that.linkStatus = false;
  835. } else {
  836. //标识已连接
  837. for (let k = 0; k < list.length; k++) {
  838. if (
  839. that.userLink.mac !== "" &&
  840. that.userLink.mac == list[k].mac
  841. ) {
  842. that.linkStatus = true;
  843. }
  844. }
  845. }
  846. }
  847. } else {
  848. that.connectedData = [];
  849. }
  850. //打开数据接口
  851. // that.tableData = res.data;
  852. // that.totolSize = res.data.totalElements;
  853. } else {
  854. // this.$message.error("访问服务器失败!");
  855. }
  856. });
  857. },
  858. typeFormatter(val) {
  859. // console.log(val.deviceType)
  860. if (val.deviceType == "1") {
  861. return "心电";
  862. } else {
  863. return "脑电";
  864. }
  865. },
  866. openTableFun() {
  867. this.tableVisible = true;
  868. //调用扫描接口
  869. // this.queryScan();
  870. },
  871. //扫描设备
  872. queryScan() {
  873. let that = this;
  874. let filter_name = null;
  875. if (this.equipment == 1) {
  876. filter_name = 0;
  877. } else {
  878. filter_name = 1;
  879. }
  880. that.$http.postTmp(
  881. `/v1/device/scan`,
  882. {},
  883. // { filter_name: filter_name, filter_rssi: -99 },
  884. (res) => {
  885. // if (res.code == 200) {
  886. // console.log(res.data);
  887. // if (this.equipment == 1) {
  888. // }
  889. // } else {
  890. // this.$message.error("访问服务器失败!");
  891. // }
  892. }
  893. );
  894. },
  895. //进来后先连接websocket
  896. //连上后进行扫描
  897. //扫描以后出现列表
  898. //列表出现后点击连接并打开数据如果有数据才算成功
  899. //初始化websocket
  900. initWebsocket() {
  901. // const wsuri = "ws://192.168.2.101:8000/ws?uid=client&to_uid=server";
  902. const wsuri = "ws://localhost:8000/ws?uid=client&to_uid=server";
  903. this.websock = new WebSocket(wsuri);
  904. this.websock.onmessage = this.websocketonmessage;
  905. this.websock.onopen = this.websocketonopen;
  906. this.websock.onerror = this.websocketonerror;
  907. this.websock.onclose = this.websocketclose;
  908. },
  909. websocketonopen() {
  910. //连接建立之后执行send方法发送数据
  911. let actions = { test: "12345" };
  912. this.websocketsend(JSON.stringify(actions));
  913. },
  914. websocketonerror() {
  915. //连接建立失败重连
  916. this.initWebSocket();
  917. },
  918. websocketsend(Data) {
  919. //数据发送
  920. this.websock.send(Data);
  921. },
  922. websocketonmessage(e) {
  923. let that = this;
  924. //数据接收
  925. const redata = JSON.parse(e.data);
  926. // console.log(redata);
  927. if (redata.content != "Successful connection to socket service") {
  928. //首先判断是否redata.content是否是未定义
  929. // console.log(redata.content)
  930. if (redata.hasOwnProperty("content")) {
  931. let dataLin = JSON.parse(redata.content);
  932. if (redata.msgType == "device") {
  933. // let dataLin = JSON.parse(redata.content);
  934. let list = [];
  935. for (var key in dataLin) {
  936. let a = {
  937. mac: dataLin[key]["MAC"],
  938. name: dataLin[key].Name,
  939. rssi: dataLin[key].Rssi,
  940. deviceType: dataLin[key].DeviceType,
  941. chip: dataLin[key].Chip,
  942. };
  943. that.changeList(a);
  944. }
  945. //获取到很多数据,取每秒最大的包含量
  946. } else if (redata.msgType == "eegData") {
  947. // let dataLin = JSON.parse(redata.content);
  948. // console.log(dataLin);
  949. ///先判断第一个用户是否有mac---有mac代表已连接
  950. if (that.userLink.mac !== "" && that.userLink.mac == dataLin.id) {
  951. ipcRenderer.send("asynchronoushrv-naoData", {
  952. value: dataLin.value,
  953. mac: dataLin.id,
  954. });
  955. }
  956. if (
  957. that.userTwoLink.mac !== "" &&
  958. that.userTwoLink.mac == dataLin.id
  959. ) {
  960. ipcRenderer.send("asynchronoushrv-naoTwoData", {
  961. value: dataLin.value,
  962. mac: dataLin.id,
  963. });
  964. }
  965. //判断第二个用户的mac是否有,有则代表已连接 --
  966. } else if (redata.msgType == "ecgData") {
  967. //判断该数据对应的mac是否是当前绑定过用户的
  968. //判断当前是否是绑定该用户的数据,是的话进行用户处理
  969. //接到数据进行处理
  970. //当该用户的mac与id相同时,取这个数据
  971. // console.log(dataLin.id === that.userLink.mac);
  972. if (dataLin.id === that.userLink.mac) {
  973. let list = dataLin.value.split(",");
  974. // console.log(list)
  975. list.forEach((item) => {
  976. let tmp = parseInt(item);
  977. that.userLink.ecgAllList.push(tmp);
  978. that.userLink.ecgSectionList.push(tmp);
  979. if (that.userLink.ecgSectionList.length > that.intervalLength) {
  980. that.userLink.ecgSectionList.shift();
  981. }
  982. if (that.userLink.ecgAllList.length % 100 == 0) {
  983. // console.log(that.ecgAllList.length);
  984. if (that.echartsVisible) {
  985. that.renderEcgOne();
  986. }
  987. }
  988. });
  989. }
  990. }
  991. }
  992. }
  993. },
  994. //处理数据让其变化最慢
  995. //这个是最大的扫描列表
  996. changeList(obj) {
  997. // console.log(obj);
  998. let that = this;
  999. that.listTmp.push(obj);
  1000. let arrayStr = JSON.stringify(that.listTmp);
  1001. let array = JSON.parse(arrayStr);
  1002. //取list中不相同的
  1003. // console.log(array)
  1004. // array = array.reduce(function (item, next) {
  1005. // obj[next.MAC] ? "" : (obj[next.MAC] = true && item.push(next));
  1006. // return item;
  1007. // }, []);
  1008. //循环数组arr
  1009. //设置储存不一样的数组
  1010. var newArr = new Array();
  1011. var flag = false;
  1012. for (var i = 0; i < array.length; i++) {
  1013. for (var j = 0; j < newArr.length; j++) {
  1014. if (array[i].mac == newArr[j].mac) {
  1015. newArr[j] = array[i];
  1016. flag = true;
  1017. break;
  1018. }
  1019. }
  1020. if (!flag) {
  1021. newArr.push(array[i]);
  1022. }
  1023. }
  1024. // newArr=JSON.parse(newArr)
  1025. // let newArr = {}
  1026. // array.forEach(item => {
  1027. // newArr[item.MAC] = item
  1028. // })
  1029. that.listTmp = JSON.parse(JSON.stringify(newArr));
  1030. // console.log(JSON.stringify(newArr));
  1031. //listTmp即使最大扫描列表
  1032. that.scanData = newArr;
  1033. //目前无法知道当前设备是脑电还是脉搏
  1034. // listShaking:false,
  1035. //判断标志是true或false
  1036. // if (that.listShaking) {
  1037. // let flagTime = setTimeout(() => {
  1038. // that.listShaking = true;
  1039. // let arrayStr = JSON.stringify(that.listTmp);
  1040. // let array = JSON.parse(arrayStr);
  1041. // //取list中不相同的
  1042. // console.log(array)
  1043. // // array = array.reduce(function (item, next) {
  1044. // // obj[next.MAC] ? "" : (obj[next.MAC] = true && item.push(next));
  1045. // // return item;
  1046. // // }, []);
  1047. // //循环数组arr
  1048. // //设置储存不一样的数组
  1049. // var newArr = new Array();
  1050. // var flag = false;
  1051. // for (var i = 0; i < array.length; i++) {
  1052. // for (var j = 0; j < newArr.length; j++) {
  1053. // if (array[i].mac == newArr[j].mac) {
  1054. // newArr[j] = array[i];
  1055. // flag = true;
  1056. // break;
  1057. // }
  1058. // }
  1059. // if (!flag) {
  1060. // newArr.push(array[i]);
  1061. // }
  1062. // }
  1063. // // newArr=JSON.parse(newArr)
  1064. // // let newArr = {}
  1065. // // array.forEach(item => {
  1066. // // newArr[item.MAC] = item
  1067. // // })
  1068. // that.listTmp = JSON.parse(JSON.stringify(newArr));
  1069. // console.log(JSON.stringify(newArr));
  1070. // //listTmp即使最大扫描列表
  1071. // that.scanData = newArr;
  1072. // //当前扫描列表
  1073. // clearTimeout(flagTime);
  1074. // }, 1000);
  1075. // }
  1076. // that.listShaking = false;
  1077. },
  1078. websocketclose(e) {
  1079. if (e.code == 1005) {
  1080. this.initWebsocket();
  1081. } else {
  1082. console.log("断开连接", e);
  1083. }
  1084. },
  1085. //切换选项时需要清空数据
  1086. clearDataFun() {
  1087. //1.首先清楚所有定时器
  1088. clearInterval(this.pulseTime);
  1089. clearInterval(this.gameTimeTimer);
  1090. //2.计时的时间
  1091. this.pulseTimeNum = 180;
  1092. //3.重置开始的按钮
  1093. this.buttonFlag = "开始";
  1094. this.gameTimeTimerFlag = false;
  1095. //4.重置数据
  1096. this.resetData();
  1097. },
  1098. resetData() {
  1099. this.send(0);
  1100. this.buttonFlag = "开始";
  1101. if (this.gameTime == 1) {
  1102. this.gameTimeReserve = 180;
  1103. this.timeShow = "03:00";
  1104. } else if (this.gameTime == 2) {
  1105. this.gameTimeReserve = 300;
  1106. this.timeShow = "05:00";
  1107. } else if (this.gameTime == 3) {
  1108. this.gameTimeReserve = 600;
  1109. this.timeShow = "10:00";
  1110. }
  1111. },
  1112. //格式化倒计时格式
  1113. formatterTimeFun(val) {
  1114. let min = Math.floor(val / 60);
  1115. min = this.formatterSs(min);
  1116. let ss = val % 60;
  1117. ss = this.formatterSs(ss);
  1118. return min + ":" + ss;
  1119. },
  1120. formatterSs(val) {
  1121. if (val < 10) {
  1122. return "0" + val;
  1123. } else {
  1124. return val + "";
  1125. }
  1126. },
  1127. gameTimeFun(val) {
  1128. this.clearDataFun();
  1129. if (val == 1) {
  1130. this.gameTimeReserve = 180;
  1131. } else if (val == 2) {
  1132. this.gameTimeReserve = 300;
  1133. } else if (val == 3) {
  1134. this.gameTimeReserve = 600;
  1135. }
  1136. },
  1137. //当设备更换时需要初始化动画数值为0
  1138. //并且按钮初始化为开始状态
  1139. //倒计时时间也变为最初始化
  1140. //定时3分钟倒计时方法
  1141. // threeReserve(){
  1142. // },
  1143. gameDiffFun() {
  1144. this.clearDataFun();
  1145. },
  1146. equipmentFun(val) {
  1147. //先判断当选择的设备是否连接
  1148. //如果已连接,则继续测试
  1149. //如果未连接则提示连接设备
  1150. //先判断脑电
  1151. this.clearDataFun();
  1152. this.send(0);
  1153. // this.userLink.linkStatus = false;
  1154. // this.userTwoLink.linkStatus = false;
  1155. this.resetData();
  1156. this.disconnectDevice();
  1157. //结束测试
  1158. },
  1159. //断开所有设备的操作
  1160. disconnectDevice() {
  1161. let that = this;
  1162. that.$http.getTmp(`v1/device/connected`, {}, (res) => {
  1163. // console.log(res)
  1164. //判断当前的列表是否存在该用户已点击的列表
  1165. if (res.code == 200) {
  1166. if (res.data) {
  1167. if (res.data) {
  1168. let list = [];
  1169. for (let i = 0; i < res.data.length; i++) {
  1170. let obj = {
  1171. rssi: "",
  1172. name: "",
  1173. mac: "",
  1174. connent: false,
  1175. deviceType: "",
  1176. };
  1177. obj.rssi = "";
  1178. obj.name = res.data[i].Name;
  1179. obj.mac = res.data[i].MAC;
  1180. obj.connent = true;
  1181. obj.deviceType = res.data[i].DeviceType;
  1182. obj.userNum = "";
  1183. list.push(obj);
  1184. }
  1185. that.connectedData = list;
  1186. // console.log(list);
  1187. if (list.length == 0) {
  1188. //表示未连接
  1189. that.userLink.linkStatus = false;
  1190. } else {
  1191. //标识已连接
  1192. for (let k = 0; k < list.length; k++) {
  1193. //调用断开设备的方法
  1194. that.disconnectEquipment(list[k]);
  1195. }
  1196. }
  1197. }
  1198. } else {
  1199. that.connectedData = [];
  1200. }
  1201. //打开数据接口
  1202. // that.tableData = res.data;
  1203. // that.totolSize = res.data.totalElements;
  1204. } else {
  1205. // this.$message.error("访问服务器失败!");
  1206. }
  1207. });
  1208. },
  1209. //需要先判断代码是否点击开始测试按钮了
  1210. //如果点击开始测试按钮了//才能发送信号到游戏
  1211. //定时器方法进行倒计时
  1212. //这是脉搏点击开始的倒计时
  1213. //倒计时结束以后进行3分钟或5分钟倒计时或十分钟倒计时
  1214. //然后自动结束
  1215. timeFun1() {
  1216. let that = this;
  1217. clearInterval(that.pulseTime);
  1218. that.pulseTimeNum = 180;
  1219. that.pulseTime = setInterval(() => {
  1220. that.timeShow = that.formatterTimeFun(that.pulseTimeNum);
  1221. that.pulseTimeNum--;
  1222. if (that.pulseTimeNum == 0) {
  1223. // that.buttonDisable = false;
  1224. //将状态改为结束
  1225. // this.buttonFlag = "结束";
  1226. clearInterval(that.pulseTime);
  1227. //倒计时开始后需要
  1228. that.timeCom();
  1229. }
  1230. }, 1000);
  1231. },
  1232. getGameSence(val) {
  1233. console.log(val);
  1234. let gameName = "";
  1235. switch (val) {
  1236. case "1":
  1237. gameName = "心灵之火";
  1238. break;
  1239. case "2":
  1240. gameName = "心之花";
  1241. break;
  1242. case "3":
  1243. gameName = "急速赛车";
  1244. break;
  1245. case "4":
  1246. gameName = "爆爆桶";
  1247. break;
  1248. case "5":
  1249. gameName = "炸弹";
  1250. break;
  1251. case "6":
  1252. gameName = "漂浮球";
  1253. break;
  1254. default:
  1255. break;
  1256. }
  1257. console.log(gameName);
  1258. return gameName;
  1259. },
  1260. //获取游戏难度
  1261. getGameDiff(val) {
  1262. if (val == 1) {
  1263. return "简单";
  1264. }
  1265. if (val == 2) {
  1266. return "普通";
  1267. }
  1268. if (val == 3) {
  1269. return "困难";
  1270. }
  1271. },
  1272. formatterGameTime(val) {
  1273. if (val == "1") {
  1274. return "3分钟";
  1275. }
  1276. if (val == "2") {
  1277. return "5分钟";
  1278. }
  1279. if (val == "3") {
  1280. return "10分钟";
  1281. }
  1282. return "";
  1283. },
  1284. //获取当前时间
  1285. getCurrentTimeFun() {
  1286. let data = new Date();
  1287. let year = this.formatterDate(data.getFullYear());
  1288. let month = this.formatterDate(data.getMonth() + 1);
  1289. let day = this.formatterDate(data.getDate());
  1290. let hour = this.formatterDate(data.getHours());
  1291. let minutes = this.formatterDate(data.getMinutes());
  1292. let seconds = this.formatterDate(data.getSeconds());
  1293. let microseconds = this.formatterMill(data.getMilliseconds());
  1294. return (
  1295. year +
  1296. "年" +
  1297. month +
  1298. "月" +
  1299. day +
  1300. "日" +
  1301. hour +
  1302. "时" +
  1303. minutes +
  1304. "分" +
  1305. seconds +
  1306. "秒" +
  1307. microseconds
  1308. );
  1309. },
  1310. //格式化两位数的时间数据
  1311. formatterDate(val) {
  1312. if (val < 10) {
  1313. return "0" + val;
  1314. } else {
  1315. return val;
  1316. }
  1317. },
  1318. //格式化毫秒数据
  1319. formatterMill(val) {
  1320. if (val < 10) {
  1321. return "00" + val;
  1322. } else if (val < 100) {
  1323. return "0" + val;
  1324. } else {
  1325. return val;
  1326. }
  1327. },
  1328. timeCom() {
  1329. let that = this;
  1330. //有个标志显示当前的倒计时的状态
  1331. this.gameTimeTimerFlag = true;
  1332. //获取当前选择的是几分钟
  1333. //当选择的是3分钟时
  1334. //this.gameTimeReserve
  1335. this.gameTimeTimer = setInterval(() => {
  1336. this.timeShow = this.formatterTimeFun(this.gameTimeReserve);
  1337. this.gameTimeReserve--;
  1338. if (this.gameTimeReserve == 0) {
  1339. clearInterval(this.gameTimeTimer);
  1340. //当倒计时为0
  1341. //按钮状态改为结束
  1342. this.gameTimeTimerFlag = false;
  1343. this.buttonFlag = "开始";
  1344. if (this.equipment == 1) {
  1345. //当倒计时完成的时候需要
  1346. //对数据进行保存//保存完成可以清空数据
  1347. //需要获取当前的设备//难度//游戏时间//游戏特定指标//以及用户编号
  1348. let params = {
  1349. type: "1", //1表示是单人模式 2代表是双人模式
  1350. num: sessionStorage.getItem("num"), //个人编号
  1351. gameScene: that.getGameSence(that.$route.query.gameType), //游戏场景
  1352. equipmentType: "脑电", //设备类型
  1353. gameDifficulty: that.getGameDiff(that.gameDifficulty), //游戏难度
  1354. gameTime: that.formatterGameTime(that.gameTime), //游戏时间
  1355. // animationSourceList: that.animationSourceList, //原始数据
  1356. // fileName: "-",
  1357. // animationTarget: "", //指标数据
  1358. saveTime: that.getCurrentTimeFun(), //保存数据的时间
  1359. };
  1360. //调用保存数据的方法
  1361. that.saveAnimation(params);
  1362. }
  1363. if (this.equipment == 2) {
  1364. let params = {
  1365. type: "1", //1表示是单人模式 2代表是双人模式
  1366. num: sessionStorage.getItem("num"), //个人编号
  1367. gameScene: that.getGameSence(that.$route.query.gameType), //游戏场景
  1368. equipmentType: "心电", //设备类型
  1369. gameDifficulty: that.getGameDiff(that.gameDifficulty), //游戏难度
  1370. gameTime: that.formatterGameTime(that.gameTime), //游戏时间
  1371. // animationSourceList: that.animationSourceList, //原始数据
  1372. // fileName: "-",
  1373. // animationTarget: "", //指标数据
  1374. saveTime: that.getCurrentTimeFun(), //保存数据的时间
  1375. };
  1376. //调用保存数据的方法
  1377. that.saveAnimation(params);
  1378. }
  1379. this.resetData();
  1380. }
  1381. }, 1000);
  1382. },
  1383. startTest() {
  1384. let that = this;
  1385. //首先先判断是脑电还是脉搏
  1386. if (this.buttonFlag == "开始") {
  1387. if (this.equipment == 1) {
  1388. //如果是脑电.则需要判断脑电是否连接
  1389. if (!this.linkStatus) {
  1390. this.$message.warning("请先连接脑电设备");
  1391. } else {
  1392. this.buttonFlag = "结束";
  1393. this.timeCom();
  1394. //先将脑电数据置空
  1395. this.clearNaoData();
  1396. }
  1397. } else {
  1398. //如果是脉搏,则需要判断脉搏是否是连接
  1399. if (!this.linkStatus) {
  1400. this.$message.warning("请先连接心电设备");
  1401. } else {
  1402. //如果是脉搏已连接
  1403. //点击了开始按钮
  1404. //则开始倒计时3分钟
  1405. this.timeFun1();
  1406. this.buttonFlag = "结束";
  1407. //清空心电数据
  1408. this.userLink.ecgAllList = [];
  1409. this.userLink.ecgSectionList = [];
  1410. }
  1411. }
  1412. } else {
  1413. //调用 保存方法
  1414. //主动点击结束的方法
  1415. if (this.equipment == 1) {
  1416. //当倒计时完成的时候需要
  1417. //对数据进行保存//保存完成可以清空数据
  1418. //需要获取当前的设备//难度//游戏时间//游戏特定指标//以及用户编号
  1419. let params = {
  1420. type: "1", //1表示是单人模式 2代表是双人模式
  1421. num: sessionStorage.getItem("num"), //个人编号
  1422. gameScene: that.getGameSence(that.$route.query.gameType), //游戏场景
  1423. equipmentType: "脑电", //设备类型
  1424. gameDifficulty: that.getGameDiff(that.gameDifficulty), //游戏难度
  1425. gameTime: this.attentionData.length, //游戏时间
  1426. // animationSourceList: that.animationSourceList, //原始数据
  1427. // fileName: "-",
  1428. // animationTarget: "", //指标数据
  1429. saveTime: that.getCurrentTimeFun(), //保存数据的时间
  1430. };
  1431. //调用保存数据的方法
  1432. that.saveAnimation(params);
  1433. }
  1434. if (this.equipment == 2) {
  1435. //获取心电数据
  1436. let params = {
  1437. type: "1", //1表示是单人模式 2代表是双人模式
  1438. num: sessionStorage.getItem("num"), //个人编号
  1439. gameScene: that.getGameSence(that.$route.query.gameType), //游戏场景
  1440. equipmentType: "心电", //设备类型
  1441. gameDifficulty: that.getGameDiff(that.gameDifficulty), //游戏难度
  1442. gameTime: Math.floor(that.userLink.ecgAllList.length / 100), //游戏时间
  1443. // animationSourceList: that.animationSourceList, //原始数据
  1444. // fileName: "-",
  1445. // animationTarget: "", //指标数据
  1446. saveTime: that.getCurrentTimeFun(), //保存数据的时间
  1447. };
  1448. //调用保存数据的方法
  1449. that.saveAnimation(params);
  1450. }
  1451. //改变按钮状态
  1452. this.clearDataFun();
  1453. this.resetData();
  1454. }
  1455. },
  1456. clearNaoData() {
  1457. this.waveDataAll = [];
  1458. this.waveData = [];
  1459. //开始测试时需要清空所有数据,从头开始渲染
  1460. this.deltaDataFlagAll = [];
  1461. this.deltaDataFlag = [];
  1462. this.thetaDataAll = [];
  1463. this.thetaData = [];
  1464. this.lowAlphaDataAll = [];
  1465. this.lowAlphaData = [];
  1466. this.highAlphaDataAll = [];
  1467. this.highAlphaData = [];
  1468. this.lowBetaDataAll = [];
  1469. this.lowBetaData = [];
  1470. this.highBetaDataAll = [];
  1471. this.highBetaData = [];
  1472. this.lowGammaDataAll = [];
  1473. this.lowGammaData = [];
  1474. this.midGammaDataAll = [];
  1475. this.midGammaData = [];
  1476. this.noiseDataAll = [];
  1477. this.noiseData = [];
  1478. this.attentionDataAll = [];
  1479. this.attentionData = [];
  1480. this.meditationData = [];
  1481. this.meditationDataAll = [];
  1482. this.focusNaoAll = [];
  1483. this.focusNao = [];
  1484. },
  1485. //保存游戏数据
  1486. saveAnimation(params) {
  1487. console.log(params);
  1488. console.log("游戏和数据保存");
  1489. },
  1490. setUrl() {},
  1491. getSize() {
  1492. let width = this.$refs.animationFlow.clientWidth;
  1493. let height = this.$refs.animationFlow.clientHeight - 20;
  1494. this.widthIframe = width;
  1495. this.heightIframe = height + 20;
  1496. this.changeSize(width, height);
  1497. },
  1498. changeSize(width, height) {
  1499. this.$refs.unityIframe.contentWindow.changeSize(width, height);
  1500. },
  1501. send(val) {
  1502. this.$refs.unityIframe.contentWindow.Bloomsize(val);
  1503. },
  1504. // btt() {
  1505. // let that = this;
  1506. // this.$refs.unityvueFlower.message("flower", "enableCamera", "true");
  1507. // },
  1508. delayTime() {
  1509. let that = this;
  1510. setTimeout(() => {
  1511. that.getSize();
  1512. }, 5000);
  1513. },
  1514. changeGame(val) {
  1515. console.log(val);
  1516. this.clearDataFun();
  1517. switch (val) {
  1518. case 1:
  1519. this.urlThreeP = this.pubSrc + "/candle/index.html";
  1520. // this.urlThreeP = pubSrc+ + "/candle/index.html";
  1521. this.delayTime();
  1522. break;
  1523. case 2:
  1524. this.urlThreeP = this.pubSrc + "/flower/index.html";
  1525. // this.urlThreeP = __static + "/flower/index.html";
  1526. this.delayTime();
  1527. break;
  1528. case 3:
  1529. this.urlThreeP = this.pubSrc + "/car/index.html";
  1530. // this.urlThreeP = __static + "/car/index.html";
  1531. this.delayTime();
  1532. break;
  1533. case 4:
  1534. this.urlThreeP = this.pubSrc + "/baobaotong/index.html";
  1535. // this.urlThreeP = __static + "/baobaotong/index.html";
  1536. this.delayTime();
  1537. break;
  1538. case 5:
  1539. this.urlThreeP = this.pubSrc + "/bomb/index.html";
  1540. // this.urlThreeP = __static + "/bomb/index.html";
  1541. this.delayTime();
  1542. break;
  1543. case 6:
  1544. this.urlThreeP = this.pubSrc + "/piaofuqiu/index.html";
  1545. // this.urlThreeP = __static + "/piaofuqiu/index.html";
  1546. this.delayTime();
  1547. break;
  1548. default:
  1549. this.urlThreeP = this.pubSrc + "/candle/index.html";
  1550. // this.urlThreeP = __static + "/candle/index.html";
  1551. }
  1552. this.gameScene = val;
  1553. this.flag = this.gameScene;
  1554. },
  1555. chlz() {
  1556. this.sendUnity(Math.round(Math.random() * 100));
  1557. },
  1558. sendUnity(val) {
  1559. let a = val / 100;
  1560. this.$refs.unityvue.message("littlefire", "sssize", a);
  1561. },
  1562. goBack() {
  1563. this.$router.go(-1);
  1564. },
  1565. //心电1
  1566. renderEcgOne() {
  1567. let that = this;
  1568. let sarr = [];
  1569. // 当全量小于等于10时 显示1-10
  1570. if (that.userLink.ecgAllList.length <= that.intervalLength) {
  1571. for (let i = 0; i <= that.intervalLength; i++) {
  1572. // i = i.toFixed(3);
  1573. sarr.push(i.toString());
  1574. }
  1575. } else if (that.userLink.ecgAllList.length > that.intervalLength) {
  1576. for (
  1577. let i = that.userLink.ecgAllList.length - that.intervalLength;
  1578. i < that.userLink.ecgAllList.length;
  1579. i++
  1580. ) {
  1581. sarr.push(i.toString());
  1582. }
  1583. }
  1584. let dataEcg = JSON.parse(JSON.stringify(that.userLink.ecgSectionList));
  1585. let min = Math.min(...dataEcg);
  1586. let dataEcgFin = [];
  1587. for (let i = 0; i < dataEcg.length; i++) {
  1588. dataEcgFin.push(dataEcg[i] - min);
  1589. }
  1590. // console.log(dataEcg)
  1591. // console.log(Math.max(...dataEcg));
  1592. // console.log(Math.min(...dataEcg));
  1593. this.optionEcg = {
  1594. animation: false,
  1595. title: {
  1596. text: "心电信号",
  1597. subtext: "",
  1598. left: "center",
  1599. align: "right",
  1600. x: "center",
  1601. y: "bottom",
  1602. },
  1603. grid: {
  1604. bottom: 80,
  1605. },
  1606. legend: {
  1607. data: ["ECG"],
  1608. // left: 10,
  1609. },
  1610. xAxis: [
  1611. {
  1612. name: "秒(s)",
  1613. type: "category",
  1614. boundaryGap: false,
  1615. axisLine: { onZero: false },
  1616. splitLine: { show: true },
  1617. data: sarr,
  1618. axisLabel: {
  1619. interval: 99,
  1620. formatter: function (value, index) {
  1621. // console.log(value);
  1622. // console.log(index);
  1623. let a = parseInt(value);
  1624. // a = Math.round(a / 120);
  1625. return a / 100;
  1626. },
  1627. },
  1628. },
  1629. ],
  1630. yAxis: [
  1631. {
  1632. name: "",
  1633. type: "value",
  1634. // max: Math.max(that.userLink.ecgSectionList),
  1635. // min: Math.min(that.userLink.ecgSectionList),
  1636. },
  1637. ],
  1638. series: [
  1639. {
  1640. smooth: true,
  1641. showSymbol: false,
  1642. name: "ECG",
  1643. type: "line",
  1644. lineStyle: {
  1645. width: 1,
  1646. },
  1647. data: dataEcgFin,
  1648. },
  1649. ],
  1650. };
  1651. this.echartsEcg.setOption(this.optionEcg);
  1652. },
  1653. //脑电1
  1654. renderEegOne() {
  1655. let sarr = [];
  1656. // 当全量小于等于10时 显示1-10
  1657. if (this.focusNaoAll.length <= 10) {
  1658. for (let i = 0; i <= 10; i++) {
  1659. // i = i.toFixed(3);
  1660. sarr.push(i.toString());
  1661. }
  1662. } else if (this.focusNaoAll.length > 10) {
  1663. for (
  1664. let i = this.focusNaoAll.length - 10;
  1665. i < this.focusNaoAll.length;
  1666. i++
  1667. ) {
  1668. sarr.push(i.toString());
  1669. }
  1670. }
  1671. this.optionOne = {
  1672. animation: false,
  1673. title: {
  1674. text: "频谱成分",
  1675. subtext: "",
  1676. left: "center",
  1677. align: "right",
  1678. x: "center",
  1679. y: "bottom",
  1680. },
  1681. grid: {
  1682. bottom: 80,
  1683. },
  1684. legend: {
  1685. data: [
  1686. "Delta",
  1687. "Theta",
  1688. "Low Alpha",
  1689. "High Alpha",
  1690. "Low Beta",
  1691. "High Beta",
  1692. "Low Gamma",
  1693. "Mid Gamma",
  1694. ],
  1695. },
  1696. xAxis: [
  1697. {
  1698. name: "秒(s)",
  1699. type: "category",
  1700. boundaryGap: false,
  1701. axisLine: { onZero: false },
  1702. splitLine: { show: true },
  1703. data: sarr,
  1704. axisLabel: {
  1705. // interval: 999,
  1706. formatter: function (value, index) {
  1707. let a = parseInt(value);
  1708. if (a % 1000 == 0) {
  1709. if ((a / 1000) % 2 == 0) {
  1710. return a / 1000;
  1711. }
  1712. }
  1713. return value;
  1714. },
  1715. },
  1716. },
  1717. ],
  1718. yAxis: [
  1719. {
  1720. name: "",
  1721. type: "value",
  1722. // max: 500,
  1723. },
  1724. ],
  1725. series: [
  1726. {
  1727. smooth: true,
  1728. showSymbol: false,
  1729. name: "Delta",
  1730. type: "line",
  1731. areaStyle: {},
  1732. lineStyle: {
  1733. width: 1,
  1734. },
  1735. emphasis: {
  1736. focus: "series",
  1737. },
  1738. markArea: {
  1739. silent: true,
  1740. itemStyle: {
  1741. opacity: 0.3,
  1742. },
  1743. data: [
  1744. [
  1745. {
  1746. xAxis: "2009/9/10\n7:00",
  1747. },
  1748. {
  1749. xAxis: "2009/9/20\n7:00",
  1750. },
  1751. ],
  1752. ],
  1753. },
  1754. data: this.deltaData,
  1755. },
  1756. {
  1757. smooth: true,
  1758. showSymbol: false,
  1759. name: "Theta",
  1760. type: "line",
  1761. areaStyle: {},
  1762. lineStyle: {
  1763. width: 1,
  1764. },
  1765. emphasis: {
  1766. focus: "series",
  1767. },
  1768. markArea: {
  1769. silent: true,
  1770. itemStyle: {
  1771. opacity: 0.3,
  1772. },
  1773. data: [
  1774. [
  1775. {
  1776. xAxis: "2009/9/10\n7:00",
  1777. },
  1778. {
  1779. xAxis: "2009/9/20\n7:00",
  1780. },
  1781. ],
  1782. ],
  1783. },
  1784. data: this.thetaData,
  1785. },
  1786. {
  1787. smooth: true,
  1788. showSymbol: false,
  1789. name: "Low Alpha",
  1790. type: "line",
  1791. areaStyle: {},
  1792. lineStyle: {
  1793. width: 1,
  1794. },
  1795. emphasis: {
  1796. focus: "series",
  1797. },
  1798. markArea: {
  1799. silent: true,
  1800. itemStyle: {
  1801. opacity: 0.3,
  1802. },
  1803. data: [
  1804. [
  1805. {
  1806. xAxis: "2009/9/10\n7:00",
  1807. },
  1808. {
  1809. xAxis: "2009/9/20\n7:00",
  1810. },
  1811. ],
  1812. ],
  1813. },
  1814. data: this.lowAlphaData,
  1815. },
  1816. {
  1817. smooth: true,
  1818. showSymbol: false,
  1819. name: "High Alpha",
  1820. type: "line",
  1821. areaStyle: {},
  1822. lineStyle: {
  1823. width: 1,
  1824. },
  1825. emphasis: {
  1826. focus: "series",
  1827. },
  1828. markArea: {
  1829. silent: true,
  1830. itemStyle: {
  1831. opacity: 0.3,
  1832. },
  1833. data: [
  1834. [
  1835. {
  1836. xAxis: "2009/9/10\n7:00",
  1837. },
  1838. {
  1839. xAxis: "2009/9/20\n7:00",
  1840. },
  1841. ],
  1842. ],
  1843. },
  1844. data: this.highAlphaData,
  1845. },
  1846. {
  1847. smooth: true,
  1848. showSymbol: false,
  1849. name: "Low Beta",
  1850. type: "line",
  1851. areaStyle: {},
  1852. lineStyle: {
  1853. width: 1,
  1854. },
  1855. emphasis: {
  1856. focus: "series",
  1857. },
  1858. markArea: {
  1859. silent: true,
  1860. itemStyle: {
  1861. opacity: 0.3,
  1862. },
  1863. data: [
  1864. [
  1865. {
  1866. xAxis: "2009/9/10\n7:00",
  1867. },
  1868. {
  1869. xAxis: "2009/9/20\n7:00",
  1870. },
  1871. ],
  1872. ],
  1873. },
  1874. data: this.lowBetaData,
  1875. },
  1876. {
  1877. smooth: true,
  1878. showSymbol: false,
  1879. name: "High Beta",
  1880. type: "line",
  1881. areaStyle: {},
  1882. lineStyle: {
  1883. width: 1,
  1884. },
  1885. emphasis: {
  1886. focus: "series",
  1887. },
  1888. markArea: {
  1889. silent: true,
  1890. itemStyle: {
  1891. opacity: 0.3,
  1892. },
  1893. data: [
  1894. [
  1895. {
  1896. xAxis: "2009/9/10\n7:00",
  1897. },
  1898. {
  1899. xAxis: "2009/9/20\n7:00",
  1900. },
  1901. ],
  1902. ],
  1903. },
  1904. data: this.highBetaData,
  1905. },
  1906. {
  1907. smooth: true,
  1908. showSymbol: false,
  1909. name: "Low Gamma",
  1910. type: "line",
  1911. areaStyle: {},
  1912. lineStyle: {
  1913. width: 1,
  1914. },
  1915. emphasis: {
  1916. focus: "series",
  1917. },
  1918. markArea: {
  1919. silent: true,
  1920. itemStyle: {
  1921. opacity: 0.3,
  1922. },
  1923. data: [
  1924. [
  1925. {
  1926. xAxis: "2009/9/10\n7:00",
  1927. },
  1928. {
  1929. xAxis: "2009/9/20\n7:00",
  1930. },
  1931. ],
  1932. ],
  1933. },
  1934. data: this.lowGammaData,
  1935. },
  1936. {
  1937. smooth: true,
  1938. showSymbol: false,
  1939. name: "Mid Gamma",
  1940. type: "line",
  1941. areaStyle: {},
  1942. lineStyle: {
  1943. width: 1,
  1944. },
  1945. emphasis: {
  1946. focus: "series",
  1947. },
  1948. markArea: {
  1949. silent: true,
  1950. itemStyle: {
  1951. opacity: 0.3,
  1952. },
  1953. data: [
  1954. [
  1955. {
  1956. xAxis: "2009/9/10\n7:00",
  1957. },
  1958. {
  1959. xAxis: "2009/9/20\n7:00",
  1960. },
  1961. ],
  1962. ],
  1963. },
  1964. data: this.midGammaData,
  1965. },
  1966. ],
  1967. };
  1968. this.echartsOne.setOption(this.optionOne);
  1969. },
  1970. renderEegTwo() {
  1971. let sarr = [];
  1972. // 当全量小于等于10时 显示1-10
  1973. if (this.focusNaoAll.length <= 10) {
  1974. for (let i = 0; i <= 10; i++) {
  1975. // i = i.toFixed(3);
  1976. sarr.push(i.toString());
  1977. }
  1978. } else if (this.focusNaoAll.length > 10) {
  1979. for (
  1980. let i = this.focusNaoAll.length - 10;
  1981. i < this.focusNaoAll.length;
  1982. i++
  1983. ) {
  1984. sarr.push(i.toString());
  1985. }
  1986. }
  1987. this.optionTwo = {
  1988. animation: false,
  1989. title: {
  1990. text: "注意力指标",
  1991. subtext: "",
  1992. left: "center",
  1993. align: "right",
  1994. x: "center",
  1995. y: "bottom",
  1996. },
  1997. grid: {
  1998. bottom: 80,
  1999. },
  2000. legend: {
  2001. data: ["Noise", "Attention", "Medition"],
  2002. // left: 10,
  2003. },
  2004. xAxis: [
  2005. {
  2006. name: "秒(s)",
  2007. type: "category",
  2008. boundaryGap: false,
  2009. axisLine: { onZero: false },
  2010. splitLine: { show: true },
  2011. data: sarr,
  2012. },
  2013. ],
  2014. yAxis: [
  2015. {
  2016. name: "秒(s)",
  2017. type: "value",
  2018. // max: 500,
  2019. },
  2020. // {
  2021. // name: "秒(s)",
  2022. // nameLocation: "start",
  2023. // // max: 5,
  2024. // type: "value",
  2025. // inverse: false,
  2026. // },
  2027. ],
  2028. series: [
  2029. {
  2030. smooth: true,
  2031. showSymbol: false,
  2032. name: "Noise",
  2033. type: "line",
  2034. yAxisIndex: 0,
  2035. areaStyle: {},
  2036. lineStyle: {
  2037. width: 1,
  2038. },
  2039. emphasis: {
  2040. focus: "series",
  2041. },
  2042. markArea: {
  2043. silent: true,
  2044. itemStyle: {
  2045. opacity: 0.3,
  2046. },
  2047. data: [
  2048. [
  2049. {
  2050. xAxis: "2009/9/10\n7:00",
  2051. },
  2052. {
  2053. xAxis: "2009/9/20\n7:00",
  2054. },
  2055. ],
  2056. ],
  2057. },
  2058. data: this.noiseData,
  2059. },
  2060. {
  2061. smooth: true,
  2062. showSymbol: false,
  2063. name: "Attention",
  2064. type: "line",
  2065. yAxisIndex: 0,
  2066. areaStyle: {},
  2067. lineStyle: {
  2068. width: 1,
  2069. },
  2070. emphasis: {
  2071. focus: "series",
  2072. },
  2073. markArea: {
  2074. silent: true,
  2075. itemStyle: {
  2076. opacity: 0.3,
  2077. },
  2078. data: [
  2079. [
  2080. {
  2081. xAxis: "2009/9/10\n7:00",
  2082. },
  2083. {
  2084. xAxis: "2009/9/20\n7:00",
  2085. },
  2086. ],
  2087. ],
  2088. },
  2089. data: this.attentionData,
  2090. },
  2091. {
  2092. smooth: true,
  2093. showSymbol: false,
  2094. name: "Medition",
  2095. type: "line",
  2096. yAxisIndex: 0,
  2097. areaStyle: {},
  2098. lineStyle: {
  2099. width: 1,
  2100. },
  2101. emphasis: {
  2102. focus: "series",
  2103. },
  2104. markArea: {
  2105. silent: true,
  2106. itemStyle: {
  2107. opacity: 0.3,
  2108. },
  2109. data: [
  2110. [
  2111. {
  2112. xAxis: "2009/9/10\n7:00",
  2113. },
  2114. {
  2115. xAxis: "2009/9/20\n7:00",
  2116. },
  2117. ],
  2118. ],
  2119. },
  2120. data: this.meditationData,
  2121. },
  2122. ],
  2123. };
  2124. this.echartsTwo.setOption(this.optionTwo);
  2125. },
  2126. renderEegThree() {
  2127. let sarr = [];
  2128. // 当全量小于等于10时 显示1-10
  2129. if (this.waveDataAll.length <= 5120) {
  2130. for (let i = 0; i <= 5120; i++) {
  2131. // i = i.toFixed(3);
  2132. sarr.push(i.toString());
  2133. }
  2134. } else if (this.waveDataAll.length > 5120) {
  2135. for (
  2136. let i = this.waveDataAll.length - 5120;
  2137. i < this.waveDataAll.length;
  2138. i++
  2139. ) {
  2140. sarr.push(i.toString());
  2141. }
  2142. }
  2143. this.optionThree = {
  2144. animation: false,
  2145. title: {
  2146. text: "原始信号",
  2147. subtext: "",
  2148. left: "center",
  2149. align: "right",
  2150. x: "center",
  2151. y: "bottom",
  2152. },
  2153. grid: {
  2154. bottom: 80,
  2155. },
  2156. legend: {
  2157. data: ["RAW Wave"],
  2158. // left: 10,
  2159. },
  2160. xAxis: [
  2161. {
  2162. name: "秒(s)",
  2163. type: "category",
  2164. boundaryGap: false,
  2165. axisLine: { onZero: false },
  2166. splitLine: { show: true },
  2167. data: sarr,
  2168. axisLabel: {
  2169. interval: 512,
  2170. formatter: function (value, index) {
  2171. // 当当前value除以1000为整数是
  2172. // console.log(value);
  2173. // 将value转化为int类型
  2174. let a = parseInt(value);
  2175. a = Math.round(a / 512);
  2176. // if (a %510 == 0) {
  2177. // // if ((a / 1000) % 2 == 0) {
  2178. // // return a / 1000;
  2179. // // }
  2180. // return a / 1000;
  2181. // }
  2182. return a;
  2183. },
  2184. },
  2185. },
  2186. ],
  2187. yAxis: [
  2188. {
  2189. name: "",
  2190. type: "value",
  2191. // max: 500,
  2192. },
  2193. ],
  2194. series: [
  2195. {
  2196. smooth: true,
  2197. showSymbol: false,
  2198. name: "RAW Wave",
  2199. type: "line",
  2200. lineStyle: {
  2201. width: 1,
  2202. },
  2203. data: this.waveData,
  2204. },
  2205. ],
  2206. };
  2207. this.echartsThree.setOption(this.optionThree);
  2208. },
  2209. },
  2210. };
  2211. </script>
  2212. <style scoped>
  2213. .equipment_status {
  2214. display: flex;
  2215. flex-direction: row;
  2216. align-items: center;
  2217. }
  2218. .main_right_height {
  2219. height: 100vh !important;
  2220. display: block !important;
  2221. overflow-y: auto !important;
  2222. background: #ffffff;
  2223. }
  2224. canvas {
  2225. /* width: 100%;
  2226. height: 100%; */
  2227. }
  2228. .main-unity {
  2229. margin-top: 10px;
  2230. }
  2231. </style>
  2232. <style>
  2233. .footer {
  2234. text-align: center;
  2235. }
  2236. .fullscreen {
  2237. margin-top: 25px !important;
  2238. text-align: center !important;
  2239. display: none !important;
  2240. }
  2241. .musicTitle {
  2242. display: block;
  2243. font-size: 18px;
  2244. color: #57acbb;
  2245. margin-bottom: 5px;
  2246. }
  2247. .flood-plan-page {
  2248. /* margin-top:20px; */
  2249. }
  2250. .selectSty {
  2251. width: 100px;
  2252. font-size: 14px;
  2253. }
  2254. .desSty {
  2255. font-size: 12px;
  2256. font-family: Source Han Sans CN-Regular, Source Han Sans CN;
  2257. font-weight: 500;
  2258. /* color: #0f0f0f; */
  2259. }
  2260. .animation_fk {
  2261. }
  2262. .select_option {
  2263. font-size: 10px;
  2264. }
  2265. .select_class_animation {
  2266. display: flex;
  2267. flex-direction: row;
  2268. align-items: center;
  2269. }
  2270. .animation-middle-m {
  2271. display: flex;
  2272. flex-direction: row;
  2273. flex: 1;
  2274. }
  2275. .naoOneClass {
  2276. width: 100%;
  2277. height: 30vh;
  2278. width: 100%;
  2279. }
  2280. </style>