2023-09-05 14:47:38 +08:00
|
|
|
|
package system
|
|
|
|
|
|
2023-09-05 18:16:36 +08:00
|
|
|
|
import (
|
|
|
|
|
"github.com/yohamta/donburi/filter"
|
|
|
|
|
"joylink.club/ecs"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 继电器: true-吸合;false-未吸合
|
|
|
|
|
type SwitchZdj9State struct {
|
|
|
|
|
//定操继电器
|
|
|
|
|
DCJ bool
|
|
|
|
|
//反操继电器
|
|
|
|
|
FCJ bool
|
|
|
|
|
//允许操作继电器
|
|
|
|
|
YCJ bool
|
|
|
|
|
//总定表继电器
|
|
|
|
|
ZDBJ bool
|
|
|
|
|
//总反表继电器
|
|
|
|
|
ZFBJ bool
|
|
|
|
|
//表示电路变压器,将220V交流电变压后作为为道岔表示电路的电源
|
|
|
|
|
//0-无电源;规定52端子为正,则,1-输出瞬时正电压;-1 - 输出瞬时负电压
|
|
|
|
|
J1_BB int8
|
|
|
|
|
//道岔第一启动继电器
|
|
|
|
|
J1_1DQJ bool
|
2023-09-06 18:07:12 +08:00
|
|
|
|
//缓放剩余时间,单位ms
|
|
|
|
|
J1_1DQJ_ReleaseTime int64
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//道岔保护继电器
|
|
|
|
|
J1_BHJ bool
|
2023-09-06 18:07:12 +08:00
|
|
|
|
//缓放剩余时间,单位ms
|
|
|
|
|
J1_BHJ_ReleaseTime int64
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//道岔第二启动继电器
|
2023-09-06 18:07:12 +08:00
|
|
|
|
//true-吸起即1-3通;false-打落即1-2通
|
2023-09-05 18:16:36 +08:00
|
|
|
|
J1_2DQJ bool
|
|
|
|
|
//道岔第一启动继电器复示继电器
|
|
|
|
|
J1_1DQJF bool
|
|
|
|
|
//断相保护器
|
|
|
|
|
J1_DBQ DBQState
|
|
|
|
|
//定位表示继电器
|
|
|
|
|
J1_DBJ bool
|
|
|
|
|
//反位表示继电器
|
|
|
|
|
J1_FBJ bool
|
|
|
|
|
//道岔启动切断继电器
|
|
|
|
|
J1_QDJ bool
|
2023-09-06 18:07:12 +08:00
|
|
|
|
//缓放剩余时间,单位ms
|
|
|
|
|
J1_QDJ_ReleaseTime int64
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//道岔启动切断继电器的LC震荡电路保磁剩余时间,单位ms
|
|
|
|
|
//最长保持时长3000ms
|
|
|
|
|
J1_QDJ_LcTime int64
|
|
|
|
|
//总保护继电器
|
|
|
|
|
J1_ZBHJ bool
|
2023-09-06 18:07:12 +08:00
|
|
|
|
//缓放剩余时间,单位ms
|
|
|
|
|
J1_ZBHJ_ReleaseTime int64
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//表示电路变压器,将220V交流电变压后作为为道岔表示电路的电源
|
|
|
|
|
//0-无电源;规定52端子为正,则,1-输出瞬时正电压;-1 - 输出瞬时负电压
|
|
|
|
|
J2_BB int8
|
|
|
|
|
//道岔第一启动继电器
|
|
|
|
|
J2_1DQJ bool
|
2023-09-06 18:07:12 +08:00
|
|
|
|
//缓放剩余时间,单位ms
|
|
|
|
|
J2_1DQJ_ReleaseTime int64
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//道岔保护继电器
|
|
|
|
|
J2_BHJ bool
|
2023-09-06 18:07:12 +08:00
|
|
|
|
//缓放剩余时间,单位ms
|
|
|
|
|
J2_BHJ_ReleaseTime int64
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//道岔第二启动继电器
|
2023-09-06 18:07:12 +08:00
|
|
|
|
//true-吸起即1-3通;false-打落即1-2通
|
2023-09-05 18:16:36 +08:00
|
|
|
|
J2_2DQJ bool
|
|
|
|
|
//道岔第一启动继电器复示继电器
|
|
|
|
|
J2_1DQJF bool
|
|
|
|
|
//断相保护器
|
|
|
|
|
J2_DBQ DBQState
|
|
|
|
|
//定位表示继电器
|
|
|
|
|
J2_DBJ bool
|
|
|
|
|
//反位表示继电器
|
|
|
|
|
J2_FBJ bool
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 带限时功能断相保护器
|
|
|
|
|
// 限时13秒
|
|
|
|
|
type DBQState struct {
|
|
|
|
|
//是否缺相,true-缺相,false-三相电正常未缺相
|
|
|
|
|
PhaseLoss bool
|
|
|
|
|
//剩余限时时间,单位ms
|
|
|
|
|
LimitedTime int64
|
|
|
|
|
//当三相电正常时,断相保护器内的24V直流整流电路会正常输出24V直流电
|
|
|
|
|
//当三相电不正常如缺相时,断相保护器内的24V直流整流电路不会输出24V直流电
|
|
|
|
|
//BHJ道岔保护继电器的励磁线圈由该24V直流供电
|
|
|
|
|
Dc24Voltage bool
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-06 18:07:12 +08:00
|
|
|
|
const (
|
|
|
|
|
//JWXC-1700无极缓放继电器,缓放时间ms
|
|
|
|
|
JWXC_1700_RELEASE_TIME int64 = 300
|
|
|
|
|
//JWJXC-H125/80无极加强缓放继电器,缓放时间ms
|
|
|
|
|
JWJXC_H125_80_RELEASE_TIME int64 = 300
|
|
|
|
|
//QDJ 电源切断继电器LC震荡电路有效震荡时间ms
|
|
|
|
|
QDJ_LC_TIME int64 = 3000
|
|
|
|
|
//断相保护器限时,单位ms
|
|
|
|
|
DBQ_LIMITED_TIME = 13 * 1000
|
|
|
|
|
)
|
|
|
|
|
|
2023-09-05 18:16:36 +08:00
|
|
|
|
// 道岔ZDJ9电路状态组件
|
|
|
|
|
var SwitchZdj9StateComponent = ecs.NewComponentType[SwitchZdj9State]()
|
|
|
|
|
|
2023-09-05 14:47:38 +08:00
|
|
|
|
// ZDJ9道岔系统
|
|
|
|
|
type SwitchZdj9System struct {
|
2023-09-05 18:16:36 +08:00
|
|
|
|
zdj9Query *ecs.Query
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewSwitchZdj9System() *SwitchZdj9System {
|
|
|
|
|
return &SwitchZdj9System{zdj9Query: ecs.NewQuery(filter.Contains(SwitchZdj9StateComponent))}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// world 执行
|
|
|
|
|
func (me *SwitchZdj9System) Update(w ecs.World) {
|
|
|
|
|
me.zdj9Query.Each(w, func(e *ecs.Entry) {
|
|
|
|
|
zdj9State := SwitchZdj9StateComponent.Get(e)
|
|
|
|
|
//断相保护器电路
|
|
|
|
|
calculateDBQ(w, zdj9State)
|
|
|
|
|
//断相保护继电器励磁电路
|
|
|
|
|
calculateBHJ(w, zdj9State)
|
|
|
|
|
//总保护继电器励磁电路
|
|
|
|
|
calculateZBHJ(w, zdj9State)
|
|
|
|
|
//道岔转换启动切断继电器励磁电路
|
|
|
|
|
calculateQDJ(w, zdj9State)
|
2023-09-06 18:07:12 +08:00
|
|
|
|
//道岔第一启动继电器励磁电路
|
|
|
|
|
calculate1DQJ(w, zdj9State)
|
|
|
|
|
//道岔第一启动继电器复示继电器励磁电路
|
|
|
|
|
calculate1DQJF(w, zdj9State)
|
|
|
|
|
//道岔第二启动继电器励磁电路
|
|
|
|
|
calculate2DQJ(w, zdj9State)
|
|
|
|
|
//总定表/总反表继电器励磁电路
|
|
|
|
|
calculateZDBJ(w, zdj9State)
|
|
|
|
|
calculateZFBJ(w, zdj9State)
|
|
|
|
|
//道岔转辙机定表反表继电器励磁电路
|
|
|
|
|
calculateDBJ(w, zdj9State)
|
|
|
|
|
calculateFBJ(w, zdj9State)
|
2023-09-05 18:16:36 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 断相保护电路运算
|
|
|
|
|
func calculateDBQ(w ecs.World, state *SwitchZdj9State) {
|
|
|
|
|
if state.J1_DBQ.LimitedTime > 0 {
|
|
|
|
|
state.J1_DBQ.LimitedTime -= int64(w.Tick())
|
2023-09-06 18:07:12 +08:00
|
|
|
|
if state.J1_DBQ.LimitedTime < 0 {
|
|
|
|
|
state.J1_DBQ.LimitedTime = 0
|
|
|
|
|
}
|
2023-09-05 18:16:36 +08:00
|
|
|
|
}
|
|
|
|
|
state.J1_DBQ.Dc24Voltage = !state.J1_DBQ.PhaseLoss
|
|
|
|
|
//
|
|
|
|
|
if state.J2_DBQ.LimitedTime > 0 {
|
|
|
|
|
state.J2_DBQ.LimitedTime -= int64(w.Tick())
|
2023-09-06 18:07:12 +08:00
|
|
|
|
if state.J2_DBQ.LimitedTime < 0 {
|
|
|
|
|
state.J2_DBQ.LimitedTime = 0
|
|
|
|
|
}
|
2023-09-05 18:16:36 +08:00
|
|
|
|
}
|
|
|
|
|
state.J2_DBQ.Dc24Voltage = !state.J2_DBQ.PhaseLoss
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 断相保护继电器运算
|
2023-09-06 18:07:12 +08:00
|
|
|
|
// BHJ JWXC-1700无极缓放继电器
|
2023-09-05 18:16:36 +08:00
|
|
|
|
func calculateBHJ(w ecs.World, state *SwitchZdj9State) {
|
2023-09-06 18:07:12 +08:00
|
|
|
|
if state.J1_DBQ.Dc24Voltage {
|
|
|
|
|
state.J1_BHJ_ReleaseTime = JWXC_1700_RELEASE_TIME
|
|
|
|
|
} else {
|
|
|
|
|
if state.J1_BHJ_ReleaseTime > 0 {
|
|
|
|
|
state.J1_BHJ_ReleaseTime -= int64(w.Tick())
|
|
|
|
|
if state.J1_BHJ_ReleaseTime < 0 {
|
|
|
|
|
state.J1_BHJ_ReleaseTime = 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
state.J1_BHJ = state.J1_DBQ.Dc24Voltage || state.J1_BHJ_ReleaseTime > 0
|
|
|
|
|
//
|
|
|
|
|
if state.J2_DBQ.Dc24Voltage {
|
|
|
|
|
state.J2_BHJ_ReleaseTime = JWXC_1700_RELEASE_TIME
|
|
|
|
|
} else {
|
|
|
|
|
if state.J2_BHJ_ReleaseTime > 0 {
|
|
|
|
|
state.J2_BHJ_ReleaseTime -= int64(w.Tick())
|
|
|
|
|
if state.J2_BHJ_ReleaseTime < 0 {
|
|
|
|
|
state.J2_BHJ_ReleaseTime = 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
state.J2_BHJ = state.J2_DBQ.Dc24Voltage || state.J2_BHJ_ReleaseTime > 0
|
2023-09-05 18:16:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 总保护继电器运算
|
2023-09-06 18:07:12 +08:00
|
|
|
|
// ZBHJ JWXC-1700无极缓放继电器
|
2023-09-05 18:16:36 +08:00
|
|
|
|
func calculateZBHJ(w ecs.World, state *SwitchZdj9State) {
|
|
|
|
|
//励磁
|
2023-09-06 18:07:12 +08:00
|
|
|
|
method := state.J1_BHJ && state.J2_BHJ
|
|
|
|
|
//自闭
|
|
|
|
|
self := state.J1_ZBHJ && (state.J1_BHJ || state.J2_BHJ)
|
|
|
|
|
//
|
|
|
|
|
is := method || self
|
|
|
|
|
//缓放
|
|
|
|
|
if is {
|
|
|
|
|
state.J1_ZBHJ_ReleaseTime = JWXC_1700_RELEASE_TIME
|
|
|
|
|
} else {
|
|
|
|
|
if state.J1_ZBHJ_ReleaseTime > 0 {
|
|
|
|
|
state.J1_ZBHJ_ReleaseTime -= int64(w.Tick())
|
|
|
|
|
if state.J1_ZBHJ_ReleaseTime < 0 {
|
|
|
|
|
state.J1_ZBHJ_ReleaseTime = 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//为总保护继电器励磁
|
2023-09-06 18:07:12 +08:00
|
|
|
|
state.J1_ZBHJ = is || state.J1_ZBHJ_ReleaseTime > 0
|
2023-09-05 18:16:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔转换启动切断继电器运算
|
2023-09-06 18:07:12 +08:00
|
|
|
|
// QDJ JWXC-1700无极缓放继电器
|
2023-09-05 18:16:36 +08:00
|
|
|
|
func calculateQDJ(w ecs.World, state *SwitchZdj9State) {
|
|
|
|
|
//LC震荡电路运算
|
|
|
|
|
fullLc := (!state.J1_BHJ && !state.J2_BHJ) || state.J1_ZBHJ
|
|
|
|
|
if fullLc {
|
2023-09-06 18:07:12 +08:00
|
|
|
|
state.J1_QDJ_LcTime = QDJ_LC_TIME
|
2023-09-05 18:16:36 +08:00
|
|
|
|
} else {
|
2023-09-06 18:07:12 +08:00
|
|
|
|
if state.J1_QDJ_LcTime > 0 {
|
|
|
|
|
state.J1_QDJ_LcTime -= int64(w.Tick())
|
|
|
|
|
if state.J1_QDJ_LcTime < 0 {
|
|
|
|
|
state.J1_QDJ_LcTime = 0
|
|
|
|
|
}
|
2023-09-05 18:16:36 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//自闭励磁电路
|
|
|
|
|
self := state.J1_QDJ && state.J1_ZBHJ
|
2023-09-06 18:07:12 +08:00
|
|
|
|
//缓放
|
|
|
|
|
if self {
|
|
|
|
|
state.J1_QDJ_ReleaseTime = JWXC_1700_RELEASE_TIME
|
|
|
|
|
} else {
|
|
|
|
|
if state.J1_QDJ_ReleaseTime > 0 {
|
|
|
|
|
state.J1_QDJ_ReleaseTime -= int64(w.Tick())
|
|
|
|
|
if state.J1_QDJ_ReleaseTime < 0 {
|
|
|
|
|
state.J1_QDJ_ReleaseTime = 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//为启动切断继电器励磁
|
2023-09-06 18:07:12 +08:00
|
|
|
|
state.J1_QDJ = self || fullLc || state.J1_QDJ_LcTime > 0 || state.J1_QDJ_ReleaseTime > 0
|
2023-09-05 18:16:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔第一启动继电器运算
|
2023-09-06 18:07:12 +08:00
|
|
|
|
// 1DQJ JWJXC-H125/80无极加强缓放继电器
|
|
|
|
|
// J1先启动J2后启动
|
|
|
|
|
func calculate1DQJ(w ecs.World, state *SwitchZdj9State) {
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//励磁电路
|
|
|
|
|
j1DqjMethod1 := state.YCJ && (state.DCJ || state.FCJ)
|
|
|
|
|
//自闭电路
|
|
|
|
|
j1DqjSelf := state.J1_QDJ && state.J1_BHJ && state.J1_1DQJ
|
2023-09-06 18:07:12 +08:00
|
|
|
|
//缓放
|
|
|
|
|
j1DqjIs := j1DqjMethod1 || j1DqjSelf
|
|
|
|
|
if j1DqjIs {
|
|
|
|
|
state.J1_1DQJ_ReleaseTime = JWJXC_H125_80_RELEASE_TIME
|
|
|
|
|
} else {
|
|
|
|
|
if state.J1_1DQJ_ReleaseTime > 0 {
|
|
|
|
|
state.J1_1DQJ_ReleaseTime -= int64(w.Tick())
|
|
|
|
|
if state.J1_1DQJ_ReleaseTime < 0 {
|
|
|
|
|
state.J1_1DQJ_ReleaseTime = 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//为J1第一启动继电器励磁
|
2023-09-06 18:07:12 +08:00
|
|
|
|
state.J1_1DQJ = j1DqjIs || state.J1_1DQJ_ReleaseTime > 0
|
|
|
|
|
//
|
|
|
|
|
//自闭电路
|
|
|
|
|
j2DqjSelf := state.J1_QDJ && state.J2_BHJ && state.J2_1DQJ
|
|
|
|
|
//励磁电路
|
|
|
|
|
j2DqjMethod1 := state.YCJ && state.J1_1DQJ && (state.DCJ || state.FCJ)
|
|
|
|
|
//缓放
|
|
|
|
|
j2DqjIs := j2DqjMethod1 || j2DqjSelf
|
|
|
|
|
if j2DqjIs {
|
|
|
|
|
state.J2_1DQJ_ReleaseTime = JWJXC_H125_80_RELEASE_TIME
|
|
|
|
|
} else {
|
|
|
|
|
if state.J2_1DQJ_ReleaseTime > 0 {
|
|
|
|
|
state.J2_1DQJ_ReleaseTime -= int64(w.Tick())
|
|
|
|
|
if state.J2_1DQJ_ReleaseTime < 0 {
|
|
|
|
|
state.J2_1DQJ_ReleaseTime = 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//为J2第一启动继电器励磁
|
|
|
|
|
state.J2_1DQJ = j2DqjIs || state.J2_1DQJ_ReleaseTime > 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔第一启动继电器复示继电器运算
|
|
|
|
|
// 1DQJF JWJXC-480无极继电器
|
|
|
|
|
func calculate1DQJF(w ecs.World, state *SwitchZdj9State) {
|
|
|
|
|
state.J1_1DQJF = state.J1_1DQJ
|
|
|
|
|
state.J2_1DQJF = state.J2_1DQJ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔第二启动继电器运算
|
|
|
|
|
// 2DQJ JYJXC-160/260有极加强继电器
|
|
|
|
|
// 2DQJ为有极继电器,根据线圈中电流极性不同具有 定位和反位 两种稳定状态,这两种稳定状态当线圈中电流消失时仍能继续保持;
|
|
|
|
|
// 在线圈中通以规定极性的电流时,继电器吸起,断电后仍保持在吸起位置;通以反方向电流时,继电器打落,断电后保持在打落位置;
|
|
|
|
|
// 断电保持由磁路系统中的一块长条形永久磁铁取代了大部分轭铁来实现;
|
|
|
|
|
// 电流3->4吸起,电流2->1打落,如果21和34同时通过电流时磁场相互抵消则继电器保持原来状态不变
|
|
|
|
|
func calculate2DQJ(w ecs.World, state *SwitchZdj9State) {
|
|
|
|
|
//J1-2DQJ
|
|
|
|
|
j1_2dqj_21 := state.J1_1DQJF && state.FCJ
|
|
|
|
|
j1_2dqj_34 := state.J1_1DQJF && state.DCJ
|
|
|
|
|
//磁通量,矢量
|
|
|
|
|
var j12dqj int8 = 0
|
|
|
|
|
if j1_2dqj_34 {
|
|
|
|
|
j12dqj++
|
|
|
|
|
}
|
|
|
|
|
if j1_2dqj_21 {
|
|
|
|
|
j12dqj--
|
|
|
|
|
}
|
|
|
|
|
if j12dqj != 0 {
|
|
|
|
|
state.J1_2DQJ = j12dqj > 0
|
|
|
|
|
}
|
|
|
|
|
//J2-2DQJ
|
|
|
|
|
j2_2dqj_21 := state.J2_1DQJF && state.FCJ
|
|
|
|
|
j2_2dqj_34 := state.J2_1DQJF && state.DCJ
|
|
|
|
|
//磁通量,矢量
|
|
|
|
|
var j22dqj int8 = 0
|
|
|
|
|
if j2_2dqj_34 {
|
|
|
|
|
j22dqj++
|
|
|
|
|
}
|
|
|
|
|
if j2_2dqj_21 {
|
|
|
|
|
j22dqj--
|
|
|
|
|
}
|
|
|
|
|
if j22dqj != 0 {
|
|
|
|
|
state.J2_2DQJ = j22dqj > 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔总定表继电器运算
|
|
|
|
|
// ZDBJ JPXC-1000 偏极继电器是为了鉴别信号电路中的电流极性而设计
|
|
|
|
|
// 继电器在磁路中增加一个偏极磁钢,使衔铁受永磁力的作用而偏于落下位置。衔铁的吸起与线圈中的电流的极性有关,
|
|
|
|
|
// 通过线圈的电流为规定的方向时,衔铁才吸起,而电流的方向相反时,衔铁保持不动。
|
|
|
|
|
// 它只具有一种稳定状态,即衔铁靠电磁力吸起后,断电即落下,始终偏向落下的定位状态
|
|
|
|
|
func calculateZDBJ(w ecs.World, state *SwitchZdj9State) {
|
|
|
|
|
state.ZDBJ = state.J1_DBJ && state.J2_DBJ
|
|
|
|
|
}
|
|
|
|
|
func calculateZFBJ(w ecs.World, state *SwitchZdj9State) {
|
|
|
|
|
state.ZFBJ = state.J1_FBJ && state.J2_FBJ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔定表继电器运算
|
|
|
|
|
// DBJ JPXC-1000 偏极继电器
|
|
|
|
|
func calculateDBJ(w ecs.World, state *SwitchZdj9State) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔反表继电器运算
|
|
|
|
|
// FBJ JPXC-1000 偏极继电器
|
|
|
|
|
func calculateFBJ(w ecs.World, state *SwitchZdj9State) {
|
2023-09-05 18:16:36 +08:00
|
|
|
|
|
2023-09-05 14:47:38 +08:00
|
|
|
|
}
|