AnimationDouble.vue 99 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540
  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. <div class="select_class_animation">
  8. <span class="desSty">选择设备</span>&nbsp;
  9. <el-select
  10. v-model="equipment"
  11. placeholder="请选择"
  12. class="selectSty"
  13. size="medium"
  14. @change="equipmentFun"
  15. >
  16. <el-option
  17. class="select_option"
  18. v-for="item in optionsEquipment"
  19. :key="item.value"
  20. :label="item.label"
  21. :value="item.value"
  22. >
  23. </el-option>
  24. </el-select>
  25. &nbsp;&nbsp;&nbsp;&nbsp;
  26. <span class="desSty">游戏难度</span>&nbsp;
  27. <el-select
  28. v-model="gameDifficulty"
  29. placeholder="请选择"
  30. class="selectSty"
  31. size="medium"
  32. @change="gameDiffFun"
  33. >
  34. <el-option
  35. v-for="item in difficultyOptions"
  36. :key="item.value"
  37. :label="item.label"
  38. :value="item.value"
  39. >
  40. </el-option>
  41. </el-select>
  42. &nbsp;&nbsp;&nbsp;&nbsp;
  43. <span class="desSty">游戏时间</span>&nbsp;
  44. <el-select
  45. v-model="gameTime"
  46. placeholder="请选择"
  47. class="selectSty"
  48. size="medium"
  49. @change="gameTimeFun"
  50. >
  51. <el-option
  52. v-for="item in timeOptions"
  53. :key="item.value"
  54. :label="item.label"
  55. :value="item.value"
  56. >
  57. </el-option>
  58. </el-select>
  59. &nbsp;&nbsp;&nbsp;&nbsp;
  60. <span
  61. style="font-size: 12px"
  62. v-show="equipment == '2' && pulseTimeNum < 180 && pulseTimeNum > 0"
  63. >还剩{{ timeShow }}开始</span
  64. >
  65. <span
  66. style="font-size: 12px"
  67. v-show="buttonFlag == '结束' && gameTimeTimerFlag"
  68. >{{ timeShow }}</span
  69. >
  70. <div class="animation-middle-m">&nbsp;</div>
  71. <el-button
  72. @click="startTest"
  73. size="small"
  74. class="xl_animation_button"
  75. style="float: right; font-size: 12px"
  76. >{{ buttonFlag }}</el-button
  77. >
  78. </div>
  79. </el-col>
  80. <el-col :span="1"> &nbsp; </el-col>
  81. </el-row>
  82. <el-row>
  83. <el-col :span="1"> &nbsp; </el-col>
  84. <el-col :span="22">
  85. <div class="select_class_animation" style="margin-top: 10px">
  86. <div class="equipment_status">
  87. <div class="desSty">用户编号:</div>
  88. <div class="desSty">{{ userLink.num }}</div>
  89. &nbsp;&nbsp;&nbsp;&nbsp;
  90. <span
  91. class="desSty"
  92. v-show="userLink.linkStatus"
  93. :style="{ color: userLink.linkStatus ? '#0FB577' : '#000000' }"
  94. >设备已连接:</span
  95. >
  96. <span class="desSty" v-show="!userLink.linkStatus"
  97. >设备未连接:</span
  98. >
  99. <img
  100. v-show="!userLink.linkStatus"
  101. @click="openTableFun(1)"
  102. style="width: 14px; height: 20px; color: #ffffff"
  103. src="../assets/newAnimation/lanya.png"
  104. />
  105. <img
  106. v-show="userLink.linkStatus"
  107. @click="openTableFun(1)"
  108. style="width: 14px; height: 20px; color: #ffffff"
  109. src="../assets/newAnimation/lanyaActive.png"
  110. />
  111. </div>
  112. &nbsp;&nbsp;&nbsp;&nbsp;
  113. <span
  114. class="desSty"
  115. @click="viewEchartsFun(1)"
  116. :style="{ color: userLink.linkStatus ? '#0FB577' : '#000000' }"
  117. >查看波形图</span
  118. >
  119. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  120. <div class="equipment_status">
  121. <div class="desSty">用户编号:</div>
  122. <div class="desSty">{{ userTwoLink.num }}</div>
  123. &nbsp;&nbsp;&nbsp;&nbsp;
  124. <span
  125. class="desSty"
  126. v-show="userTwoLink.linkStatus"
  127. :style="{ color: userTwoLink.linkStatus ? '#0FB577' : '#000000' }"
  128. >设备已连接:</span
  129. >
  130. <span class="desSty" v-show="!userTwoLink.linkStatus"
  131. >设备未连接:</span
  132. >
  133. <img
  134. v-show="!userTwoLink.linkStatus"
  135. @click="openTableFun(2)"
  136. style="width: 14px; height: 20px; color: #ffffff"
  137. src="../assets/newAnimation/lanya.png"
  138. />
  139. <img
  140. v-show="userTwoLink.linkStatus"
  141. @click="openTableFun(2)"
  142. style="width: 14px; height: 20px; color: #ffffff"
  143. src="../assets/newAnimation/lanyaActive.png"
  144. />
  145. </div>
  146. &nbsp;&nbsp;&nbsp;&nbsp;
  147. <span
  148. class="desSty"
  149. @click="viewEchartsFun(2)"
  150. :style="{ color: userTwoLink.linkStatus ? '#0FB577' : '#000000' }"
  151. >查看波形图</span
  152. >
  153. </div>
  154. </el-col>
  155. <el-col :span="1"> &nbsp; </el-col>
  156. </el-row>
  157. <el-row>
  158. <el-col :span="1">&nbsp;</el-col>
  159. <el-col :span="22">
  160. <div
  161. class="flood-plan-page"
  162. ref="animationFlow"
  163. style="display: block; height: 72vh; margin-top: 10px"
  164. >
  165. <iframe
  166. scrolling="no"
  167. :src="urlThreeP"
  168. ref="unityIframe"
  169. frameborder="0"
  170. :width="widthIframe"
  171. :height="heightIframe"
  172. >
  173. </iframe>
  174. </div>
  175. </el-col>
  176. <el-col :span="1">&nbsp;</el-col>
  177. </el-row>
  178. <el-dialog title="提示" :visible.sync="tableVisible" width="60%" center>
  179. <span>
  180. <el-table
  181. :data="mergeData"
  182. style="width: 100%; max-height: 400px; overflow-y: auto"
  183. :header-cell-style="{
  184. background: '#66B497',
  185. color: '#FFFFFF',
  186. 'letter-spacing': '4px',
  187. }"
  188. >
  189. <el-table-column prop="rssi" align="center" label="信号强度">
  190. </el-table-column>
  191. <el-table-column
  192. prop="deviceType"
  193. align="center"
  194. label="类型"
  195. :formatter="typeFormatter"
  196. >
  197. </el-table-column>
  198. <el-table-column prop="userNum" align="center" label="已绑用户">
  199. </el-table-column>
  200. <el-table-column prop="mac" align="center" label="mac">
  201. </el-table-column>
  202. <el-table-column label="操作" align="center">
  203. <template slot-scope="scope">
  204. <el-button
  205. :disabled="buttonLinkFlag"
  206. class="xl_d_button"
  207. size="mini"
  208. slot="reference"
  209. @click="linkJudge(scope.row, scope.row.connent)"
  210. >
  211. <span v-if="scope.row.connent">断开连接</span
  212. ><span v-if="!scope.row.connent">连接</span></el-button
  213. >
  214. </template>
  215. </el-table-column>
  216. </el-table>
  217. </span>
  218. <span slot="footer" class="dialog-footer">
  219. <el-button @click="tableVisible = false">取 消</el-button>
  220. <el-button type="primary" @click="tableVisible = false"
  221. >确 定</el-button
  222. >
  223. </span>
  224. </el-dialog>
  225. <!-- 用户选择框 -->
  226. <el-dialog
  227. title="选择连接用户"
  228. :visible.sync="userVisible"
  229. width="50%"
  230. center
  231. >
  232. <span>
  233. <el-input
  234. style="width: 180px; margin-bottom: 10px"
  235. placeholder="请输入搜索内容"
  236. v-model="nameSearch"
  237. prefix-icon="el-icon-search"
  238. @input="searchUser"
  239. size="small"
  240. >
  241. </el-input>
  242. <el-table
  243. :data="userData"
  244. style="width: 100%; max-height: 300px; overflow-y: auto"
  245. :header-cell-style="{
  246. background: '#66B497',
  247. color: '#FFFFFF',
  248. 'letter-spacing': '4px',
  249. }"
  250. >
  251. <el-table-column>
  252. <template slot-scope="scope">
  253. <el-radio v-model="selectUserRadio" :label="scope.row.identifier"
  254. >&nbsp;</el-radio
  255. >
  256. </template>
  257. </el-table-column>
  258. <el-table-column prop="userName" align="center" label="姓名">
  259. </el-table-column>
  260. <el-table-column prop="identifier" align="center" label="编号">
  261. </el-table-column>
  262. </el-table>
  263. <p align="center" style="margin-bottom: 40px">
  264. <el-pagination
  265. @size-change="handleSizeChange"
  266. @current-change="handleCurrentChange"
  267. :current-page="pageNum"
  268. :page-size="pageSize"
  269. layout="total, prev, pager, next, jumper"
  270. :total="totolSize"
  271. >
  272. </el-pagination>
  273. </p>
  274. </span>
  275. <span slot="footer" class="dialog-footer">
  276. <el-button @click="userVisible = false">取 消</el-button>
  277. <!-- <el-button type="primary" @click="userVisible = false">确 定</el-button> -->
  278. <el-button type="primary" @click="userComfirm">确 定</el-button>
  279. </span>
  280. </el-dialog>
  281. <el-dialog
  282. title="查看波形图"
  283. :visible.sync="echartsVisible"
  284. width="90%"
  285. center
  286. >
  287. <span>
  288. <div class="outPage" v-show="equipment == '1'">
  289. <div id="eegOne" class="naoOneClass"></div>
  290. </div>
  291. <div class="outPage" v-show="equipment == '1'">
  292. <div id="eegTwo" class="naoOneClass"></div>
  293. </div>
  294. <div class="outThreePage" v-show="equipment == '1'">
  295. <div id="eegThree" class="naoOneClass"></div>
  296. </div>
  297. <div class="outPage" v-show="equipment == '2'">
  298. <div id="ecgOne" class="naoOneClass" style="height: 500px"></div>
  299. </div>
  300. </span>
  301. <span slot="footer" class="dialog-footer">
  302. <el-button @click="echartsVisible = false">取 消</el-button>
  303. <el-button type="primary" @click="echartsVisible = false"
  304. >确 定</el-button
  305. >
  306. </span>
  307. </el-dialog>
  308. <!-- //第二个人的渲染图 -->
  309. <el-dialog
  310. title="查看波形图"
  311. :visible.sync="echartsSecondVisible"
  312. width="90%"
  313. center
  314. >
  315. <span>
  316. <div class="outPage" v-show="equipment == '1'">
  317. <div id="eegOneSecond" class="naoOneClass"></div>
  318. </div>
  319. <div class="outPage" v-show="equipment == '1'">
  320. <div id="eegTwoSecond" class="naoOneClass"></div>
  321. </div>
  322. <div class="outThreePage" v-show="equipment == '1'">
  323. <div id="eegThreeSecond" class="naoOneClass"></div>
  324. </div>
  325. <div class="outPage" v-show="equipment == '2'">
  326. <div id="ecgTwo" class="naoOneClass" style="height: 500px"></div>
  327. </div>
  328. </span>
  329. <span slot="footer" class="dialog-footer">
  330. <el-button @click="echartsSecondVisible = false">取 消</el-button>
  331. <el-button type="primary" @click="echartsSecondVisible = false"
  332. >确 定</el-button
  333. >
  334. </span>
  335. </el-dialog>
  336. </div>
  337. </template>
  338. <script>
  339. //一个弹出框显示脑电或心电的显示图,外边显示脑电设备状态
  340. // 查看选择设备的状态,判断波形是哪个?
  341. import * as echarts from "echarts";
  342. import Utils from "./util.js";
  343. const fs = require("fs");
  344. const { ipcRenderer } = require("electron");
  345. const RingBuffer = require("ringbufferjs");
  346. // import RingBuffer from 'ringbufferjs'
  347. export default {
  348. data() {
  349. return {
  350. activeName: "first",
  351. //echarts渲染标志
  352. echartsVisible: false,
  353. echartsOne: null,
  354. echartsTwo: null,
  355. echartsThree: null,
  356. //第二个人的图渲染标志
  357. echartsSecondVisible: false,
  358. echartsOneSecond: null,
  359. echartsTwoSecond: null,
  360. echartsThreeSecond: null,
  361. //心电1连接对象
  362. echartsEcg: null,
  363. //心电2连接对象
  364. echartsEcgTwo: null,
  365. optionOne: null,
  366. optionTwo: null,
  367. optionThree: null,
  368. //第二个用户的脑电
  369. optionOneSecond: null,
  370. optionTwoSecond: null,
  371. optionThreeSecond: null,
  372. //心电1 option
  373. optionEcg: null,
  374. //心电2 option
  375. optionEcgTwo: null,
  376. //打开设备进行选择的列表
  377. openTableFlag: "",
  378. scanData: [],
  379. connectedData: [],
  380. websock: null,
  381. tableVisible: false,
  382. linkIndex: null,
  383. //是否是单个训练
  384. singleFlag: true,
  385. buttonDisable: true,
  386. //脉搏开始前倒计时
  387. pulseTimeNum: 180,
  388. pulseTime: null,
  389. gameValue: 0,
  390. timeShow: "",
  391. buttonFlag: "开始",
  392. //脑电是否连接的状态
  393. eleFlag: "未连接",
  394. //脉搏是否连接的状态
  395. pulseFlag: "未连接",
  396. widthIframe: 900,
  397. heightIframe: 600,
  398. flag: 1,
  399. //游戏场景
  400. gameScene: 1,
  401. optionsGame: [
  402. {
  403. value: 1,
  404. label: "心灵之火",
  405. },
  406. {
  407. value: 2,
  408. label: "心之花",
  409. },
  410. {
  411. value: 3,
  412. label: "急速赛车",
  413. },
  414. {
  415. value: 4,
  416. label: "爆爆桶",
  417. },
  418. {
  419. value: 5,
  420. label: "炸弹",
  421. },
  422. {
  423. value: 6,
  424. label: "漂浮球",
  425. },
  426. ],
  427. //设备选择
  428. equipment: 1,
  429. optionsEquipment: [
  430. { value: 1, label: "脑电" },
  431. { value: 2, label: "心电" },
  432. ],
  433. //游戏难度
  434. gameDifficulty: 1,
  435. difficultyOptions: [
  436. { value: 1, label: "简单" },
  437. { value: 2, label: "普通" },
  438. { value: 3, label: "困难" },
  439. ],
  440. //游戏时间
  441. gameTimeReserve: 180,
  442. gameTime: 1,
  443. timeOptions: [
  444. { value: 1, label: "三分钟" },
  445. { value: 2, label: "五分钟" },
  446. { value: 3, label: "十分钟" },
  447. ],
  448. waitTimePluse: 0,
  449. testTime: 0,
  450. gameTimeTimer: null,
  451. //是否显示的倒计时标志
  452. gameTimeTimerFlag: false,
  453. //用户1的脑电变量//脑电变量
  454. waveData: [],
  455. // 全量
  456. waveDataAll: [],
  457. deltaDataFlag: [],
  458. // 全量
  459. deltaDataFlagAll: [],
  460. deltaData: [],
  461. // 全量
  462. deltaDataAll: [],
  463. thetaData: [],
  464. // 全量
  465. thetaDataAll: [],
  466. lowAlphaData: [],
  467. // 全量
  468. lowAlphaDataAll: [],
  469. highAlphaData: [],
  470. // 全量
  471. highAlphaDataAll: [],
  472. lowBetaData: [],
  473. // 全量
  474. lowBetaDataAll: [],
  475. highBetaData: [],
  476. // 全量
  477. highBetaDataAll: [],
  478. lowGammaData: [],
  479. // 全量
  480. lowGammaDataAll: [],
  481. midGammaData: [],
  482. // 全量
  483. midGammaDataAll: [],
  484. noiseData: [],
  485. // 全量
  486. noiseDataAll: [],
  487. attentionData: [],
  488. // 全量
  489. attentionDataAll: [],
  490. meditationData: [],
  491. // 全量
  492. meditationDataAll: [],
  493. focusNao: [],
  494. // 全量
  495. focusNaoAll: [],
  496. // urlThreeP: "../../../static/candle/index.html",
  497. urlThreeP: __static + "/candle/index.html",
  498. // pubSrc: "../../../static",
  499. pubsrc: __static,
  500. userLink: {
  501. num: "",
  502. mac: "",
  503. linkStatus: false,
  504. ecgAllList: [], //心电数据部分
  505. ecgSectionList: [], //心电数据全部
  506. //开始脑电各个部分的数据
  507. },
  508. userTwoLink: {
  509. num: "",
  510. mac: "",
  511. linkStatus: false,
  512. ecgAllList: [], //心电数据部分
  513. ecgSectionList: [], //心电数据全部
  514. //开始脑电各个部分的数据
  515. },
  516. //用户2的脑电变量//脑电变量
  517. waveDataSecond: [],
  518. // 全量
  519. waveDataAllSecond: [],
  520. deltaDataFlagSecond: [],
  521. // 全量
  522. deltaDataFlagAllSecond: [],
  523. deltaDataSecond: [],
  524. // 全量
  525. deltaDataAllSecond: [],
  526. thetaDataSecond: [],
  527. // 全量
  528. thetaDataAllSecond: [],
  529. lowAlphaDataSecond: [],
  530. // 全量
  531. lowAlphaDataAllSecond: [],
  532. highAlphaDataSecond: [],
  533. // 全量
  534. highAlphaDataAllSecond: [],
  535. lowBetaDataSecond: [],
  536. // 全量
  537. lowBetaDataAllSecond: [],
  538. highBetaDataSecond: [],
  539. // 全量
  540. highBetaDataAllSecond: [],
  541. lowGammaDataSecond: [],
  542. // 全量
  543. lowGammaDataAllSecond: [],
  544. midGammaDataSecond: [],
  545. // 全量
  546. midGammaDataAllSecond: [],
  547. noiseDataSecond: [],
  548. // 全量
  549. noiseDataAllSecond: [],
  550. attentionDataSecond: [],
  551. // 全量
  552. attentionDataAllSecond: [],
  553. meditationDataSecond: [],
  554. // 全量
  555. meditationDataAllSecond: [],
  556. focusNaoSecond: [],
  557. // 全量
  558. focusNaoAllSecond: [],
  559. //定时器标志
  560. listTimeFlagSecond: null,
  561. //是否已连接的标志
  562. //单人
  563. //标志等待点击开始按钮后,打开定时器开始渲染
  564. timeSendFlag: null,
  565. //优化显示列表进行防抖
  566. listShaking: true,
  567. listTmp: [],
  568. //合并的定时器
  569. mergeTimeFlag: null,
  570. mergeData: [],
  571. //连接按钮flag
  572. buttonLinkFlag: false,
  573. //按钮状态
  574. disabledTimeFlag: null,
  575. //用户列表
  576. userData: [],
  577. //用户分页
  578. pageNum: 1,
  579. //每页多少条
  580. pageSize: 10,
  581. //总条数
  582. totolSize: 10,
  583. //用户搜索姓名
  584. nameSearch: "",
  585. //选择用户
  586. selectUserRadio: "",
  587. //选择用户的窗口
  588. userVisible: false,
  589. //一个标志标志着点击的是哪个用户的设备连接
  590. //当数值等于1时代表选择的是用户用户1的选择
  591. userDeviceFlag: null,
  592. //获取当前选择设备的连接状态和值
  593. currentSingle: {},
  594. //当前设备的连接状态
  595. currentFlag: false,
  596. //间隔长度
  597. intervalLength: 500,
  598. };
  599. },
  600. mounted() {
  601. //获取当前用户num
  602. // RingBuffer=null;
  603. //添加监听接收到数据后开始驱动
  604. //脑电监听
  605. //进来之前得到传过来的参数
  606. //调用切换场景的方法
  607. let that = this;
  608. //进入当前页面需要关闭掉所有连接的设备
  609. that.disconnectDevice();
  610. let count = 0;
  611. var k = 1;
  612. var flagAnimation = true;
  613. window.addEventListener("resize", function () {
  614. // that.getSize();
  615. if (flagAnimation) {
  616. setTimeout(() => {
  617. that.getSize();
  618. //判断当前是脑电还是心电
  619. if (that.equipment == "1") {
  620. if (that.echartsVisible) {
  621. that.echartsOne.resize();
  622. that.echartsTwo.resize();
  623. that.echartsThree.resize();
  624. }
  625. if (that.echartsSecondVisible) {
  626. that.echartsOneSecond.resize();
  627. that.echartsTwoSecond.resize();
  628. that.echartsThreeSecond.resize();
  629. }
  630. }
  631. if (that.equipment == "2") {
  632. if (that.echartsVisible) {
  633. that.echartsEcg.resize();
  634. }
  635. if (that.echartsSecondVisible) {
  636. that.echartsEcgTwo.resize();
  637. }
  638. }
  639. flagAnimation = true;
  640. }, 1000);
  641. }
  642. flagAnimation = false;
  643. });
  644. setTimeout(() => {
  645. that.getSize();
  646. }, 5000);
  647. setTimeout(() => {
  648. that.changeGame(parseInt(that.$route.query.gameType));
  649. console.log(that.$route.query.gameType);
  650. }, 3000);
  651. that.singleFlag = that.$route.query.single;
  652. console.log(that.singleFlag);
  653. ipcRenderer.on("accelerationData-message", this.acceptNao);
  654. this.initWebsocket();
  655. //当点击开始时调用方法开发发送游戏数据
  656. //上来就查询已连接列表
  657. that.listTimeFlag = setInterval(that.connectList, 2000);
  658. //根据扫描列表和已连接列表看看哪些是重复的//重复的就是已连接的
  659. that.mergeTimeFlag = setInterval(that.mergeDataFun, 1000);
  660. },
  661. destroyed() {
  662. clearTimeout(this.mergeTimeFlag);
  663. clearTimeout(this.disabledTimeFlag);
  664. clearInterval(this.timeSendFlag);
  665. clearInterval(this.listTimeFlag);
  666. console.log(ipcRenderer);
  667. this.websock.close(1000);
  668. //清除特定的监听的ipcRenderer
  669. ipcRenderer.removeListener("accelerationData-message", this.acceptNao);
  670. this.disconnectDevice();
  671. },
  672. methods: {
  673. //合并数据
  674. mergeDataFun() {
  675. let that = this;
  676. let scanDataTmp = JSON.stringify(this.scanData);
  677. let scanDataTmpFin = JSON.parse(scanDataTmp);
  678. let list = [];
  679. for (let i = 0; i < scanDataTmpFin.length; i++) {
  680. let obj = {
  681. rssi: "",
  682. name: "",
  683. mac: "",
  684. connent: false,
  685. deviceType: "",
  686. userNum: "",
  687. };
  688. obj.rssi = scanDataTmpFin[i].rssi;
  689. obj.name = scanDataTmpFin[i].name;
  690. obj.mac = scanDataTmpFin[i].mac;
  691. obj.connent = false;
  692. obj.deviceType = scanDataTmpFin[i].deviceType;
  693. list.push(obj);
  694. }
  695. //判断某个
  696. //先取出与扫描列表显示不一样的
  697. //循环list
  698. //与已选列表进行对比,如果已选列表中有重复
  699. //已选列表必定显示
  700. //如果已选列表为空
  701. //已连接列表中应该全部显示+扫描列表与已选列表不重复的mac的则为全部的
  702. //先将扫描列表与已选列表全部格式化合并为一个数组
  703. //先查已选列表中在扫描列表中没有的----
  704. //然后最后将其加入扫描列表
  705. //然后查询已选列表中在扫描列表中有的
  706. //已选列表
  707. let connectedDataTmp = JSON.stringify(this.connectedData);
  708. let connectedDataTmpFin = JSON.parse(connectedDataTmp);
  709. //不包含的列表
  710. let listBarring = [];
  711. for (let i = 0; i < connectedDataTmpFin.length; i++) {
  712. let flag = false;
  713. for (let j = 0; j < list.length; j++) {
  714. if (connectedDataTmpFin[i].mac == list[j].mac) {
  715. flag = true;
  716. }
  717. }
  718. if (!flag) {
  719. listBarring.push(connectedDataTmpFin[i]);
  720. }
  721. }
  722. for (let i = 0; i < list.length; i++) {
  723. for (let j = 0; j < connectedDataTmpFin.length; j++) {
  724. if (list[i].mac == connectedDataTmpFin[j].mac) {
  725. list[i].connent = true;
  726. list[i].rssi = connectedDataTmpFin[j].rssi;
  727. }
  728. }
  729. }
  730. //然后合并两个数组
  731. let listFin = list.concat(listBarring);
  732. //判断当前选择的是脑电还是心电
  733. let currentDeviceList = [];
  734. if (this.equipment == "1") {
  735. //当是脑电时
  736. for (let i = 0; i < listFin.length; i++) {
  737. if (listFin[i].deviceType == "0") {
  738. currentDeviceList.push(listFin[i]);
  739. }
  740. }
  741. } else {
  742. for (let i = 0; i < listFin.length; i++) {
  743. if (listFin[i].deviceType == "1") {
  744. currentDeviceList.push(listFin[i]);
  745. }
  746. }
  747. }
  748. for (let k = 0; k < currentDeviceList.length; k++) {
  749. if (
  750. that.userLink.mac !== "" &&
  751. that.userLink.mac == currentDeviceList[k].mac
  752. ) {
  753. currentDeviceList[k].userNum = that.userLink.num;
  754. }
  755. if (
  756. that.userTwoLink.mac !== "" &&
  757. that.userTwoLink.mac == currentDeviceList[k].mac
  758. ) {
  759. currentDeviceList[k].userNum = that.userTwoLink.num;
  760. }
  761. }
  762. //将数组其他选项
  763. // console.log(listFin);
  764. this.mergeData = currentDeviceList;
  765. //将将列表表现得多一点 用于测试列表溢出
  766. // let obj = {
  767. // rssi: "2",
  768. // name: "2",
  769. // mac: "2",
  770. // connent: false,
  771. // deviceType: "2",
  772. // userNum: "2",
  773. // };
  774. // for (let i = 0; i < 10; i++) {
  775. // this.mergeData.push(obj);
  776. // }
  777. },
  778. //用户选择点击确定
  779. userComfirm() {
  780. //点击的是哪个用户选怎设备
  781. console.log(this.userDeviceFlag);
  782. console.log(this.selectUserRadio);
  783. if (this.selectUserRadio !== "") {
  784. //判断是哪个用户
  785. if (this.userDeviceFlag == 1) {
  786. //则第一个用户的编号则是当前选择用户的
  787. this.userLink.num = this.selectUserRadio;
  788. } else {
  789. this.userTwoLink.num = this.selectUserRadio;
  790. }
  791. }
  792. let value = JSON.parse(JSON.stringify(this.currentSingle));
  793. if (this.currentFlag) {
  794. //buttonLinkFlag
  795. this.disconnectEquipment(value);
  796. } else {
  797. //调用连接的时候需要知道选的是哪个用户的
  798. //打开连接的时候需要弹出用户选择框进行选择用户
  799. this.linkFun(value);
  800. }
  801. this.userVisible = false;
  802. //判断绑定的用户是选择的哪个
  803. // if(){
  804. // }
  805. },
  806. searchUser() {
  807. this.pageNum = 1;
  808. this.queryUser();
  809. },
  810. //选择用户
  811. queryUser() {
  812. let that = this;
  813. that.$http.post(
  814. `v1/user/find`,
  815. {
  816. pageNum: that.pageNum,
  817. pageSize: that.pageSize,
  818. startDate: "",
  819. endDate: "",
  820. userName: that.nameSearch,
  821. role: 0,
  822. },
  823. (res) => {
  824. if (res.data.code == 200) {
  825. that.userData = res.data.data.content;
  826. that.totolSize = res.data.data.totalElements;
  827. } else {
  828. this.$message.error("访问服务器失败!");
  829. }
  830. }
  831. );
  832. },
  833. handleSizeChange(val) {
  834. this.queryUser();
  835. },
  836. handleCurrentChange(val) {
  837. this.pageNum = val;
  838. this.queryUser();
  839. // this.pageNum = val;
  840. // this.queryList();
  841. },
  842. //脑电图渲染
  843. acceptNao(event, data) {
  844. let arg = data.arg;
  845. let mac = data.mac;
  846. if (this.userLink.mac == mac) {
  847. if (arg["_c"].size == 1) {
  848. this.waveData.push(arg["_c"].get("rawWaveData"));
  849. this.waveDataAll.push(arg["_c"].get("rawWaveData"));
  850. if (this.waveData.length > 5120) {
  851. this.waveData.shift();
  852. }
  853. } else {
  854. if (arg["_c"].size == 11) {
  855. // 当不为undefined时
  856. let ll = 11;
  857. // 获取长度
  858. this.deltaDataFlag.push(arg["_c"].get("Delta"));
  859. this.deltaDataFlagAll.push(arg["_c"].get("Delta"));
  860. if (this.deltaDataFlag.length > ll) {
  861. this.deltaDataFlag.shift();
  862. }
  863. this.noiseData.push(arg["_c"].get("Signal"));
  864. this.noiseDataAll.push(arg["_c"].get("Signal"));
  865. if (this.noiseData.length > ll) {
  866. this.noiseData.shift();
  867. }
  868. // console.log(arg["_c"].get("Attention") / 100);
  869. // console.log(Math.random() * 10);
  870. if (
  871. this.equipment == 1 &&
  872. // this.linkStatus &&
  873. this.buttonFlag == "结束"
  874. ) {
  875. this.send(Math.random() * 10);
  876. }
  877. //先设为随机数
  878. // this.send(Math.random()*10)
  879. // console.log(arg["_c"].get("Attention")/100)
  880. this.attentionData.push(arg["_c"].get("Attention"));
  881. this.attentionDataAll.push(arg["_c"].get("Attention"));
  882. if (this.attentionData.length > ll) {
  883. this.attentionData.shift();
  884. }
  885. this.meditationData.push(arg["_c"].get("Meditation"));
  886. this.meditationDataAll.push(arg["_c"].get("Meditation"));
  887. if (this.meditationData.length > ll) {
  888. this.meditationData.shift();
  889. }
  890. this.thetaData.push(arg["_c"].get("Theta"));
  891. this.thetaDataAll.push(arg["_c"].get("Theta"));
  892. if (this.thetaData.length > ll) {
  893. this.thetaData.shift();
  894. }
  895. this.lowAlphaData.push(arg["_c"].get("LowAlpha"));
  896. this.lowAlphaDataAll.push(arg["_c"].get("LowAlpha"));
  897. if (this.lowAlphaData.length > ll) {
  898. this.lowAlphaData.shift();
  899. }
  900. this.highAlphaData.push(arg["_c"].get("HighAlpha"));
  901. this.highAlphaDataAll.push(arg["_c"].get("HighAlpha"));
  902. if (this.highAlphaData.length > ll) {
  903. this.highAlphaData.shift();
  904. }
  905. this.lowBetaData.push(arg["_c"].get("LowBeta"));
  906. this.lowBetaDataAll.push(arg["_c"].get("LowBeta"));
  907. if (this.lowBetaData.length > ll) {
  908. this.lowBetaData.shift();
  909. }
  910. this.highBetaData.push(arg["_c"].get("HighBeta"));
  911. this.highBetaDataAll.push(arg["_c"].get("HighBeta"));
  912. if (this.highBetaData.length > ll) {
  913. this.highBetaData.shift();
  914. }
  915. this.lowGammaData.push(arg["_c"].get("LowGamma"));
  916. this.lowGammaDataAll.push(arg["_c"].get("LowGamma"));
  917. if (this.lowGammaData.length > ll) {
  918. this.lowGammaData.shift();
  919. }
  920. this.midGammaData.push(arg["_c"].get("MiddleGamma"));
  921. this.midGammaDataAll.push(arg["_c"].get("MiddleGamma"));
  922. if (this.midGammaData.length > ll) {
  923. this.midGammaData.shift();
  924. }
  925. this.focusNao.push(arg["_c"].get("Attention"));
  926. this.focusNaoAll.push(arg["_c"].get("Attention"));
  927. if (this.focusNao > ll) {
  928. this.focusNao.shift();
  929. }
  930. // this.numEleDom = this.focusNaoAll.length.toString();
  931. if (this.echartsVisible) {
  932. console.log(this.attentionDataAll.length);
  933. this.renderEegOne();
  934. this.renderEegTwo();
  935. this.renderEegThree();
  936. }
  937. }
  938. }
  939. }
  940. //第二个用户的数据渲染
  941. if (this.userTwoLink.mac == mac) {
  942. if (arg["_c"].size == 1) {
  943. this.waveDataSecond.push(arg["_c"].get("rawWaveData"));
  944. this.waveDataAllSecond.push(arg["_c"].get("rawWaveData"));
  945. if (this.waveDataSecond.length > 5120) {
  946. this.waveDataSecond.shift();
  947. }
  948. } else {
  949. if (arg["_c"].size == 11) {
  950. // 当不为undefined时
  951. let ll = 11;
  952. // 获取长度
  953. this.deltaDataFlagSecond.push(arg["_c"].get("Delta"));
  954. this.deltaDataFlagAllSecond.push(arg["_c"].get("Delta"));
  955. if (this.deltaDataFlagSecond.length > ll) {
  956. this.deltaDataFlagSecond.shift();
  957. }
  958. this.noiseDataSecond.push(arg["_c"].get("Signal"));
  959. this.noiseDataAllSecond.push(arg["_c"].get("Signal"));
  960. if (this.noiseDataSecond.length > ll) {
  961. this.noiseDataSecond.shift();
  962. }
  963. // console.log(arg["_c"].get("Attention") / 100);
  964. // console.log(Math.random() * 10);
  965. if (
  966. this.equipment == 1 &&
  967. // this.linkStatus &&
  968. this.buttonFlag == "结束"
  969. ) {
  970. this.send(Math.random() * 10);
  971. }
  972. //先设为随机数
  973. // this.send(Math.random()*10)
  974. // console.log(arg["_c"].get("Attention")/100)
  975. this.attentionDataSecond.push(arg["_c"].get("Attention"));
  976. this.attentionDataAllSecond.push(arg["_c"].get("Attention"));
  977. if (this.attentionDataSecond.length > ll) {
  978. this.attentionDataSecond.shift();
  979. }
  980. this.meditationDataSecond.push(arg["_c"].get("Meditation"));
  981. this.meditationDataAllSecond.push(arg["_c"].get("Meditation"));
  982. if (this.meditationDataSecond.length > ll) {
  983. this.meditationDataSecond.shift();
  984. }
  985. this.thetaDataSecond.push(arg["_c"].get("Theta"));
  986. this.thetaDataAllSecond.push(arg["_c"].get("Theta"));
  987. if (this.thetaDataSecond.length > ll) {
  988. this.thetaDataSecond.shift();
  989. }
  990. this.lowAlphaDataSecond.push(arg["_c"].get("LowAlpha"));
  991. this.lowAlphaDataAllSecond.push(arg["_c"].get("LowAlpha"));
  992. if (this.lowAlphaDataSecond.length > ll) {
  993. this.lowAlphaDataSecond.shift();
  994. }
  995. this.highAlphaDataSecond.push(arg["_c"].get("HighAlpha"));
  996. this.highAlphaDataAllSecond.push(arg["_c"].get("HighAlpha"));
  997. if (this.highAlphaDataSecond.length > ll) {
  998. this.highAlphaDataSecond.shift();
  999. }
  1000. this.lowBetaDataSecond.push(arg["_c"].get("LowBeta"));
  1001. this.lowBetaDataAllSecond.push(arg["_c"].get("LowBeta"));
  1002. if (this.lowBetaDataSecond.length > ll) {
  1003. this.lowBetaDataSecond.shift();
  1004. }
  1005. this.highBetaDataSecond.push(arg["_c"].get("HighBeta"));
  1006. this.highBetaDataAllSecond.push(arg["_c"].get("HighBeta"));
  1007. if (this.highBetaDataSecond.length > ll) {
  1008. this.highBetaDataSecond.shift();
  1009. }
  1010. this.lowGammaDataSecond.push(arg["_c"].get("LowGamma"));
  1011. this.lowGammaDataAllSecond.push(arg["_c"].get("LowGamma"));
  1012. if (this.lowGammaDataSecond.length > ll) {
  1013. this.lowGammaDataSecond.shift();
  1014. }
  1015. this.midGammaDataSecond.push(arg["_c"].get("MiddleGamma"));
  1016. this.midGammaDataAllSecond.push(arg["_c"].get("MiddleGamma"));
  1017. if (this.midGammaDataSecond.length > ll) {
  1018. this.midGammaDataSecond.shift();
  1019. }
  1020. this.focusNaoSecond.push(arg["_c"].get("Attention"));
  1021. this.focusNaoAllSecond.push(arg["_c"].get("Attention"));
  1022. if (this.focusNaoSecond > ll) {
  1023. this.focusNaoSecond.shift();
  1024. }
  1025. // this.numEleDom = this.focusNaoAll.length.toString();
  1026. if (this.echartsSecondVisible) {
  1027. //console.log(this.attentionDataAllSecond.length);
  1028. this.renderEegOneSecond();
  1029. this.renderEegTwoSecond();
  1030. this.renderEegThreeSecond();
  1031. }
  1032. }
  1033. }
  1034. }
  1035. },
  1036. viewEchartsFun(val) {
  1037. if (val == 1) {
  1038. this.echartsVisible = true;
  1039. } else {
  1040. this.echartsSecondVisible = true;
  1041. }
  1042. setTimeout(() => {
  1043. //先判断选择的是哪个设备
  1044. //如果是脑电的话,需要判断是用户1还是用户2
  1045. //如果是心电的话,需要判断是用户1还是用户2
  1046. if (this.equipment == "1") {
  1047. if (val == 1) {
  1048. if (this.echartsOne == null) {
  1049. this.echartsOne = echarts.init(document.getElementById("eegOne"));
  1050. this.echartsTwo = echarts.init(document.getElementById("eegTwo"));
  1051. this.echartsThree = echarts.init(
  1052. document.getElementById("eegThree")
  1053. );
  1054. this.renderEegOne();
  1055. this.renderEegTwo();
  1056. this.renderEegThree();
  1057. setTimeout(() => {
  1058. this.echartsOne.resize();
  1059. this.echartsTwo.resize();
  1060. this.echartsThree.resize();
  1061. }, 1000);
  1062. } else {
  1063. this.echartsOne.resize();
  1064. this.echartsTwo.resize();
  1065. this.echartsThree.resize();
  1066. }
  1067. } else {
  1068. if (this.echartsOneSecond == null) {
  1069. this.echartsOneSecond = echarts.init(
  1070. document.getElementById("eegOneSecond")
  1071. );
  1072. this.echartsTwoSecond = echarts.init(
  1073. document.getElementById("eegTwoSecond")
  1074. );
  1075. this.echartsThreeSecond = echarts.init(
  1076. document.getElementById("eegThreeSecond")
  1077. );
  1078. this.renderEegOneSecond();
  1079. this.renderEegTwoSecond();
  1080. this.renderEegThreeSecond();
  1081. setTimeout(() => {
  1082. this.echartsOneSecond.resize();
  1083. this.echartsTwoSecond.resize();
  1084. this.echartsThreeSecond.resize();
  1085. }, 1000);
  1086. } else {
  1087. this.echartsOneSecond.resize();
  1088. this.echartsTwoSecond.resize();
  1089. this.echartsThreeSecond.resize();
  1090. }
  1091. }
  1092. } else {
  1093. if (val == 1) {
  1094. if (this.echartsEcg == null) {
  1095. this.echartsEcg = echarts.init(document.getElementById("ecgOne"));
  1096. this.renderEcgOne();
  1097. setTimeout(() => {
  1098. this.echartsEcg.resize();
  1099. }, 1000);
  1100. } else {
  1101. this.echartsEcg.resize();
  1102. }
  1103. } else {
  1104. if (this.echartsEcgTwo == null) {
  1105. this.echartsEcgTwo = echarts.init(
  1106. document.getElementById("ecgTwo")
  1107. );
  1108. this.renderEcgTwo();
  1109. setTimeout(() => {
  1110. this.echartsEcgTwo.resize();
  1111. }, 1000);
  1112. } else {
  1113. this.echartsEcgTwo.resize();
  1114. }
  1115. }
  1116. }
  1117. // 先调用
  1118. }, 2000);
  1119. },
  1120. //状态切换
  1121. linkJudge(val, flag) {
  1122. //打开用户
  1123. this.currentSingle = val;
  1124. this.currentFlag = flag;
  1125. //当前设备已连接时
  1126. if (flag) {
  1127. this.userVisible = false;
  1128. this.disconnectEquipment(val);
  1129. } else {
  1130. this.userVisible = true;
  1131. }
  1132. //当前设备的连接状态
  1133. //当前设备的连接状态
  1134. //获取当前用户的val 和flag
  1135. //查询用户
  1136. this.queryUser();
  1137. },
  1138. //进行解析脑电数据
  1139. linkFun(val) {
  1140. console.log(val);
  1141. let that = this;
  1142. that.buttonLinkFlag = true;
  1143. that.$http.postTmp(
  1144. `/v1/device/connection`,
  1145. {
  1146. chip: val.deviceType,
  1147. mac: val.mac,
  1148. addrType: "public",
  1149. filterName: val.deviceType,
  1150. },
  1151. (res) => {
  1152. that.disableStatus();
  1153. if (res.data.code == 200) {
  1154. // this.linkIndex = index;
  1155. //如果是脑电的话直接调用打开数据接口
  1156. //如果是心电需要先调用写入输入数据-发送指令接口
  1157. if (val.deviceType == "1") {
  1158. this.writeData(val);
  1159. if (that.userDeviceFlag == 1) {
  1160. that.userLink.mac = val.mac;
  1161. } else {
  1162. that.userTwoLink.mac = val.mac;
  1163. }
  1164. } else {
  1165. //判断脑电设备
  1166. //脑电的情况下
  1167. //记录下当前mac,
  1168. if (that.userDeviceFlag == 1) {
  1169. that.userLink.mac = val.mac;
  1170. } else {
  1171. that.userTwoLink.mac = val.mac;
  1172. }
  1173. //然后调用已连接列表确定改mac是否存在在列表中,如果已存在则表示该设备已连接
  1174. // that.openData();
  1175. // this.$message.success("设备连接成功");
  1176. }
  1177. // that.tableData = res.data;
  1178. // that.totolSize = res.data.totalElements;
  1179. } else {
  1180. // this.$message.error("访问服务器失败!");
  1181. this.$message.error(res.data.message);
  1182. }
  1183. }
  1184. );
  1185. },
  1186. //写入数据--发送指令
  1187. writeData(val) {
  1188. let that = this;
  1189. let userName = sessionStorage.getItem("name");
  1190. that.$http.postTmp(
  1191. `/v1/device/write/data`,
  1192. { mac: val.mac, userName: userName },
  1193. (res) => {
  1194. // that.openData();
  1195. if (res.data.code == 200) {
  1196. } else {
  1197. this.$message.error("访问服务器失败!");
  1198. }
  1199. }
  1200. );
  1201. },
  1202. //打开数据接口
  1203. // openData() {
  1204. // let that = this;
  1205. // that.$http.getTmp(`/v1/device/open/notify`, {}, (res) => {
  1206. // if (res.code == 200) {
  1207. // //打开数据接口
  1208. // // that.tableData = res.data;
  1209. // // that.totolSize = res.data.totalElements;
  1210. // } else {
  1211. // this.$message.error("访问服务器失败!");
  1212. // }
  1213. // });
  1214. // },
  1215. disableStatus() {
  1216. let that = this;
  1217. this.disabledTimeFlag = setTimeout(() => {
  1218. this.buttonLinkFlag = false;
  1219. }, 1500);
  1220. },
  1221. //断开连接的脑电
  1222. disconnectEquipment(val) {
  1223. let that = this;
  1224. that.buttonLinkFlag = true;
  1225. that.$http.getTmp(`v1/device/${val.mac}/disconnect`, {}, (res) => {
  1226. that.disableStatus();
  1227. if (res.code == 200) {
  1228. //关闭连接的时候看是不是当前绑定的mac与用户的mac是否相同
  1229. //如果相同则 连接标志变为false;
  1230. //如果不同则不变
  1231. if (that.userLink.mac == val.mac) {
  1232. that.userLink.linkStatus = false;
  1233. that.userLink.mac = "";
  1234. }
  1235. if (that.userTwoLink.mac == val.mac) {
  1236. that.userTwoLink.linkStatus = false;
  1237. that.userTwoLink.mac = "";
  1238. }
  1239. } else {
  1240. this.$message.error(res.message);
  1241. }
  1242. });
  1243. },
  1244. //查询连接列表
  1245. connectList() {
  1246. let that = this;
  1247. that.$http.getTmp(`v1/device/connected`, {}, (res) => {
  1248. // console.log(res)
  1249. //判断当前的列表是否存在该用户已点击的列表
  1250. if (res.code == 200) {
  1251. if (res.data) {
  1252. if (res.data) {
  1253. let list = [];
  1254. for (let i = 0; i < res.data.length; i++) {
  1255. let obj = {
  1256. rssi: "",
  1257. name: "",
  1258. mac: "",
  1259. connent: false,
  1260. deviceType: "",
  1261. };
  1262. obj.rssi = "";
  1263. obj.name = res.data[i].Name;
  1264. obj.mac = res.data[i].MAC;
  1265. obj.connent = true;
  1266. obj.deviceType = res.data[i].DeviceType;
  1267. obj.userNum = "";
  1268. list.push(obj);
  1269. }
  1270. that.connectedData = list;
  1271. // console.log(list);
  1272. if (list.length == 0) {
  1273. //表示未连接
  1274. that.userLink.linkStatus = false;
  1275. that.userTwoLink.linkStatus = false;
  1276. } else {
  1277. //标识已连接
  1278. for (let k = 0; k < list.length; k++) {
  1279. if (
  1280. that.userLink.mac !== "" &&
  1281. that.userLink.mac == list[k].mac
  1282. ) {
  1283. that.userLink.linkStatus = true;
  1284. }
  1285. if (
  1286. that.userTwoLink.mac !== "" &&
  1287. that.userTwoLink.mac == list[k].mac
  1288. ) {
  1289. that.userTwoLink.linkStatus = true;
  1290. }
  1291. }
  1292. }
  1293. }
  1294. } else {
  1295. that.connectedData = [];
  1296. }
  1297. //打开数据接口
  1298. // that.tableData = res.data;
  1299. // that.totolSize = res.data.totalElements;
  1300. } else {
  1301. // this.$message.error("访问服务器失败!");
  1302. }
  1303. });
  1304. },
  1305. typeFormatter(val) {
  1306. // console.log(val.deviceType)
  1307. if (val.deviceType == "1") {
  1308. return "心电";
  1309. } else {
  1310. return "脑电";
  1311. }
  1312. },
  1313. openTableFun(val) {
  1314. this.userDeviceFlag = val;
  1315. this.tableVisible = true;
  1316. },
  1317. //进来后先连接websocket
  1318. //连上后进行扫描
  1319. //扫描以后出现列表
  1320. //列表出现后点击连接并打开数据如果有数据才算成功
  1321. //初始化websocket
  1322. initWebsocket() {
  1323. // const wsuri = "ws://192.168.2.101:8000/ws?uid=client&to_uid=server";
  1324. const wsuri = "ws://localhost:8000/ws?uid=client&to_uid=server";
  1325. this.websock = new WebSocket(wsuri);
  1326. this.websock.onmessage = this.websocketonmessage;
  1327. this.websock.onopen = this.websocketonopen;
  1328. this.websock.onerror = this.websocketonerror;
  1329. this.websock.onclose = this.websocketclose;
  1330. },
  1331. websocketonopen() {
  1332. //连接建立之后执行send方法发送数据
  1333. let actions = { test: "12345" };
  1334. this.websocketsend(JSON.stringify(actions));
  1335. },
  1336. websocketonerror() {
  1337. //连接建立失败重连
  1338. this.initWebSocket();
  1339. },
  1340. websocketsend(Data) {
  1341. //数据发送
  1342. this.websock.send(Data);
  1343. },
  1344. websocketonmessage(e) {
  1345. let that = this;
  1346. //数据接收
  1347. const redata = JSON.parse(e.data);
  1348. if (redata.content != "Successful connection to socket service") {
  1349. //首先判断是否redata.content是否是未定义
  1350. // console.log(redata.content)
  1351. if (redata.hasOwnProperty("content")) {
  1352. let dataLin = JSON.parse(redata.content);
  1353. if (redata.msgType == "device") {
  1354. // let dataLin = JSON.parse(redata.content);
  1355. let list = [];
  1356. for (var key in dataLin) {
  1357. let a = {
  1358. mac: dataLin[key]["MAC"],
  1359. name: dataLin[key].Name,
  1360. rssi: dataLin[key].Rssi,
  1361. deviceType: dataLin[key].DeviceType,
  1362. chip: dataLin[key].Chip,
  1363. };
  1364. that.changeList(a);
  1365. }
  1366. //获取到很多数据,取每秒最大的包含量
  1367. } else if (redata.msgType == "eegData") {
  1368. // let dataLin = JSON.parse(redata.content);
  1369. // console.log(dataLin);
  1370. ///先判断第一个用户是否有mac---有mac代表已连接
  1371. if (that.userLink.mac !== "" && that.userLink.mac == dataLin.id) {
  1372. ipcRenderer.send("asynchronoushrv-naoData", {
  1373. value: dataLin.value,
  1374. mac: dataLin.id,
  1375. });
  1376. }
  1377. if (
  1378. that.userTwoLink.mac !== "" &&
  1379. that.userTwoLink.mac == dataLin.id
  1380. ) {
  1381. ipcRenderer.send("asynchronoushrv-naoTwoData", {
  1382. value: dataLin.value,
  1383. mac: dataLin.id,
  1384. });
  1385. }
  1386. //判断第二个用户的mac是否有,有则代表已连接 --
  1387. } else if (redata.msgType == "ecgData") {
  1388. // console.log(dataLin)
  1389. //判断该数据对应的mac是否是当前绑定过用户的
  1390. //判断当前是否是绑定该用户的数据,是的话进行用户处理
  1391. //接到数据进行处理
  1392. // console.log(dataLin);
  1393. //当该用户的mac与id相同时,取这个数据
  1394. // console.log(dataLin.id === that.userLink.mac);
  1395. //用户1
  1396. if (that.userLink.mac !== "" && dataLin.id === that.userLink.mac) {
  1397. let list = dataLin.value.split(",");
  1398. // console.log(list)
  1399. list.forEach((item) => {
  1400. let tmp = parseInt(item);
  1401. that.userLink.ecgAllList.push(tmp);
  1402. that.userLink.ecgSectionList.push(tmp);
  1403. if (that.userLink.ecgSectionList.length > that.intervalLength) {
  1404. that.userLink.ecgSectionList.shift();
  1405. }
  1406. if (that.userLink.ecgAllList.length % 100 == 0) {
  1407. // console.log(that.ecgAllList.length);
  1408. if (that.echartsVisible && that.equipment == "2") {
  1409. that.renderEcgOne();
  1410. }
  1411. }
  1412. });
  1413. }
  1414. //用户2
  1415. if (
  1416. that.userTwoLink.mac !== "" &&
  1417. dataLin.id === that.userTwoLink.mac
  1418. ) {
  1419. let list = dataLin.value.split(",");
  1420. list.forEach((item) => {
  1421. let tmp = parseInt(item);
  1422. that.userTwoLink.ecgAllList.push(tmp);
  1423. that.userTwoLink.ecgSectionList.push(tmp);
  1424. if (that.userTwoLink.ecgSectionList.length > 500) {
  1425. that.userTwoLink.ecgSectionList.shift();
  1426. }
  1427. if (that.userTwoLink.ecgAllList.length % 100 == 0) {
  1428. // console.log(that.ecgAllList.length);
  1429. if (that.echartsSecondVisible) {
  1430. that.renderEcgTwo();
  1431. }
  1432. }
  1433. });
  1434. }
  1435. }
  1436. }
  1437. }
  1438. },
  1439. //处理数据让其变化最慢
  1440. //这个是最大的扫描列表
  1441. changeList(obj) {
  1442. // console.log(obj);
  1443. let that = this;
  1444. that.listTmp.push(obj);
  1445. let arrayStr = JSON.stringify(that.listTmp);
  1446. let array = JSON.parse(arrayStr);
  1447. //取list中不相同的
  1448. // console.log(array)
  1449. // array = array.reduce(function (item, next) {
  1450. // obj[next.MAC] ? "" : (obj[next.MAC] = true && item.push(next));
  1451. // return item;
  1452. // }, []);
  1453. //循环数组arr
  1454. //设置储存不一样的数组
  1455. var newArr = new Array();
  1456. var flag = false;
  1457. for (var i = 0; i < array.length; i++) {
  1458. for (var j = 0; j < newArr.length; j++) {
  1459. if (array[i].mac == newArr[j].mac) {
  1460. newArr[j] = array[i];
  1461. flag = true;
  1462. break;
  1463. }
  1464. }
  1465. if (!flag) {
  1466. newArr.push(array[i]);
  1467. }
  1468. }
  1469. // newArr=JSON.parse(newArr)
  1470. // let newArr = {}
  1471. // array.forEach(item => {
  1472. // newArr[item.MAC] = item
  1473. // })
  1474. that.listTmp = JSON.parse(JSON.stringify(newArr));
  1475. // console.log(JSON.stringify(newArr));
  1476. //listTmp即使最大扫描列表
  1477. that.scanData = newArr;
  1478. //目前无法知道当前设备是脑电还是脉搏
  1479. // listShaking:false,
  1480. //判断标志是true或false
  1481. // if (that.listShaking) {
  1482. // let flagTime = setTimeout(() => {
  1483. // that.listShaking = true;
  1484. // let arrayStr = JSON.stringify(that.listTmp);
  1485. // let array = JSON.parse(arrayStr);
  1486. // //取list中不相同的
  1487. // console.log(array)
  1488. // // array = array.reduce(function (item, next) {
  1489. // // obj[next.MAC] ? "" : (obj[next.MAC] = true && item.push(next));
  1490. // // return item;
  1491. // // }, []);
  1492. // //循环数组arr
  1493. // //设置储存不一样的数组
  1494. // var newArr = new Array();
  1495. // var flag = false;
  1496. // for (var i = 0; i < array.length; i++) {
  1497. // for (var j = 0; j < newArr.length; j++) {
  1498. // if (array[i].mac == newArr[j].mac) {
  1499. // newArr[j] = array[i];
  1500. // flag = true;
  1501. // break;
  1502. // }
  1503. // }
  1504. // if (!flag) {
  1505. // newArr.push(array[i]);
  1506. // }
  1507. // }
  1508. // // newArr=JSON.parse(newArr)
  1509. // // let newArr = {}
  1510. // // array.forEach(item => {
  1511. // // newArr[item.MAC] = item
  1512. // // })
  1513. // that.listTmp = JSON.parse(JSON.stringify(newArr));
  1514. // console.log(JSON.stringify(newArr));
  1515. // //listTmp即使最大扫描列表
  1516. // that.scanData = newArr;
  1517. // //当前扫描列表
  1518. // clearTimeout(flagTime);
  1519. // }, 1000);
  1520. // }
  1521. // that.listShaking = false;
  1522. },
  1523. websocketclose(e) {
  1524. if (e.code == 1005) {
  1525. this.initWebsocket();
  1526. } else {
  1527. console.log("断开连接", e);
  1528. }
  1529. },
  1530. //保存文件
  1531. saveFileGame(val) {
  1532. fs.appendFile("D:\\pulseGame.txt", val + "@", (err) => {
  1533. if (err) {
  1534. console.error("Error writing to file:", err);
  1535. } else {
  1536. // console.log("Content appended successfully to file");
  1537. }
  1538. });
  1539. },
  1540. //切换选项时需要清空数据
  1541. clearDataFun() {
  1542. //1.首先清楚所有定时器
  1543. clearInterval(this.pulseTime);
  1544. clearInterval(this.gameTimeTimer);
  1545. //2.计时的时间
  1546. this.pulseTimeNum = 180;
  1547. //3.重置开始的按钮
  1548. this.buttonFlag = "开始";
  1549. this.gameTimeTimerFlag = false;
  1550. //4.重置数据
  1551. this.resetData();
  1552. },
  1553. resetData() {
  1554. this.send(0);
  1555. this.buttonFlag = "开始";
  1556. if (this.gameTime == 1) {
  1557. this.gameTimeReserve = 180;
  1558. this.timeShow = "03:00";
  1559. } else if (this.gameTime == 2) {
  1560. this.gameTimeReserve = 300;
  1561. this.timeShow = "05:00";
  1562. } else if (this.gameTime == 3) {
  1563. this.gameTimeReserve = 600;
  1564. this.timeShow = "10:00";
  1565. }
  1566. },
  1567. //格式化倒计时格式
  1568. formatterTimeFun(val) {
  1569. let min = Math.floor(val / 60);
  1570. min = this.formatterSs(min);
  1571. let ss = val % 60;
  1572. ss = this.formatterSs(ss);
  1573. return min + ":" + ss;
  1574. },
  1575. formatterSs(val) {
  1576. if (val < 10) {
  1577. return "0" + val;
  1578. } else {
  1579. return val + "";
  1580. }
  1581. },
  1582. gameTimeFun(val) {
  1583. this.clearDataFun();
  1584. if (val == 1) {
  1585. this.gameTimeReserve = 180;
  1586. } else if (val == 2) {
  1587. this.gameTimeReserve = 300;
  1588. } else if (val == 3) {
  1589. this.gameTimeReserve = 600;
  1590. }
  1591. },
  1592. //当设备更换时需要初始化动画数值为0
  1593. //并且按钮初始化为开始状态
  1594. //倒计时时间也变为最初始化
  1595. //定时3分钟倒计时方法
  1596. // threeReserve(){
  1597. // },
  1598. gameDiffFun() {
  1599. this.clearDataFun();
  1600. },
  1601. equipmentFun(val) {
  1602. //先判断当选择的设备是否连接
  1603. //如果已连接,则继续测试
  1604. //如果未连接则提示连接设备
  1605. //先判断脑电
  1606. this.clearDataFun();
  1607. this.send(0);
  1608. // this.userLink.linkStatus = false;
  1609. // this.userTwoLink.linkStatus = false;
  1610. this.resetData();
  1611. this.disconnectDevice();
  1612. //切换完成后将已连接的设备调用断开的接口
  1613. //或退出当前页面时---
  1614. //设备切换以后将设备未连接的状态显示出来
  1615. //结束测试
  1616. },
  1617. //断开所有设备的操作
  1618. disconnectDevice() {
  1619. let that = this;
  1620. that.$http.getTmp(`v1/device/connected`, {}, (res) => {
  1621. // console.log(res)
  1622. //判断当前的列表是否存在该用户已点击的列表
  1623. if (res.code == 200) {
  1624. if (res.data) {
  1625. if (res.data) {
  1626. let list = [];
  1627. for (let i = 0; i < res.data.length; i++) {
  1628. let obj = {
  1629. rssi: "",
  1630. name: "",
  1631. mac: "",
  1632. connent: false,
  1633. deviceType: "",
  1634. };
  1635. obj.rssi = "";
  1636. obj.name = res.data[i].Name;
  1637. obj.mac = res.data[i].MAC;
  1638. obj.connent = true;
  1639. obj.deviceType = res.data[i].DeviceType;
  1640. obj.userNum = "";
  1641. list.push(obj);
  1642. }
  1643. that.connectedData = list;
  1644. // console.log(list);
  1645. if (list.length == 0) {
  1646. //表示未连接
  1647. that.userLink.linkStatus = false;
  1648. that.userTwoLink.linkStatus = false;
  1649. } else {
  1650. //标识已连接
  1651. for (let k = 0; k < list.length; k++) {
  1652. //调用断开设备的方法
  1653. that.disconnectEquipment(list[k]);
  1654. }
  1655. }
  1656. }
  1657. } else {
  1658. that.connectedData = [];
  1659. }
  1660. //打开数据接口
  1661. // that.tableData = res.data;
  1662. // that.totolSize = res.data.totalElements;
  1663. } else {
  1664. // this.$message.error("访问服务器失败!");
  1665. }
  1666. });
  1667. },
  1668. //需要先判断代码是否点击开始测试按钮了
  1669. //如果点击开始测试按钮了//才能发送信号到游戏
  1670. //定时器方法进行倒计时
  1671. //这是脉搏点击开始的倒计时
  1672. //倒计时结束以后进行3分钟或5分钟倒计时或十分钟倒计时
  1673. //然后自动结束
  1674. timeFun1() {
  1675. let that = this;
  1676. clearInterval(that.pulseTime);
  1677. that.pulseTimeNum = 180;
  1678. that.pulseTime = setInterval(() => {
  1679. that.timeShow = that.formatterTimeFun(that.pulseTimeNum);
  1680. that.pulseTimeNum--;
  1681. if (that.pulseTimeNum == 0) {
  1682. // that.buttonDisable = false;
  1683. //将状态改为结束
  1684. // this.buttonFlag = "结束";
  1685. clearInterval(that.pulseTime);
  1686. //倒计时开始后需要
  1687. that.timeCom();
  1688. }
  1689. }, 1000);
  1690. },
  1691. getGameSence(val) {
  1692. console.log(val);
  1693. let gameName = "";
  1694. switch (val) {
  1695. case "1":
  1696. gameName = "心灵之火";
  1697. break;
  1698. case "2":
  1699. gameName = "心之花";
  1700. break;
  1701. case "3":
  1702. gameName = "急速赛车";
  1703. break;
  1704. case "4":
  1705. gameName = "爆爆桶";
  1706. break;
  1707. case "5":
  1708. gameName = "炸弹";
  1709. break;
  1710. case "6":
  1711. gameName = "漂浮球";
  1712. break;
  1713. default:
  1714. break;
  1715. }
  1716. console.log(gameName);
  1717. return gameName;
  1718. },
  1719. //获取游戏难度
  1720. getGameDiff(val) {
  1721. if (val == 1) {
  1722. return "简单";
  1723. }
  1724. if (val == 2) {
  1725. return "普通";
  1726. }
  1727. if (val == 3) {
  1728. return "困难";
  1729. }
  1730. },
  1731. formatterGameTime(val) {
  1732. if (val == "1") {
  1733. return "3分钟";
  1734. }
  1735. if (val == "2") {
  1736. return "5分钟";
  1737. }
  1738. if (val == "3") {
  1739. return "10分钟";
  1740. }
  1741. return "";
  1742. },
  1743. //获取当前时间
  1744. getCurrentTimeFun() {
  1745. let data = new Date();
  1746. let year = this.formatterDate(data.getFullYear());
  1747. let month = this.formatterDate(data.getMonth() + 1);
  1748. let day = this.formatterDate(data.getDate());
  1749. let hour = this.formatterDate(data.getHours());
  1750. let minutes = this.formatterDate(data.getMinutes());
  1751. let seconds = this.formatterDate(data.getSeconds());
  1752. let microseconds = this.formatterMill(data.getMilliseconds());
  1753. return (
  1754. year +
  1755. "年" +
  1756. month +
  1757. "月" +
  1758. day +
  1759. "日" +
  1760. hour +
  1761. "时" +
  1762. minutes +
  1763. "分" +
  1764. seconds +
  1765. "秒" +
  1766. microseconds
  1767. );
  1768. },
  1769. //格式化两位数的时间数据
  1770. formatterDate(val) {
  1771. if (val < 10) {
  1772. return "0" + val;
  1773. } else {
  1774. return val;
  1775. }
  1776. },
  1777. //格式化毫秒数据
  1778. formatterMill(val) {
  1779. if (val < 10) {
  1780. return "00" + val;
  1781. } else if (val < 100) {
  1782. return "0" + val;
  1783. } else {
  1784. return val;
  1785. }
  1786. },
  1787. timeCom() {
  1788. let that = this;
  1789. //有个标志显示当前的倒计时的状态
  1790. this.gameTimeTimerFlag = true;
  1791. //获取当前选择的是几分钟
  1792. //当选择的是3分钟时
  1793. //this.gameTimeReserve
  1794. this.gameTimeTimer = setInterval(() => {
  1795. this.timeShow = this.formatterTimeFun(this.gameTimeReserve);
  1796. this.gameTimeReserve--;
  1797. if (this.gameTimeReserve == 0) {
  1798. clearInterval(this.gameTimeTimer);
  1799. //当倒计时为0
  1800. //按钮状态改为结束
  1801. this.gameTimeTimerFlag = false;
  1802. this.buttonFlag = "开始";
  1803. if (this.equipment == 1) {
  1804. // 保存脑电数据
  1805. //参数进行保存
  1806. let params = {
  1807. type: "2", //1表示是单人模式 2代表是双人模式
  1808. num: [{ num: that.userLink.num }, { num: that.userTwoLink.num }], //个人编号
  1809. gameScene: that.getGameSence(that.$route.query.gameType), //游戏场景
  1810. equipmentType: "脑电", //设备类型
  1811. gameDifficulty: that.getGameDiff(that.gameDifficulty), //游戏难度
  1812. gameTime: that.formatterGameTime(that.gameTime), //游戏时间
  1813. // animationSourceList: that.animationSourceList, //原始数据
  1814. // fileName: "-",
  1815. // animationTarget: "", //指标数据
  1816. saveTime: that.getCurrentTimeFun(), //保存数据的时间
  1817. };
  1818. //调用保存数据的方法
  1819. that.saveAnimation(params);
  1820. }
  1821. if (this.equipment == 2) {
  1822. // 保存心电数据
  1823. //参数进行保存
  1824. let params = {
  1825. type: "2", //1表示是单人模式 2代表是双人模式
  1826. num: [{ num: that.userLink.num }, { num: that.userTwoLink.num }], //个人编号
  1827. gameScene: that.getGameSence(that.$route.query.gameType), //游戏场景
  1828. equipmentType: "心电", //设备类型
  1829. gameDifficulty: that.getGameDiff(that.gameDifficulty), //游戏难度
  1830. gameTime: that.formatterGameTime(that.gameTime), //游戏时间
  1831. // animationSourceList: that.animationSourceList, //原始数据
  1832. // fileName: "-",
  1833. // animationTarget: "", //指标数据
  1834. saveTime: that.getCurrentTimeFun(), //保存数据的时间
  1835. };
  1836. //调用保存数据的方法
  1837. that.saveAnimation(params);
  1838. }
  1839. this.resetData();
  1840. }
  1841. }, 1000);
  1842. },
  1843. //保存游戏数据
  1844. saveAnimation(params) {
  1845. console.log(params);
  1846. console.log("游戏和数据保存");
  1847. },
  1848. startTest() {
  1849. //首先先判断是脑电还是脉搏
  1850. if (this.buttonFlag == "开始") {
  1851. if (this.equipment == 1) {
  1852. //如果是脑电.则需要判断脑电是否连接
  1853. if (this.userLink.linkStatus && this.userTwoLink.linkStatus) {
  1854. this.buttonFlag = "结束";
  1855. this.clearNaoData();
  1856. this.timeCom();
  1857. } else {
  1858. this.$message.warning("请先连接脑电设备");
  1859. }
  1860. } else {
  1861. //如果是脉搏,则需要判断脉搏是否是连接
  1862. if (this.userLink.linkStatus && this.userTwoLink.linkStatus) {
  1863. //如果是脉搏已连接
  1864. //点击了开始按钮
  1865. //则开始倒计时3分钟
  1866. this.timeFun1();
  1867. //清空心电数据
  1868. this.userLink.ecgAllList = [];
  1869. this.userLink.ecgSectionList = [];
  1870. this.userTwoLink.ecgAllList = [];
  1871. this.userTwoLink.ecgSectionList = [];
  1872. this.buttonFlag = "结束";
  1873. } else {
  1874. this.$message.warning("请先连接心电设备");
  1875. }
  1876. }
  1877. } else {
  1878. //改变按钮状态
  1879. this.clearDataFun();
  1880. this.resetData();
  1881. }
  1882. },
  1883. clearNaoData() {
  1884. //清空第一个数组的数据
  1885. this.waveDataAll = [];
  1886. this.waveData = [];
  1887. //开始测试时需要清空所有数据,从头开始渲染
  1888. this.deltaDataFlagAll = [];
  1889. this.deltaDataFlag = [];
  1890. this.thetaDataAll = [];
  1891. this.thetaData = [];
  1892. this.lowAlphaDataAll = [];
  1893. this.lowAlphaData = [];
  1894. this.highAlphaDataAll = [];
  1895. this.highAlphaData = [];
  1896. this.lowBetaDataAll = [];
  1897. this.lowBetaData = [];
  1898. this.highBetaDataAll = [];
  1899. this.highBetaData = [];
  1900. this.lowGammaDataAll = [];
  1901. this.lowGammaData = [];
  1902. this.midGammaDataAll = [];
  1903. this.midGammaData = [];
  1904. this.noiseDataAll = [];
  1905. this.noiseData = [];
  1906. this.attentionDataAll = [];
  1907. this.attentionData = [];
  1908. this.meditationData = [];
  1909. this.meditationDataAll = [];
  1910. this.focusNaoAll = [];
  1911. this.focusNao = [];
  1912. //第二个用户数组的数据
  1913. this.waveDataSecond = [];
  1914. // 全量
  1915. this.waveDataAllSecond = [];
  1916. this.deltaDataFlagSecond = [];
  1917. // 全量
  1918. this.deltaDataFlagAllSecond = [];
  1919. this.deltaDataSecond = [];
  1920. // 全量
  1921. this.deltaDataAllSecond = [];
  1922. this.thetaDataSecond = [];
  1923. // 全量
  1924. this.thetaDataAllSecond = [];
  1925. this.lowAlphaDataSecond = [];
  1926. // 全量
  1927. this.lowAlphaDataAllSecond = [];
  1928. this.highAlphaDataSecond = [];
  1929. // 全量
  1930. this.highAlphaDataAllSecond = [];
  1931. this.lowBetaDataSecond = [];
  1932. // 全量
  1933. this.lowBetaDataAllSecond = [];
  1934. this.highBetaDataSecond = [];
  1935. // 全量
  1936. this.highBetaDataAllSecond = [];
  1937. this.lowGammaDataSecond = [];
  1938. // 全量
  1939. this.lowGammaDataAllSecond = [];
  1940. this.midGammaDataSecond = [];
  1941. // 全量
  1942. this.midGammaDataAllSecond = [];
  1943. this.noiseDataSecond = [];
  1944. // 全量
  1945. this.noiseDataAllSecond = [];
  1946. this.attentionDataSecond = [];
  1947. // 全量
  1948. this.attentionDataAllSecond = [];
  1949. this.meditationDataSecond = [];
  1950. // 全量
  1951. this.meditationDataAllSecond = [];
  1952. this.focusNaoSecond = [];
  1953. // 全量
  1954. this.focusNaoAllSecond = [];
  1955. },
  1956. setUrl() {},
  1957. getSize() {
  1958. let width = this.$refs.animationFlow.clientWidth;
  1959. let height = this.$refs.animationFlow.clientHeight - 20;
  1960. this.widthIframe = width;
  1961. this.heightIframe = height + 20;
  1962. this.changeSize(width, height);
  1963. },
  1964. changeSize(width, height) {
  1965. this.$refs.unityIframe.contentWindow.changeSize(width, height);
  1966. },
  1967. send(val) {
  1968. this.$refs.unityIframe.contentWindow.Bloomsize(val);
  1969. },
  1970. // btt() {
  1971. // let that = this;
  1972. // this.$refs.unityvueFlower.message("flower", "enableCamera", "true");
  1973. // },
  1974. delayTime() {
  1975. let that = this;
  1976. setTimeout(() => {
  1977. that.getSize();
  1978. }, 5000);
  1979. },
  1980. changeGame(val) {
  1981. console.log(val);
  1982. this.clearDataFun();
  1983. switch (val) {
  1984. case 1:
  1985. this.urlThreeP = this.pubSrc + "/candle/index.html";
  1986. // this.urlThreeP = pubSrc+ + "/candle/index.html";
  1987. this.delayTime();
  1988. break;
  1989. case 2:
  1990. this.urlThreeP = this.pubSrc + "/flower/index.html";
  1991. // this.urlThreeP = __static + "/flower/index.html";
  1992. this.delayTime();
  1993. break;
  1994. case 3:
  1995. this.urlThreeP = this.pubSrc + "/car/index.html";
  1996. // this.urlThreeP = __static + "/car/index.html";
  1997. this.delayTime();
  1998. break;
  1999. case 4:
  2000. this.urlThreeP = this.pubSrc + "/baobaotong/index.html";
  2001. // this.urlThreeP = __static + "/baobaotong/index.html";
  2002. this.delayTime();
  2003. break;
  2004. case 5:
  2005. this.urlThreeP = this.pubSrc + "/bomb/index.html";
  2006. // this.urlThreeP = __static + "/bomb/index.html";
  2007. this.delayTime();
  2008. break;
  2009. case 6:
  2010. this.urlThreeP = this.pubSrc + "/piaofuqiu/index.html";
  2011. // this.urlThreeP = __static + "/piaofuqiu/index.html";
  2012. this.delayTime();
  2013. break;
  2014. default:
  2015. this.urlThreeP = this.pubSrc + "/candle/index.html";
  2016. // this.urlThreeP = __static + "/candle/index.html";
  2017. }
  2018. this.gameScene = val;
  2019. this.flag = this.gameScene;
  2020. },
  2021. chlz() {
  2022. this.sendUnity(Math.round(Math.random() * 100));
  2023. },
  2024. sendUnity(val) {
  2025. let a = val / 100;
  2026. this.$refs.unityvue.message("littlefire", "sssize", a);
  2027. },
  2028. goBack() {
  2029. this.$router.go(-1);
  2030. },
  2031. //心电1
  2032. renderEcgOne() {
  2033. let that = this;
  2034. let sarr = [];
  2035. // 当全量小于等于10时 显示1-10
  2036. if (that.userLink.ecgAllList.length <= that.intervalLength) {
  2037. for (let i = 0; i <= that.intervalLength; i++) {
  2038. // i = i.toFixed(3);
  2039. sarr.push(i.toString());
  2040. }
  2041. } else if (that.userLink.ecgAllList.length > that.intervalLength) {
  2042. for (
  2043. let i = that.userLink.ecgAllList.length - that.intervalLength;
  2044. i < that.userLink.ecgAllList.length;
  2045. i++
  2046. ) {
  2047. sarr.push(i.toString());
  2048. }
  2049. }
  2050. let dataEcg = JSON.parse(JSON.stringify(that.userLink.ecgSectionList));
  2051. let min = Math.min(...dataEcg);
  2052. let dataEcgFin = [];
  2053. for (let i = 0; i < dataEcg.length; i++) {
  2054. dataEcgFin.push(dataEcg[i] - min);
  2055. }
  2056. this.optionEcg = {
  2057. animation: false,
  2058. title: {
  2059. text: "心电信号",
  2060. subtext: "",
  2061. left: "center",
  2062. align: "right",
  2063. x: "center",
  2064. y: "bottom",
  2065. },
  2066. grid: {
  2067. bottom: 80,
  2068. },
  2069. legend: {
  2070. data: ["ECG"],
  2071. // left: 10,
  2072. },
  2073. xAxis: [
  2074. {
  2075. name: "秒(s)",
  2076. type: "category",
  2077. boundaryGap: false,
  2078. axisLine: { onZero: false },
  2079. splitLine: { show: true },
  2080. data: sarr,
  2081. axisLabel: {
  2082. interval: 99,
  2083. formatter: function (value, index) {
  2084. // console.log(value);
  2085. // console.log(index);
  2086. let a = parseInt(value);
  2087. // a = Math.round(a / 120);
  2088. return a / 100;
  2089. },
  2090. },
  2091. },
  2092. ],
  2093. yAxis: [
  2094. {
  2095. name: "",
  2096. type: "value",
  2097. },
  2098. ],
  2099. series: [
  2100. {
  2101. smooth: true,
  2102. showSymbol: false,
  2103. name: "ECG",
  2104. type: "line",
  2105. lineStyle: {
  2106. width: 1,
  2107. },
  2108. data: dataEcgFin,
  2109. },
  2110. ],
  2111. };
  2112. this.echartsEcg.setOption(this.optionEcg);
  2113. },
  2114. //心电2
  2115. renderEcgTwo() {
  2116. let that = this;
  2117. let sarr = [];
  2118. // 当全量小于等于10时 显示1-10
  2119. if (that.userTwoLink.ecgAllList.length <= that.intervalLength) {
  2120. for (let i = 0; i <= that.intervalLength; i++) {
  2121. // i = i.toFixed(3);
  2122. sarr.push(i.toString());
  2123. }
  2124. } else if (that.userTwoLink.ecgAllList.length > that.intervalLength) {
  2125. for (
  2126. let i = that.userTwoLink.ecgAllList.length - that.intervalLength;
  2127. i < that.userTwoLink.ecgAllList.length;
  2128. i++
  2129. ) {
  2130. sarr.push(i.toString());
  2131. }
  2132. }
  2133. let dataEcg = JSON.parse(JSON.stringify(that.userTwoLink.ecgSectionList));
  2134. let min = Math.min(...dataEcg);
  2135. let dataEcgFin = [];
  2136. for (let i = 0; i < dataEcg.length; i++) {
  2137. dataEcgFin.push(dataEcg[i] - min);
  2138. }
  2139. this.optionEcgTwo = {
  2140. animation: false,
  2141. title: {
  2142. text: "心电信号",
  2143. subtext: "",
  2144. left: "center",
  2145. align: "right",
  2146. x: "center",
  2147. y: "bottom",
  2148. },
  2149. grid: {
  2150. bottom: 80,
  2151. },
  2152. legend: {
  2153. data: ["ECG"],
  2154. // left: 10,
  2155. },
  2156. xAxis: [
  2157. {
  2158. name: "秒(s)",
  2159. type: "category",
  2160. boundaryGap: false,
  2161. axisLine: { onZero: false },
  2162. splitLine: { show: true },
  2163. data: sarr,
  2164. axisLabel: {
  2165. interval: 99,
  2166. formatter: function (value, index) {
  2167. console.log(value);
  2168. let a = parseInt(value);
  2169. // a = Math.round(a / 100);
  2170. // if(a%100==0){
  2171. // return value;
  2172. // }
  2173. return a / 100;
  2174. },
  2175. },
  2176. // axisLabel: {
  2177. // interval: 512,
  2178. // formatter: function (value, index) {
  2179. // // 当当前value除以1000为整数是
  2180. // // console.log(value);
  2181. // // 将value转化为int类型
  2182. // let a = parseInt(value);
  2183. // a = Math.round(a / 512);
  2184. // // if (a %510 == 0) {
  2185. // // // if ((a / 1000) % 2 == 0) {
  2186. // // // return a / 1000;
  2187. // // // }
  2188. // // return a / 1000;
  2189. // // }
  2190. // return a;
  2191. // },
  2192. // },
  2193. },
  2194. ],
  2195. yAxis: [
  2196. {
  2197. name: "",
  2198. type: "value",
  2199. },
  2200. ],
  2201. series: [
  2202. {
  2203. smooth: true,
  2204. showSymbol: false,
  2205. name: "ECG",
  2206. type: "line",
  2207. lineStyle: {
  2208. width: 1,
  2209. },
  2210. data: dataEcgFin,
  2211. },
  2212. ],
  2213. };
  2214. this.echartsEcgTwo.setOption(this.optionEcgTwo);
  2215. },
  2216. //脑电1
  2217. renderEegOne() {
  2218. let sarr = [];
  2219. // 当全量小于等于10时 显示1-10
  2220. if (this.focusNaoAll.length <= 10) {
  2221. for (let i = 0; i <= 10; i++) {
  2222. // i = i.toFixed(3);
  2223. sarr.push(i.toString());
  2224. }
  2225. } else if (this.focusNaoAll.length > 10) {
  2226. for (
  2227. let i = this.focusNaoAll.length - 10;
  2228. i < this.focusNaoAll.length;
  2229. i++
  2230. ) {
  2231. sarr.push(i.toString());
  2232. }
  2233. }
  2234. this.optionOne = {
  2235. animation: false,
  2236. title: {
  2237. text: "频谱成分",
  2238. subtext: "",
  2239. left: "center",
  2240. align: "right",
  2241. x: "center",
  2242. y: "bottom",
  2243. },
  2244. grid: {
  2245. bottom: 80,
  2246. },
  2247. legend: {
  2248. data: [
  2249. "Delta",
  2250. "Theta",
  2251. "Low Alpha",
  2252. "High Alpha",
  2253. "Low Beta",
  2254. "High Beta",
  2255. "Low Gamma",
  2256. "Mid Gamma",
  2257. ],
  2258. },
  2259. xAxis: [
  2260. {
  2261. name: "秒(s)",
  2262. type: "category",
  2263. boundaryGap: false,
  2264. axisLine: { onZero: false },
  2265. splitLine: { show: true },
  2266. data: sarr,
  2267. axisLabel: {
  2268. // interval: 999,
  2269. formatter: function (value, index) {
  2270. let a = parseInt(value);
  2271. if (a % 1000 == 0) {
  2272. if ((a / 1000) % 2 == 0) {
  2273. return a / 1000;
  2274. }
  2275. }
  2276. return value;
  2277. },
  2278. },
  2279. },
  2280. ],
  2281. yAxis: [
  2282. {
  2283. name: "",
  2284. type: "value",
  2285. // max: 500,
  2286. },
  2287. ],
  2288. series: [
  2289. {
  2290. smooth: true,
  2291. showSymbol: false,
  2292. name: "Delta",
  2293. type: "line",
  2294. areaStyle: {},
  2295. lineStyle: {
  2296. width: 1,
  2297. },
  2298. emphasis: {
  2299. focus: "series",
  2300. },
  2301. markArea: {
  2302. silent: true,
  2303. itemStyle: {
  2304. opacity: 0.3,
  2305. },
  2306. data: [
  2307. [
  2308. {
  2309. xAxis: "2009/9/10\n7:00",
  2310. },
  2311. {
  2312. xAxis: "2009/9/20\n7:00",
  2313. },
  2314. ],
  2315. ],
  2316. },
  2317. data: this.deltaData,
  2318. },
  2319. {
  2320. smooth: true,
  2321. showSymbol: false,
  2322. name: "Theta",
  2323. type: "line",
  2324. areaStyle: {},
  2325. lineStyle: {
  2326. width: 1,
  2327. },
  2328. emphasis: {
  2329. focus: "series",
  2330. },
  2331. markArea: {
  2332. silent: true,
  2333. itemStyle: {
  2334. opacity: 0.3,
  2335. },
  2336. data: [
  2337. [
  2338. {
  2339. xAxis: "2009/9/10\n7:00",
  2340. },
  2341. {
  2342. xAxis: "2009/9/20\n7:00",
  2343. },
  2344. ],
  2345. ],
  2346. },
  2347. data: this.thetaData,
  2348. },
  2349. {
  2350. smooth: true,
  2351. showSymbol: false,
  2352. name: "Low Alpha",
  2353. type: "line",
  2354. areaStyle: {},
  2355. lineStyle: {
  2356. width: 1,
  2357. },
  2358. emphasis: {
  2359. focus: "series",
  2360. },
  2361. markArea: {
  2362. silent: true,
  2363. itemStyle: {
  2364. opacity: 0.3,
  2365. },
  2366. data: [
  2367. [
  2368. {
  2369. xAxis: "2009/9/10\n7:00",
  2370. },
  2371. {
  2372. xAxis: "2009/9/20\n7:00",
  2373. },
  2374. ],
  2375. ],
  2376. },
  2377. data: this.lowAlphaData,
  2378. },
  2379. {
  2380. smooth: true,
  2381. showSymbol: false,
  2382. name: "High Alpha",
  2383. type: "line",
  2384. areaStyle: {},
  2385. lineStyle: {
  2386. width: 1,
  2387. },
  2388. emphasis: {
  2389. focus: "series",
  2390. },
  2391. markArea: {
  2392. silent: true,
  2393. itemStyle: {
  2394. opacity: 0.3,
  2395. },
  2396. data: [
  2397. [
  2398. {
  2399. xAxis: "2009/9/10\n7:00",
  2400. },
  2401. {
  2402. xAxis: "2009/9/20\n7:00",
  2403. },
  2404. ],
  2405. ],
  2406. },
  2407. data: this.highAlphaData,
  2408. },
  2409. {
  2410. smooth: true,
  2411. showSymbol: false,
  2412. name: "Low Beta",
  2413. type: "line",
  2414. areaStyle: {},
  2415. lineStyle: {
  2416. width: 1,
  2417. },
  2418. emphasis: {
  2419. focus: "series",
  2420. },
  2421. markArea: {
  2422. silent: true,
  2423. itemStyle: {
  2424. opacity: 0.3,
  2425. },
  2426. data: [
  2427. [
  2428. {
  2429. xAxis: "2009/9/10\n7:00",
  2430. },
  2431. {
  2432. xAxis: "2009/9/20\n7:00",
  2433. },
  2434. ],
  2435. ],
  2436. },
  2437. data: this.lowBetaData,
  2438. },
  2439. {
  2440. smooth: true,
  2441. showSymbol: false,
  2442. name: "High Beta",
  2443. type: "line",
  2444. areaStyle: {},
  2445. lineStyle: {
  2446. width: 1,
  2447. },
  2448. emphasis: {
  2449. focus: "series",
  2450. },
  2451. markArea: {
  2452. silent: true,
  2453. itemStyle: {
  2454. opacity: 0.3,
  2455. },
  2456. data: [
  2457. [
  2458. {
  2459. xAxis: "2009/9/10\n7:00",
  2460. },
  2461. {
  2462. xAxis: "2009/9/20\n7:00",
  2463. },
  2464. ],
  2465. ],
  2466. },
  2467. data: this.highBetaData,
  2468. },
  2469. {
  2470. smooth: true,
  2471. showSymbol: false,
  2472. name: "Low Gamma",
  2473. type: "line",
  2474. areaStyle: {},
  2475. lineStyle: {
  2476. width: 1,
  2477. },
  2478. emphasis: {
  2479. focus: "series",
  2480. },
  2481. markArea: {
  2482. silent: true,
  2483. itemStyle: {
  2484. opacity: 0.3,
  2485. },
  2486. data: [
  2487. [
  2488. {
  2489. xAxis: "2009/9/10\n7:00",
  2490. },
  2491. {
  2492. xAxis: "2009/9/20\n7:00",
  2493. },
  2494. ],
  2495. ],
  2496. },
  2497. data: this.lowGammaData,
  2498. },
  2499. {
  2500. smooth: true,
  2501. showSymbol: false,
  2502. name: "Mid Gamma",
  2503. type: "line",
  2504. areaStyle: {},
  2505. lineStyle: {
  2506. width: 1,
  2507. },
  2508. emphasis: {
  2509. focus: "series",
  2510. },
  2511. markArea: {
  2512. silent: true,
  2513. itemStyle: {
  2514. opacity: 0.3,
  2515. },
  2516. data: [
  2517. [
  2518. {
  2519. xAxis: "2009/9/10\n7:00",
  2520. },
  2521. {
  2522. xAxis: "2009/9/20\n7:00",
  2523. },
  2524. ],
  2525. ],
  2526. },
  2527. data: this.midGammaData,
  2528. },
  2529. ],
  2530. };
  2531. this.echartsOne.setOption(this.optionOne);
  2532. },
  2533. renderEegTwo() {
  2534. let sarr = [];
  2535. // 当全量小于等于10时 显示1-10
  2536. if (this.focusNaoAll.length <= 10) {
  2537. for (let i = 0; i <= 10; i++) {
  2538. // i = i.toFixed(3);
  2539. sarr.push(i.toString());
  2540. }
  2541. } else if (this.focusNaoAll.length > 10) {
  2542. for (
  2543. let i = this.focusNaoAll.length - 10;
  2544. i < this.focusNaoAll.length;
  2545. i++
  2546. ) {
  2547. sarr.push(i.toString());
  2548. }
  2549. }
  2550. this.optionTwo = {
  2551. animation: false,
  2552. title: {
  2553. text: "注意力指标",
  2554. subtext: "",
  2555. left: "center",
  2556. align: "right",
  2557. x: "center",
  2558. y: "bottom",
  2559. },
  2560. grid: {
  2561. bottom: 80,
  2562. },
  2563. legend: {
  2564. data: ["Noise", "Attention", "Medition"],
  2565. // left: 10,
  2566. },
  2567. xAxis: [
  2568. {
  2569. name: "秒(s)",
  2570. type: "category",
  2571. boundaryGap: false,
  2572. axisLine: { onZero: false },
  2573. splitLine: { show: true },
  2574. data: sarr,
  2575. },
  2576. ],
  2577. yAxis: [
  2578. {
  2579. name: "秒(s)",
  2580. type: "value",
  2581. // max: 500,
  2582. },
  2583. // {
  2584. // name: "秒(s)",
  2585. // nameLocation: "start",
  2586. // // max: 5,
  2587. // type: "value",
  2588. // inverse: false,
  2589. // },
  2590. ],
  2591. series: [
  2592. {
  2593. smooth: true,
  2594. showSymbol: false,
  2595. name: "Noise",
  2596. type: "line",
  2597. yAxisIndex: 0,
  2598. areaStyle: {},
  2599. lineStyle: {
  2600. width: 1,
  2601. },
  2602. emphasis: {
  2603. focus: "series",
  2604. },
  2605. markArea: {
  2606. silent: true,
  2607. itemStyle: {
  2608. opacity: 0.3,
  2609. },
  2610. data: [
  2611. [
  2612. {
  2613. xAxis: "2009/9/10\n7:00",
  2614. },
  2615. {
  2616. xAxis: "2009/9/20\n7:00",
  2617. },
  2618. ],
  2619. ],
  2620. },
  2621. data: this.noiseData,
  2622. },
  2623. {
  2624. smooth: true,
  2625. showSymbol: false,
  2626. name: "Attention",
  2627. type: "line",
  2628. yAxisIndex: 0,
  2629. areaStyle: {},
  2630. lineStyle: {
  2631. width: 1,
  2632. },
  2633. emphasis: {
  2634. focus: "series",
  2635. },
  2636. markArea: {
  2637. silent: true,
  2638. itemStyle: {
  2639. opacity: 0.3,
  2640. },
  2641. data: [
  2642. [
  2643. {
  2644. xAxis: "2009/9/10\n7:00",
  2645. },
  2646. {
  2647. xAxis: "2009/9/20\n7:00",
  2648. },
  2649. ],
  2650. ],
  2651. },
  2652. data: this.attentionData,
  2653. },
  2654. {
  2655. smooth: true,
  2656. showSymbol: false,
  2657. name: "Medition",
  2658. type: "line",
  2659. yAxisIndex: 0,
  2660. areaStyle: {},
  2661. lineStyle: {
  2662. width: 1,
  2663. },
  2664. emphasis: {
  2665. focus: "series",
  2666. },
  2667. markArea: {
  2668. silent: true,
  2669. itemStyle: {
  2670. opacity: 0.3,
  2671. },
  2672. data: [
  2673. [
  2674. {
  2675. xAxis: "2009/9/10\n7:00",
  2676. },
  2677. {
  2678. xAxis: "2009/9/20\n7:00",
  2679. },
  2680. ],
  2681. ],
  2682. },
  2683. data: this.meditationData,
  2684. },
  2685. ],
  2686. };
  2687. this.echartsTwo.setOption(this.optionTwo);
  2688. },
  2689. renderEegThree() {
  2690. let sarr = [];
  2691. // 当全量小于等于10时 显示1-10
  2692. if (this.waveDataAll.length <= 5120) {
  2693. for (let i = 0; i <= 5120; i++) {
  2694. // i = i.toFixed(3);
  2695. sarr.push(i.toString());
  2696. }
  2697. } else if (this.waveDataAll.length > 5120) {
  2698. for (
  2699. let i = this.waveDataAll.length - 5120;
  2700. i < this.waveDataAll.length;
  2701. i++
  2702. ) {
  2703. sarr.push(i.toString());
  2704. }
  2705. }
  2706. this.optionThree = {
  2707. animation: false,
  2708. title: {
  2709. text: "原始信号",
  2710. subtext: "",
  2711. left: "center",
  2712. align: "right",
  2713. x: "center",
  2714. y: "bottom",
  2715. },
  2716. grid: {
  2717. bottom: 80,
  2718. },
  2719. legend: {
  2720. data: ["RAW Wave"],
  2721. // left: 10,
  2722. },
  2723. xAxis: [
  2724. {
  2725. name: "秒(s)",
  2726. type: "category",
  2727. boundaryGap: false,
  2728. axisLine: { onZero: false },
  2729. splitLine: { show: true },
  2730. data: sarr,
  2731. axisLabel: {
  2732. interval: 512,
  2733. formatter: function (value, index) {
  2734. // 当当前value除以1000为整数是
  2735. // console.log(value);
  2736. // 将value转化为int类型
  2737. let a = parseInt(value);
  2738. a = Math.round(a / 512);
  2739. // if (a %510 == 0) {
  2740. // // if ((a / 1000) % 2 == 0) {
  2741. // // return a / 1000;
  2742. // // }
  2743. // return a / 1000;
  2744. // }
  2745. return a;
  2746. },
  2747. },
  2748. },
  2749. ],
  2750. yAxis: [
  2751. {
  2752. name: "",
  2753. type: "value",
  2754. // max: 500,
  2755. },
  2756. ],
  2757. series: [
  2758. {
  2759. smooth: true,
  2760. showSymbol: false,
  2761. name: "RAW Wave",
  2762. type: "line",
  2763. lineStyle: {
  2764. width: 1,
  2765. },
  2766. data: this.waveData,
  2767. },
  2768. ],
  2769. };
  2770. this.echartsThree.setOption(this.optionThree);
  2771. },
  2772. //脑电2
  2773. renderEegOneSecond() {
  2774. let sarr = [];
  2775. // 当全量小于等于10时 显示1-10
  2776. if (this.focusNaoAllSecond.length <= 10) {
  2777. for (let i = 0; i <= 10; i++) {
  2778. // i = i.toFixed(3);
  2779. sarr.push(i.toString());
  2780. }
  2781. } else if (this.focusNaoAllSecond.length > 10) {
  2782. for (
  2783. let i = this.focusNaoAllSecond.length - 10;
  2784. i < this.focusNaoAllSecond.length;
  2785. i++
  2786. ) {
  2787. sarr.push(i.toString());
  2788. }
  2789. }
  2790. this.optionOneSecond = {
  2791. animation: false,
  2792. title: {
  2793. text: "频谱成分",
  2794. subtext: "",
  2795. left: "center",
  2796. align: "right",
  2797. x: "center",
  2798. y: "bottom",
  2799. },
  2800. grid: {
  2801. bottom: 80,
  2802. },
  2803. legend: {
  2804. data: [
  2805. "Delta",
  2806. "Theta",
  2807. "Low Alpha",
  2808. "High Alpha",
  2809. "Low Beta",
  2810. "High Beta",
  2811. "Low Gamma",
  2812. "Mid Gamma",
  2813. ],
  2814. },
  2815. xAxis: [
  2816. {
  2817. name: "秒(s)",
  2818. type: "category",
  2819. boundaryGap: false,
  2820. axisLine: { onZero: false },
  2821. splitLine: { show: true },
  2822. data: sarr,
  2823. axisLabel: {
  2824. // interval: 999,
  2825. formatter: function (value, index) {
  2826. let a = parseInt(value);
  2827. if (a % 1000 == 0) {
  2828. if ((a / 1000) % 2 == 0) {
  2829. return a / 1000;
  2830. }
  2831. }
  2832. return value;
  2833. },
  2834. },
  2835. },
  2836. ],
  2837. yAxis: [
  2838. {
  2839. name: "",
  2840. type: "value",
  2841. // max: 500,
  2842. },
  2843. ],
  2844. series: [
  2845. {
  2846. smooth: true,
  2847. showSymbol: false,
  2848. name: "Delta",
  2849. type: "line",
  2850. areaStyle: {},
  2851. lineStyle: {
  2852. width: 1,
  2853. },
  2854. emphasis: {
  2855. focus: "series",
  2856. },
  2857. markArea: {
  2858. silent: true,
  2859. itemStyle: {
  2860. opacity: 0.3,
  2861. },
  2862. data: [
  2863. [
  2864. {
  2865. xAxis: "2009/9/10\n7:00",
  2866. },
  2867. {
  2868. xAxis: "2009/9/20\n7:00",
  2869. },
  2870. ],
  2871. ],
  2872. },
  2873. data: this.deltaDataSecond,
  2874. },
  2875. {
  2876. smooth: true,
  2877. showSymbol: false,
  2878. name: "Theta",
  2879. type: "line",
  2880. areaStyle: {},
  2881. lineStyle: {
  2882. width: 1,
  2883. },
  2884. emphasis: {
  2885. focus: "series",
  2886. },
  2887. markArea: {
  2888. silent: true,
  2889. itemStyle: {
  2890. opacity: 0.3,
  2891. },
  2892. data: [
  2893. [
  2894. {
  2895. xAxis: "2009/9/10\n7:00",
  2896. },
  2897. {
  2898. xAxis: "2009/9/20\n7:00",
  2899. },
  2900. ],
  2901. ],
  2902. },
  2903. data: this.thetaDataSecond,
  2904. },
  2905. {
  2906. smooth: true,
  2907. showSymbol: false,
  2908. name: "Low Alpha",
  2909. type: "line",
  2910. areaStyle: {},
  2911. lineStyle: {
  2912. width: 1,
  2913. },
  2914. emphasis: {
  2915. focus: "series",
  2916. },
  2917. markArea: {
  2918. silent: true,
  2919. itemStyle: {
  2920. opacity: 0.3,
  2921. },
  2922. data: [
  2923. [
  2924. {
  2925. xAxis: "2009/9/10\n7:00",
  2926. },
  2927. {
  2928. xAxis: "2009/9/20\n7:00",
  2929. },
  2930. ],
  2931. ],
  2932. },
  2933. data: this.lowAlphaDataSecond,
  2934. },
  2935. {
  2936. smooth: true,
  2937. showSymbol: false,
  2938. name: "High Alpha",
  2939. type: "line",
  2940. areaStyle: {},
  2941. lineStyle: {
  2942. width: 1,
  2943. },
  2944. emphasis: {
  2945. focus: "series",
  2946. },
  2947. markArea: {
  2948. silent: true,
  2949. itemStyle: {
  2950. opacity: 0.3,
  2951. },
  2952. data: [
  2953. [
  2954. {
  2955. xAxis: "2009/9/10\n7:00",
  2956. },
  2957. {
  2958. xAxis: "2009/9/20\n7:00",
  2959. },
  2960. ],
  2961. ],
  2962. },
  2963. data: this.highAlphaDataSecond,
  2964. },
  2965. {
  2966. smooth: true,
  2967. showSymbol: false,
  2968. name: "Low Beta",
  2969. type: "line",
  2970. areaStyle: {},
  2971. lineStyle: {
  2972. width: 1,
  2973. },
  2974. emphasis: {
  2975. focus: "series",
  2976. },
  2977. markArea: {
  2978. silent: true,
  2979. itemStyle: {
  2980. opacity: 0.3,
  2981. },
  2982. data: [
  2983. [
  2984. {
  2985. xAxis: "2009/9/10\n7:00",
  2986. },
  2987. {
  2988. xAxis: "2009/9/20\n7:00",
  2989. },
  2990. ],
  2991. ],
  2992. },
  2993. data: this.lowBetaDataSecond,
  2994. },
  2995. {
  2996. smooth: true,
  2997. showSymbol: false,
  2998. name: "High Beta",
  2999. type: "line",
  3000. areaStyle: {},
  3001. lineStyle: {
  3002. width: 1,
  3003. },
  3004. emphasis: {
  3005. focus: "series",
  3006. },
  3007. markArea: {
  3008. silent: true,
  3009. itemStyle: {
  3010. opacity: 0.3,
  3011. },
  3012. data: [
  3013. [
  3014. {
  3015. xAxis: "2009/9/10\n7:00",
  3016. },
  3017. {
  3018. xAxis: "2009/9/20\n7:00",
  3019. },
  3020. ],
  3021. ],
  3022. },
  3023. data: this.highBetaDataSecond,
  3024. },
  3025. {
  3026. smooth: true,
  3027. showSymbol: false,
  3028. name: "Low Gamma",
  3029. type: "line",
  3030. areaStyle: {},
  3031. lineStyle: {
  3032. width: 1,
  3033. },
  3034. emphasis: {
  3035. focus: "series",
  3036. },
  3037. markArea: {
  3038. silent: true,
  3039. itemStyle: {
  3040. opacity: 0.3,
  3041. },
  3042. data: [
  3043. [
  3044. {
  3045. xAxis: "2009/9/10\n7:00",
  3046. },
  3047. {
  3048. xAxis: "2009/9/20\n7:00",
  3049. },
  3050. ],
  3051. ],
  3052. },
  3053. data: this.lowGammaDataSecond,
  3054. },
  3055. {
  3056. smooth: true,
  3057. showSymbol: false,
  3058. name: "Mid Gamma",
  3059. type: "line",
  3060. areaStyle: {},
  3061. lineStyle: {
  3062. width: 1,
  3063. },
  3064. emphasis: {
  3065. focus: "series",
  3066. },
  3067. markArea: {
  3068. silent: true,
  3069. itemStyle: {
  3070. opacity: 0.3,
  3071. },
  3072. data: [
  3073. [
  3074. {
  3075. xAxis: "2009/9/10\n7:00",
  3076. },
  3077. {
  3078. xAxis: "2009/9/20\n7:00",
  3079. },
  3080. ],
  3081. ],
  3082. },
  3083. data: this.midGammaDataSecond,
  3084. },
  3085. ],
  3086. };
  3087. this.echartsOneSecond.setOption(this.optionOneSecond);
  3088. },
  3089. renderEegTwoSecond() {
  3090. let sarr = [];
  3091. // 当全量小于等于10时 显示1-10
  3092. if (this.focusNaoAllSecond.length <= 10) {
  3093. for (let i = 0; i <= 10; i++) {
  3094. // i = i.toFixed(3);
  3095. sarr.push(i.toString());
  3096. }
  3097. } else if (this.focusNaoAllSecond.length > 10) {
  3098. for (
  3099. let i = this.focusNaoAllSecond.length - 10;
  3100. i < this.focusNaoAllSecond.length;
  3101. i++
  3102. ) {
  3103. sarr.push(i.toString());
  3104. }
  3105. }
  3106. this.optionTwoSecond = {
  3107. animation: false,
  3108. title: {
  3109. text: "注意力指标",
  3110. subtext: "",
  3111. left: "center",
  3112. align: "right",
  3113. x: "center",
  3114. y: "bottom",
  3115. },
  3116. grid: {
  3117. bottom: 80,
  3118. },
  3119. legend: {
  3120. data: ["Noise", "Attention", "Medition"],
  3121. // left: 10,
  3122. },
  3123. xAxis: [
  3124. {
  3125. name: "秒(s)",
  3126. type: "category",
  3127. boundaryGap: false,
  3128. axisLine: { onZero: false },
  3129. splitLine: { show: true },
  3130. data: sarr,
  3131. },
  3132. ],
  3133. yAxis: [
  3134. {
  3135. name: "秒(s)",
  3136. type: "value",
  3137. // max: 500,
  3138. },
  3139. // {
  3140. // name: "秒(s)",
  3141. // nameLocation: "start",
  3142. // // max: 5,
  3143. // type: "value",
  3144. // inverse: false,
  3145. // },
  3146. ],
  3147. series: [
  3148. {
  3149. smooth: true,
  3150. showSymbol: false,
  3151. name: "Noise",
  3152. type: "line",
  3153. yAxisIndex: 0,
  3154. areaStyle: {},
  3155. lineStyle: {
  3156. width: 1,
  3157. },
  3158. emphasis: {
  3159. focus: "series",
  3160. },
  3161. markArea: {
  3162. silent: true,
  3163. itemStyle: {
  3164. opacity: 0.3,
  3165. },
  3166. data: [
  3167. [
  3168. {
  3169. xAxis: "2009/9/10\n7:00",
  3170. },
  3171. {
  3172. xAxis: "2009/9/20\n7:00",
  3173. },
  3174. ],
  3175. ],
  3176. },
  3177. data: this.noiseDataSecond,
  3178. },
  3179. {
  3180. smooth: true,
  3181. showSymbol: false,
  3182. name: "Attention",
  3183. type: "line",
  3184. yAxisIndex: 0,
  3185. areaStyle: {},
  3186. lineStyle: {
  3187. width: 1,
  3188. },
  3189. emphasis: {
  3190. focus: "series",
  3191. },
  3192. markArea: {
  3193. silent: true,
  3194. itemStyle: {
  3195. opacity: 0.3,
  3196. },
  3197. data: [
  3198. [
  3199. {
  3200. xAxis: "2009/9/10\n7:00",
  3201. },
  3202. {
  3203. xAxis: "2009/9/20\n7:00",
  3204. },
  3205. ],
  3206. ],
  3207. },
  3208. data: this.attentionDataSecond,
  3209. },
  3210. {
  3211. smooth: true,
  3212. showSymbol: false,
  3213. name: "Medition",
  3214. type: "line",
  3215. yAxisIndex: 0,
  3216. areaStyle: {},
  3217. lineStyle: {
  3218. width: 1,
  3219. },
  3220. emphasis: {
  3221. focus: "series",
  3222. },
  3223. markArea: {
  3224. silent: true,
  3225. itemStyle: {
  3226. opacity: 0.3,
  3227. },
  3228. data: [
  3229. [
  3230. {
  3231. xAxis: "2009/9/10\n7:00",
  3232. },
  3233. {
  3234. xAxis: "2009/9/20\n7:00",
  3235. },
  3236. ],
  3237. ],
  3238. },
  3239. data: this.meditationDataSecond,
  3240. },
  3241. ],
  3242. };
  3243. this.echartsTwoSecond.setOption(this.optionTwoSecond);
  3244. },
  3245. renderEegThreeSecond() {
  3246. let sarr = [];
  3247. // 当全量小于等于10时 显示1-10
  3248. if (this.waveDataAllSecond.length <= 5120) {
  3249. for (let i = 0; i <= 5120; i++) {
  3250. // i = i.toFixed(3);
  3251. sarr.push(i.toString());
  3252. }
  3253. } else if (this.waveDataAllSecond.length > 5120) {
  3254. for (
  3255. let i = this.waveDataAllSecond.length - 5120;
  3256. i < this.waveDataAllSecond.length;
  3257. i++
  3258. ) {
  3259. sarr.push(i.toString());
  3260. }
  3261. }
  3262. this.optionThreeSecond = {
  3263. animation: false,
  3264. title: {
  3265. text: "原始信号",
  3266. subtext: "",
  3267. left: "center",
  3268. align: "right",
  3269. x: "center",
  3270. y: "bottom",
  3271. },
  3272. grid: {
  3273. bottom: 80,
  3274. },
  3275. legend: {
  3276. data: ["RAW Wave"],
  3277. // left: 10,
  3278. },
  3279. xAxis: [
  3280. {
  3281. name: "秒(s)",
  3282. type: "category",
  3283. boundaryGap: false,
  3284. axisLine: { onZero: false },
  3285. splitLine: { show: true },
  3286. data: sarr,
  3287. axisLabel: {
  3288. interval: 512,
  3289. formatter: function (value, index) {
  3290. // 当当前value除以1000为整数是
  3291. // console.log(value);
  3292. // 将value转化为int类型
  3293. let a = parseInt(value);
  3294. a = Math.round(a / 512);
  3295. // if (a %510 == 0) {
  3296. // // if ((a / 1000) % 2 == 0) {
  3297. // // return a / 1000;
  3298. // // }
  3299. // return a / 1000;
  3300. // }
  3301. return a;
  3302. },
  3303. },
  3304. },
  3305. ],
  3306. yAxis: [
  3307. {
  3308. name: "",
  3309. type: "value",
  3310. // max: 500,
  3311. },
  3312. ],
  3313. series: [
  3314. {
  3315. smooth: true,
  3316. showSymbol: false,
  3317. name: "RAW Wave",
  3318. type: "line",
  3319. lineStyle: {
  3320. width: 1,
  3321. },
  3322. data: this.waveDataSecond,
  3323. },
  3324. ],
  3325. };
  3326. this.echartsThreeSecond.setOption(this.optionThreeSecond);
  3327. },
  3328. },
  3329. };
  3330. </script>
  3331. <style scoped>
  3332. .equipment_status {
  3333. display: flex;
  3334. flex-direction: row;
  3335. align-items: center;
  3336. }
  3337. .main_right_height {
  3338. height: 100vh !important;
  3339. display: block !important;
  3340. overflow-y: auto !important;
  3341. background: #ffffff;
  3342. }
  3343. canvas {
  3344. /* width: 100%;
  3345. height: 100%; */
  3346. }
  3347. .main-unity {
  3348. margin-top: 10px;
  3349. }
  3350. </style>
  3351. <style>
  3352. .footer {
  3353. text-align: center;
  3354. }
  3355. .fullscreen {
  3356. margin-top: 25px !important;
  3357. text-align: center !important;
  3358. display: none !important;
  3359. }
  3360. .musicTitle {
  3361. display: block;
  3362. font-size: 18px;
  3363. color: #57acbb;
  3364. margin-bottom: 5px;
  3365. }
  3366. .flood-plan-page {
  3367. /* margin-top:20px; */
  3368. }
  3369. .selectSty {
  3370. width: 100px;
  3371. font-size: 14px;
  3372. }
  3373. .desSty {
  3374. font-size: 12px;
  3375. font-family: Source Han Sans CN-Regular, Source Han Sans CN;
  3376. font-weight: 500;
  3377. /* color: #0f0f0f; */
  3378. }
  3379. .animation_fk {
  3380. }
  3381. .select_option {
  3382. font-size: 10px;
  3383. }
  3384. .select_class_animation {
  3385. display: flex;
  3386. flex-direction: row;
  3387. align-items: center;
  3388. }
  3389. .animation-middle-m {
  3390. display: flex;
  3391. flex-direction: row;
  3392. flex: 1;
  3393. }
  3394. .naoOneClass {
  3395. width: 100%;
  3396. height: 30vh;
  3397. width: 100%;
  3398. }
  3399. </style>