修改ZDJ9双机电路切断继电器保持电路实现方式

This commit is contained in:
walker 2023-10-07 11:16:24 +08:00
parent 0744081d90
commit 41e22bd7bf
2 changed files with 22 additions and 13 deletions

View File

@ -57,6 +57,8 @@ type Zdj9TwoElectronic struct {
TDFJ1_QDJ *ecs.Entry // 切断继电器
TDFJ1_ZBHJ *ecs.Entry // 总保护继电器
TDFJ1_QDJ_Remain int // 切断继电器保持电路保持剩余时间
// 二机
TDFJ2_1DQJ *ecs.Entry // 一启动继电器
TDFJ2_BHJ *ecs.Entry // 保护继电器

View File

@ -2,7 +2,6 @@ package circuit_sys
import (
"fmt"
"unsafe"
"github.com/yohamta/donburi/filter"
"joylink.club/ecs"
@ -162,25 +161,33 @@ func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_QDJ(w ecs.World, entry *ecs.Entry, ele
if !tdfj1_qdj.Val { // 落下状态
if (!tdfj1_bhj.Val && !tdfj2_bhj.Val) || tdfj1_zbhj.Val { // 电路导通
drive.Td = true
if entry.HasComponent(component.CounterDownType) {
entry.RemoveComponent(component.CounterDownType)
}
elec.TDFJ1_QDJ_Remain = QDJ_DELAY
// if entry.HasComponent(component.CounterDownType) {
// entry.RemoveComponent(component.CounterDownType)
// }
}
} else { // 吸起状态
if drive.Td && !tdfj1_zbhj.Val && !(tdfj1_bhj.Val && tdfj2_bhj.Val) { // 电路断开
// 延时电路
if entry.HasComponent(component.CounterDownType) {
cd := component.CounterDownType.Get(entry)
if cd.Val <= 0 {
if elec.TDFJ1_QDJ_Remain > 0 {
remain := elec.TDFJ1_QDJ_Remain - w.Tick()
if remain <= 0 {
elec.TDFJ1_QDJ_Remain = 0
drive.Td = false
entry.RemoveComponent(component.CounterDownType)
}
} else {
entry.AddComponent(component.CounterDownType, unsafe.Pointer(&component.CounterDown{
Val: QDJ_DELAY,
Step: w.Tick(),
}))
}
// if entry.HasComponent(component.CounterDownType) {
// cd := component.CounterDownType.Get(entry)
// if cd.Val <= 0 {
// drive.Td = false
// entry.RemoveComponent(component.CounterDownType)
// }
// } else {
// entry.AddComponent(component.CounterDownType, unsafe.Pointer(&component.CounterDown{
// Val: QDJ_DELAY,
// Step: w.Tick(),
// }))
// }
}
}
}