更新proto

This commit is contained in:
2025-10-07 16:14:47 +08:00
parent 759caadb21
commit b611f132f1
4 changed files with 179 additions and 186 deletions

View File

@@ -14,7 +14,6 @@ import (
"github.com/google/uuid"
gproto "google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
)
type GeneralDeviceService struct {
@@ -90,14 +89,10 @@ func (g *GeneralDeviceService) Switch(device *models.Device, action DeviceAction
CommandBytes: modbusCommandBytes,
}
data, err := anypb.New(raw485Cmd)
if err != nil {
return fmt.Errorf("创建 Raw485Command Any Protobuf 失败: %w", err)
}
instruction := &proto.Instruction{
Method: proto.MethodType_INSTRUCTION, // 使用通用指令类型
Data: data,
Payload: &proto.Instruction_Raw_485Command{
Raw_485Command: raw485Cmd,
},
}
message, err := gproto.Marshal(instruction)
@@ -224,14 +219,10 @@ func (g *GeneralDeviceService) Collect(regionalControllerID uint, devicesToColle
CorrelationId: correlationID,
Tasks: collectTasks,
}
anyData, err := anypb.New(batchCmd)
if err != nil {
g.logger.Errorf("创建 Any Protobuf 失败 (CorrelationID: %s): %v", correlationID, err)
return err
}
instruction := &proto.Instruction{
Method: proto.MethodType_COLLECT, // 使用 COLLECT 指令类型
Data: anyData,
Payload: &proto.Instruction_BatchCollectCommand{
BatchCollectCommand: batchCmd,
},
}
payload, err := gproto.Marshal(instruction)
if err != nil {