From 9e1d108c7785941f880a1c13396d4444b8b94876 Mon Sep 17 00:00:00 2001 From: walker Date: Tue, 10 Oct 2023 18:28:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7go=E7=89=88=E6=9C=AC=E5=88=B0?= =?UTF-8?q?1.21=20=E5=88=87=E6=8D=A2fmt=E8=BE=93=E5=87=BA=E4=B8=BAslog?= =?UTF-8?q?=E8=BE=93=E5=87=BA=20=E7=BB=A7=E7=94=B5=E5=99=A8entity=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E6=B7=BB=E5=8A=A0=E6=95=B4=E6=B5=81=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/relay.go | 4 ++-- entity/relay.go | 5 +---- go.mod | 2 +- go.work | 2 +- go.work.sum | 1 + jl-ecs-go | 2 +- sys/circuit_sys/turnout_zdj9_2.go | 32 +++++++++++++++---------------- 7 files changed, 23 insertions(+), 25 deletions(-) diff --git a/component/relay.go b/component/relay.go index 5dd04d4..a0548aa 100644 --- a/component/relay.go +++ b/component/relay.go @@ -8,8 +8,8 @@ var ( RelayTag = ecs.NewTag() // 无极继电器 WjRelayTag = ecs.NewTag() - // 偏极继电器 - PjRelayTag = ecs.NewTag() + // // 偏极继电器 + // PjRelayTag = ecs.NewTag() // 有极 YjRelayTag = ecs.NewTag() // 缓放继电器 diff --git a/entity/relay.go b/entity/relay.go index 44eef0c..f24cb29 100644 --- a/entity/relay.go +++ b/entity/relay.go @@ -19,11 +19,8 @@ func NewRelayEntity(w ecs.World, relay *repository.Relay, entityMap map[string]* component.UidType.SetValue(entry, component.Uid{Id: uid}) if strings.Contains(model, "Y") { // 有极继电器 entry.AddComponent(component.YjRelayTag) - } else if strings.Contains(model, "W") { // 无极继电器 + } else if strings.Contains(model, "W") || strings.Contains(model, "Z") || strings.Contains(model, "P") { // 无极继电器 entry.AddComponent(component.WjRelayTag) - } else if strings.Contains(model, "P") { // 偏极继电器 - entry.AddComponent(component.WjRelayTag) - entry.AddComponent(component.PjRelayTag) } if strings.Contains(model, "H") { // 缓放继电器 entry.AddComponent(component.HfRelayTag) diff --git a/go.mod b/go.mod index d0d5a3a..0f11a0a 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module joylink.club/rtsssimulation -go 1.20 +go 1.21 require ( github.com/yohamta/donburi v1.3.8 diff --git a/go.work b/go.work index 6673469..92d8716 100644 --- a/go.work +++ b/go.work @@ -1,4 +1,4 @@ -go 1.20 +go 1.21 use ( . diff --git a/go.work.sum b/go.work.sum index 4a3ba34..a64fc72 100644 --- a/go.work.sum +++ b/go.work.sum @@ -14,6 +14,7 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4= golang.org/x/image v0.1.0/go.mod h1:iyPr49SD/G/TBxYVB/9RRtGUT5eNbo2u4NamWeQcD5c= golang.org/x/mobile v0.0.0-20221012134814-c746ac228303/go.mod h1:M32cGdzp91A8Ex9qQtyZinr19EYxzkFqDjW2oyHzTDQ= diff --git a/jl-ecs-go b/jl-ecs-go index 47f78cb..e779734 160000 --- a/jl-ecs-go +++ b/jl-ecs-go @@ -1 +1 @@ -Subproject commit 47f78cb54ddc2673b87d3f85eea23e3769e417ad +Subproject commit e7797346722a572814539d9a453789b89ffe6bf4 diff --git a/sys/circuit_sys/turnout_zdj9_2.go b/sys/circuit_sys/turnout_zdj9_2.go index 617cae3..b58de43 100644 --- a/sys/circuit_sys/turnout_zdj9_2.go +++ b/sys/circuit_sys/turnout_zdj9_2.go @@ -1,7 +1,7 @@ package circuit_sys import ( - "fmt" + "log/slog" "joylink.club/ecs" "joylink.club/ecs/filter" @@ -147,7 +147,7 @@ func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_QDJ(w ecs.World, entry *ecs.Entry, ele if !drive.Td && (!tdfj1_bhj.Val && !tdfj2_bhj.Val) || tdfj1_zbhj.Val { // 电路导通 drive.Td = true elec.TDFJ1_QDJ_Remain = consts.QDJ_DELAY - fmt.Println("切断继电器通电") + slog.Debug("切断继电器通电") } } else { // 吸起状态 if drive.Td && !tdfj1_zbhj.Val && !(!tdfj1_bhj.Val && !tdfj2_bhj.Val) { // 电路断开 @@ -157,7 +157,7 @@ func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_QDJ(w ecs.World, entry *ecs.Entry, ele if remain <= 0 { elec.TDFJ1_QDJ_Remain = 0 drive.Td = false - fmt.Println("切断继电器断电") + slog.Debug("切断继电器断电") } else { elec.TDFJ1_QDJ_Remain = remain } @@ -211,21 +211,21 @@ func (zdj9 *ZDJ9TwoDragSys) exciteDBQ(i int, _1dqj *component.BitState, _1dqjf * !(_1dqj.Val && _1dqjf.Val && zzj.JD34 && _2dqj.Val) { // 断开 dbq.Td = false zzj.Td = false - fmt.Printf("转辙机%v断电\n", i) + slog.Debug("转辙机%v断电\n", i) } else { // 处理正反转 if zzj.Dw && !_2dqj.Val { zzj.Dw = false - fmt.Printf("转辙机%v转到反位\n", i) + slog.Debug("转辙机%v转到反位\n", i) } else if !zzj.Dw && _2dqj.Val { zzj.Dw = true - fmt.Printf("转辙机%v转到定位\n", i) + slog.Debug("转辙机%v转到定位\n", i) } } } else { // 未通电 if _1dqj.Val && _1dqjf.Val && ((!zzj.JD12 && !_2dqj.Val) || (zzj.JD34 && _2dqj.Val)) { // 通电 dbq.Td = true zzj.Td = true - fmt.Printf("转辙机%v通电\n", i) + slog.Debug("转辙机%v通电\n", i) } } } @@ -295,13 +295,13 @@ func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_1DQJ(elec *component.Zdj9TwoElectronic // 判定是否所有励磁电路断开(todo 暂不考虑应急按钮) if !(qdj.Val && bhj.Val) && !(ycj.Val && ((tdfj1_2dqj.Val && fcj.Val) || (!tdfj1_2dqj.Val && dcj.Val))) { // 电路断开 drive.Td = false - fmt.Println("TDFJ1_1DQJ断电") + slog.Debug("TDFJ1_1DQJ断电") } } else { // 未通电 if (ycj.Val && ((tdfj1_2dqj.Val && fcj.Val) || (!tdfj1_2dqj.Val && dcj.Val))) || (tdfj1_1dqj.Val && qdj.Val && bhj.Val) { // 电路导通 drive.Td = true - fmt.Println("TDFJ1_1DQJ通电") + slog.Debug("TDFJ1_1DQJ通电") } } } @@ -321,12 +321,12 @@ func (zdj9 *ZDJ9TwoDragSys) exciteM2_TDFJ_1DQJ(elec *component.Zdj9TwoElectronic if drive.Td { // 通电 if !(qdj.Val && bhj.Val) && !(tdfj1_1dqj.Val && ycj.Val && ((tdfj2_2dqj.Val && fcj.Val) || (!tdfj2_2dqj.Val && dcj.Val))) { // 电路断开 drive.Td = false - fmt.Println("TDFJ2_1DQJ断电") + slog.Debug("TDFJ2_1DQJ断电") } } else { // 未通电 if (tdfj1_1dqj.Val && ycj.Val && ((tdfj2_2dqj.Val && fcj.Val) || (!tdfj2_2dqj.Val && dcj.Val))) || (tdfj2_1dqj.Val && qdj.Val && bhj.Val) { // 电路导通 drive.Td = true - fmt.Println("TDFJ2_1DQJ通电") + slog.Debug("TDFJ2_1DQJ通电") } } } @@ -356,24 +356,24 @@ func (zdj9 *ZDJ9TwoDragSys) excite2DQJ(i int, _1dqjf *component.BitState, dcj *c if drive.Td { // 通电 if !drive.Xq && _1dqjf.Val && dcj.Val { drive.Xq = true - fmt.Printf("TDFJ%v_2DQJ到定位\n", i) + slog.Debug("TDFJ%v_2DQJ到定位\n", i) } else if drive.Xq && _1dqjf.Val && fcj.Val { drive.Xq = false - fmt.Printf("TDFJ%v_2DQJ到反位\n", i) + slog.Debug("TDFJ%v_2DQJ到反位\n", i) } else if !(_1dqjf.Val && (dcj.Val || fcj.Val)) { // 断电 drive.Td = false - fmt.Printf("TDFJ%v_2DQJ断电\n", i) + slog.Debug("TDFJ%v_2DQJ断电\n", i) } } else { // 未通电 if _1dqjf.Val { if dcj.Val { // 通电,到吸起位 drive.Td = true drive.Xq = true - fmt.Printf("TDFJ%v_2DQJ通电,到吸起位\n", i) + slog.Debug("TDFJ%v_2DQJ通电,到吸起位\n", i) } else if fcj.Val { // 通电,到落下位 drive.Td = true drive.Xq = false - fmt.Printf("TDFJ%v_2DQJ通电,到落下位\n", i) + slog.Debug("TDFJ%v_2DQJ通电,到落下位\n", i) } } }