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