model repo 用例

This commit is contained in:
soul-walker 2024-06-19 19:29:46 +08:00
parent 7a13df1b0d
commit f66d826418
14 changed files with 8660 additions and 11 deletions

View File

@ -0,0 +1,33 @@
package main
import (
"joylink.club/rtss-core/example/data_proto"
"joylink.club/rtss-core/model"
)
var (
_stationMap = make(map[uint32]*data_proto.Station)
_sectionMap = make(map[uint32]*data_proto.Section)
_turnoutMap = make(map[uint32]*data_proto.Turnout)
)
func main() {
rtssGraphicStorage := data_proto.GetLineSytle1()
// log.Println(rtssGraphicStorage.Stations)
// log.Println(rtssGraphicStorage.Section)
// log.Println(rtssGraphicStorage.Turnouts)
for _, station := range rtssGraphicStorage.Stations {
_stationMap[station.Common.Id] = station
}
for _, section := range rtssGraphicStorage.Section {
if section.CentralizedStations == nil || len(section.CentralizedStations) == 0 || _stationMap[section.CentralizedStations[0]] == nil {
continue
}
_sectionMap[section.Common.Id] = section
model.NewSection(getSectionUid(section))
}
}
func getSectionUid(section *data_proto.Section) string {
return _stationMap[section.CentralizedStations[0]].Code + "-" + section.Code
}

View File

