【新增】车库门及车库门控制盒操作接口

This commit is contained in:
thesai 2024-03-20 14:35:34 +08:00
parent cd5946438c
commit b748c7ff3e
3 changed files with 134 additions and 0 deletions

86
main.go Normal file
View File

@ -0,0 +1,86 @@
package main
import (
"bufio"
"fmt"
"io/fs"
"log"
"os"
"os/exec"
"path/filepath"
"strings"
)
var (
basePath, _ = os.Getwd()
protoFolder = filepath.Join(basePath, "rts-sim-testing-message", "protos")
protocPath = filepath.Join(basePath, "rts-sim-testing-message", "protoc-23.1", "bin", "win64", "protoc")
modulePrefix = "joylink.club/bj-rtsts-server"
)
func main() {
//先安装以下插件
//go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
protoFiles := getProtoFiles()
// 编译proto文件为Go文件
if err := compileProto(protoFiles); err != nil {
log.Fatalf("编译proto文件失败%v", err)
}
}
// 获取指定文件夹下的所有proto文件的绝对路径
func getProtoFiles() []string {
var protoFiles []string
err := filepath.WalkDir(protoFolder, func(path string, d fs.DirEntry, err error) error {
if !d.IsDir() {
protoFiles = append(protoFiles, path)
}
return err
})
if err != nil {
log.Fatal("获取proto文件列表失败:", err)
}
return protoFiles
}
// 编译proto文件为Go文件
func compileProto(protoFiles []string) error {
for _, fileName := range protoFiles {
file, err := os.Open(fileName)
if err != nil {
return err
}
scanner := bufio.NewScanner(file)
var outPath string
for scanner.Scan() {
text := scanner.Text()
if !strings.HasPrefix(text, "option go_package") {
continue
}
start := strings.Index(text, modulePrefix)
if start < 0 {
break
}
start += len(modulePrefix)
dir := "." + text[start:len(text)-2]
err := os.MkdirAll(dir, fs.ModeDir)
if err != nil {
panic(fmt.Sprintf("创建目录 %s 失败:%v", dir, err))
}
outPath = "paths=source_relative:" + dir
break
}
if outPath == "" {
outPath = "./"
}
cmd := exec.Command(protocPath, "-I="+protoFolder, "--go_out="+outPath, fileName)
fmt.Println(cmd.String())
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
return err
}
}
return nil
}

View File

@ -227,3 +227,42 @@ enum DriverType{
ONE_END = 0;
TWO_END = 1;
}
message CkmOperationReq {
string simulationId = 1;
int32 mapId = 2;
uint32 deviceId = 3; //idid
Ckm.Operation operation = 4; //
CkmParam param = 5; //operation为SetParams时有效
}
message Ckm {
enum Operation {
Undefined= 0;
SetParams = 1;
}
enum Force {
F_NONE = 0; //
F_KM = 1; //
F_GM = 2; //
}
enum Fault {
FA_NONE = 0; //
FA_State_Loss = 1; //
}
}
message CkmParam {
Ckm.Force force = 1;
Ckm.Fault fault = 2;
}
//
message CkmBoxOperationReq {
string simulationId = 1;
int32 mapId = 2;
uint32 ckmBoxId = 3;
string buttonCode = 4;
bool down = 5; ///
}

View File

@ -55,6 +55,7 @@ message RtssGraphicStorage {
repeated CarWashing carWashings = 45; //
repeated GarageDoor garageDoors = 46; //
repeated FloodGate floodGates = 47; //
repeated GarageDoorBox garageDoorBoxes = 48; //Psl开启按钮
}
message Canvas {
@ -722,3 +723,11 @@ message OtherLine {
repeated string oldids = 2; // id列表
repeated uint32 ids = 3; // id列表
}
//
message GarageDoorBox {
CommonInfo common = 1;
string code = 2;
string refPslMapCode = 3; // Psl地图的code
uint32 refGarageDoorId = 4; // id
}