Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
ec691ab12c
11
third_party/dynamics/dynamics.go
vendored
11
third_party/dynamics/dynamics.go
vendored
@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
type DynamicsMessageManager interface {
|
||||
CollectDynamicsTurnoutInfo() []*message.DynamicsTurnoutInfo
|
||||
CollectDynamicsTurnoutInfo() *message.DynamicsTurnoutInfo
|
||||
HandleDynamicsTrainInfo(info *message.DynamicsTrainInfo)
|
||||
GetDynamicsRunConfig() *config.DynamicsConfig
|
||||
GetDynamicsRunRepository() *message.LineBaseInfo
|
||||
@ -277,13 +277,10 @@ func (d *dynamics) sendTurnoutStateTask(ctx context.Context) {
|
||||
return
|
||||
default:
|
||||
}
|
||||
turnoutStates := d.manager.CollectDynamicsTurnoutInfo()
|
||||
// slog.Debug("发送道岔状态", "count", len(turnoutStates))
|
||||
for _, state := range turnoutStates {
|
||||
turnoutState := d.manager.CollectDynamicsTurnoutInfo()
|
||||
turnoutStateLifeSignal++
|
||||
state.LifeSignal = turnoutStateLifeSignal
|
||||
d.turnoutStateUdpClient.SendMsg(state)
|
||||
}
|
||||
turnoutState.LifeSignal = turnoutStateLifeSignal
|
||||
d.turnoutStateUdpClient.SendMsg(turnoutState)
|
||||
time.Sleep(time.Millisecond * TurnoutMessageSendInterval)
|
||||
}
|
||||
}
|
||||
|
12
third_party/message/dynamics.go
vendored
12
third_party/message/dynamics.go
vendored
@ -7,6 +7,10 @@ import (
|
||||
|
||||
type DynamicsTurnoutInfo struct {
|
||||
LifeSignal uint16
|
||||
TurnoutInfos []*TurnoutInfo
|
||||
}
|
||||
|
||||
type TurnoutInfo struct {
|
||||
Code uint16
|
||||
NPosition bool
|
||||
RPosition bool
|
||||
@ -15,15 +19,17 @@ type DynamicsTurnoutInfo struct {
|
||||
func (t *DynamicsTurnoutInfo) Encode() []byte {
|
||||
var data []byte
|
||||
data = binary.BigEndian.AppendUint16(data, t.LifeSignal)
|
||||
data = binary.BigEndian.AppendUint16(data, t.Code)
|
||||
for _, info := range t.TurnoutInfos {
|
||||
data = binary.BigEndian.AppendUint16(data, info.Code)
|
||||
var b byte
|
||||
if t.NPosition {
|
||||
if info.NPosition {
|
||||
b |= 1 << 7
|
||||
}
|
||||
if t.RPosition {
|
||||
if info.RPosition {
|
||||
b |= 1 << 6
|
||||
}
|
||||
data = append(data, b)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
|
@ -219,21 +219,29 @@ func (s *VerifySimulation) CollectSectionStatus(city string, lineId string, cent
|
||||
}
|
||||
|
||||
// 采集动力学道岔状态
|
||||
func (s *VerifySimulation) CollectDynamicsTurnoutInfo() []*message.DynamicsTurnoutInfo {
|
||||
var turnoutStates []*message.DynamicsTurnoutInfo
|
||||
for _, o := range s.Repo.TurnoutList() {
|
||||
sta := s.uidMap[o.Id()]
|
||||
func (s *VerifySimulation) CollectDynamicsTurnoutInfo() *message.DynamicsTurnoutInfo {
|
||||
turnoutState := &message.DynamicsTurnoutInfo{}
|
||||
for _, turnout := range s.Repo.TurnoutList() {
|
||||
sta := s.uidMap[turnout.Id()]
|
||||
if sta == nil {
|
||||
continue
|
||||
}
|
||||
s := handlerDynamicsTurnoutState(s.World, o.Id())
|
||||
if s == nil {
|
||||
continue
|
||||
entry, ok := entity.GetEntityByUid(s.World, turnout.Id())
|
||||
if !ok {
|
||||
slog.Warn(fmt.Sprintf("id=%s的道岔不存在", turnout.Id()))
|
||||
return nil
|
||||
}
|
||||
s.Code = uint16(sta.CommonId)
|
||||
turnoutStates = append(turnoutStates, s)
|
||||
if !entry.HasComponent(component.TurnoutPositionType) {
|
||||
return nil
|
||||
}
|
||||
return turnoutStates
|
||||
pos := component.TurnoutPositionType.Get(entry)
|
||||
turnoutState.TurnoutInfos = append(turnoutState.TurnoutInfos, &message.TurnoutInfo{
|
||||
Code: 0,
|
||||
NPosition: pos.Dw,
|
||||
RPosition: pos.Fw,
|
||||
})
|
||||
}
|
||||
return turnoutState
|
||||
}
|
||||
|
||||
// HandleSectionCmdMsg 计轴设备接收到联锁发送来的控制命令
|
||||
@ -268,19 +276,6 @@ func (s *VerifySimulation) HandleSectionCmdMsg(city string, lineId string, centr
|
||||
fi.AxleSectionRstDrive(s.World, cmds)
|
||||
}
|
||||
|
||||
func handlerDynamicsTurnoutState(w ecs.World, uid string) *message.DynamicsTurnoutInfo {
|
||||
entry, ok := entity.GetEntityByUid(w, uid)
|
||||
if !ok {
|
||||
fmt.Printf("id=%s的道岔不存在", uid)
|
||||
return nil
|
||||
}
|
||||
if !entry.HasComponent(component.TurnoutPositionType) {
|
||||
return nil
|
||||
}
|
||||
pos := component.TurnoutPositionType.Get(entry)
|
||||
return &message.DynamicsTurnoutInfo{NPosition: pos.Dw, RPosition: pos.Fw}
|
||||
}
|
||||
|
||||
// 处理动力学列车速度消息
|
||||
func (s *VerifySimulation) HandleDynamicsTrainInfo(info *message.DynamicsTrainInfo) {
|
||||
trainId := strconv.Itoa(int(info.Number))
|
||||
|
Loading…
Reference in New Issue
Block a user