增加485重连
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
# 左门循环开关调试功能
|
||||
|
||||
> 调试用功能,每隔 5 秒循环:开左门 → 5秒 → 关左门 → 5秒 → 开左门 ...
|
||||
> 无需本地配置,不新建页面,所有逻辑写在 `start.vue` 中。
|
||||
|
||||
---
|
||||
|
||||
## 1. data 新增变量
|
||||
|
||||
```js
|
||||
// start.vue → data() 中新增
|
||||
leftDoorCycleTimer: null, // 左门循环定时器
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. onLoad 中启动定时器
|
||||
|
||||
在 `start.vue` → `onLoad()` 末尾追加:
|
||||
|
||||
```js
|
||||
// 启动左门循环定时器
|
||||
this.startLeftDoorCycle()
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. 新增方法
|
||||
|
||||
在 `start.vue` → `methods` 中新增:
|
||||
|
||||
```js
|
||||
/**
|
||||
* 左门循环开关(调试用,独立定时器)
|
||||
* 每5秒切换一次左门状态
|
||||
*/
|
||||
startLeftDoorCycle() {
|
||||
clearInterval(this.leftDoorCycleTimer)
|
||||
let isOpen = false
|
||||
this.leftDoorCycleTimer = setInterval(async () => {
|
||||
try {
|
||||
if (isOpen) {
|
||||
cmd.LeftDoor(false)
|
||||
// this.addLog('左门循环', '关左门')
|
||||
} else {
|
||||
cmd.LeftDoor(true)
|
||||
// this.addLog('左门循环', '开左门')
|
||||
}
|
||||
isOpen = !isOpen
|
||||
} catch (error) {
|
||||
this.addLog('左门循环错误', error.message || error)
|
||||
}
|
||||
}, 5000)
|
||||
},
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. 总结
|
||||
|
||||
| 项目 | 说明 |
|
||||
|------|------|
|
||||
| 间隔 | 每 **5 秒** 切换一次 |
|
||||
| 逻辑 | 当前开 → 5秒后关 → 5秒后开 → 循环 |
|
||||
| 启动 | `onLoad` 里自动启动 |
|
||||
| 日志 | 代码里注释掉了,需要时可取消注释 |
|
||||
| 无需改动 | 不建新文件、不改 store、不用 storage |
|
||||
Reference in New Issue
Block a user