Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
Z
zhmes-agecal
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
耿迪迪
zhmes-agecal
Commits
107a82cf
Commit
107a82cf
authored
Dec 31, 2025
by
wanghao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1 写自检后 判断下 是否写成功
parent
fb889f80
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
+8
-9
Modbus4jUtils.java
...ain/java/com/zehong/system/modbus/util/Modbus4jUtils.java
+8
-9
No files found.
zhmes-agecal-system/src/main/java/com/zehong/system/modbus/util/Modbus4jUtils.java
View file @
107a82cf
...
@@ -35,7 +35,7 @@ public class Modbus4jUtils {
...
@@ -35,7 +35,7 @@ public class Modbus4jUtils {
private
static
ModbusMaster
master
;
private
static
ModbusMaster
master
;
private
static
final
int
START_ADDRESS
=
0
;
// 对应40001
private
static
final
int
START_ADDRESS
=
0
;
// 对应40001
private
static
final
int
REGISTER_COUNT
=
1
5
;
// 读取15个寄存器
private
static
final
int
REGISTER_COUNT
=
1
6
;
// 读取15个寄存器
private
static
final
int
TARGET_VALUE
=
1
;
// 目标值(第二个寄存器的期望值)
private
static
final
int
TARGET_VALUE
=
1
;
// 目标值(第二个寄存器的期望值)
private
static
final
int
MAX_RETRIES
=
3
;
// 最大重试次数
private
static
final
int
MAX_RETRIES
=
3
;
// 最大重试次数
private
static
final
int
RETRY_DELAY
=
500
;
// 重试延迟(ms)// 监控参数
private
static
final
int
RETRY_DELAY
=
500
;
// 重试延迟(ms)// 监控参数
...
@@ -1067,14 +1067,13 @@ public class Modbus4jUtils {
...
@@ -1067,14 +1067,13 @@ public class Modbus4jUtils {
// 20251206 写完时间写自检,写自检就在时间后边写就行,不管时间写不写成功
// 20251206 写完时间写自检,写自检就在时间后边写就行,不管时间写不写成功
try
{
try
{
Modbus4jUtils
.
writeRegister
(
master
,
deviceId
,
15
,
(
short
)
1
);
Modbus4jUtils
.
writeRegister
(
master
,
deviceId
,
15
,
(
short
)
1
);
Thread
.
sleep
(
2000
);
int
[]
ints
=
Modbus4jUtils
.
readDeviceRegisters
(
master
,
deviceId
);
if
(
ints
[
15
]
==
1
)
{
return
1
;
return
1
;
// Thread.sleep(2000);
}
else
{
// int[] ints = Modbus4jUtils.readDeviceRegisters(master, deviceId);
return
0
;
// if (ints[15] == 1) {
}
// return 1;
// } else {
// return 0;
// }
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
return
0
;
return
0
;
}
}
...
...
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