2023-09-05 14:47:38 +08:00
|
|
|
|
package system
|
|
|
|
|
|
2023-09-05 18:16:36 +08:00
|
|
|
|
import (
|
2023-09-13 14:19:03 +08:00
|
|
|
|
"fmt"
|
|
|
|
|
|
2023-09-05 18:16:36 +08:00
|
|
|
|
"github.com/yohamta/donburi/filter"
|
|
|
|
|
"joylink.club/ecs"
|
2023-09-13 14:19:03 +08:00
|
|
|
|
sysEvent "joylink.club/rtsssimulation/system/event"
|
|
|
|
|
"joylink.club/rtsssimulation/umi"
|
2023-09-05 18:16:36 +08:00
|
|
|
|
)
|
|
|
|
|
|
2023-09-11 13:33:01 +08:00
|
|
|
|
// 双机ZDJ9道岔电路系统状态定义
|
2023-09-05 18:16:36 +08:00
|
|
|
|
// 继电器: true-吸合;false-未吸合
|
2023-09-11 13:33:01 +08:00
|
|
|
|
type Switch2jZdj9State struct {
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//定操继电器
|
|
|
|
|
DCJ bool
|
|
|
|
|
//反操继电器
|
|
|
|
|
FCJ bool
|
|
|
|
|
//允许操作继电器
|
|
|
|
|
YCJ bool
|
|
|
|
|
//总定表继电器
|
|
|
|
|
ZDBJ bool
|
|
|
|
|
//总反表继电器
|
|
|
|
|
ZFBJ bool
|
|
|
|
|
//道岔第一启动继电器
|
|
|
|
|
J1_1DQJ bool
|
|
|
|
|
//道岔保护继电器
|
|
|
|
|
J1_BHJ bool
|
|
|
|
|
//道岔第二启动继电器
|
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
|
2023-09-14 13:52:36 +08:00
|
|
|
|
//true-2DQJ由落下转换到吸起,即定操
|
|
|
|
|
J1_2DQJ_ToD bool
|
|
|
|
|
//true-2DQJ由吸起转换到落下,即反操
|
|
|
|
|
J1_2DQJ_ToF bool
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//道岔第一启动继电器复示继电器
|
|
|
|
|
J1_1DQJF bool
|
|
|
|
|
//断相保护器
|
|
|
|
|
J1_DBQ DBQState
|
|
|
|
|
//定位表示继电器
|
|
|
|
|
J1_DBJ bool
|
2023-09-07 17:59:38 +08:00
|
|
|
|
//true-当道岔转换到定位时,转辙机内端子9与电路接通;false-转辙机内端子9断开切断电路
|
|
|
|
|
J1_DB_K9 bool
|
|
|
|
|
//转辙机内部自动开闭器
|
|
|
|
|
//true-接通1、3排表示电路,用于定操;false-接通2、4排表示电路,用于反操
|
|
|
|
|
J1_AKB bool
|
|
|
|
|
//道岔电机1的电源
|
|
|
|
|
J1_Power Switch380ACPower
|
|
|
|
|
//电机线圈相电流
|
|
|
|
|
J1_U1 Switch380ACPhase
|
|
|
|
|
J1_V1 Switch380ACPhase
|
|
|
|
|
J1_W1 Switch380ACPhase
|
2023-09-13 18:03:55 +08:00
|
|
|
|
//电机输出牵引力,大于0表示正转即定操,小于0表示反转即反操,等于0表示不转
|
|
|
|
|
J1_Traction int8
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//反位表示继电器
|
|
|
|
|
J1_FBJ bool
|
2023-09-07 17:59:38 +08:00
|
|
|
|
//true-当道岔转换到反位时,转辙机内端子10与电路接通;false-转辙机内端子10断开切断电路
|
|
|
|
|
J1_FB_K10 bool
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//道岔启动切断继电器
|
|
|
|
|
J1_QDJ bool
|
|
|
|
|
//道岔启动切断继电器的LC震荡电路保磁剩余时间,单位ms
|
|
|
|
|
//最长保持时长3000ms
|
|
|
|
|
J1_QDJ_LcTime int64
|
|
|
|
|
//总保护继电器
|
|
|
|
|
J1_ZBHJ bool
|
|
|
|
|
//道岔第一启动继电器
|
|
|
|
|
J2_1DQJ bool
|
|
|
|
|
//道岔保护继电器
|
|
|
|
|
J2_BHJ bool
|
|
|
|
|
//道岔第二启动继电器
|
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
|
2023-09-14 13:52:36 +08:00
|
|
|
|
//true-2DQJ由落下转换到吸起,即定操
|
|
|
|
|
J2_2DQJ_ToD bool
|
|
|
|
|
//true-2DQJ由吸起转换到落下,即反操
|
|
|
|
|
J2_2DQJ_ToF bool
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//道岔第一启动继电器复示继电器
|
|
|
|
|
J2_1DQJF bool
|
|
|
|
|
//断相保护器
|
|
|
|
|
J2_DBQ DBQState
|
|
|
|
|
//定位表示继电器
|
|
|
|
|
J2_DBJ bool
|
2023-09-07 17:59:38 +08:00
|
|
|
|
//true-当道岔转换到定位时,转辙机内端子9与电路接通;false-转辙机内端子9断开切断电路
|
|
|
|
|
J2_DB_K9 bool
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//反位表示继电器
|
|
|
|
|
J2_FBJ bool
|
2023-09-07 17:59:38 +08:00
|
|
|
|
//true-当道岔转换到反位时,转辙机内端子10与电路接通;false-转辙机内端子10断开切断电路
|
|
|
|
|
J2_FB_K10 bool
|
|
|
|
|
//转辙机内部自动开闭器
|
|
|
|
|
//true-接通1、3排表示电路,用于定操;false-接通2、4排表示电路,用于反操
|
|
|
|
|
J2_AKB bool
|
|
|
|
|
//道岔电机2的电源
|
|
|
|
|
J2_Power Switch380ACPower
|
|
|
|
|
//电机线圈相电流
|
|
|
|
|
J2_U1 Switch380ACPhase
|
|
|
|
|
J2_V1 Switch380ACPhase
|
|
|
|
|
J2_W1 Switch380ACPhase
|
|
|
|
|
//电机转速,大于0表示正转即定操,小于0表示反转即反操,等于0表示不转
|
2023-09-13 18:03:55 +08:00
|
|
|
|
J2_Traction int8
|
2023-09-05 18:16:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-08 11:24:06 +08:00
|
|
|
|
// 创建ZDJ9道岔状态并初始化
|
2023-09-11 13:33:01 +08:00
|
|
|
|
func NewSwitch2jZdj9State() *Switch2jZdj9State {
|
|
|
|
|
return &Switch2jZdj9State{
|
2023-09-13 13:33:47 +08:00
|
|
|
|
DCJ: false,
|
|
|
|
|
FCJ: false,
|
|
|
|
|
YCJ: false,
|
|
|
|
|
ZDBJ: true,
|
|
|
|
|
ZFBJ: false,
|
|
|
|
|
J1_1DQJ: false,
|
|
|
|
|
J1_BHJ: false,
|
|
|
|
|
J1_2DQJ: true,
|
2023-09-14 13:52:36 +08:00
|
|
|
|
J1_2DQJ_ToD: false,
|
|
|
|
|
J1_2DQJ_ToF: false,
|
2023-09-13 13:33:47 +08:00
|
|
|
|
J1_1DQJF: false,
|
|
|
|
|
J1_DBQ: DBQState{PhaseLoss: true, LimitedTime: 0, Dc24Voltage: false},
|
|
|
|
|
J1_DBJ: true,
|
|
|
|
|
J1_DB_K9: true,
|
|
|
|
|
J1_AKB: true,
|
2023-09-14 13:52:36 +08:00
|
|
|
|
J1_Power: Switch380ACPower{Active: false, PhaseA: false, PhaseB: false, PhaseC: false},
|
2023-09-13 13:33:47 +08:00
|
|
|
|
J1_U1: ACPahseN,
|
|
|
|
|
J1_V1: ACPahseN,
|
|
|
|
|
J1_W1: ACPahseN,
|
2023-09-13 18:03:55 +08:00
|
|
|
|
J1_Traction: 0,
|
2023-09-13 13:33:47 +08:00
|
|
|
|
J1_FBJ: false,
|
|
|
|
|
J1_FB_K10: false,
|
|
|
|
|
J1_QDJ: true,
|
|
|
|
|
J1_QDJ_LcTime: 0,
|
|
|
|
|
J1_ZBHJ: false,
|
|
|
|
|
J2_1DQJ: false,
|
|
|
|
|
J2_BHJ: false,
|
|
|
|
|
J2_2DQJ: true,
|
2023-09-14 13:52:36 +08:00
|
|
|
|
J2_2DQJ_ToD: false,
|
|
|
|
|
J2_2DQJ_ToF: false,
|
2023-09-13 13:33:47 +08:00
|
|
|
|
J2_1DQJF: false,
|
|
|
|
|
J2_DBQ: DBQState{PhaseLoss: true, LimitedTime: 0, Dc24Voltage: false},
|
|
|
|
|
J2_DBJ: true,
|
|
|
|
|
J2_DB_K9: true,
|
|
|
|
|
J2_FBJ: false,
|
|
|
|
|
J2_FB_K10: false,
|
|
|
|
|
J2_AKB: true,
|
2023-09-14 13:52:36 +08:00
|
|
|
|
J2_Power: Switch380ACPower{Active: false, PhaseA: false, PhaseB: false, PhaseC: false},
|
2023-09-13 13:33:47 +08:00
|
|
|
|
J2_U1: ACPahseN,
|
|
|
|
|
J2_V1: ACPahseN,
|
|
|
|
|
J2_W1: ACPahseN,
|
2023-09-13 18:03:55 +08:00
|
|
|
|
J2_Traction: 0,
|
2023-09-08 11:24:06 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-05 18:16:36 +08:00
|
|
|
|
// 带限时功能断相保护器
|
|
|
|
|
// 限时13秒
|
|
|
|
|
type DBQState struct {
|
|
|
|
|
//是否缺相,true-缺相,false-三相电正常未缺相
|
|
|
|
|
PhaseLoss bool
|
|
|
|
|
//剩余限时时间,单位ms
|
|
|
|
|
LimitedTime int64
|
|
|
|
|
//当三相电正常时,断相保护器内的24V直流整流电路会正常输出24V直流电
|
|
|
|
|
//当三相电不正常如缺相时,断相保护器内的24V直流整流电路不会输出24V直流电
|
|
|
|
|
//BHJ道岔保护继电器的励磁线圈由该24V直流供电
|
|
|
|
|
Dc24Voltage bool
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-07 17:59:38 +08:00
|
|
|
|
// 表示电路变压器,变压比2:1,将220V交流电变压后作为为道岔表示电路的电源
|
|
|
|
|
// 0-无电源;规定52端子为正,则,1-输出瞬时正电压;-1 - 输出瞬时负电压
|
|
|
|
|
type SwitchBB struct {
|
|
|
|
|
//true-变压器初级输入正常
|
|
|
|
|
InDj220V bool
|
|
|
|
|
//次级输出电压
|
|
|
|
|
//0-无电源;规定52端子为正,则,1-输出瞬时正电压;-1 - 输出瞬时负电压
|
|
|
|
|
OutBb int8
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔380V动力交流电源
|
|
|
|
|
type Switch380ACPower struct {
|
2023-09-14 13:52:36 +08:00
|
|
|
|
//true-激活
|
|
|
|
|
Active bool
|
2023-09-07 17:59:38 +08:00
|
|
|
|
//true-A相电正常输出
|
|
|
|
|
PhaseA bool
|
|
|
|
|
//true-B相电正常输出
|
|
|
|
|
PhaseB bool
|
|
|
|
|
//true-C相电正常输出
|
|
|
|
|
PhaseC bool
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔380V动力交流电相位定义
|
|
|
|
|
type Switch380ACPhase int8
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
//不存在相位交流电
|
|
|
|
|
ACPahseN Switch380ACPhase = iota
|
|
|
|
|
//存在A相位交流电
|
|
|
|
|
ACPahseA
|
|
|
|
|
//存在B相位交流电
|
|
|
|
|
ACPahseB
|
|
|
|
|
//存在C相位交流电
|
|
|
|
|
ACPahseC
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 继电器常量定义
|
2023-09-06 18:07:12 +08:00
|
|
|
|
const (
|
|
|
|
|
//QDJ 电源切断继电器LC震荡电路有效震荡时间ms
|
|
|
|
|
QDJ_LC_TIME int64 = 3000
|
|
|
|
|
//断相保护器限时,单位ms
|
|
|
|
|
DBQ_LIMITED_TIME = 13 * 1000
|
|
|
|
|
)
|
|
|
|
|
|
2023-09-05 18:16:36 +08:00
|
|
|
|
// 道岔ZDJ9电路状态组件
|
2023-09-11 13:33:01 +08:00
|
|
|
|
var Switch2jZdj9StateComponent = ecs.NewComponentType[Switch2jZdj9State]()
|
2023-09-05 18:16:36 +08:00
|
|
|
|
|
2023-09-13 14:19:03 +08:00
|
|
|
|
// zdj9查询
|
|
|
|
|
var zdj9Query = ecs.NewQuery(filter.Contains(EntityIdentityComponent, Switch2jZdj9StateComponent))
|
|
|
|
|
|
2023-09-13 18:03:55 +08:00
|
|
|
|
// 双机ZDJ9道岔系统
|
|
|
|
|
type Switch2jZdj9System struct {
|
2023-09-05 18:16:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-13 18:03:55 +08:00
|
|
|
|
// 双机ZDJ9道岔系统
|
|
|
|
|
func NewSwitch2jZdj9System() *Switch2jZdj9System {
|
|
|
|
|
return &Switch2jZdj9System{}
|
2023-09-13 14:20:12 +08:00
|
|
|
|
}
|
2023-09-05 18:16:36 +08:00
|
|
|
|
|
|
|
|
|
// world 执行
|
2023-09-13 18:03:55 +08:00
|
|
|
|
func (me *Switch2jZdj9System) Update(w ecs.World) {
|
2023-09-13 14:19:03 +08:00
|
|
|
|
zdj9Query.Each(w, func(e *ecs.Entry) {
|
2023-09-11 13:33:01 +08:00
|
|
|
|
zdj9State := Switch2jZdj9StateComponent.Get(e)
|
2023-09-14 13:52:36 +08:00
|
|
|
|
//电机电源
|
|
|
|
|
me.calculateJPower(w, e, zdj9State)
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//断相保护器电路
|
2023-09-13 15:16:16 +08:00
|
|
|
|
me.calculateDBQ(w, e, zdj9State)
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//断相保护继电器励磁电路
|
2023-09-13 15:16:16 +08:00
|
|
|
|
me.calculateBHJ(w, e, zdj9State)
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//总保护继电器励磁电路
|
2023-09-13 15:16:16 +08:00
|
|
|
|
me.calculateZBHJ(w, e, zdj9State)
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//道岔转换启动切断继电器励磁电路
|
2023-09-13 15:16:16 +08:00
|
|
|
|
me.calculateQDJ(w, e, zdj9State)
|
2023-09-06 18:07:12 +08:00
|
|
|
|
//道岔第一启动继电器励磁电路
|
2023-09-13 15:16:16 +08:00
|
|
|
|
me.calculate1DQJ(w, e, zdj9State)
|
2023-09-06 18:07:12 +08:00
|
|
|
|
//道岔第一启动继电器复示继电器励磁电路
|
2023-09-13 15:16:16 +08:00
|
|
|
|
me.calculate1DQJF(w, e, zdj9State)
|
2023-09-06 18:07:12 +08:00
|
|
|
|
//道岔第二启动继电器励磁电路
|
2023-09-13 15:16:16 +08:00
|
|
|
|
me.calculate2DQJ(w, e, zdj9State)
|
2023-09-11 13:33:01 +08:00
|
|
|
|
//转辙机内自动开闭器
|
2023-09-13 15:16:16 +08:00
|
|
|
|
me.calculateAKB(w, e, zdj9State)
|
2023-09-06 18:07:12 +08:00
|
|
|
|
//道岔转辙机定表反表继电器励磁电路
|
2023-09-13 15:16:16 +08:00
|
|
|
|
me.calculateDBJ(w, e, zdj9State)
|
|
|
|
|
me.calculateFBJ(w, e, zdj9State)
|
2023-09-11 13:33:01 +08:00
|
|
|
|
//总定表/总反表继电器励磁电路
|
2023-09-13 15:16:16 +08:00
|
|
|
|
me.calculateZDBJ(w, e, zdj9State)
|
|
|
|
|
me.calculateZFBJ(w, e, zdj9State)
|
2023-09-07 17:59:38 +08:00
|
|
|
|
//道岔转辙机内电机驱动电路
|
2023-09-13 15:16:16 +08:00
|
|
|
|
me.calculateMotor(w, e, zdj9State)
|
2023-09-13 18:03:55 +08:00
|
|
|
|
me.calculateMove(w, e, zdj9State)
|
|
|
|
|
me.calculateK9K10(w, e, zdj9State)
|
2023-09-05 18:16:36 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-13 15:16:16 +08:00
|
|
|
|
// SJZDJ9双机zdj9
|
|
|
|
|
const (
|
|
|
|
|
//继电器组合类型
|
|
|
|
|
SJZDJ9_TDC = "TDC"
|
|
|
|
|
SJZDJ9_TDFJ1 = "TDFJ1"
|
|
|
|
|
SJZDJ9_TDFJ2 = "TDFJ2"
|
|
|
|
|
//继电器功能名称
|
|
|
|
|
SJZDJ9_1DQJ = "1DQJ"
|
|
|
|
|
SJZDJ9_BHJ = "BHJ"
|
|
|
|
|
SJZDJ9_2DQJ = "2DQJ"
|
|
|
|
|
SJZDJ9_1DQJF = "1DQJF"
|
|
|
|
|
SJZDJ9_DBJ = "DBJ"
|
|
|
|
|
SJZDJ9_FBJ = "FBJ"
|
|
|
|
|
SJZDJ9_QDJ = "QDJ"
|
|
|
|
|
SJZDJ9_ZBHJ = "ZBHJ"
|
|
|
|
|
SJZDJ9_DCJ = "DCJ"
|
|
|
|
|
SJZDJ9_FCJ = "FCJ"
|
|
|
|
|
SJZDJ9_YCJ = "YCJ"
|
|
|
|
|
SJZDJ9_ZDBJ = "ZDBJ"
|
|
|
|
|
SJZDJ9_ZFBJ = "ZFBJ"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 接收继电器动作事件
|
2023-09-13 14:19:03 +08:00
|
|
|
|
var Switch2jzdj9RelayActionEventProcessor = func(w ecs.World, event sysEvent.RelayActionEvent) {
|
|
|
|
|
zdj9Query.Each(w, func(e *ecs.Entry) {
|
|
|
|
|
switchModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
|
|
|
|
roler, ok := switchModel.(umi.IRelayCRole)
|
|
|
|
|
if ok {
|
|
|
|
|
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
|
|
|
|
state := Switch2jZdj9StateComponent.Get(e)
|
|
|
|
|
switch relayGroup {
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_TDC:
|
2023-09-13 14:19:03 +08:00
|
|
|
|
{
|
2023-09-13 14:20:12 +08:00
|
|
|
|
switch relayName {
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_DCJ:
|
2023-09-13 14:20:12 +08:00
|
|
|
|
state.DCJ = event.Xh
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_FCJ:
|
2023-09-13 14:20:12 +08:00
|
|
|
|
state.FCJ = event.Xh
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_YCJ:
|
2023-09-13 14:20:12 +08:00
|
|
|
|
state.YCJ = event.Xh
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_ZDBJ:
|
2023-09-13 14:20:12 +08:00
|
|
|
|
state.ZDBJ = event.Xh
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_ZFBJ:
|
2023-09-13 14:20:12 +08:00
|
|
|
|
state.ZFBJ = event.Xh
|
|
|
|
|
default:
|
|
|
|
|
panic(fmt.Sprintf("SwitchZdj9的模型[%s]中继电器功能名称[%s]无法识别", switchModel.GetId(), relayName))
|
|
|
|
|
}
|
2023-09-13 14:19:03 +08:00
|
|
|
|
}
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_TDFJ1:
|
2023-09-13 14:19:03 +08:00
|
|
|
|
{
|
|
|
|
|
switch relayName {
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_1DQJ:
|
2023-09-13 14:19:03 +08:00
|
|
|
|
state.J1_1DQJ = event.Xh
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_BHJ:
|
2023-09-13 14:19:03 +08:00
|
|
|
|
state.J1_BHJ = event.Xh
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_2DQJ:
|
2023-09-14 13:52:36 +08:00
|
|
|
|
{
|
|
|
|
|
state.J1_2DQJ_ToD = !state.J1_2DQJ && event.Xh
|
|
|
|
|
state.J1_2DQJ_ToF = state.J1_2DQJ && !event.Xh
|
|
|
|
|
state.J1_2DQJ = event.Xh
|
|
|
|
|
}
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_1DQJF:
|
2023-09-13 14:19:03 +08:00
|
|
|
|
state.J1_1DQJF = event.Xh
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_DBJ:
|
2023-09-13 14:19:03 +08:00
|
|
|
|
state.J1_DBJ = event.Xh
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_FBJ:
|
2023-09-13 14:19:03 +08:00
|
|
|
|
state.J1_FBJ = event.Xh
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_QDJ:
|
2023-09-13 14:19:03 +08:00
|
|
|
|
state.J1_QDJ = event.Xh
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_ZBHJ:
|
2023-09-13 14:19:03 +08:00
|
|
|
|
state.J1_ZBHJ = event.Xh
|
|
|
|
|
default:
|
|
|
|
|
panic(fmt.Sprintf("SwitchZdj9的模型[%s]中继电器功能名称[%s]无法识别", switchModel.GetId(), relayName))
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_TDFJ2:
|
2023-09-13 14:19:03 +08:00
|
|
|
|
{
|
|
|
|
|
switch relayName {
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_1DQJ:
|
2023-09-13 14:19:03 +08:00
|
|
|
|
state.J2_1DQJ = event.Xh
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_BHJ:
|
2023-09-13 14:19:03 +08:00
|
|
|
|
state.J2_BHJ = event.Xh
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_2DQJ:
|
2023-09-14 13:52:36 +08:00
|
|
|
|
{
|
|
|
|
|
state.J2_2DQJ_ToD = !state.J2_2DQJ && event.Xh
|
|
|
|
|
state.J2_2DQJ_ToF = state.J2_2DQJ && !event.Xh
|
|
|
|
|
state.J2_2DQJ = event.Xh
|
|
|
|
|
}
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_1DQJF:
|
2023-09-13 14:19:03 +08:00
|
|
|
|
state.J2_1DQJF = event.Xh
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_DBJ:
|
2023-09-13 14:19:03 +08:00
|
|
|
|
state.J2_DBJ = event.Xh
|
2023-09-13 15:16:16 +08:00
|
|
|
|
case SJZDJ9_FBJ:
|
2023-09-13 14:19:03 +08:00
|
|
|
|
state.J2_FBJ = event.Xh
|
|
|
|
|
default:
|
|
|
|
|
panic(fmt.Sprintf("SwitchZdj9的模型[%s]中继电器功能名称[%s]无法识别", switchModel.GetId(), relayName))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
panic(fmt.Sprintf("SwitchZdj9的模型[%s]中继电器组合类型[%s]无法识别", switchModel.GetId(), relayGroup))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
panic("SwitchZdj9的模型未实现接口umi.IRelayCRoler")
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-13 15:16:16 +08:00
|
|
|
|
// 发送继电器需要改变事件
|
2023-09-13 18:03:55 +08:00
|
|
|
|
func (me *Switch2jZdj9System) publishRelayNeedChangeEvent(w ecs.World, switchEntry *ecs.Entry, relayGroup string, relayName string, needXh bool) {
|
2023-09-13 15:16:16 +08:00
|
|
|
|
switchModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(switchEntry).Id)
|
|
|
|
|
relayRole, _ := switchModel.(umi.IRelayCRole)
|
|
|
|
|
relayModel := relayRole.FindRelayModelByCRole(relayGroup, relayName)
|
|
|
|
|
sysEvent.RelayNeedChangeEventBus.Publish(w, &sysEvent.RelayNeedChangeEvent{Id: relayModel.GetId(), Xh: needXh})
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-05 18:16:36 +08:00
|
|
|
|
// 断相保护电路运算
|
2023-09-13 18:03:55 +08:00
|
|
|
|
func (me *Switch2jZdj9System) calculateDBQ(w ecs.World, switchEntry *ecs.Entry, state *Switch2jZdj9State) {
|
2023-09-05 18:16:36 +08:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
//
|
2023-09-07 17:59:38 +08:00
|
|
|
|
state.J1_DBQ.PhaseLoss = !state.J1_Power.PhaseA || !state.J1_Power.PhaseB || !state.J1_Power.PhaseC
|
|
|
|
|
//
|
|
|
|
|
state.J1_DBQ.Dc24Voltage = !state.J1_DBQ.PhaseLoss
|
|
|
|
|
///////////////////////////////////////////////////
|
2023-09-05 18:16:36 +08:00
|
|
|
|
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
|
|
|
|
}
|
2023-09-07 17:59:38 +08:00
|
|
|
|
//
|
|
|
|
|
state.J2_DBQ.PhaseLoss = !state.J2_Power.PhaseA || !state.J2_Power.PhaseB || !state.J2_Power.PhaseC
|
|
|
|
|
//
|
2023-09-05 18:16:36 +08:00
|
|
|
|
state.J2_DBQ.Dc24Voltage = !state.J2_DBQ.PhaseLoss
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 13:33:01 +08:00
|
|
|
|
// 转辙机内自动开闭器动作实现
|
|
|
|
|
// 暂时规定:自动开闭器跟随2DQJ
|
2023-09-13 18:03:55 +08:00
|
|
|
|
func (me *Switch2jZdj9System) calculateAKB(w ecs.World, switchEntry *ecs.Entry, state *Switch2jZdj9State) {
|
2023-09-11 13:33:01 +08:00
|
|
|
|
state.J1_AKB = state.J1_2DQJ
|
|
|
|
|
state.J2_AKB = state.J2_2DQJ
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-05 18:16:36 +08:00
|
|
|
|
// 断相保护继电器运算
|
2023-09-06 18:07:12 +08:00
|
|
|
|
// BHJ JWXC-1700无极缓放继电器
|
2023-09-13 18:03:55 +08:00
|
|
|
|
func (me *Switch2jZdj9System) calculateBHJ(w ecs.World, switchEntry *ecs.Entry, state *Switch2jZdj9State) {
|
2023-09-13 15:16:16 +08:00
|
|
|
|
_J1_BHJ := state.J1_DBQ.Dc24Voltage
|
|
|
|
|
_J2_BHJ := state.J2_DBQ.Dc24Voltage
|
|
|
|
|
if _J1_BHJ != state.J1_BHJ {
|
|
|
|
|
me.publishRelayNeedChangeEvent(w, switchEntry, SJZDJ9_TDFJ1, SJZDJ9_BHJ, _J1_BHJ)
|
|
|
|
|
}
|
|
|
|
|
if _J2_BHJ != state.J2_BHJ {
|
|
|
|
|
me.publishRelayNeedChangeEvent(w, switchEntry, SJZDJ9_TDFJ2, SJZDJ9_BHJ, _J2_BHJ)
|
|
|
|
|
}
|
2023-09-05 18:16:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 总保护继电器运算
|
2023-09-06 18:07:12 +08:00
|
|
|
|
// ZBHJ JWXC-1700无极缓放继电器
|
2023-09-13 18:03:55 +08:00
|
|
|
|
func (me *Switch2jZdj9System) calculateZBHJ(w ecs.World, switchEntry *ecs.Entry, state *Switch2jZdj9State) {
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//励磁
|
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)
|
|
|
|
|
//
|
2023-09-13 15:16:16 +08:00
|
|
|
|
_J1_ZBHJ := method || self
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//为总保护继电器励磁
|
2023-09-13 15:16:16 +08:00
|
|
|
|
if _J1_ZBHJ != state.J1_ZBHJ {
|
|
|
|
|
me.publishRelayNeedChangeEvent(w, switchEntry, SJZDJ9_TDFJ1, SJZDJ9_ZBHJ, _J1_ZBHJ)
|
|
|
|
|
}
|
2023-09-05 18:16:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔转换启动切断继电器运算
|
2023-09-06 18:07:12 +08:00
|
|
|
|
// QDJ JWXC-1700无极缓放继电器
|
2023-09-13 18:03:55 +08:00
|
|
|
|
func (me *Switch2jZdj9System) calculateQDJ(w ecs.World, switchEntry *ecs.Entry, state *Switch2jZdj9State) {
|
2023-09-05 18:16:36 +08:00
|
|
|
|
//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-13 15:16:16 +08:00
|
|
|
|
_J1_QDJ := self || fullLc || state.J1_QDJ_LcTime > 0
|
|
|
|
|
if _J1_QDJ != state.J1_QDJ {
|
|
|
|
|
me.publishRelayNeedChangeEvent(w, switchEntry, SJZDJ9_TDFJ1, SJZDJ9_QDJ, _J1_QDJ)
|
|
|
|
|
}
|
2023-09-05 18:16:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔第一启动继电器运算
|
2023-09-06 18:07:12 +08:00
|
|
|
|
// 1DQJ JWJXC-H125/80无极加强缓放继电器
|
|
|
|
|
// J1先启动J2后启动
|
2023-09-13 18:03:55 +08:00
|
|
|
|
func (me *Switch2jZdj9System) calculate1DQJ(w ecs.World, switchEntry *ecs.Entry, state *Switch2jZdj9State) {
|
2023-09-06 18:07:12 +08:00
|
|
|
|
//自闭电路
|
|
|
|
|
j2DqjSelf := state.J1_QDJ && state.J2_BHJ && state.J2_1DQJ
|
|
|
|
|
//励磁电路
|
2023-09-07 17:59:38 +08:00
|
|
|
|
j2DqjMethod1 := state.YCJ && state.J1_1DQJ && (!state.J2_2DQJ && state.DCJ || state.J2_2DQJ && state.FCJ)
|
2023-09-13 13:33:47 +08:00
|
|
|
|
//
|
2023-09-06 18:07:12 +08:00
|
|
|
|
j2DqjIs := j2DqjMethod1 || j2DqjSelf
|
|
|
|
|
//为J2第一启动继电器励磁
|
2023-09-13 15:16:16 +08:00
|
|
|
|
if j2DqjIs != state.J2_1DQJ {
|
|
|
|
|
me.publishRelayNeedChangeEvent(w, switchEntry, SJZDJ9_TDFJ2, SJZDJ9_1DQJ, j2DqjIs)
|
|
|
|
|
}
|
2023-09-11 13:33:01 +08:00
|
|
|
|
// ---------------
|
|
|
|
|
//励磁电路
|
|
|
|
|
j1DqjMethod1 := state.YCJ && (!state.J1_2DQJ && state.DCJ || state.J1_2DQJ && state.FCJ)
|
|
|
|
|
//自闭电路
|
|
|
|
|
j1DqjSelf := state.J1_QDJ && state.J1_BHJ && state.J1_1DQJ
|
2023-09-13 13:33:47 +08:00
|
|
|
|
//
|
2023-09-11 13:33:01 +08:00
|
|
|
|
j1DqjIs := j1DqjMethod1 || j1DqjSelf
|
|
|
|
|
//为J1第一启动继电器励磁
|
2023-09-13 15:16:16 +08:00
|
|
|
|
if j1DqjIs != state.J1_1DQJ {
|
|
|
|
|
me.publishRelayNeedChangeEvent(w, switchEntry, SJZDJ9_TDFJ1, SJZDJ9_1DQJ, j1DqjIs)
|
|
|
|
|
}
|
2023-09-06 18:07:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔第一启动继电器复示继电器运算
|
|
|
|
|
// 1DQJF JWJXC-480无极继电器
|
2023-09-13 18:03:55 +08:00
|
|
|
|
func (me *Switch2jZdj9System) calculate1DQJF(w ecs.World, switchEntry *ecs.Entry, state *Switch2jZdj9State) {
|
2023-09-13 15:16:16 +08:00
|
|
|
|
_J1_1DQJF := state.J1_1DQJ
|
|
|
|
|
_J2_1DQJF := state.J2_1DQJ
|
|
|
|
|
if _J1_1DQJF != state.J1_1DQJF {
|
|
|
|
|
me.publishRelayNeedChangeEvent(w, switchEntry, SJZDJ9_TDFJ1, SJZDJ9_1DQJF, _J1_1DQJF)
|
|
|
|
|
}
|
|
|
|
|
if _J2_1DQJF != state.J2_1DQJF {
|
|
|
|
|
me.publishRelayNeedChangeEvent(w, switchEntry, SJZDJ9_TDFJ2, SJZDJ9_1DQJF, _J2_1DQJF)
|
|
|
|
|
}
|
2023-09-06 18:07:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔第二启动继电器运算
|
|
|
|
|
// 2DQJ JYJXC-160/260有极加强继电器
|
|
|
|
|
// 2DQJ为有极继电器,根据线圈中电流极性不同具有 定位和反位 两种稳定状态,这两种稳定状态当线圈中电流消失时仍能继续保持;
|
|
|
|
|
// 在线圈中通以规定极性的电流时,继电器吸起,断电后仍保持在吸起位置;通以反方向电流时,继电器打落,断电后保持在打落位置;
|
|
|
|
|
// 断电保持由磁路系统中的一块长条形永久磁铁取代了大部分轭铁来实现;
|
|
|
|
|
// 电流3->4吸起,电流2->1打落,如果21和34同时通过电流时磁场相互抵消则继电器保持原来状态不变
|
2023-09-13 18:03:55 +08:00
|
|
|
|
func (me *Switch2jZdj9System) calculate2DQJ(w ecs.World, switchEntry *ecs.Entry, state *Switch2jZdj9State) {
|
2023-09-06 18:07:12 +08:00
|
|
|
|
//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 {
|
2023-09-13 15:16:16 +08:00
|
|
|
|
_J1_2DQJ := j12dqj > 0
|
|
|
|
|
if _J1_2DQJ != state.J1_2DQJ {
|
|
|
|
|
me.publishRelayNeedChangeEvent(w, switchEntry, SJZDJ9_TDFJ1, SJZDJ9_2DQJ, _J1_2DQJ)
|
|
|
|
|
}
|
2023-09-06 18:07:12 +08:00
|
|
|
|
}
|
|
|
|
|
//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 {
|
2023-09-13 15:16:16 +08:00
|
|
|
|
_J2_2DQJ := j22dqj > 0
|
|
|
|
|
if _J2_2DQJ != state.J2_2DQJ {
|
|
|
|
|
me.publishRelayNeedChangeEvent(w, switchEntry, SJZDJ9_TDFJ2, SJZDJ9_2DQJ, _J2_2DQJ)
|
|
|
|
|
}
|
2023-09-06 18:07:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔总定表继电器运算
|
|
|
|
|
// ZDBJ JPXC-1000 偏极继电器是为了鉴别信号电路中的电流极性而设计
|
|
|
|
|
// 继电器在磁路中增加一个偏极磁钢,使衔铁受永磁力的作用而偏于落下位置。衔铁的吸起与线圈中的电流的极性有关,
|
|
|
|
|
// 通过线圈的电流为规定的方向时,衔铁才吸起,而电流的方向相反时,衔铁保持不动。
|
|
|
|
|
// 它只具有一种稳定状态,即衔铁靠电磁力吸起后,断电即落下,始终偏向落下的定位状态
|
2023-09-13 18:03:55 +08:00
|
|
|
|
func (me *Switch2jZdj9System) calculateZDBJ(w ecs.World, switchEntry *ecs.Entry, state *Switch2jZdj9State) {
|
2023-09-13 15:16:16 +08:00
|
|
|
|
_ZDBJ := state.J1_DBJ && state.J2_DBJ
|
|
|
|
|
if _ZDBJ != state.ZDBJ {
|
|
|
|
|
me.publishRelayNeedChangeEvent(w, switchEntry, SJZDJ9_TDC, SJZDJ9_ZDBJ, _ZDBJ)
|
|
|
|
|
}
|
2023-09-06 18:07:12 +08:00
|
|
|
|
}
|
2023-09-13 18:03:55 +08:00
|
|
|
|
func (me *Switch2jZdj9System) calculateZFBJ(w ecs.World, switchEntry *ecs.Entry, state *Switch2jZdj9State) {
|
2023-09-13 15:16:16 +08:00
|
|
|
|
_ZFBJ := state.J1_FBJ && state.J2_FBJ
|
|
|
|
|
if _ZFBJ != state.ZFBJ {
|
|
|
|
|
me.publishRelayNeedChangeEvent(w, switchEntry, SJZDJ9_TDC, SJZDJ9_ZFBJ, _ZFBJ)
|
|
|
|
|
}
|
2023-09-06 18:07:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔定表继电器运算
|
|
|
|
|
// DBJ JPXC-1000 偏极继电器
|
2023-09-07 17:59:38 +08:00
|
|
|
|
// BB的负半周期提供DBJ的励磁电流
|
2023-09-13 18:03:55 +08:00
|
|
|
|
func (me *Switch2jZdj9System) calculateDBJ(w ecs.World, switchEntry *ecs.Entry, state *Switch2jZdj9State) {
|
2023-09-07 17:59:38 +08:00
|
|
|
|
//j1 DBJ励磁
|
2023-09-13 13:47:00 +08:00
|
|
|
|
j1DbjLc := state.J1_2DQJ && state.J1_AKB && state.J1_DB_K9 && !state.J1_1DQJ
|
2023-09-13 15:16:16 +08:00
|
|
|
|
if j1DbjLc != state.J1_DBJ {
|
|
|
|
|
me.publishRelayNeedChangeEvent(w, switchEntry, SJZDJ9_TDFJ1, SJZDJ9_DBJ, j1DbjLc)
|
|
|
|
|
}
|
2023-09-07 17:59:38 +08:00
|
|
|
|
//j2 DBJ励磁
|
2023-09-13 13:47:00 +08:00
|
|
|
|
j2DbjLc := state.J2_2DQJ && state.J2_AKB && state.J2_DB_K9 && !state.J2_1DQJ
|
2023-09-13 15:16:16 +08:00
|
|
|
|
if j2DbjLc != state.J2_DBJ {
|
|
|
|
|
me.publishRelayNeedChangeEvent(w, switchEntry, SJZDJ9_TDFJ2, SJZDJ9_DBJ, j2DbjLc)
|
|
|
|
|
}
|
2023-09-06 18:07:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔反表继电器运算
|
|
|
|
|
// FBJ JPXC-1000 偏极继电器
|
2023-09-07 17:59:38 +08:00
|
|
|
|
// BB的正半周期提供FBJ的励磁流
|
2023-09-13 18:03:55 +08:00
|
|
|
|
func (me *Switch2jZdj9System) calculateFBJ(w ecs.World, switchEntry *ecs.Entry, state *Switch2jZdj9State) {
|
2023-09-07 17:59:38 +08:00
|
|
|
|
//j1 FBJ励磁
|
2023-09-13 13:47:00 +08:00
|
|
|
|
j1FbjLc := !state.J1_2DQJ && !state.J1_AKB && state.J1_FB_K10 && !state.J1_1DQJ
|
2023-09-13 15:16:16 +08:00
|
|
|
|
if j1FbjLc != state.J1_FBJ {
|
|
|
|
|
me.publishRelayNeedChangeEvent(w, switchEntry, SJZDJ9_TDFJ1, SJZDJ9_FBJ, j1FbjLc)
|
|
|
|
|
}
|
2023-09-07 17:59:38 +08:00
|
|
|
|
//j2
|
2023-09-13 13:47:00 +08:00
|
|
|
|
j2FbjLc := !state.J2_2DQJ && !state.J2_AKB && state.J2_FB_K10 && !state.J2_1DQJ
|
2023-09-13 15:16:16 +08:00
|
|
|
|
if j2FbjLc != state.J2_FBJ {
|
|
|
|
|
me.publishRelayNeedChangeEvent(w, switchEntry, SJZDJ9_TDFJ2, SJZDJ9_FBJ, j2FbjLc)
|
|
|
|
|
}
|
2023-09-07 17:59:38 +08:00
|
|
|
|
}
|
2023-09-05 18:16:36 +08:00
|
|
|
|
|
2023-09-13 18:03:55 +08:00
|
|
|
|
// 道岔转动运算
|
|
|
|
|
// j1 完全转动须4000ms
|
|
|
|
|
// j2 完全转动须5000ms
|
|
|
|
|
const (
|
2023-09-14 13:52:36 +08:00
|
|
|
|
J1Range int64 = 4000
|
|
|
|
|
J2Range int64 = 5000
|
2023-09-13 18:03:55 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 道岔转动运算
|
|
|
|
|
// j1 完全转动须4000ms
|
|
|
|
|
// j2 完全转动须5000ms
|
|
|
|
|
// j.Value 0-反位 jRange-定位
|
|
|
|
|
func (me *Switch2jZdj9System) calculateMove(w ecs.World, switchEntry *ecs.Entry, state *Switch2jZdj9State) {
|
2023-09-14 13:52:36 +08:00
|
|
|
|
j1 := MovableObject1Component.Get(switchEntry)
|
2023-09-13 18:03:55 +08:00
|
|
|
|
//
|
|
|
|
|
if j1.Value < 0 {
|
|
|
|
|
j1.Value = 0
|
2023-09-14 13:52:36 +08:00
|
|
|
|
} else if j1.Value > J1Range {
|
|
|
|
|
j1.Value = J1Range
|
2023-09-13 18:03:55 +08:00
|
|
|
|
}
|
|
|
|
|
j1.direction = state.J1_Traction
|
|
|
|
|
//
|
2023-09-14 13:52:36 +08:00
|
|
|
|
j2 := MovableObject2Component.Get(switchEntry)
|
2023-09-13 18:03:55 +08:00
|
|
|
|
//
|
|
|
|
|
if j2.Value < 0 {
|
|
|
|
|
j2.Value = 0
|
2023-09-14 13:52:36 +08:00
|
|
|
|
} else if j2.Value > J2Range {
|
|
|
|
|
j2.Value = J2Range
|
2023-09-13 18:03:55 +08:00
|
|
|
|
}
|
|
|
|
|
j2.direction = state.J2_Traction
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 转辙机对外端子9、10运算
|
|
|
|
|
func (me *Switch2jZdj9System) calculateK9K10(w ecs.World, switchEntry *ecs.Entry, state *Switch2jZdj9State) {
|
2023-09-14 13:52:36 +08:00
|
|
|
|
j1 := MovableObject1Component.Get(switchEntry)
|
|
|
|
|
j2 := MovableObject2Component.Get(switchEntry)
|
2023-09-13 18:03:55 +08:00
|
|
|
|
//
|
2023-09-14 13:52:36 +08:00
|
|
|
|
state.J1_DB_K9 = j1.Value >= J1Range
|
2023-09-13 18:03:55 +08:00
|
|
|
|
state.J1_FB_K10 = j1.Value <= 0
|
|
|
|
|
//
|
2023-09-14 13:52:36 +08:00
|
|
|
|
state.J2_DB_K9 = j2.Value >= J2Range
|
2023-09-13 18:03:55 +08:00
|
|
|
|
state.J2_FB_K10 = j2.Value <= 0
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-14 13:52:36 +08:00
|
|
|
|
// 转辙机电源控制
|
|
|
|
|
// 1DQj启动继电器吸合时接通电源
|
|
|
|
|
func (me *Switch2jZdj9System) calculateJPower(w ecs.World, switchEntry *ecs.Entry, state *Switch2jZdj9State) {
|
|
|
|
|
//超时断电
|
|
|
|
|
j1csdd := state.J1_Power.Active && state.J1_DBQ.LimitedTime <= 0
|
|
|
|
|
//转换到位断电
|
|
|
|
|
j1zhdwdd := state.J1_2DQJ_ToD && state.J1_DB_K9 || state.J1_2DQJ_ToF && state.J1_FB_K10
|
|
|
|
|
if j1csdd || j1zhdwdd {
|
|
|
|
|
state.J1_Power.PhaseA = false
|
|
|
|
|
state.J1_Power.PhaseB = false
|
|
|
|
|
state.J1_Power.PhaseC = false
|
|
|
|
|
state.J1_2DQJ_ToD = false
|
|
|
|
|
state.J1_2DQJ_ToF = false
|
|
|
|
|
}
|
|
|
|
|
//第一启动继电器落下
|
|
|
|
|
if !state.J1_1DQJ {
|
|
|
|
|
state.J1_Power.Active = false
|
|
|
|
|
}
|
|
|
|
|
//接通电源
|
|
|
|
|
if state.J1_1DQJ && !state.J1_Power.Active {
|
|
|
|
|
state.J1_Power.Active = true
|
|
|
|
|
state.J1_Power.PhaseA = true
|
|
|
|
|
state.J1_Power.PhaseB = true
|
|
|
|
|
state.J1_Power.PhaseC = true
|
|
|
|
|
state.J1_DBQ.LimitedTime = DBQ_LIMITED_TIME
|
|
|
|
|
}
|
|
|
|
|
//----------------
|
|
|
|
|
//超时断电
|
|
|
|
|
j2csdd := state.J2_Power.Active && state.J2_DBQ.LimitedTime <= 0
|
|
|
|
|
//转换到位断电
|
|
|
|
|
j2zhdwdd := state.J2_2DQJ_ToD && state.J2_DB_K9 || state.J2_2DQJ_ToF && state.J2_FB_K10
|
|
|
|
|
if j2csdd || j2zhdwdd {
|
|
|
|
|
state.J2_Power.PhaseA = false
|
|
|
|
|
state.J2_Power.PhaseB = false
|
|
|
|
|
state.J2_Power.PhaseC = false
|
|
|
|
|
state.J2_2DQJ_ToD = false
|
|
|
|
|
state.J2_2DQJ_ToF = false
|
|
|
|
|
}
|
|
|
|
|
//第一启动继电器落下
|
|
|
|
|
if !state.J2_1DQJ {
|
|
|
|
|
state.J2_Power.Active = false
|
|
|
|
|
}
|
|
|
|
|
//接通电源
|
|
|
|
|
if state.J2_1DQJ && !state.J2_Power.Active {
|
|
|
|
|
state.J2_Power.Active = true
|
|
|
|
|
state.J2_Power.PhaseA = true
|
|
|
|
|
state.J2_Power.PhaseB = true
|
|
|
|
|
state.J2_Power.PhaseC = true
|
|
|
|
|
state.J2_DBQ.LimitedTime = DBQ_LIMITED_TIME
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-07 17:59:38 +08:00
|
|
|
|
// 道岔转辙机电机内线圈电路运算
|
|
|
|
|
// ABC三相电,电机线圈UVW,
|
|
|
|
|
// 定位到反位U-A V-C W-B 即U->W->V电机反转,反操接通2、4排表示电路
|
|
|
|
|
// 反位到定位U-A V-B W-C 即U->V->W电机正转,定操接通1、3排表示电路
|
2023-09-13 18:03:55 +08:00
|
|
|
|
func (me *Switch2jZdj9System) calculateMotor(w ecs.World, switchEntry *ecs.Entry, state *Switch2jZdj9State) {
|
2023-09-07 17:59:38 +08:00
|
|
|
|
//电机1
|
|
|
|
|
state.J1_U1 = ACPahseN
|
|
|
|
|
state.J1_V1 = ACPahseN
|
|
|
|
|
state.J1_W1 = ACPahseN
|
2023-09-13 18:03:55 +08:00
|
|
|
|
state.J1_Traction = 0
|
2023-09-07 17:59:38 +08:00
|
|
|
|
//A相电
|
|
|
|
|
if state.J1_Power.PhaseA && state.J1_1DQJ {
|
|
|
|
|
state.J1_U1 = ACPahseA
|
|
|
|
|
}
|
|
|
|
|
//B相电
|
|
|
|
|
if state.J1_Power.PhaseB && state.J1_1DQJF {
|
|
|
|
|
if state.J1_2DQJ {
|
|
|
|
|
if state.J1_AKB {
|
|
|
|
|
state.J1_V1 = ACPahseB
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if !state.J1_AKB {
|
|
|
|
|
state.J1_W1 = ACPahseB
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//C相电
|
|
|
|
|
if state.J1_Power.PhaseC && state.J1_1DQJF {
|
|
|
|
|
if state.J1_2DQJ {
|
|
|
|
|
if state.J1_AKB {
|
|
|
|
|
state.J1_W1 = ACPahseC
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if !state.J1_AKB {
|
|
|
|
|
state.J1_V1 = ACPahseC
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-13 18:03:55 +08:00
|
|
|
|
//牵引力
|
2023-09-07 17:59:38 +08:00
|
|
|
|
if state.J1_U1 == ACPahseA {
|
|
|
|
|
switch {
|
|
|
|
|
case state.J1_V1 == ACPahseB: //U-A V-B W-C
|
|
|
|
|
{
|
|
|
|
|
if state.J1_W1 == ACPahseC {
|
2023-09-13 18:03:55 +08:00
|
|
|
|
state.J1_Traction = 1
|
2023-09-07 17:59:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case state.J1_V1 == ACPahseC: //U-A W-B V-C
|
|
|
|
|
{
|
|
|
|
|
if state.J1_W1 == ACPahseB {
|
2023-09-13 18:03:55 +08:00
|
|
|
|
state.J1_Traction = -1
|
2023-09-07 17:59:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/////////////
|
|
|
|
|
//电机2
|
|
|
|
|
state.J2_U1 = ACPahseN
|
|
|
|
|
state.J2_V1 = ACPahseN
|
|
|
|
|
state.J2_W1 = ACPahseN
|
2023-09-13 18:03:55 +08:00
|
|
|
|
state.J2_Traction = 0
|
2023-09-07 17:59:38 +08:00
|
|
|
|
//A相电
|
|
|
|
|
if state.J2_Power.PhaseA && state.J2_1DQJ {
|
|
|
|
|
state.J2_U1 = ACPahseA
|
|
|
|
|
}
|
|
|
|
|
//B相电
|
|
|
|
|
if state.J2_Power.PhaseB && state.J2_1DQJF {
|
|
|
|
|
if state.J2_2DQJ {
|
|
|
|
|
if state.J2_AKB {
|
|
|
|
|
state.J2_V1 = ACPahseB
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if !state.J2_AKB {
|
|
|
|
|
state.J2_W1 = ACPahseB
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//C相电
|
|
|
|
|
if state.J2_Power.PhaseC && state.J2_1DQJF {
|
|
|
|
|
if state.J2_2DQJ {
|
|
|
|
|
if state.J2_AKB {
|
|
|
|
|
state.J2_W1 = ACPahseC
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if !state.J2_AKB {
|
|
|
|
|
state.J2_V1 = ACPahseC
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-13 18:03:55 +08:00
|
|
|
|
//牵引力
|
2023-09-07 17:59:38 +08:00
|
|
|
|
if state.J2_U1 == ACPahseA {
|
|
|
|
|
switch {
|
|
|
|
|
case state.J2_V1 == ACPahseB: //U-A V-B W-C
|
|
|
|
|
{
|
|
|
|
|
if state.J2_W1 == ACPahseC {
|
2023-09-13 18:03:55 +08:00
|
|
|
|
state.J2_Traction = 1
|
2023-09-07 17:59:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case state.J2_V1 == ACPahseC: //U-A W-B V-C
|
|
|
|
|
{
|
|
|
|
|
if state.J2_W1 == ACPahseB {
|
2023-09-13 18:03:55 +08:00
|
|
|
|
state.J2_Traction = -1
|
2023-09-07 17:59:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-05 14:47:38 +08:00
|
|
|
|
}
|