Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
bd2f928a94
@ -6,7 +6,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"joylink.club/rtsssimulation/repository/model/proto"
|
"joylink.club/rtsssimulation/repository/model/proto"
|
||||||
ecsSimulation "joylink.club/rtsssimulation/simulation"
|
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -112,7 +111,8 @@ func DestroySimulation(simulationId string) {
|
|||||||
simulationInfo := s.(*memory.VerifySimulation)
|
simulationInfo := s.(*memory.VerifySimulation)
|
||||||
simulationMap.Delete(simulationId)
|
simulationMap.Delete(simulationId)
|
||||||
// 停止ecs world
|
// 停止ecs world
|
||||||
ecsSimulation.DestroySimulation(simulationInfo.WorldId)
|
simulationInfo.World.Close()
|
||||||
|
//ecsSimulation.DestroySimulation(simulationInfo.WorldId)
|
||||||
//移除道岔状态发送
|
//移除道岔状态发送
|
||||||
dynamics.Stop()
|
dynamics.Stop()
|
||||||
//通知动力学
|
//通知动力学
|
||||||
|
@ -140,6 +140,7 @@ func turnoutMapToEcsLink(repo *repository.Repository, id string, port string, of
|
|||||||
}
|
}
|
||||||
// 岔心公里标
|
// 岔心公里标
|
||||||
crossKm = turnout.GetTurnoutKm(proto2.Port_None)
|
crossKm = turnout.GetTurnoutKm(proto2.Port_None)
|
||||||
|
portKm = repo.ConvertKilometer(portKm, crossKm.CoordinateSystem)
|
||||||
// 关联link
|
// 关联link
|
||||||
link := portPosition.Link()
|
link := portPosition.Link()
|
||||||
isStart := link.ARelation().Device().Id() == id
|
isStart := link.ARelation().Device().Id() == id
|
||||||
@ -173,7 +174,7 @@ func QueryDeviceByCalcLink(repo *repository.Repository, id string, offset int64,
|
|||||||
// 判断是否在道岔上
|
// 判断是否在道岔上
|
||||||
onTurnout, isA := isOnLinkTurnout(link, offset)
|
onTurnout, isA := isOnLinkTurnout(link, offset)
|
||||||
if onTurnout {
|
if onTurnout {
|
||||||
return ecsLinkMapToTurnout(isA, offset, up, link)
|
return ecsLinkMapToTurnout(repo, isA, offset, up, link)
|
||||||
} else {
|
} else {
|
||||||
return ecsLinkMapToSection(offset, up, link)
|
return ecsLinkMapToSection(offset, up, link)
|
||||||
}
|
}
|
||||||
@ -198,7 +199,7 @@ func isOnLinkTurnout(link *repository.Link, offset int64) (bool, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 处理在道岔上link映射
|
// 处理在道岔上link映射
|
||||||
func ecsLinkMapToTurnout(isA bool, offset int64, up bool, link *repository.Link) (
|
func ecsLinkMapToTurnout(repo *repository.Repository, isA bool, offset int64, up bool, link *repository.Link) (
|
||||||
deviceId, port string, deviceOffset int64, runDirection, pointTo bool, km int64) {
|
deviceId, port string, deviceOffset int64, runDirection, pointTo bool, km int64) {
|
||||||
tp := link.ARelation()
|
tp := link.ARelation()
|
||||||
if !isA {
|
if !isA {
|
||||||
@ -206,7 +207,9 @@ func ecsLinkMapToTurnout(isA bool, offset int64, up bool, link *repository.Link)
|
|||||||
}
|
}
|
||||||
deviceId = tp.Turnout().Id()
|
deviceId = tp.Turnout().Id()
|
||||||
tpOffset := tp.Turnout().FindLinkPositionByPort(tp.Port()).Offset()
|
tpOffset := tp.Turnout().FindLinkPositionByPort(tp.Port()).Offset()
|
||||||
crossKm, portKm := tp.Turnout().GetTurnoutKm(proto2.Port_None).Value, tp.Turnout().GetTurnoutKm(tp.Port()).Value
|
crossKmInfo, portKmInfo := tp.Turnout().GetTurnoutKm(proto2.Port_None), tp.Turnout().GetTurnoutKm(tp.Port())
|
||||||
|
portKmInfo = repo.ConvertKilometer(portKmInfo, crossKmInfo.CoordinateSystem)
|
||||||
|
crossKm, portKm := crossKmInfo.Value, portKmInfo.Value
|
||||||
if isA {
|
if isA {
|
||||||
deviceOffset = tpOffset - (tpOffset - offset)
|
deviceOffset = tpOffset - (tpOffset - offset)
|
||||||
pointTo = !up
|
pointTo = !up
|
||||||
@ -217,10 +220,17 @@ func ecsLinkMapToTurnout(isA bool, offset int64, up bool, link *repository.Link)
|
|||||||
// 查询公里标大于端口公里标
|
// 查询公里标大于端口公里标
|
||||||
if crossKm > portKm {
|
if crossKm > portKm {
|
||||||
km = crossKm - deviceOffset
|
km = crossKm - deviceOffset
|
||||||
runDirection = pointTo
|
|
||||||
} else {
|
} else {
|
||||||
km = crossKm + deviceOffset
|
km = crossKm + deviceOffset
|
||||||
runDirection = !pointTo
|
}
|
||||||
|
if up && isA { // link offset 趋大,A端岔心 ---> 边界
|
||||||
|
runDirection = crossKm < portKm
|
||||||
|
} else if up && !isA { // link offset 趋大,B端边界 ---> 岔心
|
||||||
|
runDirection = crossKm > portKm
|
||||||
|
} else if !up && isA { // link offset 趋小,A端边界 ---> 岔心
|
||||||
|
runDirection = crossKm > portKm
|
||||||
|
} else { // link offset 趋小,B端岔心 ---> 边界
|
||||||
|
runDirection = crossKm < portKm
|
||||||
}
|
}
|
||||||
switch tp.Port() {
|
switch tp.Port() {
|
||||||
case proto2.Port_A:
|
case proto2.Port_A:
|
||||||
|
@ -3,7 +3,8 @@ package memory
|
|||||||
import (
|
import (
|
||||||
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
||||||
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
|
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
|
||||||
"joylink.club/rtsssimulation/entities"
|
"joylink.club/rtsssimulation/component"
|
||||||
|
"joylink.club/rtsssimulation/entity"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 获取仿真地图的继电器状态,前端推送
|
// 获取仿真地图的继电器状态,前端推送
|
||||||
@ -12,11 +13,13 @@ func GetMapAllRelayState(sim *VerifySimulation, mapId int32) []*state.ReplyState
|
|||||||
uidMap := QueryMapUidMapByType(mapId, &graphicData.Relay{})
|
uidMap := QueryMapUidMapByType(mapId, &graphicData.Relay{})
|
||||||
var replyStateArr []*state.ReplyState
|
var replyStateArr []*state.ReplyState
|
||||||
for _, u := range uidMap {
|
for _, u := range uidMap {
|
||||||
p := entities.GetRelayState(sim.WorldId, u.Uid)
|
entry, _ := entity.GetEntityByUid(sim.World, u.Uid)
|
||||||
if p == nil {
|
bit := component.BitStateType.Get(entry)
|
||||||
continue
|
// p := entities.GetRelayState(sim.WorldId, u.Uid)
|
||||||
}
|
// if p == nil {
|
||||||
replyStateArr = append(replyStateArr, &state.ReplyState{Id: u.CommonId, Xh: p.Xh})
|
// continue
|
||||||
|
// }
|
||||||
|
replyStateArr = append(replyStateArr, &state.ReplyState{Id: u.CommonId, Xh: bit.Val})
|
||||||
}
|
}
|
||||||
return replyStateArr
|
return replyStateArr
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package memory
|
package memory
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"joylink.club/rtsssimulation/entities"
|
"joylink.club/rtsssimulation/component"
|
||||||
|
"joylink.club/rtsssimulation/entity"
|
||||||
|
"joylink.club/rtsssimulation/fi"
|
||||||
|
|
||||||
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
||||||
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
|
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
|
||||||
@ -11,9 +13,11 @@ import (
|
|||||||
func ChangeTurnoutState(simulation *VerifySimulation, status *state.SwitchState, mapId int32) {
|
func ChangeTurnoutState(simulation *VerifySimulation, status *state.SwitchState, mapId int32) {
|
||||||
uid := QueryUidByMidAndComId(mapId, status.Id, &graphicData.Turnout{})
|
uid := QueryUidByMidAndComId(mapId, status.Id, &graphicData.Turnout{})
|
||||||
if status.Normal {
|
if status.Normal {
|
||||||
entities.TurnToNormal(simulation.WorldId, uid)
|
fi.DriveTurnoutDCOn(simulation.World, uid)
|
||||||
|
// entities.TurnToNormal(simulation.WorldId, uid)
|
||||||
} else if status.Reverse {
|
} else if status.Reverse {
|
||||||
entities.TurnToReverse(simulation.WorldId, uid)
|
fi.DriveTurnoutFCOn(simulation.World, uid)
|
||||||
|
// entities.TurnToReverse(simulation.WorldId, uid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,15 +26,19 @@ func GetAllTurnoutState(sim *VerifySimulation) []*state.SwitchState {
|
|||||||
var switchArr []*state.SwitchState
|
var switchArr []*state.SwitchState
|
||||||
turnoutList := sim.Repo.TurnoutList()
|
turnoutList := sim.Repo.TurnoutList()
|
||||||
for _, o := range turnoutList {
|
for _, o := range turnoutList {
|
||||||
p := entities.GetTurnoutState(sim.WorldId, o.Id())
|
entry, _ := entity.GetEntityByUid(sim.World, o.Id())
|
||||||
if p == nil {
|
tp := component.TurnoutPositionType.Get(entry)
|
||||||
continue
|
// p := entities.GetTurnoutState(sim.WorldId, o.Id())
|
||||||
}
|
// if p == nil {
|
||||||
|
// continue
|
||||||
|
// }
|
||||||
switchArr = append(switchArr, &state.SwitchState{
|
switchArr = append(switchArr, &state.SwitchState{
|
||||||
Id: sim.GetComIdByUid(o.Id()),
|
Id: sim.GetComIdByUid(o.Id()),
|
||||||
Normal: p.Normal,
|
// Normal: p.Normal,
|
||||||
Reverse: p.Reverse,
|
// Reverse: p.Reverse,
|
||||||
Turning: p.Turning,
|
// Turning: p.Turning,
|
||||||
|
Normal: tp.Dw,
|
||||||
|
Reverse: tp.Fw,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return switchArr
|
return switchArr
|
||||||
@ -42,15 +50,19 @@ func GetMapAllTurnoutState(sim *VerifySimulation, mapId int32) []*state.SwitchSt
|
|||||||
uidMap := QueryMapUidMapByType(mapId, &graphicData.Turnout{})
|
uidMap := QueryMapUidMapByType(mapId, &graphicData.Turnout{})
|
||||||
var switchArr []*state.SwitchState
|
var switchArr []*state.SwitchState
|
||||||
for _, u := range uidMap {
|
for _, u := range uidMap {
|
||||||
p := entities.GetTurnoutState(sim.WorldId, u.Uid)
|
entry, _ := entity.GetEntityByUid(sim.World, u.Uid)
|
||||||
if p == nil {
|
tp := component.TurnoutPositionType.Get(entry)
|
||||||
continue
|
// p := entities.GetTurnoutState(sim.WorldId, o.Id())
|
||||||
}
|
// if p == nil {
|
||||||
|
// continue
|
||||||
|
// }
|
||||||
switchArr = append(switchArr, &state.SwitchState{
|
switchArr = append(switchArr, &state.SwitchState{
|
||||||
Id: u.CommonId,
|
Id: u.CommonId,
|
||||||
Normal: p.Normal,
|
// Normal: p.Normal,
|
||||||
Reverse: p.Reverse,
|
// Reverse: p.Reverse,
|
||||||
Turning: p.Turning,
|
// Turning: p.Turning,
|
||||||
|
Normal: tp.Dw,
|
||||||
|
Reverse: tp.Fw,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return switchArr
|
return switchArr
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"joylink.club/rtsssimulation/simulation/world"
|
rtss_simulation "joylink.club/rtsssimulation"
|
||||||
|
|
||||||
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
||||||
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
|
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
|
||||||
@ -32,6 +32,7 @@ type VerifySimulation struct {
|
|||||||
Repo *repository.Repository
|
Repo *repository.Repository
|
||||||
//Rtss仿真世界的id
|
//Rtss仿真世界的id
|
||||||
WorldId ecs.WorldId
|
WorldId ecs.WorldId
|
||||||
|
World ecs.World
|
||||||
//设备UID映射
|
//设备UID映射
|
||||||
uidMap map[string]*elementIdStructure
|
uidMap map[string]*elementIdStructure
|
||||||
}
|
}
|
||||||
@ -110,13 +111,15 @@ func CreateSimulation(projectId int32, mapIds []int32) (*VerifySimulation, error
|
|||||||
// 构建所有UID映射关系,
|
// 构建所有UID映射关系,
|
||||||
allUidMap := buildRepositoryAllUidsMap(mapIds, repo)
|
allUidMap := buildRepositoryAllUidsMap(mapIds, repo)
|
||||||
//创建仿真
|
//创建仿真
|
||||||
worldId := world.CreateSimulation(repo)
|
// worldId := world.CreateSimulation(repo)
|
||||||
|
w := rtss_simulation.NewSimulation(repo)
|
||||||
verifySimulation := &VerifySimulation{
|
verifySimulation := &VerifySimulation{
|
||||||
MapIds: mapIds,
|
MapIds: mapIds,
|
||||||
ProjectId: projectId,
|
ProjectId: projectId,
|
||||||
Memory: worldMemory,
|
Memory: worldMemory,
|
||||||
Repo: repo,
|
Repo: repo,
|
||||||
WorldId: worldId,
|
World: w,
|
||||||
|
WorldId: w.Id(),
|
||||||
uidMap: allUidMap,
|
uidMap: allUidMap,
|
||||||
}
|
}
|
||||||
return verifySimulation, nil
|
return verifySimulation, nil
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit d36ba6fc7dfe5235ace72be522566e55aadd34e1
|
Subproject commit 33aca5ef48b372ac67c21272ec07267cb025dc2c
|
Loading…
Reference in New Issue
Block a user