UI / Python Websocket
This commit is contained in:
2
PointCloudWeb.Scanner/0yGrad-pc.csv
Normal file
2
PointCloudWeb.Scanner/0yGrad-pc.csv
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
x,y,z
|
||||||
|
143, 1307, 2
|
||||||
|
32401
PointCloudWeb.Scanner/Esszimmer.txt
Normal file
32401
PointCloudWeb.Scanner/Esszimmer.txt
Normal file
File diff suppressed because it is too large
Load Diff
6480
PointCloudWeb.Scanner/datafile.csv
Normal file
6480
PointCloudWeb.Scanner/datafile.csv
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1
PointCloudWeb.Scanner/lidar.csv
Normal file
1
PointCloudWeb.Scanner/lidar.csv
Normal file
@@ -0,0 +1 @@
|
|||||||
|
1,0.109375001,1315.000057
|
||||||
|
@@ -2,11 +2,16 @@
|
|||||||
import serial
|
import serial
|
||||||
import time
|
import time
|
||||||
import PyLidar3
|
import PyLidar3
|
||||||
|
import asyncio
|
||||||
|
import websockets
|
||||||
|
|
||||||
arduino = serial.Serial(port='COM8', baudrate=9600)
|
#arduino = serial.Serial(port='COM5', baudrate=9600)
|
||||||
lidar = PyLidar3.YdLidarX4(port='COM6',chunk_size=20000) #PyLidar3.your_version_of_lidar(port,chunk_size)
|
#lidar = PyLidar3.YdLidarX4(port='COM6',chunk_size=20000) #PyLidar3.your_version_of_lidar(port,chunk_size)
|
||||||
|
|
||||||
f = open("PoinCloudWeb.Scanner\datafile.txt","wt")
|
f = open("PointCloudWeb.Scanner\datafile.txt","wt")
|
||||||
|
f.write("y, x, z\n")
|
||||||
|
|
||||||
|
progress = 0
|
||||||
|
|
||||||
print("Start ...")
|
print("Start ...")
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
@@ -35,7 +40,7 @@ def filterY(data):
|
|||||||
|
|
||||||
def senddata(data,posy):
|
def senddata(data,posy):
|
||||||
for x,y in data.items():
|
for x,y in data.items():
|
||||||
f.write("y:" + str(posy) + "x:" + str(x) + "d:" + str(y) + "\n")
|
f.write(str(posy) + ", " + str(x) + ", " + str(y) + "\n")
|
||||||
|
|
||||||
def startScaner(mode):
|
def startScaner(mode):
|
||||||
if(lidar.Connect()):
|
if(lidar.Connect()):
|
||||||
@@ -68,21 +73,53 @@ def startScaner(mode):
|
|||||||
setY(0)
|
setY(0)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Mode Error")
|
print("mode error")
|
||||||
|
|
||||||
# data = next(gen)
|
|
||||||
# #print(data)
|
|
||||||
# for x,y in data.items():
|
|
||||||
# f.write("a:" + str(x) + " d:" + str(y) + "\n")
|
|
||||||
f.close()
|
f.close()
|
||||||
lidar.StopScanning()
|
lidar.StopScanning()
|
||||||
lidar.Disconnect()
|
lidar.Disconnect()
|
||||||
print("Scaner gestoppt")
|
print("scan stoped")
|
||||||
else:
|
else:
|
||||||
print("Error connecting to device")
|
print("Error connecting to device")
|
||||||
|
|
||||||
while True:
|
async def wsfilter(websocket, message):
|
||||||
startScaner(input("Scan Modus(0,1,2):"))
|
command = message[message.find("<")+1:message.find(">")]
|
||||||
|
value = message[message.find("><")+2:message.find(">", message.find("><")+2)]
|
||||||
|
#print(command + " / " + value)
|
||||||
|
await wsaction(websocket, command,value)
|
||||||
|
|
||||||
|
async def wsaction(websocket, command, value):
|
||||||
|
if(command == "start"):
|
||||||
|
if(value == "0"):
|
||||||
|
await websocket.send("start scan resolution 0")
|
||||||
|
elif(value =="1"):
|
||||||
|
await websocket.send("start scan resolution 1")
|
||||||
|
elif(value =="2"):
|
||||||
|
await websocket.send("start scan resolution 2")
|
||||||
|
else:
|
||||||
|
await websocket.send("mode error")
|
||||||
|
elif(command == "status"):
|
||||||
|
await websocket.send("Status ...")
|
||||||
|
else:
|
||||||
|
await websocket.send("command error")
|
||||||
|
#muss noch was passieren
|
||||||
|
|
||||||
|
async def wscom(websocket, path):
|
||||||
|
print("connected")
|
||||||
|
while True:
|
||||||
|
data = await websocket.recv()
|
||||||
|
await wsfilter(websocket, data)
|
||||||
|
print({data})
|
||||||
|
#await websocket.send(data)
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
server = await websockets.serve(wscom, 'localhost', 6789)
|
||||||
|
await server.wait_closed()
|
||||||
|
asyncio.run(main())
|
||||||
|
|
||||||
|
#while True:
|
||||||
|
# startScaner(input("Scan Modus(0,1,2):"))
|
||||||
|
#wsfilter(input("Befehlt Eingeben:"))
|
||||||
# for x in range(18):
|
# for x in range(18):
|
||||||
# setY(x*10)
|
# setY(x*10)
|
||||||
# time.sleep(1)
|
# time.sleep(1)
|
||||||
20
PointCloudWeb.Scanner/test/index.html
Normal file
20
PointCloudWeb.Scanner/test/index.html
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>WebSocket demo</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
var ws = new WebSocket("ws://127.0.0.1:5678/"),
|
||||||
|
messages = document.createElement('ul');
|
||||||
|
ws.onmessage = function (event) {
|
||||||
|
var messages = document.getElementsByTagName('ul')[0],
|
||||||
|
message = document.createElement('li'),
|
||||||
|
content = document.createTextNode(event.data);
|
||||||
|
message.appendChild(content);
|
||||||
|
messages.appendChild(message);
|
||||||
|
};
|
||||||
|
document.body.appendChild(messages);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
import PyLidar3
|
import PyLidar3
|
||||||
import time # Time module
|
import time # Time module
|
||||||
#Serial port to which lidar connected, Get it from device manager windows
|
#Serial port to which lidar connected, Get it from device manager windows
|
||||||
#In linux type in terminal -- ls /dev/tty*
|
#In linux type in terminal -- ls /dev/tty*
|
||||||
#port = input("Enter port name which lidar is connected:") #windows
|
#port = input("Enter port name which lidar is connected:") #windows
|
||||||
#port = "/dev/ttyUSB0" #linux
|
#port = "/dev/ttyUSB0" #linux
|
||||||
f = open("PoinCloudWeb.Scanner\datafile.txt","wt")
|
f = open("PoinCloudWeb.Scanner\datafile.txt","wt")
|
||||||
Obj = PyLidar3.YdLidarX4(port='COM6',chunk_size=20000) #PyLidar3.your_version_of_lidar(port,chunk_size)
|
Obj = PyLidar3.YdLidarX4(port='COM6',chunk_size=20000) #PyLidar3.your_version_of_lidar(port,chunk_size)
|
||||||
if(Obj.Connect()):
|
if(Obj.Connect()):
|
||||||
print(Obj.GetDeviceInfo())
|
print(Obj.GetDeviceInfo())
|
||||||
gen = Obj.StartScanning()
|
gen = Obj.StartScanning()
|
||||||
t = time.time() # start time
|
t = time.time() # start time
|
||||||
data = next(gen)
|
data = next(gen)
|
||||||
#print(data)
|
#print(data)
|
||||||
for x,y in data.items():
|
for x,y in data.items():
|
||||||
f.write(str(x) + " / " + str(y) + "\n")
|
f.write(str(x) + " / " + str(y) + "\n")
|
||||||
f.close()
|
f.close()
|
||||||
Obj.StopScanning()
|
Obj.StopScanning()
|
||||||
Obj.Disconnect()
|
Obj.Disconnect()
|
||||||
else:
|
else:
|
||||||
print("Error connecting to device")
|
print("Error connecting to device")
|
||||||
69
PointCloudWeb.Scanner/test/ws.py
Normal file
69
PointCloudWeb.Scanner/test/ws.py
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
# WS server example that synchronizes state across clients
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import websockets
|
||||||
|
|
||||||
|
logging.basicConfig()
|
||||||
|
|
||||||
|
STATE = {"value": 0}
|
||||||
|
|
||||||
|
USERS = set()
|
||||||
|
|
||||||
|
|
||||||
|
def state_event():
|
||||||
|
return json.dumps({"type": "state", **STATE})
|
||||||
|
|
||||||
|
|
||||||
|
def users_event():
|
||||||
|
return json.dumps({"type": "users", "count": len(USERS)})
|
||||||
|
|
||||||
|
|
||||||
|
async def notify_state():
|
||||||
|
if USERS: # asyncio.wait doesn't accept an empty list
|
||||||
|
message = state_event()
|
||||||
|
await asyncio.wait([user.send(message) for user in USERS])
|
||||||
|
|
||||||
|
|
||||||
|
async def notify_users():
|
||||||
|
if USERS: # asyncio.wait doesn't accept an empty list
|
||||||
|
message = users_event()
|
||||||
|
await asyncio.wait([user.send(message) for user in USERS])
|
||||||
|
|
||||||
|
|
||||||
|
async def register(websocket):
|
||||||
|
USERS.add(websocket)
|
||||||
|
await notify_users()
|
||||||
|
|
||||||
|
|
||||||
|
async def unregister(websocket):
|
||||||
|
USERS.remove(websocket)
|
||||||
|
await notify_users()
|
||||||
|
|
||||||
|
|
||||||
|
async def counter(websocket, path):
|
||||||
|
# register(websocket) sends user_event() to websocket
|
||||||
|
await register(websocket)
|
||||||
|
try:
|
||||||
|
await websocket.send(state_event())
|
||||||
|
async for message in websocket:
|
||||||
|
data = json.loads(message)
|
||||||
|
if data["action"] == "minus":
|
||||||
|
STATE["value"] -= 1
|
||||||
|
await notify_state()
|
||||||
|
elif data["action"] == "plus":
|
||||||
|
STATE["value"] += 1
|
||||||
|
await notify_state()
|
||||||
|
else:
|
||||||
|
logging.error("unsupported event: %s", data)
|
||||||
|
finally:
|
||||||
|
await unregister(websocket)
|
||||||
|
|
||||||
|
|
||||||
|
start_server = websockets.serve(counter, "localhost", 6789)
|
||||||
|
|
||||||
|
asyncio.get_event_loop().run_until_complete(start_server)
|
||||||
|
asyncio.get_event_loop().run_forever()
|
||||||
160
PointCloudWeb.Web/package-lock.json
generated
160
PointCloudWeb.Web/package-lock.json
generated
@@ -1781,6 +1781,63 @@
|
|||||||
"integrity": "sha1-/q7SVZc9LndVW4PbwIhRpsY1IPo=",
|
"integrity": "sha1-/q7SVZc9LndVW4PbwIhRpsY1IPo=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"ansi-styles": {
|
||||||
|
"version": "4.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||||
|
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"color-convert": "^2.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"chalk": {
|
||||||
|
"version": "4.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
||||||
|
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"ansi-styles": "^4.1.0",
|
||||||
|
"supports-color": "^7.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"color-convert": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"color-name": "~1.1.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"color-name": {
|
||||||
|
"version": "1.1.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
||||||
|
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"has-flag": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"loader-utils": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"big.js": "^5.2.2",
|
||||||
|
"emojis-list": "^3.0.0",
|
||||||
|
"json5": "^2.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"ssri": {
|
"ssri": {
|
||||||
"version": "8.0.1",
|
"version": "8.0.1",
|
||||||
"resolved": "https://registry.nlark.com/ssri/download/ssri-8.0.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fssri%2Fdownload%2Fssri-8.0.1.tgz",
|
"resolved": "https://registry.nlark.com/ssri/download/ssri-8.0.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fssri%2Fdownload%2Fssri-8.0.1.tgz",
|
||||||
@@ -1789,6 +1846,28 @@
|
|||||||
"requires": {
|
"requires": {
|
||||||
"minipass": "^3.1.1"
|
"minipass": "^3.1.1"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"supports-color": {
|
||||||
|
"version": "7.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||||
|
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"has-flag": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"vue-loader-v16": {
|
||||||
|
"version": "npm:vue-loader@16.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.4.0.tgz",
|
||||||
|
"integrity": "sha512-oySoEgEedGw0jz2czEOdb6sycQ2PPyzUmF8Yclj1NTpoTVHGCYCQaGf+jsvxhdDVfhOnDLjkRzT2fLpGOrVPjg==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"chalk": "^4.1.0",
|
||||||
|
"hash-sum": "^2.0.0",
|
||||||
|
"loader-utils": "^2.0.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -11287,87 +11366,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"vue-loader-v16": {
|
|
||||||
"version": "npm:vue-loader@16.3.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.3.3.tgz",
|
|
||||||
"integrity": "sha512-/1GzCuQ6MRORbC+leKTKoTGtpQt60bYe0gDGEextSteA2OM+v201FPha5jzmjQzVhRcwieZeUvezAtG5a/e5cw==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"chalk": "^4.1.0",
|
|
||||||
"hash-sum": "^2.0.0",
|
|
||||||
"loader-utils": "^2.0.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"ansi-styles": {
|
|
||||||
"version": "4.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
|
||||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"color-convert": "^2.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"chalk": {
|
|
||||||
"version": "4.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz",
|
|
||||||
"integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"ansi-styles": "^4.1.0",
|
|
||||||
"supports-color": "^7.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"color-convert": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"color-name": "~1.1.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"color-name": {
|
|
||||||
"version": "1.1.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
|
||||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"has-flag": {
|
|
||||||
"version": "4.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
|
||||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"loader-utils": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz",
|
|
||||||
"integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"big.js": "^5.2.2",
|
|
||||||
"emojis-list": "^3.0.0",
|
|
||||||
"json5": "^2.1.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"supports-color": {
|
|
||||||
"version": "7.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
|
||||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"has-flag": "^4.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"vue-router": {
|
"vue-router": {
|
||||||
"version": "4.0.10",
|
"version": "4.0.10",
|
||||||
"resolved": "https://registry.nlark.com/vue-router/download/vue-router-4.0.10.tgz",
|
"resolved": "https://registry.nlark.com/vue-router/download/vue-router-4.0.10.tgz",
|
||||||
|
|||||||
@@ -1,6 +1,53 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<h1>Welcome to PointCloudWeb</h1>
|
<h1>Welcome to PointCloudWeb</h1>
|
||||||
<h1>Scanner</h1>
|
<div class="scanresolution">
|
||||||
|
<button v-on:click="sendMessage('<start><0>')" >Start Scan: low</button>
|
||||||
|
<button v-on:click="sendMessage('<start><1>')" >Start Scan: medium</button>
|
||||||
|
<button v-on:click="sendMessage('<start><2>')" >Start Scan: high</button>
|
||||||
|
<button v-on:click="sendMessage('Connect')" >Connect</button>
|
||||||
|
</div>
|
||||||
|
<div class="scanresolution">
|
||||||
|
<h1>status: {{status}}</h1>
|
||||||
|
<div class="value" v-for="(item, index) in logs" :key="item.id">
|
||||||
|
{{logs[index]}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
logs: [],
|
||||||
|
status: "disconnected"
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
sendMessage: function(message) {
|
||||||
|
|
||||||
|
this.connection.send(message);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created: function() {
|
||||||
|
this.connection = new WebSocket("ws://127.0.0.1:6789/")
|
||||||
|
let that = this
|
||||||
|
|
||||||
|
this.connection.onopen = function(){
|
||||||
|
that.status = "connected"
|
||||||
|
that.logs.push("successfully connected to scanserver")
|
||||||
|
}
|
||||||
|
|
||||||
|
this.connection.onmessage = function(event){
|
||||||
|
console.log(event)
|
||||||
|
that.logs.push(event.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user