@ -0,0 +1,39 @@
package data_proto
import (
"encoding/base64"
"os"
"path/filepath"
"google.golang.org/protobuf/proto"
)
// / 线路样式1
// / xxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxx
// / x x x
// / x x x
// / x x x
// / x x
// / x x x
// / x x x
// / x x x
// / xxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
func GetLineSytle1() *RtssGraphicStorage {
basePath, _ := os.Getwd()
filename := filepath.Join(basePath, "example/data_proto/linestyle1.base64")
bs, err := os.ReadFile(filename)
if err != nil {
panic(err)
}
protobytes, err := base64.StdEncoding.DecodeString(string(bs))
if err != nil {
panic(err)
}
rtssGraphicStorage := RtssGraphicStorage{}
err = proto.Unmarshal(protobytes, &rtssGraphicStorage)
if err != nil {
panic(err)
}
return &rtssGraphicStorage
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,758 @@
syntax = "proto3";
package graphicData;
option go_package = "joylink.club/rtss-core/example/data_proto";
message RtssGraphicStorage {
Canvas canvas = 1;
// repeated Link links = 2;
// repeated IscsFan iscsFans = 3;
repeated Platform Platforms = 4;
repeated Station stations = 5;
// repeated Rect rects = 6;
repeated Train train = 7;
repeated Signal signals = 8;
repeated Turnout turnouts = 9;
repeated Section section = 10;
repeated Polygon polygons = 11;
repeated TrainWindow trainWindows = 12;
repeated AxleCounting axleCountings = 13;
repeated Separator separators = 14;
repeated SectionLink sectionLinks = 15;
repeated AxleCountingSection axleCountingSections = 16;
repeated LogicSection logicSections = 17;
repeated StopPosition stopPositions = 18;
repeated SpksSwitch spksSwitchs = 19;
repeated EsbButton esbButtons = 20; //
repeated GatedBox gateBoxs = 21; // //
repeated Transponder transponders = 22; //
repeated Slope slopes = 23; //
// repeated CalculateLink CalculateLink = 24; // link信息
repeated SlopeKiloMarker slopeKiloMarker = 25; //
repeated CurvatureKiloMarker curvatureKiloMarker = 26; //
repeated Curvature curvatures = 27; //
repeated TrackSection trackSections = 28; //
repeated TrackLogicSection trackLogicSections = 29; //
//UniqueIdType UniqueIdPrefix = 30;//--
UniqueIdOfStationLayout UniqueIdPrefix = 31;//
repeated KilometerConvert kilometerConvertList = 32;//
repeated ScreenDoor screenDoors = 33;
repeated StationRelateDevice stationRelateDeviceList = 34; //
repeated SectionCodePoint sectionCodePointList = 35; //
ScreenDoorConfig screenDoorConfig = 36;//--
repeated Beacon beacons = 37; //
GenerateAxleCountingConfig generateAxleCountingConfig = 38;//
repeated DepartureTimer departureTimers = 39; //
repeated AutoReturnBox autoReturnBoxs = 40; //
repeated ConcentrationDividingLine concentrationDividingLines = 41; // 线
repeated OtherLine otherLineList = 42; // 线
repeated IbpBox ibpBoxs = 43; // ibp地图打开按钮
repeated PslBox pslBoxs = 44; // psl地图打开按钮
repeated CarWashing carWashings = 45; //
repeated GarageDoor garageDoors = 46; //
repeated GarageDoor floodGates = 47; //
//repeated GarageDoorBox garageDoorBoxes = 48; //Psl开启按钮
LianSuoData lianSuoData = 49; //
repeated HoldButton holdButtons = 50; //
repeated UnattengedButton unattengedButtons = 51; //
}
message Canvas {
//
int32 width = 1;
//
int32 height = 2;
//
string backgroundColor = 3;
//
Transform viewportTransform = 4;
//
Grid gridBackground = 5;
}
//
message Grid {
bool hasGrid = 1;
string lineColor = 2; // 线
int32 space = 3; //
}
message Point {
// x坐标
float x = 1;
// y坐标
float y = 2;
}
//
message Transform {
//
Point position = 1;
//
Point scale = 2;
//
float rotation = 3;
//
Point skew = 4;
}
//
message ChildTransform {
//
string name = 1;
//
Transform transform = 2;
}
//
message CommonInfo {
// string oldid = 1;
string graphicType = 2;
Transform transform = 3;
repeated ChildTransform childTransforms = 4;
uint32 id = 5;
}
// message Link {
// CommonInfo common = 1;
// string code = 2;
// bool curve = 3; // 线
// int32 segmentsCount = 4; // 线
// int32 lineWidth = 5; // 线
// string lineColor = 6; // 线
// repeated Point points = 7; //
// }
// message Rect {
// CommonInfo common = 1;
// string code = 2;
// int32 lineWidth = 3; // 线
// string lineColor = 4; // 线
// float width = 5; //
// float height = 6; //
// int32 radius = 7; //
// Point point = 8; //
// }
message Polygon {
enum PolygonType {
ConcentrationDividingLine = 0;
}
CommonInfo common = 1;
string code = 2; //
PolygonType polygonType = 3; //
repeated Point points = 4; //
}
message ConcentrationDividingLine {
CommonInfo common = 1;
string code = 2; //
repeated Point points = 3; //
//string oldrefLeftStationId = 4;//id
//string oldrefRightStationId = 5;//id
repeated NodeConWithSec nodeConWithSecs = 6;// 线
bool isOtherLineConcentrationDividingLine = 7;//线线
uint32 refLeftStationId = 8;//id
uint32 refRightStationId = 9;//id
}
message NodeConWithSec {
RelatedRef leftSection = 1;
RelatedRef rightSection = 2;
}
message Platform {
enum TypeOfPlatform {
Unknown = 0;
up = 1;
down = 2;
}
CommonInfo common = 1;
string code = 2;
//bool hasdoor = 3; //
//string direction = 4; //
// int32 index = 5; //
//int32 refStationIndex = 6; //
// repeated string centralizedStations = 7; //
//repeated RelatedRef platformRef = 8; //
//string oldrefStationId = 9; //id
//string oldrefSectionId = 10; //id
string refEsbRelayCode = 11;//
TypeOfPlatform type = 12; //
uint32 refStationId = 13; //id
uint32 refSectionId = 14; //id
}
message ScreenDoor {
CommonInfo common = 1;
string code = 2;
//int32 sonDoorAmount = 3; //
//string oldrefPlatformId = 4; //
//repeated ScreenDoorGroup screenDoorGroupList = 5;//
uint32 refPlatformId = 6; //
}
message ScreenDoorConfig {
int32 sonDoorAmount = 1; //
repeated ScreenDoorGroup screenDoorGroupList = 2;//
}
message ScreenDoorGroup {
int32 trainGroupAmount = 1; //
int32 startSmallDoor = 2; //
int32 endSmallDoor = 3; //
}
message Station {
CommonInfo common = 1;
string code = 2;//
// bool hasControl = 3; //
bool concentrationStations = 4; //
// string kilometerCode = 5; //
KilometerSystem kilometerSystem = 6; //
// int32 index = 7;
//string refIbpMapCode = 8; // IBP地图Code
string stationName = 9; //
string stationNameAcronym = 10; //
bool depots = 11; //
//repeated string oldmanageStations = 12; // -id
repeated uint32 manageStations = 13; // -id
}
message TrainWindow {
CommonInfo common = 1;
string code = 2;
int32 sectionId = 3;
}
message AxleCounting {
enum TypeDetectionPoint {
AxleCounting = 0;
SectionBoundary = 1;
}
CommonInfo common = 1;
string code = 2; //
KilometerSystem kilometerSystem = 3; //
repeated RelatedRef axleCountingRef = 4; // id和端口
// int32 index = 5; //
//bool invent = 6; //--
TypeDetectionPoint type = 7; //
//repeated string oldcentralizedStations = 8; // Id列表
repeated uint32 centralizedStations = 9; // Id列表
}
message GenerateAxleCountingConfig {
//repeated string oldbbConnect = 1; //bb连接处生成计轴的道岔id()
//repeated string oldnoGenerateGroup = 2;//
repeated uint32 bbConnect = 3; //bb连接处生成计轴的道岔id()
repeated uint32 noGenerateGroup = 4;//
}
// message Train {
// CommonInfo common = 1;
// string code = 2;
// }
// message IscsFan {
// CommonInfo common = 1;
// string code = 2;
// }
message Turnout { //()
enum SwitchMachineType {
Unknown = 0;
ZDJ9_Single = 1;
ZDJ9_Double = 2;
}
CommonInfo common = 1;
string code = 2;
repeated Point pointA = 6; // A端坐标列表
repeated Point pointB = 7; // B端坐标列表
repeated Point pointC = 8; // C端坐标列表
RelatedRef paRef = 9; // A端关联的设备
RelatedRef pbRef = 10; // B端关联的设备
RelatedRef pcRef = 11; // C端关联的设备
// KilometerSystem kilometerSystem = 12; //
repeated KilometerSystem kilometerSystem = 13; //
// int32 index = 14; //
//string oldpaTrackSectionId = 15; // A端轨道区段id
//string oldpbTrackSectionId = 16; // B端轨道区段id
//string oldpcTrackSectionId = 17; // C端轨道区段id
SwitchMachineType switchMachineType = 18; //
//repeated string oldcentralizedStations = 19; // Id列表
repeated uint32 centralizedStations = 20; // Id列表
uint32 paTrackSectionId = 21; // A端轨道区段id
uint32 pbTrackSectionId = 22; // B端轨道区段id
uint32 pcTrackSectionId = 23; // C端轨道区段id
}
message KilometerSystem {
/** 左右行 **/
enum Direction {
LEFT = 0;
RIGHT = 1;
}
int64 kilometer = 1; //mm
string coordinateSystem = 2; //
Direction direction = 3; //
}
message Signal {
CommonInfo common = 1;
string code = 2;
bool mirror = 3;
// int64 kilometer = 4;
// string coordinateSystem = 5;
KilometerSystem kilometerSystem = 6;
// int32 index = 7; //
RelatedRef refDev = 8; ///
//repeated string oldcentralizedStations = 9; // Id列表
//
//
//
// F- D- Y- Y-
// H- L-绿 U- A- B-
enum Model{
HL = 0; //2XH-1 绿
HLU_FU = 1; //2XH-1 绿,
HLU_DU_YY = 2; //3XH-1 绿,
HLU_YY = 3; //3XH-2JDXH 绿,
HLU_FL_DU_YY = 4;//3XH-3 绿,绿
HLU_DU = 5; //3XH-4 绿,
AB = 6; //DXCH
HBU_DU = 7; //JCKXH ,
}
//
Model mt = 10;
//string belongStation = 11; // ()
Direction direction = 12; //
repeated uint32 centralizedStations = 13; // Id列表
}
/** 上下行(区段/信号机) */
enum Direction {
UP = 0;
DOWN = 1;
}
/** 物理区段(包含岔区和非岔区) */
message Section {
enum SectionType {
Physical = 0;
TurnoutPhysical = 2;
}
enum RunningDirection {
AtoB = 0;
BtoA = 1;
BOTH = 2;
}
CommonInfo common = 1;
string code = 2; //
repeated Point points = 3; //
RelatedRef paRef = 4; // A端关联的设备()()
RelatedRef pbRef = 5; // B端关联的设备()()
SectionType sectionType = 6; //
//repeated string oldaxleCountings = 7; //
// int32 index = 8; //
//string oldtrackSectionId = 9; // id
bool isCurve = 10; // 线
int32 segmentsCount = 12; // 线
//repeated string oldcentralizedStations = 13; // Id列表
RunningDirection normalRunningDirection = 14; //
bool isTurnBackZone = 15; //
Direction direction = 16; //
repeated uint32 axleCountings = 17; //
uint32 trackSectionId = 18; // id
repeated uint32 centralizedStations = 19; // Id列表
}
//
message RelatedRef {
enum DeviceType {
Section = 0;
Turnout = 1;
TrainWindow = 2;
AxleCounting = 3;
SectionLink = 4;
signal = 5;
station = 6;
ScreenDoor = 7;
SignalFaultAlarm = 8;
Breakers = 9;//
PowerScreen = 10;//
GarageDoor = 11;
CarWashing = 12;
FloodGate = 13;
}
enum DevicePort {
A = 0;
B = 1;
C = 2;
}
DeviceType deviceType = 1; //
//string oldid = 2; //ID
DevicePort devicePort = 3; //
uint32 id = 4;
}
//
message TurnoutPosRef {
//string oldid = 1; //ID
int32 position = 2; //01
uint32 id = 3;
}
message Separator { //
CommonInfo common = 1;
string code = 2;
string separatorType = 3;
}
message Transponder { //
enum TransponderTypeEnum {
FB = 0; //
WB = 1; //
DB = 2; //
VB = 3; //
IB = 4; //
}
CommonInfo common = 1;
string code = 2;
// int32 transponderType = 3; //
// int32 index = 4; //
KilometerSystem kilometerSystem = 5; //
RelatedRef TransponderRef = 6; //
//repeated string oldcentralizedStations = 7; // Id列表
// bytes fixedTelegram = 8;//
TransponderTypeEnum type = 9;//
repeated uint32 centralizedStations = 10; // Id列表
string fixedTelegram = 11; //
string fixedUserTelegram = 12; //
string originalCode = 13; //
}
message SimpleRef {
enum DeviceType {
Turnout = 0;
AxleCounting = 1;
}
DeviceType deviceType = 1;
//string oldid = 2;
uint32 id = 3;
}
message SectionLink {
CommonInfo common = 1;
string code = 2;
repeated Point points = 3;
bool up = 4; //
SimpleRef aSimRef =
5; // SectionLink A端连接设备 AxleCounting/Turnout //
SimpleRef bSimRef =
6; // SectionLink B端连接设备 AxleCounting/Turnout //
RelatedRef aRef =
7; // SectionLink A端连接设备 SectionLink/Turnout
RelatedRef bRef = 8; // SectionLink B端连接设备
// SectionLink/Turnout
// int32 index = 9; //
}
message AxleCountingSection { //
CommonInfo common = 1;
string code = 2; //
repeated Point points = 3;
RelatedRef paRef = 4; // A端关联的计轴
RelatedRef pbRef = 5; // B端关联的计轴
repeated TurnoutPosRef turnoutPos = 6; //--01
// int32 index = 7; //
}
message LogicSection { //
CommonInfo common = 1;
string code = 2; //
repeated Point points = 3;
//string oldaxleSectionId = 4; // Id
// int32 index = 5; //
//string oldturnoutId = 6; // idC端关联的轨道link
uint32 axleSectionId = 7; // Id
uint32 turnoutId = 8; // idC端关联的轨道link
}
message TrackSection { //
enum TrackSectionType {
NORMAL = 0; //
FORK = 1; //
}
CommonInfo common = 1;
repeated Point points = 2;
string code = 3; //
// int32 index = 4; //
TrackSectionType type = 5; //
string destinationCode = 6; //
//repeated string oldtrackLogicSection = 7; //id()
// //id(/)(/)
bool isCurve = 8; // 线
int32 segmentsCount = 9; // 线
repeated uint32 trackLogicSection = 10; //id()
}
message TrackLogicSection { //
CommonInfo common = 1;
repeated Point points = 2;
string code = 3; //
int32 length = 4; //(mm)
}
message StopPosition {
enum CoachNum {
Four = 0;
Six = 1;
Eight = 2;
}
CommonInfo common = 1;
string code = 2;
bool flip = 3; //
CoachNum coachNum = 4; //
// int32 index = 5; //
KilometerSystem kilometerSystem = 6;
RelatedRef refDev = 7; //
}
message SpksSwitch {
CommonInfo common = 1;
string code = 2;
bool flip = 3; //
// int32 index = 4; //
// int32 refStand = 5; //
//repeated string oldrefSections = 6; // id
//string oldrefStand = 7; //
// repeated uint32 refSections = 8; // id
uint32 refStand = 9; //
}
message EsbButton {
CommonInfo common = 1;
string code = 2;
bool flip = 3; //
// int32 index = 4; //
// int32 refStand = 5; //
//string oldrefStand = 6; //
uint32 refStand = 7; //
//string refEsbButtonMapCode = 8; // Code--PSL地图
}
message GatedBox {
CommonInfo common = 1;
string code = 2;
bool flip = 3; //
// int32 index = 4; //
//string oldrefScreenDoor = 5; //
string refGatedBoxMapCode = 6; // Code
uint32 refScreenDoor = 7; //
}
message IbpBox {
CommonInfo common = 1;
string code = 2;
string refIbpMapCode = 3; // Ibp地图Code
uint32 refStationId = 4; // id
}
message PslBox {
CommonInfo common = 1;
string code = 2;
string refPslMapCode = 3; // Psl地图Code
uint32 refPlatformId = 4; // id
}
/** 坡度公里标 */
message SlopeKiloMarker {
CommonInfo common = 1;
string code = 2;
repeated KilometerSystem kilometerSystem = 4; //
}
/** 曲度公里标 */
message CurvatureKiloMarker {
CommonInfo common = 1;
string code = 2;
repeated KilometerSystem kilometerSystem = 4; //
}
/** 车库门 */
message GarageDoor {
CommonInfo common = 1;
string code = 2;
uint32 linkSection = 3; //
repeated uint32 centralizedStations = 4; // Id列表;
string refPslMapCode = 5; // Psl地图的code
}
/** 洗车机 */
message CarWashing {
CommonInfo common = 1;
string code = 2;
uint32 linkSection = 3; //
repeated uint32 centralizedStations = 4; // Id列表;
uint32 duanNum = 5; //
uint32 width = 6; //
}
/** 信标 */
message Beacon {
enum BeaconType {
Static = 0;
Dynamic = 1;
}
CommonInfo common = 1;
string code = 2;
BeaconType type = 3;
bool flip = 4;
}
message Slope {
CommonInfo common = 1;
repeated Point points = 2;
sint32 slopeNumber = 3; //--
//repeated string oldrefDeviceId = 4; // ()
repeated uint32 refDeviceId = 5; // ()
}
message Curvature {
CommonInfo common = 1;
repeated Point points = 2;
sint32 curvatureNumber = 3; //线--
//repeated string oldrefDeviceId = 4; // 线()
repeated uint32 refDeviceId = 5; // 线()
}
// link结构
// message CalculateLink {
// CommonInfo common = 1;
// repeated Point points = 2;
// int32 length = 3; //mm
// RelatedRef aRelatedRef = 4; // A端
// RelatedRef bRelatedRef = 5; // B端
// repeated DevicePosition devicePositions = 6; //link上的位置
// int32 index = 7; // link唯一标识
// message DevicePosition {
// int32 offset = 1;
// string deviceId = 2;
// string deviceType = 3;
// }
// }
/** 发车计时器 */
message DepartureTimer {
CommonInfo common = 1;
string code = 2;
//string oldrefStand = 3; //
string runDirection = 4; //
uint32 refStand = 5; //
}
message AutoReturnBox {
CommonInfo common = 1;
string code = 2;
bool flip = 3; //
int32 index = 4; //
//string oldrefStand = 5; //
uint32 refStand = 6; //
}
message UniqueIdOfStationLayout {
string city = 1;//
string lineId = 2;//线
string mainCoordinateSystem = 3;//
}
//
message KilometerConvert {
KilometerSystem kmA = 1;
KilometerSystem kmB = 2;
bool sameTrend = 3; //
}
/* 车站关联的设备列表 */
message StationRelateDevice {
string code = 1;//
repeated DeviceCombinationtype combinationtypes = 2; //
RelatedRef.DeviceType deviceType = 3;//
}
message DeviceCombinationtype {
string code = 1;
//repeated string oldrefDevices = 2;//
repeated uint32 refDevices = 3;//
}
message SectionCodePoint {
//string oldCentralizedStation = 1; // id
//repeated string oldsectionIds = 2; //id列表
repeated uint32 sectionIds = 3; //id列表
uint32 centralizedStation = 4; // id
}
//
message Train {
enum TrainModel { //
A = 0;
B = 1;
C = 2;
D = 3;
}
TrainModel trainModel = 1; //
int32 carriageLength = 2; //
int32 totalLength = 3; //
// int32 minDiameter = 4; //
// int32 maxDiameter = 5; //
string trainSets = 6; //
// common.TrainDynamicConfig dynamicConfig = 7; //
// string trainControlMapCode = 8;
int32 trainControlMapId = 9;
}
// 线
message OtherLine {
string name = 1;
//repeated string oldids = 2; // id列表
repeated uint32 ids = 3; // id列表
}
//
message LianSuoIndexData {
uint32 id = 1; // id
uint32 index = 2; //
}
//
message LianSuoData {
repeated LianSuoIndexData stations = 1;
repeated LianSuoIndexData switchs = 2;
repeated LianSuoIndexData screenDoors = 3;
repeated LianSuoIndexData signals = 4;
repeated LianSuoIndexData sections = 5;
repeated LianSuoIndexData floodGates = 6;
repeated LianSuoIndexData spksSwitchs = 7;
repeated LianSuoIndexData garageDoors = 8;
repeated LianSuoIndexData carWashing = 9;
repeated LianSuoIndexData esbButtons = 10;
repeated LianSuoIndexData holdButtons = 11;
repeated LianSuoIndexData unattengedButtons = 12;
}
//
message UnattengedButton {
CommonInfo common = 1;
string code = 2;
bool flip = 3; //
uint32 refStand = 4; //
}
//
message HoldButton {
CommonInfo common = 1;
string code = 2;
bool flip = 3; //
uint32 refStand = 4; //
}

View File

@ -0,0 +1,7 @@
package modelimpl
import "joylink.club/rtss-core/model"
type Section struct {
model.SectionImpl
}

View File

@ -0,0 +1,7 @@
package modelimpl
import "joylink.club/rtss-core/model"
type Station struct {
model.StationImpl
}

View File

@ -0,0 +1,7 @@
package modelimpl
import "joylink.club/rtss-core/model"
type Turnout struct {
model.TurnoutImpl
}

View File

@ -0,0 +1,39 @@
package repository
import (
modelimpl "joylink.club/rtss-core/example/model_impl"
"joylink.club/rtss-core/model"
"joylink.club/rtss-core/repo"
)
type Repository struct {
id string
stationMap map[string]*modelimpl.Station
sectionMap map[string]*modelimpl.Section
turnoutMap map[string]*modelimpl.Turnout
}
func NewRepository(id string) repo.Repo {
return &Repository{
id: id,
stationMap: make(map[string]*modelimpl.Station),
sectionMap: make(map[string]*modelimpl.Section),
turnoutMap: make(map[string]*modelimpl.Turnout),
}
}
func (r *Repository) Id() string {
return r.id
}
func (r *Repository) GetStationByUid(uid string) model.Station {
return r.stationMap[uid]
}
func (r *Repository) GetSectionByUid(uid string) model.Section {
return r.sectionMap[uid]
}
func (r *Repository) GetTurnoutByUid(uid string) model.Turnout {
return r.turnoutMap[uid]
}

5
go.mod
View File

@ -1,6 +1,9 @@
module joylink.club/rtss-core
require joylink.club/ecs v0.1.0
require (
google.golang.org/protobuf v1.34.2
joylink.club/ecs v0.1.0
)
require github.com/yohamta/donburi v1.3.9 // indirect

6
go.sum
View File

@ -2,11 +2,17 @@ gitea.joylink.club/joylink/jl-ecs v0.1.0 h1:+qQw0VN4dSnAuerqCl34bQTfLEZA+foGUUG5
gitea.joylink.club/joylink/jl-ecs v0.1.0/go.mod h1:i/tBVZV1hoFNZCxmZXeUIa9sHwJcbgpj3zA9xtcQkyA=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/yohamta/donburi v1.3.9 h1:sYAPaelSnxmoTGjgH9ZlYt4pUKrnwvAv4YGXxLZCK6E=
github.com/yohamta/donburi v1.3.9/go.mod h1:5QkyraUjkzbMVTD2b8jaPFy1Uwjm/zdFN1c1lZGaezg=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

26
model/station.go Normal file
View File

@ -0,0 +1,26 @@
package model
type Station interface {
RtssModel
IsCentralized() bool
}
type StationImpl struct {
uid string
centralized bool
}
func NewStation(uid string, centralized bool) Station {
return &StationImpl{
uid: uid,
centralized: centralized,
}
}
func (s *StationImpl) Uid() string {
return s.uid
}
func (s *StationImpl) IsCentralized() bool {
return s.centralized
}

View File

@ -21,18 +21,27 @@ func main() {
//先安装以下插件
//go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
args := os.Args
if len(args) >= 2 {
switch {
case args[1] == "component": //go run . component 编译组件proto
{
protocPath = filepath.Join(basePath, "protoc-23.1", "bin", "win64", "protoc")
protoFolder = filepath.Join(basePath, "src", args[1])
goOutDir = "../"
}
}
if len(args) < 3 {
log.Fatal("usage: go run protodef/main.go [path/to/proto/dir] [goOutDir]")
}
protoFolder = filepath.Join(basePath, args[1])
goOutDir = args[2]
log.Println(protoFolder, goOutDir)
// if len(args) >= 2 {
// switch {
// case args[1] == "component": //go run . component 编译组件proto
// {
// protocPath = filepath.Join(basePath, "protoc-23.1", "bin", "win64", "protoc")
// protoFolder = filepath.Join(basePath, "src", args[1])
// goOutDir = "../"
// }
// }
// }
//
// protoFolder = filepath.Join(basePath)
protoFiles := getProtoFiles()
log.Println(protoFiles)
// 编译proto文件为Go文件
if err := compileProto(protoFiles); err != nil {
log.Fatalf("编译proto文件失败%v", err)
@ -57,7 +66,7 @@ func getProtoFiles() []string {
// 编译proto文件为Go文件
func compileProto(protoFiles []string) error {
for _, fileName := range protoFiles {
cmd := exec.Command(protocPath, "-I="+protoFolder, fmt.Sprintf("--go_out=%s", goOutDir), fileName)
cmd := exec.Command(protocPath, "-I="+protoFolder, fmt.Sprintf("--go_out=%s", goOutDir), "--go_opt=paths=source_relative", fileName)
fmt.Println(cmd.String())
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

View File

@ -1,6 +1,11 @@
package repo
import "joylink.club/rtss-core/model"
type Repo interface {
// 模型仓库id
Id() string
GetStationByUid(uid string) model.Station
GetSectionByUid(uid string) model.Section
GetTurnoutByUid(uid string) model.Turnout
}