Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
metage
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guoyu
metage
Commits
e882aea1
Commit
e882aea1
authored
Apr 13, 2023
by
qizhiqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
中文提示变英文
parent
73fcce46
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
10 deletions
+10
-10
RxtxUtils.java
src/main/java/com/mushiny/metage/util/RxtxUtils.java
+4
-4
ServerStart.java
src/main/java/com/mushiny/metage/util/ServerStart.java
+2
-2
WebSocket.java
src/main/java/com/mushiny/metage/webSocket/WebSocket.java
+4
-4
No files found.
src/main/java/com/mushiny/metage/util/RxtxUtils.java
View file @
e882aea1
...
...
@@ -56,7 +56,7 @@ public class RxtxUtils extends Thread implements SerialPortEventListener {
msgQueue
.
add
(
new
String
(
readBuffer
,
"gbk"
));
readBuffer
=
new
byte
[
1024
];
// 重新构造缓冲对象,否则有可能会影响接下来接收的数据
}
else
{
msgQueue
.
add
(
"
额------没有读到数据
"
);
msgQueue
.
add
(
"
!------No data read
"
);
}
}
}
catch
(
IOException
e
)
{
...
...
@@ -80,8 +80,8 @@ public class RxtxUtils extends Thread implements SerialPortEventListener {
// 获取相应串口对象
portId
=
(
CommPortIdentifier
)
portList
.
nextElement
();
System
.
out
.
println
(
"
设备类型
:--->"
+
portId
.
getPortType
());
System
.
out
.
println
(
"
设备名称
:---->"
+
portId
.
getName
());
System
.
out
.
println
(
"
Equipment type
:--->"
+
portId
.
getPortType
());
System
.
out
.
println
(
"
Device Name
:---->"
+
portId
.
getName
());
// 判断端口类型是否为串口
if
(
portId
.
getPortType
()
==
CommPortIdentifier
.
PORT_SERIAL
)
{
// 判断如果COM7串口存在,就打开该串口
...
...
@@ -138,7 +138,7 @@ public class RxtxUtils extends Thread implements SerialPortEventListener {
// 如果堵塞队列中存在数据就将其输出
if
(
msgQueue
.
size
()
>
0
)
{
weightings
=
Double
.
parseDouble
(
msgQueue
.
take
());
System
.
out
.
println
(
"
接收到的消息
:"
+
weightings
);
System
.
out
.
println
(
"
Received messages
:"
+
weightings
);
WebSocket
webSocket
=
new
WebSocket
();
webSocket
.
sendAllToUserMessage
(
String
.
valueOf
(
weightings
));
// sendDate(weightings);
...
...
src/main/java/com/mushiny/metage/util/ServerStart.java
View file @
e882aea1
...
...
@@ -29,9 +29,9 @@ public class ServerStart implements CommandLineRunner {
int
i
=
cRead
.
startComPort
(
portName
,
bitRate
,
dataBits
,
stopBit
,
parityBit
);
if
(
i
==
1
)
{
cRead
.
start
();
System
.
out
.
println
(
"
打开端口
"
);
System
.
out
.
println
(
"
open port
"
);
}
else
{
System
.
out
.
println
(
"
端口打开失败
!"
);
System
.
out
.
println
(
"
Port opening failed
!"
);
}
}
...
...
src/main/java/com/mushiny/metage/webSocket/WebSocket.java
View file @
e882aea1
...
...
@@ -21,7 +21,7 @@ public class WebSocket {
this
.
session
=
session
;
//加入set中
webSocketSet
.
add
(
this
);
System
.
out
.
println
(
"
建立连接
:"
+
webSocketSet
.
size
());
System
.
out
.
println
(
"
Establishing a connection
:"
+
webSocketSet
.
size
());
}
//给所有当前连接的用户发送消息
...
...
@@ -31,7 +31,7 @@ public class WebSocket {
for
(
WebSocket
item:
webSocketSet
)
{
item
.
session
.
getBasicRemote
().
sendText
(
message
);
System
.
out
.
println
(
"
服务端发送的消息
:"
+
message
);
System
.
out
.
println
(
"
Messages sent by the server
:"
+
message
);
}
}
}
catch
(
Exception
e
){
...
...
@@ -43,7 +43,7 @@ public class WebSocket {
@OnClose
public
void
onClose
(
Session
session
){
webSocketSet
.
remove
(
this
);
System
.
out
.
println
(
"
建立连接
:"
+
webSocketSet
.
size
());
System
.
out
.
println
(
"
Establishing a connection
:"
+
webSocketSet
.
size
());
}
//接收前端发送的消息
...
...
@@ -56,7 +56,7 @@ public class WebSocket {
//发送错误时调用
@OnError
public
void
onError
(
Session
session
,
Throwable
error
){
System
.
out
.
println
(
"webSocket
发送错误
!!!"
);
System
.
out
.
println
(
"webSocket
Sending error
!!!"
);
error
.
printStackTrace
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment