【修改第三方服务报错后没有销毁问题】
This commit is contained in:
parent
cc99be478f
commit
c7f1137e59
|
@ -21,20 +21,16 @@ func NewSimulationStateMs(vs *memory.VerifySimulation) *SimulationStateMs {
|
|||
vs: vs,
|
||||
channel: fmt.Sprintf("simulation-%s-status", vs.SimulationId),
|
||||
}
|
||||
go stateListen(ms)
|
||||
return ms
|
||||
}
|
||||
|
||||
func stateListen(ms *SimulationStateMs) {
|
||||
ecs.WorldStateChangeEvent.Subscribe(ms.vs.World, func(_ ecs.World, e ecs.WorldStateChange) {
|
||||
switch e.NewState {
|
||||
case ecs.WorldClose:
|
||||
doSendState(ms.channel, &state.SimulationStatus{
|
||||
SimulationId: ms.vs.SimulationId,
|
||||
SimulationId: vs.SimulationId,
|
||||
State: state.SimulationStatus_DESTROY,
|
||||
})
|
||||
}
|
||||
})
|
||||
return ms
|
||||
}
|
||||
|
||||
func doSendState(channel string, status *state.SimulationStatus) error {
|
||||
|
|
|
@ -184,7 +184,8 @@ func (d *dynamics) Start(manager DynamicsMessageManager) error {
|
|||
// 初始化运行资源
|
||||
err := d.initDynamicsRunRepository()
|
||||
if err != nil {
|
||||
panic("启动动力学消息服务错误: 存在正在运行的任务")
|
||||
d.Stop() // 发送错误后将信息销毁
|
||||
panic(err)
|
||||
}
|
||||
ctx, cancle := context.WithCancel(context.Background())
|
||||
go d.sendTurnoutStateTask(ctx)
|
||||
|
@ -228,8 +229,8 @@ func (d *dynamics) Stop() {
|
|||
}
|
||||
if d.turnoutTaskCancel != nil {
|
||||
d.turnoutTaskCancel()
|
||||
d.manager = nil
|
||||
}
|
||||
d.manager = nil
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
|
@ -117,8 +117,8 @@ func (i *interlockProxy) Stop() {
|
|||
}
|
||||
if i.collectInfoTaskCancel != nil {
|
||||
i.collectInfoTaskCancel()
|
||||
i.manager = nil
|
||||
}
|
||||
i.manager = nil
|
||||
}
|
||||
|
||||
func (i *interlockProxy) SendCollectMessage(b []byte) {
|
||||
|
|
|
@ -225,10 +225,6 @@ func convert(info *message.DynamicsTrainInfo, sta *state.TrainState, simulation
|
|||
|
||||
// 获取动力学配置信息
|
||||
func (s *VerifySimulation) GetDynamicsRunConfig() *config.DynamicsConfig {
|
||||
// TODO:目前为了兼容当前配置方式,做成查询方式后删除IP判断
|
||||
if config.Config.Dynamics.Ip != "" {
|
||||
return &config.Config.Dynamics
|
||||
}
|
||||
return &s.runConfig.Dynamics
|
||||
}
|
||||
|
||||
|
@ -327,10 +323,6 @@ func (s *VerifySimulation) HandleSemiPhysicalTrainControlMsg(b []byte) {
|
|||
|
||||
// 获取半实物运行配置信息
|
||||
func (s *VerifySimulation) GetSemiPhysicalRunConfig() *config.VobcConfig {
|
||||
// TODO:目前为了兼容当前配置方式,做成查询方式后删除IP判断
|
||||
if config.Config.Vobc.Ip != "" {
|
||||
return &config.Config.Vobc
|
||||
}
|
||||
return &s.runConfig.Vobc
|
||||
}
|
||||
|
||||
|
@ -348,15 +340,12 @@ func (s *VerifySimulation) HandleDriverInfo(b []byte) {
|
|||
|
||||
// 获取联锁配置
|
||||
func (s *VerifySimulation) GetInterlockRunConfig() *config.InterlockConfig {
|
||||
// TODO:目前为了兼容当前配置方式,做成查询方式后删除IP判断
|
||||
if config.Config.Interlock.Ip != "" {
|
||||
return &config.Config.Interlock
|
||||
}
|
||||
return &s.runConfig.Interlock
|
||||
}
|
||||
|
||||
// 采集联锁中的继电器消息
|
||||
func (s *VerifySimulation) CollectRelayInfo() []*message.InterlockSendMsgPkg {
|
||||
|
||||
msg := &message.InterlockSendMsgPkg{}
|
||||
relayArr := make([]string, 256)
|
||||
for index, id := range relayArr {
|
||||
|
|
Loading…
Reference in New Issue