|
@@ -113,7 +113,7 @@
|
|
|
>{{ buttonFlag }}</el-button
|
|
|
>
|
|
|
</div>
|
|
|
-
|
|
|
+ <el-button @click="send"></el-button>
|
|
|
<el-row> </el-row>
|
|
|
<el-row> </el-row>
|
|
|
<el-row>
|
|
@@ -178,10 +178,10 @@
|
|
|
class="xl_d_button"
|
|
|
size="mini"
|
|
|
slot="reference"
|
|
|
- @click="linkJudge(scope.$index, scope.row, scope.row.connent)"
|
|
|
+ @click="linkJudge(scope.$index, scope.row, scope.row.connect)"
|
|
|
>
|
|
|
- <span v-if="scope.row.connent">断开连接</span
|
|
|
- ><span v-if="!scope.row.connent">连接</span></el-button
|
|
|
+ <span v-if="scope.row.connect">断开连接</span
|
|
|
+ ><span v-if="!scope.row.connect">连接</span></el-button
|
|
|
>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -386,7 +386,9 @@ export default {
|
|
|
// 全量
|
|
|
focusNaoAll: [],
|
|
|
// urlThreeP: "../../../static/candle/index.html",
|
|
|
- urlThreeP: __static + "/candle/index.html",
|
|
|
+ // urlThreeP: __static + "/candle/index.html",
|
|
|
+ urlThreeP: "../../../static/balance/index.html",
|
|
|
+ // urlThreeP: __static + "/balance/index.html",
|
|
|
// pubSrc: "../../../static",
|
|
|
pubsrc: __static,
|
|
|
userLink: {
|
|
@@ -421,6 +423,9 @@ export default {
|
|
|
//按钮状态
|
|
|
disabledTimeFlag: null,
|
|
|
intervalLength: 500,
|
|
|
+
|
|
|
+ //新增已选列表变量
|
|
|
+ isSelectedList: [],
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
@@ -464,10 +469,10 @@ export default {
|
|
|
setTimeout(() => {
|
|
|
that.getSize();
|
|
|
}, 5000);
|
|
|
- setTimeout(() => {
|
|
|
- that.changeGame(parseInt(that.$route.query.gameType));
|
|
|
- console.log(that.$route.query.gameType);
|
|
|
- }, 3000);
|
|
|
+ // setTimeout(() => {
|
|
|
+ // that.changeGame(parseInt(that.$route.query.gameType));
|
|
|
+ // console.log(that.$route.query.gameType);
|
|
|
+ // }, 3000);
|
|
|
that.singleFlag = that.$route.query.single;
|
|
|
console.log(that.singleFlag);
|
|
|
|
|
@@ -475,7 +480,7 @@ export default {
|
|
|
this.initWebsocket();
|
|
|
//当点击开始时调用方法开发发送游戏数据
|
|
|
//上来就查询已连接列表
|
|
|
-
|
|
|
+
|
|
|
//根据扫描列表和已连接列表看看哪些是重复的//重复的就是已连接的
|
|
|
that.mergeTimeFlag = setInterval(that.mergeDataFun, 1000);
|
|
|
//进入页面就开始扫描
|
|
@@ -483,8 +488,6 @@ export default {
|
|
|
//进入生物反馈页面扫描设备
|
|
|
this.queryScan();
|
|
|
that.listTimeFlag = setInterval(that.connectList, 2000);
|
|
|
-
|
|
|
-
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
//关闭扫描
|
|
@@ -505,7 +508,12 @@ export default {
|
|
|
methods: {
|
|
|
//合并数据
|
|
|
mergeDataFun() {
|
|
|
+ console.log(this.scanData);
|
|
|
+ console.log(this.connectedData);
|
|
|
let that = this;
|
|
|
+
|
|
|
+ //先选出扫描列表
|
|
|
+ //list为扫描列表
|
|
|
let scanDataTmp = JSON.stringify(this.scanData);
|
|
|
let scanDataTmpFin = JSON.parse(scanDataTmp);
|
|
|
|
|
@@ -515,7 +523,7 @@ export default {
|
|
|
rssi: "",
|
|
|
name: "",
|
|
|
mac: "",
|
|
|
- connent: false,
|
|
|
+ connect: false,
|
|
|
type: "",
|
|
|
ai: "",
|
|
|
at: "",
|
|
@@ -523,7 +531,7 @@ export default {
|
|
|
obj.rssi = scanDataTmpFin[i].rssi;
|
|
|
obj.name = scanDataTmpFin[i].name;
|
|
|
obj.mac = scanDataTmpFin[i].mac;
|
|
|
- obj.connent = false;
|
|
|
+ obj.connect = false;
|
|
|
obj.type = scanDataTmpFin[i].type;
|
|
|
obj.ai = scanDataTmpFin[i].ai;
|
|
|
obj.at = scanDataTmpFin[i].at;
|
|
@@ -549,7 +557,11 @@ export default {
|
|
|
//已选列表
|
|
|
let connectedDataTmp = JSON.stringify(this.connectedData);
|
|
|
let connectedDataTmpFin = JSON.parse(connectedDataTmp);
|
|
|
+
|
|
|
+ //知道了已选列表
|
|
|
+ //在已选列表中找到与扫描列表不同的对象
|
|
|
//不包含的列表
|
|
|
+ //以下listBarring是已选列表中且与扫描列表不同的
|
|
|
let listBarring = [];
|
|
|
for (let i = 0; i < connectedDataTmpFin.length; i++) {
|
|
|
let flag = false;
|
|
@@ -563,10 +575,12 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //在找出扫描列表与已选列表相同的,将已选列表的数据同步给扫描列表
|
|
|
+
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
for (let j = 0; j < connectedDataTmpFin.length; j++) {
|
|
|
if (list[i].mac == connectedDataTmpFin[j].mac) {
|
|
|
- list[i].connent = true;
|
|
|
+ list[i].connect = true;
|
|
|
list[i].rssi = connectedDataTmpFin[j].rssi;
|
|
|
}
|
|
|
}
|
|
@@ -574,7 +588,7 @@ export default {
|
|
|
//然后合并两个数组
|
|
|
|
|
|
let listFin = list.concat(listBarring);
|
|
|
- console.log("------1111111111111111111");
|
|
|
+ console.log("合并后的数据组");
|
|
|
console.log(listFin);
|
|
|
//判断当前选择的是脑电还是心电
|
|
|
let currentDeviceList = [];
|
|
@@ -765,9 +779,9 @@ export default {
|
|
|
that.$http.postTmp(
|
|
|
`/v2/device/conn`,
|
|
|
{
|
|
|
- ai: val.ai+'',
|
|
|
+ ai: val.ai + "",
|
|
|
mac: val.mac,
|
|
|
- at: val.at+'',
|
|
|
+ at: val.at + "",
|
|
|
},
|
|
|
(res) => {
|
|
|
that.disableStatus();
|
|
@@ -775,23 +789,12 @@ export default {
|
|
|
// this.linkIndex = index;
|
|
|
//如果是脑电的话直接调用打开数据接口
|
|
|
//如果是心电需要先调用写入输入数据-发送指令接口
|
|
|
-
|
|
|
+ that.userLink.mac = val.mac;
|
|
|
if (val.type == "1") {
|
|
|
- // this.writeData(val);
|
|
|
- that.userLink.mac = val.mac;
|
|
|
- } else {
|
|
|
- //判断脑电设备
|
|
|
-
|
|
|
- //脑电的情况下
|
|
|
- //记录下当前mac,
|
|
|
- that.userLink.mac = val.mac;
|
|
|
- //然后调用已连接列表确定改mac是否存在在列表中,如果已存在则表示该设备已连接
|
|
|
-
|
|
|
- // that.openData();
|
|
|
- // this.$message.success("设备连接成功");
|
|
|
+ this.writeData(val);
|
|
|
+ // that.userLink.mac = val.mac;
|
|
|
}
|
|
|
- // that.tableData = res.data;
|
|
|
- // that.totolSize = res.data.totalElements;
|
|
|
+ // this.$message.success("设备连接成功");
|
|
|
} else {
|
|
|
// this.$message.error("访问服务器失败!");
|
|
|
this.$message.error(res.data.message);
|
|
@@ -804,7 +807,7 @@ export default {
|
|
|
let that = this;
|
|
|
let userName = sessionStorage.getItem("name");
|
|
|
that.$http.postTmp(
|
|
|
- `/v1/device/write/data`,
|
|
|
+ `/v2/device/write/data`,
|
|
|
{ mac: val.mac, userName: userName },
|
|
|
(res) => {
|
|
|
// that.openData();
|
|
@@ -838,8 +841,9 @@ export default {
|
|
|
disconnectEquipment(val) {
|
|
|
let that = this;
|
|
|
that.buttonLinkFlag = true;
|
|
|
- that.$http.getTmp(`v1/device/${val.mac}/disconnect`, {}, (res) => {
|
|
|
+ that.$http.postTmp(`v2/device/dis/conn`, { mac: val.mac }, (res) => {
|
|
|
that.disableStatus();
|
|
|
+ debugger;
|
|
|
if (res.code == 200) {
|
|
|
//关闭连接的时候看是不是当前绑定的mac与用户的mac是否相同
|
|
|
//如果相同则 连接标志变为false;
|
|
@@ -862,52 +866,6 @@ export default {
|
|
|
that.$http.getTmp(`v2/device/connected/list`, {}, (res) => {
|
|
|
// console.log(res)
|
|
|
//判断当前的列表是否存在该用户已点击的列表
|
|
|
- if (res.code == 200) {
|
|
|
- if (res.data) {
|
|
|
- if (res.data) {
|
|
|
- let list = [];
|
|
|
- for (let i = 0; i < res.data.length; i++) {
|
|
|
- let obj = {
|
|
|
- rssi: "",
|
|
|
- name: "",
|
|
|
- mac: "",
|
|
|
- connent: false,
|
|
|
- deviceType: "",
|
|
|
- };
|
|
|
- obj.rssi = "";
|
|
|
- obj.name = res.data[i].Name;
|
|
|
- obj.mac = res.data[i].MAC;
|
|
|
- obj.connent = true;
|
|
|
- obj.deviceType = res.data[i].DeviceType;
|
|
|
- obj.userNum = "";
|
|
|
- list.push(obj);
|
|
|
- }
|
|
|
- that.connectedData = list;
|
|
|
- // console.log(list);
|
|
|
- if (list.length == 0) {
|
|
|
- //表示未连接
|
|
|
- that.linkStatus = false;
|
|
|
- } else {
|
|
|
- //标识已连接
|
|
|
- for (let k = 0; k < list.length; k++) {
|
|
|
- if (
|
|
|
- that.userLink.mac !== "" &&
|
|
|
- that.userLink.mac == list[k].mac
|
|
|
- ) {
|
|
|
- that.linkStatus = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- that.connectedData = [];
|
|
|
- }
|
|
|
- //打开数据接口
|
|
|
- // that.tableData = res.data;
|
|
|
- // that.totolSize = res.data.totalElements;
|
|
|
- } else {
|
|
|
- // this.$message.error("访问服务器失败!");
|
|
|
- }
|
|
|
});
|
|
|
},
|
|
|
typeFormatter(val) {
|
|
@@ -954,7 +912,7 @@ export default {
|
|
|
initWebsocket() {
|
|
|
// const wsuri = "ws://192.168.1.103:8000/ws?uid=client&to_uid=server";
|
|
|
// const wsuri = "ws://localhost:8000/ws?uid=client&to_uid=server";
|
|
|
- const wsuri = "ws://192.168.1.102:8000/ws?uid=client&to_uid=server";
|
|
|
+ const wsuri = "ws://192.168.1.100:8000/ws?uid=client&to_uid=server";
|
|
|
this.websock = new WebSocket(wsuri);
|
|
|
this.websock.onmessage = this.websocketonmessage;
|
|
|
this.websock.onopen = this.websocketonopen;
|
|
@@ -979,83 +937,118 @@ export default {
|
|
|
//数据接收
|
|
|
const redata = JSON.parse(e.data);
|
|
|
console.log(redata);
|
|
|
- // console.log(redata);
|
|
|
if (
|
|
|
redata.content != "开启扫描成功" &&
|
|
|
redata.content != "设置过滤成功" &&
|
|
|
redata.content != "Successful connection to socket service" &&
|
|
|
redata.content != "关闭扫描成功" &&
|
|
|
- redata.content != "设置UUID成功"&&
|
|
|
+ redata.content != "设置UUID成功" &&
|
|
|
redata.content != "设备连接成功"
|
|
|
) {
|
|
|
//首先判断是否redata.content是否是未定义
|
|
|
// console.log(redata.content)
|
|
|
if (redata.hasOwnProperty("content")) {
|
|
|
- let dataLin = JSON.parse(redata.content);
|
|
|
- if (redata.msgType == "device") {
|
|
|
- // let dataLin = JSON.parse(redata.content);
|
|
|
- console.log("-------------");
|
|
|
- console.log(dataLin);
|
|
|
- let a = {
|
|
|
- mac: dataLin.m,
|
|
|
- name: dataLin.n,
|
|
|
- rssi: dataLin.rssi,
|
|
|
- ai: dataLin.ai,
|
|
|
- at: dataLin.at,
|
|
|
- type: dataLin.t, //当type为1时为心电
|
|
|
- };
|
|
|
- that.changeList(a);
|
|
|
- //获取到很多数据,取每秒最大的包含量
|
|
|
- } else if (redata.msgType == "eegData") {
|
|
|
- // let dataLin = JSON.parse(redata.content);
|
|
|
- // console.log(dataLin);
|
|
|
- console.log("11111111111111111111");
|
|
|
- console.log(dataLin.value);
|
|
|
- ///先判断第一个用户是否有mac---有mac代表已连接
|
|
|
- if (that.userLink.mac !== "" && that.userLink.mac == dataLin.id) {
|
|
|
- ipcRenderer.send("asynchronoushrv-naoData", {
|
|
|
- value: dataLin.value,
|
|
|
- mac: dataLin.id,
|
|
|
- });
|
|
|
- }
|
|
|
- if (
|
|
|
- that.userTwoLink.mac !== "" &&
|
|
|
- that.userTwoLink.mac == dataLin.id
|
|
|
- ) {
|
|
|
- ipcRenderer.send("asynchronoushrv-naoTwoData", {
|
|
|
- value: dataLin.value,
|
|
|
- mac: dataLin.id,
|
|
|
- });
|
|
|
- }
|
|
|
- //判断第二个用户的mac是否有,有则代表已连接 --
|
|
|
- } else if (redata.msgType == "ecgData") {
|
|
|
- //判断该数据对应的mac是否是当前绑定过用户的
|
|
|
- //判断当前是否是绑定该用户的数据,是的话进行用户处理
|
|
|
- //接到数据进行处理
|
|
|
- //当该用户的mac与id相同时,取这个数据
|
|
|
- // console.log(dataLin.id === that.userLink.mac);
|
|
|
- if (dataLin.id === that.userLink.mac) {
|
|
|
- let list = dataLin.value.split(",");
|
|
|
- // console.log(list)
|
|
|
- list.forEach((item) => {
|
|
|
- let tmp = parseInt(item);
|
|
|
- that.userLink.ecgAllList.push(tmp);
|
|
|
- that.userLink.ecgSectionList.push(tmp);
|
|
|
- if (that.userLink.ecgSectionList.length > that.intervalLength) {
|
|
|
- that.userLink.ecgSectionList.shift();
|
|
|
- }
|
|
|
- if (that.userLink.ecgAllList.length % 100 == 0) {
|
|
|
- // console.log(that.ecgAllList.length);
|
|
|
- if (that.echartsVisible) {
|
|
|
- that.renderEcgOne();
|
|
|
+ if (redata.content != "") {
|
|
|
+ let dataLin = JSON.parse(redata.content);
|
|
|
+
|
|
|
+ if (redata.msgType == "device") {
|
|
|
+ // let dataLin = JSON.parse(redata.content);
|
|
|
+ console.log("-------------");
|
|
|
+ console.log(dataLin);
|
|
|
+ let a = {
|
|
|
+ mac: dataLin.m,
|
|
|
+ name: dataLin.n,
|
|
|
+ rssi: dataLin.rssi,
|
|
|
+ ai: dataLin.ai,
|
|
|
+ at: dataLin.at,
|
|
|
+ type: dataLin.t, //当type为1时为心电
|
|
|
+ };
|
|
|
+ that.changeList(a);
|
|
|
+ //获取到很多数据,取每秒最大的包含量
|
|
|
+ } else if (redata.msgType == "eegData") {
|
|
|
+ // let dataLin = JSON.parse(redata.content);
|
|
|
+ // console.log(dataLin);
|
|
|
+ console.log("11111111111111111111");
|
|
|
+ console.log(dataLin.value);
|
|
|
+ ///先判断第一个用户是否有mac---有mac代表已连接
|
|
|
+ if (that.userLink.mac !== "" && that.userLink.mac == dataLin.id) {
|
|
|
+ ipcRenderer.send("asynchronoushrv-naoData", {
|
|
|
+ value: dataLin.value,
|
|
|
+ mac: dataLin.id,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ that.userTwoLink.mac !== "" &&
|
|
|
+ that.userTwoLink.mac == dataLin.id
|
|
|
+ ) {
|
|
|
+ ipcRenderer.send("asynchronoushrv-naoTwoData", {
|
|
|
+ value: dataLin.value,
|
|
|
+ mac: dataLin.id,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //判断第二个用户的mac是否有,有则代表已连接 --
|
|
|
+ } else if (redata.msgType == "ecgData") {
|
|
|
+ //判断该数据对应的mac是否是当前绑定过用户的
|
|
|
+ //判断当前是否是绑定该用户的数据,是的话进行用户处理
|
|
|
+ //接到数据进行处理
|
|
|
+ //当该用户的mac与id相同时,取这个数据
|
|
|
+ // console.log(dataLin.id === that.userLink.mac);
|
|
|
+ if (dataLin.id === that.userLink.mac) {
|
|
|
+ let list = dataLin.value.split(",");
|
|
|
+ // console.log(list)
|
|
|
+ list.forEach((item) => {
|
|
|
+ let tmp = parseInt(item);
|
|
|
+ that.userLink.ecgAllList.push(tmp);
|
|
|
+ that.userLink.ecgSectionList.push(tmp);
|
|
|
+ if (
|
|
|
+ that.userLink.ecgSectionList.length > that.intervalLength
|
|
|
+ ) {
|
|
|
+ that.userLink.ecgSectionList.shift();
|
|
|
+ }
|
|
|
+ if (that.userLink.ecgAllList.length % 100 == 0) {
|
|
|
+ // console.log(that.ecgAllList.length);
|
|
|
+ if (that.echartsVisible) {
|
|
|
+ that.renderEcgOne();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else if (redata.msgType == "connectedList") {
|
|
|
+ //数组储存每次返回的已选列表
|
|
|
+ //将每次的数据进行储存,然后经过去重及为已选列表的数据
|
|
|
+ let obj = {
|
|
|
+ mac: dataLin.m,
|
|
|
+ name: dataLin.n,
|
|
|
+ rssi: dataLin.rssi,
|
|
|
+ connect: true,
|
|
|
+ ai: dataLin.ai,
|
|
|
+ at: dataLin.at,
|
|
|
+ type: dataLin.t, //当type为1时为心
|
|
|
+ };
|
|
|
+
|
|
|
+ that.isSelectedList.push(obj);
|
|
|
+
|
|
|
+ //创建一个变量,将变量赋值根据mac进行去重
|
|
|
+ let list = JSON.parse(JSON.stringify(that.isSelectedList));
|
|
|
+ //然后将list进行去重
|
|
|
+
|
|
|
+ //然后将该结果去重
|
|
|
+ let listBarring = [];
|
|
|
+ for (let i = 0; i < list.length; i++) {
|
|
|
+ let flag = false;
|
|
|
+ for (let j = 0; j < listBarring.length; j++) {
|
|
|
+ if (list[i].mac == list[j].mac) {
|
|
|
+ flag = true;
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
+ if (!flag) {
|
|
|
+ listBarring.push(list[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ that.connectedData = JSON.parse(JSON.stringify(listBarring));
|
|
|
+ console.log(that.connectedData);
|
|
|
+ //listBarring 将值赋值给已选列表的值
|
|
|
}
|
|
|
- }else if(redata.msgType == "connectedList"){
|
|
|
- //数组储存每次返回的已选列表
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1093,6 +1086,7 @@ export default {
|
|
|
// console.log(JSON.stringify(newArr));
|
|
|
//listTmp即使最大扫描列表
|
|
|
that.scanData = newArr;
|
|
|
+ console.log(that.scanData);
|
|
|
},
|
|
|
websocketclose(e) {
|
|
|
if (e.code == 1005) {
|
|
@@ -1192,13 +1186,13 @@ export default {
|
|
|
rssi: "",
|
|
|
name: "",
|
|
|
mac: "",
|
|
|
- connent: false,
|
|
|
+ connect: false,
|
|
|
deviceType: "",
|
|
|
};
|
|
|
obj.rssi = "";
|
|
|
obj.name = res.data[i].Name;
|
|
|
obj.mac = res.data[i].MAC;
|
|
|
- obj.connent = true;
|
|
|
+ obj.connect = true;
|
|
|
obj.deviceType = res.data[i].DeviceType;
|
|
|
obj.userNum = "";
|
|
|
list.push(obj);
|
|
@@ -1535,7 +1529,8 @@ export default {
|
|
|
this.$refs.unityIframe.contentWindow.changeSize(width, height);
|
|
|
},
|
|
|
send(val) {
|
|
|
- this.$refs.unityIframe.contentWindow.Bloomsize(val);
|
|
|
+ // this.$refs.unityIframe.contentWindow.Bloomsize(val);
|
|
|
+ this.$refs.unityIframe.contentWindow.CallUnity();
|
|
|
},
|
|
|
// btt() {
|
|
|
// let that = this;
|