【仿真修改属性】
This commit is contained in:
parent
8ee2bb14b8
commit
0fbec96ef6
@ -22,7 +22,6 @@ import (
|
||||
|
||||
func InitSimulationRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||
authed := api.Group("/v1/simulation").Use(authMiddleware.MiddlewareFunc(), middleware.PermissMiddleware)
|
||||
authed.POST("/create", create)
|
||||
authed.POST("/createByProject", createByProjectId)
|
||||
authed.GET("/state/:id", findSimulationState)
|
||||
authed.POST("/destroy/:id", destroy)
|
||||
@ -49,34 +48,6 @@ func initPublishMapInfo() {
|
||||
}
|
||||
}
|
||||
|
||||
// 创建ATS测试仿真
|
||||
//
|
||||
// @Summary 创建ATS测试仿真
|
||||
//
|
||||
// @Security JwtAuth
|
||||
//
|
||||
// @Description 创建ATS测试仿真
|
||||
// @Tags ATS测试仿真Api
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Authorization header string true "JWT Token"
|
||||
// @Param SimulationCreateReqDto body dto.SimulationCreateReqDto true "创建仿真请求"
|
||||
// @Success 200 {object} dto.SimulationCreateRspDto
|
||||
// @Failure 500 {object} dto.ErrorDto
|
||||
// @Router /api/v1/simulation/create [post]
|
||||
func create(c *gin.Context) {
|
||||
req := dto.SimulationCreateReqDto{}
|
||||
if err := c.ShouldBind(&req); nil != err {
|
||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
||||
}
|
||||
zap.S().Debug("创建仿真请求:", req)
|
||||
rsp := dto.SimulationCreateRspDto{
|
||||
MapId: req.MapId,
|
||||
}
|
||||
rsp.SimulationId = simulation.CreateSimulation(req.MapId, req.ProjectId)
|
||||
c.JSON(http.StatusOK, &rsp)
|
||||
}
|
||||
|
||||
// 创建ATS测试仿真通过项目ID
|
||||
//
|
||||
// @Summary 创建ATS测试仿真
|
||||
@ -97,14 +68,16 @@ func createByProjectId(c *gin.Context) {
|
||||
if err := c.ShouldBind(&req); nil != err {
|
||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
||||
}
|
||||
rsp := dto.SimulationCreateRspDto{ProjectId: req.ProjectId}
|
||||
mapInfos := service.QueryProjectPublishedGi(req.ProjectId)
|
||||
if len(mapInfos) == 0 {
|
||||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: "项目未关联地图"})
|
||||
}
|
||||
mapInfo := mapInfos[0]
|
||||
rsp.MapId = mapInfo.ID
|
||||
rsp.SimulationId = simulation.CreateSimulation(mapInfo.ID, req.ProjectId)
|
||||
mapIds := make([]int32, len(mapInfos))
|
||||
for i, mapInfo := range mapInfos {
|
||||
mapIds[i] = mapInfo.ID
|
||||
}
|
||||
rsp := dto.SimulationCreateRspDto{ProjectId: req.ProjectId, MapId: mapIds[0], MapIds: mapIds}
|
||||
rsp.SimulationId = simulation.CreateSimulation(req.ProjectId, mapIds)
|
||||
c.JSON(http.StatusOK, &rsp)
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1297,6 +1297,7 @@ type SimulationStatus struct {
|
||||
SimulationId string `protobuf:"bytes,1,opt,name=simulationId,proto3" json:"simulationId,omitempty"`
|
||||
MapId int32 `protobuf:"varint,2,opt,name=mapId,proto3" json:"mapId,omitempty"`
|
||||
ProjectId int32 `protobuf:"varint,3,opt,name=projectId,proto3" json:"projectId,omitempty"`
|
||||
MapIds []int32 `protobuf:"varint,4,rep,packed,name=mapIds,proto3" json:"mapIds,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SimulationStatus) Reset() {
|
||||
@ -1352,6 +1353,13 @@ func (x *SimulationStatus) GetProjectId() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SimulationStatus) GetMapIds() []int32 {
|
||||
if x != nil {
|
||||
return x.MapIds
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 变更信息状态
|
||||
type MemoryDataStatus struct {
|
||||
state protoimpl.MessageState
|
||||
@ -1620,37 +1628,38 @@ var file_device_state_proto_rawDesc = []byte{
|
||||
0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x73,
|
||||
0x74, 0x61, 0x74, 0x65, 0x2e, 0x41, 0x6c, 0x6c, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x73, 0x53,
|
||||
0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x09, 0x61, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73,
|
||||
0x22, 0x6a, 0x0a, 0x10, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74,
|
||||
0x61, 0x74, 0x75, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x69, 0x6d, 0x75,
|
||||
0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x61, 0x70, 0x49,
|
||||
0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6d, 0x61, 0x70, 0x49, 0x64, 0x12, 0x1c,
|
||||
0x0a, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28,
|
||||
0x05, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x22, 0xdb, 0x01, 0x0a,
|
||||
0x10, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, 0x53, 0x74, 0x61, 0x74, 0x75,
|
||||
0x73, 0x12, 0x3f, 0x0a, 0x0e, 0x61, 0x6c, 0x6c, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x73, 0x74, 0x61, 0x74,
|
||||
0x65, 0x2e, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74,
|
||||
0x75, 0x73, 0x52, 0x0e, 0x61, 0x6c, 0x6c, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x12, 0x3f, 0x0a, 0x0e, 0x61, 0x64, 0x64, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x73, 0x74, 0x61,
|
||||
0x74, 0x65, 0x2e, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61,
|
||||
0x74, 0x75, 0x73, 0x52, 0x0e, 0x61, 0x64, 0x64, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0x12, 0x45, 0x0a, 0x11, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x69, 0x6d,
|
||||
0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17,
|
||||
0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x11, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53,
|
||||
0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2a, 0x37, 0x0a, 0x0b, 0x53, 0x65,
|
||||
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x6e, 0x79,
|
||||
0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x41, 0x78, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05,
|
||||
0x4c, 0x6f, 0x67, 0x69, 0x63, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x50, 0x68, 0x79, 0x73, 0x69,
|
||||
0x63, 0x10, 0x03, 0x42, 0x54, 0x0a, 0x25, 0x63, 0x6c, 0x75, 0x62, 0x2e, 0x6a, 0x6f, 0x79, 0x6c,
|
||||
0x69, 0x6e, 0x6b, 0x2e, 0x62, 0x6a, 0x72, 0x74, 0x73, 0x73, 0x2e, 0x61, 0x74, 0x73, 0x2e, 0x76,
|
||||
0x65, 0x72, 0x69, 0x66, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x42, 0x10, 0x44, 0x65,
|
||||
0x76, 0x69, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x5a, 0x19,
|
||||
0x2e, 0x2f, 0x61, 0x74, 0x73, 0x2f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x2f, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x73, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x33,
|
||||
0x22, 0x82, 0x01, 0x0a, 0x10, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53,
|
||||
0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x69, 0x6d,
|
||||
0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x61, 0x70,
|
||||
0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6d, 0x61, 0x70, 0x49, 0x64, 0x12,
|
||||
0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01,
|
||||
0x28, 0x05, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x12, 0x16, 0x0a,
|
||||
0x06, 0x6d, 0x61, 0x70, 0x49, 0x64, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x05, 0x52, 0x06, 0x6d,
|
||||
0x61, 0x70, 0x49, 0x64, 0x73, 0x22, 0xdb, 0x01, 0x0a, 0x10, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79,
|
||||
0x44, 0x61, 0x74, 0x61, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3f, 0x0a, 0x0e, 0x61, 0x6c,
|
||||
0x6c, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03,
|
||||
0x28, 0x0b, 0x32, 0x17, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x69, 0x6d, 0x75, 0x6c,
|
||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0e, 0x61, 0x6c, 0x6c,
|
||||
0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3f, 0x0a, 0x0e, 0x61,
|
||||
0x64, 0x64, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20,
|
||||
0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x69, 0x6d, 0x75,
|
||||
0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0e, 0x61, 0x64,
|
||||
0x64, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x45, 0x0a, 0x11,
|
||||
0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e,
|
||||
0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73,
|
||||
0x52, 0x11, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0x2a, 0x37, 0x0a, 0x0b, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79,
|
||||
0x70, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x6e, 0x79, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x41,
|
||||
0x78, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x10, 0x02,
|
||||
0x12, 0x0a, 0x0a, 0x06, 0x50, 0x68, 0x79, 0x73, 0x69, 0x63, 0x10, 0x03, 0x42, 0x54, 0x0a, 0x25,
|
||||
0x63, 0x6c, 0x75, 0x62, 0x2e, 0x6a, 0x6f, 0x79, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, 0x62, 0x6a, 0x72,
|
||||
0x74, 0x73, 0x73, 0x2e, 0x61, 0x74, 0x73, 0x2e, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x73, 0x42, 0x10, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x53, 0x74, 0x61,
|
||||
0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x5a, 0x19, 0x2e, 0x2f, 0x61, 0x74, 0x73, 0x2f, 0x76,
|
||||
0x65, 0x72, 0x69, 0x66, 0x79, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x73, 0x74, 0x61,
|
||||
0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -81,21 +81,24 @@ func IsExistSimulation() bool {
|
||||
}
|
||||
|
||||
// 创建仿真对象
|
||||
func CreateSimulation(mapId, projectId int32) string {
|
||||
var simulationId string
|
||||
if projectId == 0 {
|
||||
simulationId = createSimulationId(mapId)
|
||||
} else {
|
||||
simulationId = createSimulationIdByProject(projectId)
|
||||
}
|
||||
func CreateSimulation(projectId int32, mapIds []int32) string {
|
||||
simulationId := createSimulationId(projectId)
|
||||
_, e := simulationMap.Load(simulationId)
|
||||
if !e && IsExistSimulation() {
|
||||
panic(dto.ErrorDto{Code: dto.DataAlreadyExist, Message: "已有仿真在运行"})
|
||||
}
|
||||
if !e {
|
||||
verifySimulation := memory.CreateSimulation(mapId, projectId, simulationId)
|
||||
verifySimulation := memory.CreateSimulation(projectId, mapIds)
|
||||
verifySimulation.SimulationId = simulationId
|
||||
lineDataInfo := &dynamics.LineBaseInfo{}
|
||||
for _, mapId := range mapIds {
|
||||
b := buildLineBaseInfo(memory.QueryMapVerifyStructure(mapId))
|
||||
lineDataInfo.CurveList = append(lineDataInfo.CurveList, b.CurveList...)
|
||||
lineDataInfo.LinkList = append(lineDataInfo.LinkList, b.LinkList...)
|
||||
lineDataInfo.SlopeList = append(lineDataInfo.SlopeList, b.SlopeList...)
|
||||
}
|
||||
//通知动力学
|
||||
httpCode, _, err := dynamics.SendSimulationStartReq(buildLineBaseInfo(memory.QueryMapVerifyStructure(verifySimulation.MapId)))
|
||||
httpCode, _, err := dynamics.SendSimulationStartReq(lineDataInfo)
|
||||
if httpCode != http.StatusOK || err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.DynamicsError, Message: fmt.Sprintf("动力学接口调用失败:[%d][%s]", httpCode, err)})
|
||||
}
|
||||
@ -117,15 +120,9 @@ func DestroySimulation(simulationId string) {
|
||||
}
|
||||
}
|
||||
|
||||
// 创建时生成仿真Id
|
||||
func createSimulationId(mapId int32) string {
|
||||
// 当前服务器IP + 端口 + 地图
|
||||
return config.SimulationId_prefix + "_" + strconv.Itoa(config.Config.Server.Port) + "_map_" + strconv.Itoa(int(mapId))
|
||||
}
|
||||
|
||||
func createSimulationIdByProject(mapId int32) string {
|
||||
// 当前服务器IP + 端口 + 地图
|
||||
return config.SimulationId_prefix + "_" + strconv.Itoa(config.Config.Server.Port) + "_project_" + strconv.Itoa(int(mapId))
|
||||
func createSimulationId(projectId int32) string {
|
||||
// 当前服务器IP + 端口 + 项目
|
||||
return config.SimulationId_prefix + "_" + strconv.Itoa(config.Config.Server.Port) + "_" + strconv.Itoa(int(projectId))
|
||||
}
|
||||
|
||||
// 获取仿真列表
|
||||
@ -135,7 +132,8 @@ func ListAllSimulations() []*dto.SimulationInfoRspDto {
|
||||
s := v.(*memory.VerifySimulation)
|
||||
simArr = append(simArr, &dto.SimulationInfoRspDto{
|
||||
SimulationId: s.SimulationId,
|
||||
MapId: s.MapId,
|
||||
MapId: s.MapIds[0],
|
||||
MapIds: s.MapIds,
|
||||
ProjectId: s.ProjectId,
|
||||
})
|
||||
return true
|
||||
@ -163,9 +161,18 @@ func GetSimulationArr() []*memory.VerifySimulation {
|
||||
}
|
||||
|
||||
func convert(info *dynamics.TrainInfo, sta *state.TrainState, simulation *memory.VerifySimulation) *state.TrainState {
|
||||
vs := memory.QueryMapVerifyStructure(simulation.MapId)
|
||||
var vs *memory.VerifyStructure
|
||||
linkId := int32(info.Link)
|
||||
for _, mapId := range simulation.MapIds {
|
||||
vm := memory.QueryMapVerifyStructure(mapId)
|
||||
if vm.LinkModelMap[linkId] == nil {
|
||||
continue
|
||||
}
|
||||
vs = vm
|
||||
break
|
||||
}
|
||||
zap.S().Debugf("原始消息:[%d-%d-%d]", info.Number, info.Link, info.LinkOffset)
|
||||
id, port, offset, runDirection, pointTo, kilometer := memory.QueryDeviceByCalcLink(vs, int32(info.Link), int64(info.LinkOffset), info.Up, sta.RunDirection)
|
||||
id, port, offset, runDirection, pointTo, kilometer := memory.QueryDeviceByCalcLink(vs, linkId, int64(info.LinkOffset), info.Up, sta.RunDirection)
|
||||
zap.S().Debugf("转换后的消息:[%d-车头:%s-偏移:%d-上行:%v-是否ab:%v]", info.Number, id, offset, runDirection, pointTo)
|
||||
sta.HeadDeviceId = id
|
||||
sta.DevicePort = port
|
||||
|
@ -59,6 +59,11 @@ type GraphicInfoMapStructure struct {
|
||||
PhysicalSectionMap map[string]*graphicData.Section
|
||||
LogicSectionMap map[string]*graphicData.LogicSection
|
||||
SignalMap map[string]*graphicData.Signal
|
||||
TransponderMap map[string]*graphicData.Transponder
|
||||
SlopeMap map[string]*graphicData.Slope
|
||||
SlopeKiloMarkerMap map[string]*graphicData.SlopeKiloMarker
|
||||
CurvatureMap map[string]*graphicData.Curvature
|
||||
CurvatureKiloMarkerMap map[string]*graphicData.CurvatureKiloMarker
|
||||
//key-index
|
||||
CalcLinkMap map[int32]*graphicData.CalculateLink
|
||||
//设备在link上的位置。key-设备id
|
||||
@ -100,6 +105,11 @@ func PublishMapVerifyStructure(graphic *model.PublishedGi) *VerifyStructure {
|
||||
SignalMap: make(map[string]*graphicData.Signal),
|
||||
CalcLinkMap: make(map[int32]*graphicData.CalculateLink),
|
||||
DevicePositionMap: make(map[string]*ref.DevicePosition[*device.LinkModel]),
|
||||
TransponderMap: make(map[string]*graphicData.Transponder),
|
||||
SlopeMap: make(map[string]*graphicData.Slope),
|
||||
SlopeKiloMarkerMap: make(map[string]*graphicData.SlopeKiloMarker),
|
||||
CurvatureMap: make(map[string]*graphicData.Curvature),
|
||||
CurvatureKiloMarkerMap: make(map[string]*graphicData.CurvatureKiloMarker),
|
||||
}
|
||||
graphicStorage := &graphicData.RtssGraphicStorage{}
|
||||
proto.Unmarshal(graphic.Proto, graphicStorage)
|
||||
@ -109,7 +119,7 @@ func PublishMapVerifyStructure(graphic *model.PublishedGi) *VerifyStructure {
|
||||
buildDeviceRef(graphicInfoMap, verifyStructure)
|
||||
graphicDataMap.Store(graphic.ID, verifyStructure)
|
||||
// 地图原始数据
|
||||
graphicSourceDataMap.Store(graphic.ID, graphicStorage)
|
||||
graphicSourceDataMap.Store(graphic.ID, graphicInfoMap)
|
||||
return verifyStructure
|
||||
}
|
||||
|
||||
@ -134,19 +144,12 @@ func QueryMapVerifyStructure(mapId int32) *VerifyStructure {
|
||||
}
|
||||
|
||||
// 获取内存中地图原始信息
|
||||
func QueryMapSourceDataStructure(mapId int32) *graphicData.RtssGraphicStorage {
|
||||
func QueryMapSourceDataStructure(mapId int32) *GraphicInfoMapStructure {
|
||||
d, ok := graphicSourceDataMap.Load(mapId)
|
||||
if ok {
|
||||
return d.(*graphicData.RtssGraphicStorage)
|
||||
return d.(*GraphicInfoMapStructure)
|
||||
}
|
||||
mapData, _ := dbquery.PublishedGi.Where(dbquery.PublishedGi.ID.Eq(mapId), dbquery.PublishedGi.Status.Eq(1)).First()
|
||||
if mapData != nil {
|
||||
graphicStorage := &graphicData.RtssGraphicStorage{}
|
||||
proto.Unmarshal(mapData.Proto, graphicStorage)
|
||||
return graphicStorage
|
||||
} else {
|
||||
panic(fmt.Sprintf("地图【id:%d】数据不存在", mapId))
|
||||
}
|
||||
}
|
||||
|
||||
// 根据区段,道岔偏移量返回linkID和link相对偏移量
|
||||
@ -412,17 +415,20 @@ func initGraphicStructure(graphicData *graphicData.RtssGraphicStorage, verifyStr
|
||||
// 初始化信号机信息
|
||||
initGraphicSignal(graphicData.Signals, verifyStructure, graphicDataMap)
|
||||
// 初始化坡度和曲线端点
|
||||
initPoints(graphicData, verifyStructure)
|
||||
initPoints(graphicData, verifyStructure, graphicDataMap)
|
||||
// 初始化Link信息
|
||||
initLinks(graphicData.CalculateLink, verifyStructure, graphicDataMap)
|
||||
// 初始化坡度
|
||||
initSlopes(graphicData.Slopes, verifyStructure, graphicDataMap)
|
||||
// 初始化曲线
|
||||
initCurves(graphicData.Curvatures, verifyStructure, graphicDataMap)
|
||||
// 初始化应答器
|
||||
initTransponder(graphicData.Transponders, graphicDataMap)
|
||||
}
|
||||
|
||||
func initCurves(curves []*graphicData.Curvature, vs *VerifyStructure, dataMap *GraphicInfoMapStructure) {
|
||||
for _, curve := range curves {
|
||||
dataMap.CurvatureMap[curve.Common.Id] = curve
|
||||
c := §ion.CurveModel{
|
||||
DeviceModel: face.DeviceModel{
|
||||
GraphicId: curve.GetCommon().GetId(),
|
||||
@ -448,6 +454,7 @@ func initCurves(curves []*graphicData.Curvature, vs *VerifyStructure, dataMap *G
|
||||
|
||||
func initSlopes(slopes []*graphicData.Slope, vs *VerifyStructure, dataMap *GraphicInfoMapStructure) {
|
||||
for _, slope := range slopes {
|
||||
dataMap.SlopeMap[slope.Common.Id] = slope
|
||||
s := §ion.SlopeModel{
|
||||
DeviceModel: face.DeviceModel{
|
||||
GraphicId: slope.GetCommon().GetId(),
|
||||
@ -471,8 +478,9 @@ func initSlopes(slopes []*graphicData.Slope, vs *VerifyStructure, dataMap *Graph
|
||||
}
|
||||
}
|
||||
|
||||
func initPoints(storage *graphicData.RtssGraphicStorage, vs *VerifyStructure) {
|
||||
func initPoints(storage *graphicData.RtssGraphicStorage, vs *VerifyStructure, dataMap *GraphicInfoMapStructure) {
|
||||
for _, slopeKm := range storage.SlopeKiloMarker {
|
||||
dataMap.SlopeKiloMarkerMap[slopeKm.Common.Id] = slopeKm
|
||||
vs.PointMap[slopeKm.Common.Id] = &device.PointModel{
|
||||
DeviceModel: face.DeviceModel{
|
||||
GraphicId: slopeKm.Common.Id,
|
||||
@ -482,6 +490,7 @@ func initPoints(storage *graphicData.RtssGraphicStorage, vs *VerifyStructure) {
|
||||
}
|
||||
}
|
||||
for _, curvatureKm := range storage.CurvatureKiloMarker {
|
||||
dataMap.CurvatureKiloMarkerMap[curvatureKm.Common.Id] = curvatureKm
|
||||
vs.PointMap[curvatureKm.Common.Id] = &device.PointModel{
|
||||
DeviceModel: face.DeviceModel{
|
||||
GraphicId: curvatureKm.Common.Id,
|
||||
@ -585,6 +594,12 @@ func initLinks(links []*graphicData.CalculateLink, vs *VerifyStructure, dataMap
|
||||
}
|
||||
}
|
||||
|
||||
func initTransponder(transponders []*graphicData.Transponder, dataMap *GraphicInfoMapStructure) {
|
||||
for _, t := range transponders {
|
||||
dataMap.TransponderMap[t.Common.Id] = t
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化计轴信息
|
||||
func initGraphicAxlePoints(axlePoints []*graphicData.AxleCounting, data *VerifyStructure, graphicDataMap *GraphicInfoMapStructure) {
|
||||
for _, a := range axlePoints {
|
||||
|
@ -34,8 +34,19 @@ func AddTrainState(vs *VerifySimulation, status *state.TrainState) {
|
||||
status.Show = true
|
||||
//向动力学发送初始化请求
|
||||
trainIndex, _ := strconv.ParseUint(status.Id, 10, 16)
|
||||
var mapId int32
|
||||
for _, m := range vs.MapIds {
|
||||
vm := QueryMapVerifyStructure(m)
|
||||
if vm.PhysicalSectionModelMap[status.HeadDeviceId] != nil || vm.SwitchDeviceModelMap[status.HeadDeviceId] != nil {
|
||||
mapId = m
|
||||
break
|
||||
}
|
||||
}
|
||||
if mapId == 0 {
|
||||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("不存在设备【index:%s】", status.HeadDeviceId)})
|
||||
}
|
||||
// 映射link、偏移量、运行方向
|
||||
linkId, loffset, up, pointTo, kilometer := QueryMapCalcLinkByDeviceInfo(vs.MapId, status.HeadDeviceId, status.DevicePort, status.HeadOffset, status.RunDirection)
|
||||
linkId, loffset, up, pointTo, kilometer := QueryMapCalcLinkByDeviceInfo(mapId, status.HeadDeviceId, status.DevicePort, status.HeadOffset, status.RunDirection)
|
||||
status.Up = up
|
||||
status.PointTo = pointTo
|
||||
status.TrainKilometer = kilometer
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
// 轨旁仿真定义
|
||||
type VerifySimulation struct {
|
||||
//地图id
|
||||
MapId int32
|
||||
MapIds []int32
|
||||
// 项目ID
|
||||
ProjectId int32
|
||||
//仿真id
|
||||
@ -17,16 +17,18 @@ type VerifySimulation struct {
|
||||
}
|
||||
|
||||
// 创建仿真对象
|
||||
func CreateSimulation(mapId, projectId int32, simulationId string) *VerifySimulation {
|
||||
func CreateSimulation(projectId int32, mapIds []int32) *VerifySimulation {
|
||||
m := &WaysideMemory{}
|
||||
verifySimulation := &VerifySimulation{
|
||||
MapId: mapId,
|
||||
MapIds: mapIds,
|
||||
ProjectId: projectId,
|
||||
SimulationId: simulationId,
|
||||
Memory: m.Create(),
|
||||
}
|
||||
s := verifySimulation.Memory.Status
|
||||
// 初始化构地图设备状态
|
||||
InitFromMap(verifySimulation.Memory.Status, QueryMapVerifyStructure(mapId))
|
||||
for _, mapId := range mapIds {
|
||||
InitFromMap(s, QueryMapVerifyStructure(mapId))
|
||||
}
|
||||
return verifySimulation
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,8 @@ type SimulationCreateRspDto struct {
|
||||
ProjectId int32 `json:"projectId" form:"projectId"`
|
||||
//仿真id
|
||||
SimulationId string `json:"simulationId" form:"simulationId"`
|
||||
// 地图列表
|
||||
MapIds []int32 `json:"mapIds" form:"mapIds"`
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -78,7 +80,8 @@ type CheckMapDataRspDto struct {
|
||||
// 仿真实例的基本信息响应
|
||||
type SimulationInfoRspDto struct {
|
||||
SimulationId string `form:"simulationId" json:"simulationId"`
|
||||
MapId int32 `form:"mapId" json:"mapId"`
|
||||
MapId int32 `json:"mapId" form:"mapId"`
|
||||
MapIds []int32 `form:"mapIds" json:"mapIds"`
|
||||
ProjectId int32 `form:"projectId" json:"projectId"`
|
||||
}
|
||||
type SimulationInfoRspDtoArr []SimulationInfoRspDto
|
||||
|
@ -53,7 +53,7 @@ func (t *MemoryChangeServer) onTick() []TopicMsg {
|
||||
if t.SimulationMap[v.SimulationId] != nil {
|
||||
continue
|
||||
}
|
||||
status := &state.SimulationStatus{SimulationId: v.SimulationId, MapId: v.MapId, ProjectId: v.ProjectId}
|
||||
status := &state.SimulationStatus{SimulationId: v.SimulationId, MapId: v.MapIds[0], ProjectId: v.ProjectId, MapIds: v.MapIds}
|
||||
t.SimulationMap[v.SimulationId] = status
|
||||
addArr = append(addArr, status)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user