diff --git a/mappers/v1beta1-mapper/virtualdevice/Dockerfile b/mappers/v1beta1-mapper/modbus/Dockerfile similarity index 100% rename from mappers/v1beta1-mapper/virtualdevice/Dockerfile rename to mappers/v1beta1-mapper/modbus/Dockerfile diff --git a/mappers/v1beta1-mapper/virtualdevice/Makefile b/mappers/v1beta1-mapper/modbus/Makefile similarity index 100% rename from mappers/v1beta1-mapper/virtualdevice/Makefile rename to mappers/v1beta1-mapper/modbus/Makefile diff --git a/mappers/v1beta1-mapper/virtualdevice/cmd/main.go b/mappers/v1beta1-mapper/modbus/cmd/main.go similarity index 77% rename from mappers/v1beta1-mapper/virtualdevice/cmd/main.go rename to mappers/v1beta1-mapper/modbus/cmd/main.go index 84bdac37..04559263 100644 --- a/mappers/v1beta1-mapper/virtualdevice/cmd/main.go +++ b/mappers/v1beta1-mapper/modbus/cmd/main.go @@ -6,13 +6,13 @@ import ( "k8s.io/klog/v2" - "github.com/kubeedge/virtualdevice/device" - "github.com/kubeedge/virtualdevice/pkg/common" - "github.com/kubeedge/virtualdevice/pkg/config" - "github.com/kubeedge/virtualdevice/pkg/grpcserver" - "github.com/kubeedge/virtualdevice/pkg/httpserver" - "github.com/kubeedge/virtualdevice/pkg/util/grpcclient" - "github.com/kubeedge/virtualdevice/pkg/util/parse" + "github.com/kubeedge/modbus/device" + "github.com/kubeedge/modbus/pkg/common" + "github.com/kubeedge/modbus/pkg/config" + "github.com/kubeedge/modbus/pkg/grpcserver" + "github.com/kubeedge/modbus/pkg/httpserver" + "github.com/kubeedge/modbus/pkg/util/grpcclient" + "github.com/kubeedge/modbus/pkg/util/parse" ) func main() { diff --git a/mappers/v1beta1-mapper/virtualdevice/config.yaml b/mappers/v1beta1-mapper/modbus/config.yaml similarity index 52% rename from mappers/v1beta1-mapper/virtualdevice/config.yaml rename to mappers/v1beta1-mapper/modbus/config.yaml index d8cb9a09..17945135 100644 --- a/mappers/v1beta1-mapper/virtualdevice/config.yaml +++ b/mappers/v1beta1-mapper/modbus/config.yaml @@ -1,10 +1,10 @@ grpc_server: - socket_path: /etc/kubeedge/virtualdevice.sock + socket_path: /etc/kubeedge/modbus.sock common: - name: Virtualdevice-mapper + name: Modbus-mapper version: v1.13.0 api_version: v1.0.0 - protocol: virtualProtocol # replace by your protocol name + protocol: modbus # TODO add your protocol name address: 127.0.0.1 edgecore_sock: /etc/kubeedge/dmi.sock dev_init: diff --git a/mappers/v1beta1-mapper/virtualdevice/data/dbmethod/influxdb2/client.go b/mappers/v1beta1-mapper/modbus/data/dbmethod/influxdb2/client.go similarity index 96% rename from mappers/v1beta1-mapper/virtualdevice/data/dbmethod/influxdb2/client.go rename to mappers/v1beta1-mapper/modbus/data/dbmethod/influxdb2/client.go index 2bcffb9d..626886aa 100644 --- a/mappers/v1beta1-mapper/virtualdevice/data/dbmethod/influxdb2/client.go +++ b/mappers/v1beta1-mapper/modbus/data/dbmethod/influxdb2/client.go @@ -9,7 +9,7 @@ import ( "k8s.io/klog/v2" influxdb2 "github.com/influxdata/influxdb-client-go/v2" - "github.com/kubeedge/virtualdevice/pkg/common" + "github.com/kubeedge/modbus/pkg/common" ) type DataBaseConfig struct { @@ -60,6 +60,7 @@ func (d *DataBaseConfig) CloseSession(client influxdb2.Client) { } func (d *DataBaseConfig) AddData(data *common.DataModel, client influxdb2.Client) error { + // write device data to influx database writeAPI := client.WriteAPIBlocking(d.Influxdb2ClientConfig.Org, d.Influxdb2ClientConfig.Bucket) p := influxdb2.NewPoint(d.Influxdb2DataConfig.Measurement, d.Influxdb2DataConfig.Tag, diff --git a/mappers/v1beta1-mapper/modbus/data/dbmethod/openGemini/client.go b/mappers/v1beta1-mapper/modbus/data/dbmethod/openGemini/client.go new file mode 100644 index 00000000..81192c3e --- /dev/null +++ b/mappers/v1beta1-mapper/modbus/data/dbmethod/openGemini/client.go @@ -0,0 +1,48 @@ +package opengemini + +import ( + "encoding/json" + _ "github.com/influxdata/influxdb1-client" // this is important because of the bug in go mod + client "github.com/influxdata/influxdb1-client/v2" + "github.com/kubeedge/modbus/pkg/common" +) + +type DataBaseConfig struct { + OpengeminiClientConfig *OpengeminiClientConfig `json:"opengeminiClientConfig,omitempty"` + OpengeminiDataConfig *OpengeminiDataConfig `json:"opengeminiDataConfig,omitempty"` +} + +type OpengeminiClientConfig struct { + URL string `json:"url,omitempty"` + Database string `json:"database,omitempty"` + RetentionPolicy string `json:"retentionPolicy,omitempty"` +} + +type OpengeminiDataConfig struct { + Measurement string `json:"measurement,omitempty"` + Tags map[string]string `json:"tags,omitempty"` + FieldKey string `json:"fieldKey,omitempty"` +} + +func NewDataBaseClient(clientConfig json.RawMessage, dataConfig json.RawMessage) (*DataBaseConfig, error) { + // TODO parse opengemini database config data + + return &DataBaseConfig{}, nil +} + +func (d *DataBaseConfig) InitDbClient() (client.Client, error) { + // TODO add opengemini database initialization code + + conf := client.HTTPConfig{} + return client.NewHTTPClient(conf) +} + +func (d *DataBaseConfig) CloseSession(cli client.Client) error { + // TODO add opengemini database close code + return nil +} + +func (d *DataBaseConfig) AddData(data *common.DataModel, cli client.Client) error { + // TODO add opengemini database data push code + return nil +} diff --git a/mappers/v1beta1-mapper/modbus/data/dbmethod/redis/client.go b/mappers/v1beta1-mapper/modbus/data/dbmethod/redis/client.go new file mode 100644 index 00000000..1b761b8e --- /dev/null +++ b/mappers/v1beta1-mapper/modbus/data/dbmethod/redis/client.go @@ -0,0 +1,48 @@ +package redis + +import ( + "github.com/kubeedge/modbus/pkg/common" + "github.com/kubeedge/modbus/pkg/global" +) + +type DataBaseConfig struct { +} + +func NewDataBaseClient() (global.DataBaseClient, error) { + return &DataBaseConfig{}, nil +} + +func (d *DataBaseConfig) InitDbClient() error { + //TODO implement me + panic("implement me") +} + +func (d *DataBaseConfig) CloseSession() { + //TODO implement me + panic("implement me") +} + +func (d *DataBaseConfig) AddData(data *common.DataModel) { + //TODO implement me + panic("implement me") +} + +func (d *DataBaseConfig) GetDataByDeviceName(deviceName string) ([]*common.DataModel, error) { + //TODO implement me + panic("implement me") +} + +func (d *DataBaseConfig) GetPropertyDataByDeviceName(deviceName string, propertyData string) ([]*common.DataModel, error) { + //TODO implement me + panic("implement me") +} + +func (d *DataBaseConfig) GetDataByTimeRange(start int64, end int64) ([]*common.DataModel, error) { + //TODO implement me + panic("implement me") +} + +func (d *DataBaseConfig) DeleteDataByTimeRange(start int64, end int64) ([]*common.DataModel, error) { + //TODO implement me + panic("implement me") +} diff --git a/mappers/v1beta1-mapper/virtualdevice/data/publish/http/client.go b/mappers/v1beta1-mapper/modbus/data/publish/http/client.go similarity index 75% rename from mappers/v1beta1-mapper/virtualdevice/data/publish/http/client.go rename to mappers/v1beta1-mapper/modbus/data/publish/http/client.go index cfc41600..803efe4d 100644 --- a/mappers/v1beta1-mapper/virtualdevice/data/publish/http/client.go +++ b/mappers/v1beta1-mapper/modbus/data/publish/http/client.go @@ -11,8 +11,8 @@ import ( "k8s.io/klog/v2" - "github.com/kubeedge/virtualdevice/pkg/common" - "github.com/kubeedge/virtualdevice/pkg/global" + "github.com/kubeedge/modbus/pkg/common" + "github.com/kubeedge/modbus/pkg/global" ) type PushMethod struct { @@ -38,18 +38,21 @@ func NewDataPanel(config json.RawMessage) (global.DataPanel, error) { } func (pm *PushMethod) InitPushMethod() error { - fmt.Println("Init Http") + klog.V(1).Info("Init HTTP") return nil } func (pm *PushMethod) Push(data *common.DataModel) { + klog.V(2).Info("Publish device data by HTTP") targetUrl := pm.HTTP.HostName + ":" + strconv.Itoa(pm.HTTP.Port) + pm.HTTP.RequestPath - klog.V(1).Infof("targetUrl = %s", targetUrl) payload := data.PropertyName + "=" + data.Value formatTimeStr := time.Unix(data.TimeStamp/1e3, 0).Format("2006-01-02 15:04:05") currentTime := "&time" + "=" + formatTimeStr payload += currentTime + + klog.V(3).Infof("Publish %v to %s", payload, targetUrl) + resp, err := http.Post(targetUrl, "application/x-www-form-urlencoded", strings.NewReader(payload)) @@ -61,7 +64,10 @@ func (pm *PushMethod) Push(data *common.DataModel) { body, err := ioutil.ReadAll(resp.Body) if err != nil { // handle error + klog.Errorf("Publish device data by HTTP failed, err = %v", err) + return } - klog.V(1).Info(string(body)) + klog.V(1).Info("############### Message published. ###############") + klog.V(3).Infof("HTTP reviced %s", string(body)) } diff --git a/mappers/v1beta1-mapper/virtualdevice/data/publish/mqtt/client.go b/mappers/v1beta1-mapper/modbus/data/publish/mqtt/client.go similarity index 88% rename from mappers/v1beta1-mapper/virtualdevice/data/publish/mqtt/client.go rename to mappers/v1beta1-mapper/modbus/data/publish/mqtt/client.go index dcfb7aaa..8726a4dc 100644 --- a/mappers/v1beta1-mapper/virtualdevice/data/publish/mqtt/client.go +++ b/mappers/v1beta1-mapper/modbus/data/publish/mqtt/client.go @@ -9,8 +9,8 @@ import ( mqtt "github.com/eclipse/paho.mqtt.golang" "k8s.io/klog/v2" - "github.com/kubeedge/virtualdevice/pkg/common" - "github.com/kubeedge/virtualdevice/pkg/global" + "github.com/kubeedge/modbus/pkg/common" + "github.com/kubeedge/modbus/pkg/global" ) type PushMethod struct { @@ -36,7 +36,7 @@ func NewDataPanel(config json.RawMessage) (global.DataPanel, error) { } func (pm *PushMethod) InitPushMethod() error { - fmt.Println("Init Mqtt") + klog.V(1).Info("Init MQTT") return nil } @@ -59,5 +59,5 @@ func (pm *PushMethod) Push(data *common.DataModel) { token.Wait() client.Disconnect(250) - klog.V(1).Info("############### Message published. ###############") + klog.V(2).Info("############### Message published. ###############") } diff --git a/mappers/v1beta1-mapper/virtualdevice/device/device.go b/mappers/v1beta1-mapper/modbus/device/device.go similarity index 86% rename from mappers/v1beta1-mapper/virtualdevice/device/device.go rename to mappers/v1beta1-mapper/modbus/device/device.go index 2008739e..6e1bbb9a 100644 --- a/mappers/v1beta1-mapper/virtualdevice/device/device.go +++ b/mappers/v1beta1-mapper/modbus/device/device.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "os" "os/signal" "strings" @@ -13,14 +14,15 @@ import ( "k8s.io/klog/v2" - dbInflux "github.com/kubeedge/virtualdevice/data/dbmethod/influxdb2" - httpMethod "github.com/kubeedge/virtualdevice/data/publish/http" - mqttMethod "github.com/kubeedge/virtualdevice/data/publish/mqtt" - "github.com/kubeedge/virtualdevice/driver" - "github.com/kubeedge/virtualdevice/pkg/common" - "github.com/kubeedge/virtualdevice/pkg/config" - "github.com/kubeedge/virtualdevice/pkg/global" - "github.com/kubeedge/virtualdevice/pkg/util/parse" + dbInflux "github.com/kubeedge/modbus/data/dbmethod/influxdb2" + dbOpenGemini "github.com/kubeedge/modbus/data/dbmethod/openGemini" + httpMethod "github.com/kubeedge/modbus/data/publish/http" + mqttMethod "github.com/kubeedge/modbus/data/publish/mqtt" + "github.com/kubeedge/modbus/driver" + "github.com/kubeedge/modbus/pkg/common" + "github.com/kubeedge/modbus/pkg/config" + "github.com/kubeedge/modbus/pkg/global" + "github.com/kubeedge/modbus/pkg/util/parse" ) type DevPanel struct { @@ -109,7 +111,6 @@ func dataHandler(ctx context.Context, dev *driver.CustomizedDev) { var visitorConfig driver.VisitorConfig err := json.Unmarshal(twin.Property.Visitors, &visitorConfig) - visitorConfig.VisitorConfigData.DataType = strings.ToLower(visitorConfig.VisitorConfigData.DataType) if err != nil { klog.Errorf("Unmarshal VisitorConfig error: %v", err) continue @@ -132,19 +133,12 @@ func dataHandler(ctx context.Context, dev *driver.CustomizedDev) { } go twinData.Run(ctx) // handle push method - testconfig := make(map[string]interface{}) - err = json.Unmarshal(twin.Property.PushMethod.MethodConfig, &testconfig) - if err == nil { - klog.V(1).Infof("twin.Property.PushMethod.MethodConfig = %v", testconfig) - } else { - klog.Error(err) - } + // todo need to consider if PushMethod == nil if twin.Property.PushMethod.MethodConfig != nil && twin.Property.PushMethod.MethodName != "" { dataModel := common.NewDataModel(dev.Instance.Name, twin.Property.PropertyName, common.WithType(twin.ObservedDesired.Metadata.Type)) pushHandler(ctx, &twin, dev.CustomizedClient, &visitorConfig, dataModel) } // handle database - if twin.Property.PushMethod.DBMethod.DBMethodName != "" { dataModel := common.NewDataModel(dev.Instance.Name, twin.Property.PropertyName, common.WithType(twin.ObservedDesired.Metadata.Type)) dbHandler(ctx, &twin, dev.CustomizedClient, &visitorConfig, dataModel) @@ -156,18 +150,20 @@ func dataHandler(ctx context.Context, dev *driver.CustomizedDev) { func pushHandler(ctx context.Context, twin *common.Twin, client *driver.CustomizedClient, visitorConfig *driver.VisitorConfig, dataModel *common.DataModel) { var dataPanel global.DataPanel var err error + // initialization dataPanel switch twin.Property.PushMethod.MethodName { case "http": dataPanel, err = httpMethod.NewDataPanel(twin.Property.PushMethod.MethodConfig) case "mqtt": dataPanel, err = mqttMethod.NewDataPanel(twin.Property.PushMethod.MethodConfig) default: - err = errors.New("Custom protocols are not currently supported") + err = errors.New("custom protocols are not currently supported when push data") } if err != nil { klog.Errorf("new data panel error: %v", err) return } + // initialization PushMethod err = dataPanel.InitPushMethod() if err != nil { klog.Errorf("init publish method err: %v", err) @@ -205,6 +201,7 @@ func pushHandler(ctx context.Context, twin *common.Twin, client *driver.Customiz // dbHandler start db client to save data func dbHandler(ctx context.Context, twin *common.Twin, client *driver.CustomizedClient, visitorConfig *driver.VisitorConfig, dataModel *common.DataModel) { switch twin.Property.PushMethod.DBMethod.DBMethodName { + // TODO add more database case "influx": dbConfig, err := dbInflux.NewDataBaseClient(twin.Property.PushMethod.DBMethod.DBConfig.Influxdb2ClientConfig, twin.Property.PushMethod.DBMethod.DBConfig.Influxdb2DataConfig) if err != nil { @@ -249,13 +246,57 @@ func dbHandler(ctx context.Context, twin *common.Twin, client *driver.Customized } } }() + case "openGemini": + dbConfig, err := dbOpenGemini.NewDataBaseClient(twin.Property.PushMethod.DBMethod.DBConfig.OpenGeminiClientConfig, twin.Property.PushMethod.DBMethod.DBConfig.OpenGeminiDataConfig) + if err != nil { + klog.Errorf("new openGemini database client error: %v", err) + return + } + dbClient, err := dbConfig.InitDbClient() + if err != nil { + klog.Errorf("init openGemini database client err: %v", err) + return + } + reportCycle := time.Duration(twin.Property.ReportCycle) + if reportCycle == 0 { + reportCycle = 1 * time.Second + } + ticker := time.NewTicker(reportCycle) + go func() { + for { + select { + case <-ticker.C: + deviceData, err := client.GetDeviceData(visitorConfig) + if err != nil { + klog.Errorf("publish error: %v", err) + continue + } + sData, err := common.ConvertToString(deviceData) + if err != nil { + klog.Errorf("Failed to convert publish method data : %v", err) + continue + } + dataModel.SetValue(sData) + dataModel.SetTimeStamp() + + err = dbConfig.AddData(dataModel, dbClient) + if err != nil { + klog.Errorf("openGemini database add data error: %v", err) + return + } + case <-ctx.Done(): + dbConfig.CloseSession(dbClient) + return + } + } + }() } } // setVisitor check if visitor property is readonly, if not then set it. func setVisitor(visitorConfig *driver.VisitorConfig, twin *common.Twin, dev *driver.CustomizedDev) error { if twin.Property.PProperty.AccessMode == "ReadOnly" { - klog.V(1).Infof("%s twin readonly property: %s", dev.Instance.Name, twin.PropertyName) + klog.V(3).Infof("%s twin readonly property: %s", dev.Instance.Name, twin.PropertyName) return nil } klog.V(2).Infof("Convert type: %s, value: %s ", twin.Property.PProperty.DataType, twin.ObservedDesired.Value) @@ -264,7 +305,7 @@ func setVisitor(visitorConfig *driver.VisitorConfig, twin *common.Twin, dev *dri klog.Errorf("Failed to convert value as %s : %v", twin.Property.PProperty.DataType, err) return err } - err = dev.CustomizedClient.SetDeviceData(value, visitorConfig) + _, err = dev.CustomizedClient.SetDeviceData(value, visitorConfig) if err != nil { return fmt.Errorf("%s set device data error: %v", twin.PropertyName, err) } diff --git a/mappers/v1beta1-mapper/virtualdevice/device/devicetwin.go b/mappers/v1beta1-mapper/modbus/device/devicetwin.go similarity index 86% rename from mappers/v1beta1-mapper/virtualdevice/device/devicetwin.go rename to mappers/v1beta1-mapper/modbus/device/devicetwin.go index 821700cd..afd49b21 100644 --- a/mappers/v1beta1-mapper/virtualdevice/device/devicetwin.go +++ b/mappers/v1beta1-mapper/modbus/device/devicetwin.go @@ -9,11 +9,11 @@ import ( "k8s.io/klog/v2" - "github.com/kubeedge/virtualdevice/driver" - "github.com/kubeedge/virtualdevice/pkg/common" - dmiapi "github.com/kubeedge/virtualdevice/pkg/dmi-api" - "github.com/kubeedge/virtualdevice/pkg/util/grpcclient" - "github.com/kubeedge/virtualdevice/pkg/util/parse" + "github.com/kubeedge/modbus/driver" + "github.com/kubeedge/modbus/pkg/common" + dmiapi "github.com/kubeedge/modbus/pkg/dmi-api" + "github.com/kubeedge/modbus/pkg/util/grpcclient" + "github.com/kubeedge/modbus/pkg/util/parse" ) type TwinData struct { @@ -30,7 +30,7 @@ type TwinData struct { func (td *TwinData) GetPayLoad() ([]byte, error) { var err error - td.VisitorConfig.VisitorConfigData.DataType = strings.ToLower(td.VisitorConfig.VisitorConfigData.DataType) + //td.VisitorConfig.VisitorConfigData.DataType = strings.ToLower(td.VisitorConfig.VisitorConfigData.DataType) td.Results, err = td.Client.GetDeviceData(td.VisitorConfig) if err != nil { return nil, fmt.Errorf("get device data failed: %v", err) diff --git a/mappers/v1beta1-mapper/modbus/driver/devicetype.go b/mappers/v1beta1-mapper/modbus/driver/devicetype.go new file mode 100644 index 00000000..5fc559e0 --- /dev/null +++ b/mappers/v1beta1-mapper/modbus/driver/devicetype.go @@ -0,0 +1,63 @@ +package driver + +import ( + "github.com/kubeedge/modbus/pkg/common" + "github.com/sailorvii/modbus" + "sync" + "time" +) + +// CustomizedDev is the customized device configuration and client information. +type CustomizedDev struct { + Instance common.DeviceInstance + CustomizedClient *CustomizedClient +} + +type CustomizedClient struct { + // TODO add some variables to help you better implement device drivers + deviceMutex sync.Mutex + ProtocolConfig + ModbusProtocolConfig + ModbusClient modbus.Client +} + +type ProtocolConfig struct { + ProtocolName string `json:"protocolName"` + ConfigData `json:"configData"` +} + +type ConfigData struct { + // TODO: add your protocol config data + SlaveID byte + SerialPort string + BaudRate int + DataBits int + StopBits int + Parity string + Timeout int +} + +type ModbusProtocolConfig struct { + SlaveID byte + SerialPort string + BaudRate int + DataBits int + StopBits int + Parity string + Timeout time.Duration +} + +type VisitorConfig struct { + ProtocolName string `json:"protocolName"` + VisitorConfigData `json:"configData"` +} + +type VisitorConfigData struct { + // TODO: add your visitor config data + Register string `json:"register"` + Offset uint16 `json:"offset"` + Limit int `json:"limit"` + Scale float64 `json:"scale,omitempty"` + IsSwap bool `json:"isSwap,omitempty"` + IsRegisterSwap bool `json:"isRegisterSwap,omitempty"` +} diff --git a/mappers/v1beta1-mapper/modbus/driver/driver.go b/mappers/v1beta1-mapper/modbus/driver/driver.go new file mode 100644 index 00000000..984462c7 --- /dev/null +++ b/mappers/v1beta1-mapper/modbus/driver/driver.go @@ -0,0 +1,146 @@ +package driver + +import ( + "errors" + "k8s.io/klog/v2" + "sync" + "time" + + "github.com/sailorvii/modbus" +) + +var clients *sync.Map + +var clientInit sync.Once + +func initMap() { + clientInit.Do(func() { + if clients == nil { + clients = new(sync.Map) + } + }) +} + +func NewClient(protocol ProtocolConfig) (*CustomizedClient, error) { + modbusProtocolConfig := ModbusProtocolConfig{ + SlaveID: protocol.SlaveID, + SerialPort: protocol.SerialPort, + BaudRate: protocol.BaudRate, + DataBits: protocol.DataBits, + StopBits: protocol.StopBits, + Parity: protocol.Parity, + Timeout: time.Duration(protocol.Timeout), + } + client := &CustomizedClient{ + ProtocolConfig: protocol, + deviceMutex: sync.Mutex{}, + ModbusProtocolConfig: modbusProtocolConfig, + } + return client, nil +} + +func (c *CustomizedClient) InitDevice() error { + // TODO: add init operation + // you can use c.ProtocolConfig + initMap() + klog.Infoln("SerialPort : ", c.ModbusProtocolConfig.SerialPort) + v, ok := clients.Load(c.ModbusProtocolConfig.SerialPort) + if ok { + c.ModbusClient = v.(modbus.Client) + return nil + } + + handler := modbus.NewRTUClientHandler(c.ModbusProtocolConfig.SerialPort) + handler.BaudRate = c.ModbusProtocolConfig.BaudRate + handler.DataBits = c.ModbusProtocolConfig.DataBits + handler.Parity = parity(c.ModbusProtocolConfig.Parity) + handler.StopBits = c.ModbusProtocolConfig.StopBits + handler.SlaveId = c.ModbusProtocolConfig.SlaveID + handler.Timeout = c.ModbusProtocolConfig.Timeout + handler.IdleTimeout = c.ModbusProtocolConfig.Timeout + client := modbus.NewClient(handler) + clients.Store(c.ModbusProtocolConfig.SerialPort, &client) + c.ModbusClient = client + + return nil +} + +func (c *CustomizedClient) GetDeviceData(visitor *VisitorConfig) (interface{}, error) { + // TODO: add the code to get device's data + // you can use c.ProtocolConfig and visitor + c.deviceMutex.Lock() + defer c.deviceMutex.Unlock() + + var results []byte + var err error + switch visitor.Register { + case "CoilRegister": + results, err = c.ModbusClient.ReadCoils(visitor.Offset, uint16(visitor.Limit)) + case "DiscreteInputRegister": + results, err = c.ModbusClient.ReadDiscreteInputs(visitor.Offset, uint16(visitor.Limit)) + case "HoldingRegister": + results, err = c.ModbusClient.ReadHoldingRegisters(visitor.Offset, uint16(visitor.Limit)) + case "InputRegister": + results, err = c.ModbusClient.ReadInputRegisters(visitor.Offset, uint16(visitor.Limit)) + default: + return nil, errors.New("Bad register type") + } + klog.V(2).Info("Get result: ", results) + return results, err +} + +func (c *CustomizedClient) SetDeviceData(data interface{}, visitor *VisitorConfig) (interface{}, error) { + // TODO: set device's data + // you can use c.ProtocolConfig and visitor + var results []byte + var err error + + c.deviceMutex.Lock() + defer c.deviceMutex.Unlock() + + klog.V(1).Info("Set:", visitor.Register, visitor.Offset, uint16(visitor.Limit)) + + switch visitor.Register { + case "CoilRegister": + var valueSet uint16 + switch uint16(visitor.Limit) { + case 0: + valueSet = 0x0000 + case 1: + valueSet = 0xFF00 + default: + return nil, errors.New("Wrong value") + } + results, err = c.ModbusClient.WriteSingleCoil(visitor.Offset, valueSet) + case "HoldingRegister": + results, err = c.ModbusClient.WriteSingleRegister(visitor.Offset, uint16(visitor.Limit)) + default: + return nil, errors.New("Bad register type") + } + klog.V(1).Info("Set result:", err, results) + return results, err +} + +func (c *CustomizedClient) StopDevice() error { + // TODO: stop device + // you can use c.ProtocolConfig + err := c.ModbusClient.Close() + if err != nil { + return err + } + return nil +} + +// parity convert into the format that modbus driver requires. +func parity(ori string) string { + var p string + switch ori { + case "even": + p = "E" + case "odd": + p = "O" + default: + p = "N" + } + return p +} diff --git a/mappers/v1beta1-mapper/virtualdevice/go.mod b/mappers/v1beta1-mapper/modbus/go.mod similarity index 76% rename from mappers/v1beta1-mapper/virtualdevice/go.mod rename to mappers/v1beta1-mapper/modbus/go.mod index adec2fac..9eac5741 100644 --- a/mappers/v1beta1-mapper/virtualdevice/go.mod +++ b/mappers/v1beta1-mapper/modbus/go.mod @@ -1,12 +1,11 @@ -module github.com/kubeedge/virtualdevice +module github.com/kubeedge/modbus go 1.17 require ( - - github.com/eclipse/paho.mqtt.golang v1.4.3 github.com/golang/protobuf v1.5.2 github.com/gorilla/mux v1.8.0 + github.com/sailorvii/modbus v0.1.2 github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace golang.org/x/net v0.8.0 // indirect google.golang.org/grpc v1.47.0 @@ -15,11 +14,16 @@ require ( k8s.io/klog/v2 v2.80.1 ) -require github.com/influxdata/influxdb-client-go/v2 v2.12.3 +require ( + github.com/eclipse/paho.mqtt.golang v1.4.3 + github.com/influxdata/influxdb-client-go/v2 v2.12.3 + github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c +) require ( github.com/deepmap/oapi-codegen v1.8.2 // indirect github.com/go-logr/logr v1.2.0 // indirect + github.com/goburrow/serial v0.1.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839 // indirect github.com/pkg/errors v0.9.1 // indirect diff --git a/mappers/v1beta1-mapper/virtualdevice/go.sum b/mappers/v1beta1-mapper/modbus/go.sum similarity index 97% rename from mappers/v1beta1-mapper/virtualdevice/go.sum rename to mappers/v1beta1-mapper/modbus/go.sum index bf094798..5e23e373 100644 --- a/mappers/v1beta1-mapper/virtualdevice/go.sum +++ b/mappers/v1beta1-mapper/modbus/go.sum @@ -34,6 +34,8 @@ github.com/go-logr/logr v1.2.0 h1:QK40JKJyMdUDz+h+xvCsru/bJhvG0UxvePV0ufL/AcE= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/goburrow/serial v0.1.0 h1:v2T1SQa/dlUqQiYIT8+Cu7YolfqAi3K96UmhwYyuSrA= +github.com/goburrow/serial v0.1.0/go.mod h1:sAiqG0nRVswsm1C97xsttiYCzSLBmUZ/VSlVLZJ8haA= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -67,6 +69,8 @@ github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/influxdata/influxdb-client-go/v2 v2.12.3 h1:28nRlNMRIV4QbtIUvxhWqaxn0IpXeMSkY/uJa/O/vC4= github.com/influxdata/influxdb-client-go/v2 v2.12.3/go.mod h1:IrrLUbCjjfkmRuaCiGQg4m2GbkaeJDcuWoxiWdQEbA0= +github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c h1:qSHzRbhzK8RdXOsAdfDgO49TtqC1oZ+acxPrkfTxcCs= +github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839 h1:W9WBk7wlPfJLvMCdtV4zPulc4uCPrlywQOmbFOhgQNU= github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -92,6 +96,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/sailorvii/modbus v0.1.2 h1:Btjqzck5qJAkVhvzRNYjeRirN1OZwNhbVWCe2alyuOw= +github.com/sailorvii/modbus v0.1.2/go.mod h1:7KS/EFWv2J88WuVRiI/WnttT2xO+R7DlvshfdBa2cSw= github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace h1:9PNP1jnUjRhfmGMlkXHjYPishpcw4jpSt/V/xYY3FMA= github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/mappers/v1beta1-mapper/virtualdevice/hack/make-rules/mapper.sh b/mappers/v1beta1-mapper/modbus/hack/make-rules/mapper.sh old mode 100755 new mode 100644 similarity index 100% rename from mappers/v1beta1-mapper/virtualdevice/hack/make-rules/mapper.sh rename to mappers/v1beta1-mapper/modbus/hack/make-rules/mapper.sh diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/common/configmaptype.go b/mappers/v1beta1-mapper/modbus/pkg/common/configmaptype.go similarity index 87% rename from mappers/v1beta1-mapper/virtualdevice/pkg/common/configmaptype.go rename to mappers/v1beta1-mapper/modbus/pkg/common/configmaptype.go index 0cc7dc2b..4ddfcc4e 100644 --- a/mappers/v1beta1-mapper/virtualdevice/pkg/common/configmaptype.go +++ b/mappers/v1beta1-mapper/modbus/pkg/common/configmaptype.go @@ -18,7 +18,7 @@ package common import "encoding/json" -// DeviceProfile is structure to store in configMap. +// DeviceProfile is structure to store in configMap. It will be removed later type DeviceProfile struct { DeviceInstances []DeviceInstance `json:"deviceInstances,omitempty"` DeviceModels []DeviceModel `json:"deviceModels,omitempty"` @@ -49,10 +49,9 @@ type ModelProperty struct { DataType string `json:"dataType,omitempty"` Description string `json:"description,omitempty"` AccessMode string `json:"accessMode,omitempty"` - //DefaultValue interface{} `json:"defaultValue,omitempty"` - Minimum string `json:"minimum,omitempty"` //todo todo why the type is int64 - Maximum string `json:"maximum,omitempty"` - Unit string `json:"unit,omitempty"` + Minimum string `json:"minimum,omitempty"` + Maximum string `json:"maximum,omitempty"` + Unit string `json:"unit,omitempty"` } // Protocol is structure to store protocol in deviceProfile.json in configmap. @@ -74,14 +73,12 @@ type DeviceProperty struct { ModelName string `json:"modelName,omitempty"` Protocol string `json:"protocol,omitempty"` Visitors json.RawMessage `json:"visitorConfig"` - // whether be reported to the cloud ReportToCloud bool `json:"reportToCloud,omitempty"` CollectCycle int64 `json:"collectCycle"` ReportCycle int64 `json:"reportCycle,omitempty"` PushMethod PushMethodConfig `json:"pushMethod,omitempty"` - - PProperty ModelProperty + PProperty ModelProperty } // PushMethodConfig is structure to store push config @@ -97,9 +94,11 @@ type DBMethodConfig struct { } type DBConfig struct { - Influxdb2ClientConfig json.RawMessage `json:"influxdb2ClientConfig"` - Influxdb2DataConfig json.RawMessage `json:"influxdb2DataConfig"` - RedisConfigData json.RawMessage `json:"redisConfigData"` + Influxdb2ClientConfig json.RawMessage `json:"influxdb2ClientConfig"` + Influxdb2DataConfig json.RawMessage `json:"influxdb2DataConfig"` + RedisConfigData json.RawMessage `json:"redisConfigData"` + OpenGeminiClientConfig json.RawMessage `json:"openGeminiClientConfig"` + OpenGeminiDataConfig json.RawMessage `json:"openGeminiDataConfig"` } // Metadata is the metadata for data. diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/common/const.go b/mappers/v1beta1-mapper/modbus/pkg/common/const.go similarity index 100% rename from mappers/v1beta1-mapper/virtualdevice/pkg/common/const.go rename to mappers/v1beta1-mapper/modbus/pkg/common/const.go diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/common/dataconverter.go b/mappers/v1beta1-mapper/modbus/pkg/common/dataconverter.go similarity index 100% rename from mappers/v1beta1-mapper/virtualdevice/pkg/common/dataconverter.go rename to mappers/v1beta1-mapper/modbus/pkg/common/dataconverter.go diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/common/datamodel.go b/mappers/v1beta1-mapper/modbus/pkg/common/datamodel.go similarity index 100% rename from mappers/v1beta1-mapper/virtualdevice/pkg/common/datamodel.go rename to mappers/v1beta1-mapper/modbus/pkg/common/datamodel.go diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/common/event.go b/mappers/v1beta1-mapper/modbus/pkg/common/event.go similarity index 100% rename from mappers/v1beta1-mapper/virtualdevice/pkg/common/event.go rename to mappers/v1beta1-mapper/modbus/pkg/common/event.go diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/common/eventtype.go b/mappers/v1beta1-mapper/modbus/pkg/common/eventtype.go similarity index 100% rename from mappers/v1beta1-mapper/virtualdevice/pkg/common/eventtype.go rename to mappers/v1beta1-mapper/modbus/pkg/common/eventtype.go diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/config/config.go b/mappers/v1beta1-mapper/modbus/pkg/config/config.go similarity index 98% rename from mappers/v1beta1-mapper/virtualdevice/pkg/config/config.go rename to mappers/v1beta1-mapper/modbus/pkg/config/config.go index 530e3704..76900d3c 100644 --- a/mappers/v1beta1-mapper/virtualdevice/pkg/config/config.go +++ b/mappers/v1beta1-mapper/modbus/pkg/config/config.go @@ -26,7 +26,7 @@ import ( "gopkg.in/yaml.v2" "k8s.io/klog/v2" - "github.com/kubeedge/virtualdevice/pkg/common" + "github.com/kubeedge/modbus/pkg/common" ) var defaultConfigFile = "./config.yaml" diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/dmi-api/api.pb.go b/mappers/v1beta1-mapper/modbus/pkg/dmi-api/api.pb.go similarity index 85% rename from mappers/v1beta1-mapper/virtualdevice/pkg/dmi-api/api.pb.go rename to mappers/v1beta1-mapper/modbus/pkg/dmi-api/api.pb.go index 19e252db..2751341b 100644 --- a/mappers/v1beta1-mapper/virtualdevice/pkg/dmi-api/api.pb.go +++ b/mappers/v1beta1-mapper/modbus/pkg/dmi-api/api.pb.go @@ -1,5 +1,5 @@ /* -Copyright 2022 The KubeEdge Authors. +Copyright 2023 The KubeEdge Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -1088,7 +1088,8 @@ type DBMethod struct { unknownFields protoimpl.UnknownFields // the config of database . - Influxdb2 *DBMethodInfluxdb2 `protobuf:"bytes,1,opt,name=influxdb2,proto3" json:"influxdb2,omitempty"` + Influxdb2 *DBMethodInfluxdb2 `protobuf:"bytes,1,opt,name=influxdb2,proto3" json:"influxdb2,omitempty"` + OpenGemini *DBMethodOpenGemini `protobuf:"bytes,2,opt,name=openGemini,proto3" json:"openGemini,omitempty"` } func (x *DBMethod) Reset() { @@ -1130,6 +1131,13 @@ func (x *DBMethod) GetInfluxdb2() *DBMethodInfluxdb2 { return nil } +func (x *DBMethod) GetOpenGemini() *DBMethodOpenGemini { + if x != nil { + return x.OpenGemini + } + return nil +} + type DBMethodInfluxdb2 struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1316,6 +1324,192 @@ func (x *Influxdb2ClientConfig) GetBucket() string { return "" } +type DBMethodOpenGemini struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // the config of OpenGemini database. + OpenGeminiClientConfig *OpenGeminiClientConfig `protobuf:"bytes,1,opt,name=openGeminiClientConfig,proto3" json:"openGeminiClientConfig,omitempty"` + OpenGeminiDataConfig *OpenGeminiDataConfig `protobuf:"bytes,2,opt,name=openGeminiDataConfig,proto3" json:"openGeminiDataConfig,omitempty"` +} + +func (x *DBMethodOpenGemini) Reset() { + *x = DBMethodOpenGemini{} + if protoimpl.UnsafeEnabled { + mi := &file_api_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DBMethodOpenGemini) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DBMethodOpenGemini) ProtoMessage() {} + +func (x *DBMethodOpenGemini) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_msgTypes[19] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DBMethodOpenGemini.ProtoReflect.Descriptor instead. +func (*DBMethodOpenGemini) Descriptor() ([]byte, []int) { + return file_api_proto_rawDescGZIP(), []int{19} +} + +func (x *DBMethodOpenGemini) GetOpenGeminiClientConfig() *OpenGeminiClientConfig { + if x != nil { + return x.OpenGeminiClientConfig + } + return nil +} + +func (x *DBMethodOpenGemini) GetOpenGeminiDataConfig() *OpenGeminiDataConfig { + if x != nil { + return x.OpenGeminiDataConfig + } + return nil +} + +type OpenGeminiDataConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // data config when push data to OpenGemini + Measurement string `protobuf:"bytes,1,opt,name=measurement,proto3" json:"measurement,omitempty"` + Tags map[string]string `protobuf:"bytes,2,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + FieldKey string `protobuf:"bytes,3,opt,name=fieldKey,proto3" json:"fieldKey,omitempty"` +} + +func (x *OpenGeminiDataConfig) Reset() { + *x = OpenGeminiDataConfig{} + if protoimpl.UnsafeEnabled { + mi := &file_api_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *OpenGeminiDataConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OpenGeminiDataConfig) ProtoMessage() {} + +func (x *OpenGeminiDataConfig) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_msgTypes[20] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OpenGeminiDataConfig.ProtoReflect.Descriptor instead. +func (*OpenGeminiDataConfig) Descriptor() ([]byte, []int) { + return file_api_proto_rawDescGZIP(), []int{20} +} + +func (x *OpenGeminiDataConfig) GetMeasurement() string { + if x != nil { + return x.Measurement + } + return "" +} + +func (x *OpenGeminiDataConfig) GetTags() map[string]string { + if x != nil { + return x.Tags + } + return nil +} + +func (x *OpenGeminiDataConfig) GetFieldKey() string { + if x != nil { + return x.FieldKey + } + return "" +} + +type OpenGeminiClientConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // OpenGemini database url + Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` + // usr database in OpenGemini database + Database string `protobuf:"bytes,2,opt,name=database,proto3" json:"database,omitempty"` + // data retentionPolicy in OpenGemini database + RetentionPolicy string `protobuf:"bytes,3,opt,name=retentionPolicy,proto3" json:"retentionPolicy,omitempty"` +} + +func (x *OpenGeminiClientConfig) Reset() { + *x = OpenGeminiClientConfig{} + if protoimpl.UnsafeEnabled { + mi := &file_api_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *OpenGeminiClientConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OpenGeminiClientConfig) ProtoMessage() {} + +func (x *OpenGeminiClientConfig) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_msgTypes[21] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OpenGeminiClientConfig.ProtoReflect.Descriptor instead. +func (*OpenGeminiClientConfig) Descriptor() ([]byte, []int) { + return file_api_proto_rawDescGZIP(), []int{21} +} + +func (x *OpenGeminiClientConfig) GetUrl() string { + if x != nil { + return x.Url + } + return "" +} + +func (x *OpenGeminiClientConfig) GetDatabase() string { + if x != nil { + return x.Database + } + return "" +} + +func (x *OpenGeminiClientConfig) GetRetentionPolicy() string { + if x != nil { + return x.RetentionPolicy + } + return "" +} + // MapperInfo is the information of mapper. type MapperInfo struct { state protoimpl.MessageState @@ -1339,7 +1533,7 @@ type MapperInfo struct { func (x *MapperInfo) Reset() { *x = MapperInfo{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[19] + mi := &file_api_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1352,7 +1546,7 @@ func (x *MapperInfo) String() string { func (*MapperInfo) ProtoMessage() {} func (x *MapperInfo) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[19] + mi := &file_api_proto_msgTypes[22] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1365,7 +1559,7 @@ func (x *MapperInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use MapperInfo.ProtoReflect.Descriptor instead. func (*MapperInfo) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{19} + return file_api_proto_rawDescGZIP(), []int{22} } func (x *MapperInfo) GetName() string { @@ -1422,7 +1616,7 @@ type ReportDeviceStatusRequest struct { func (x *ReportDeviceStatusRequest) Reset() { *x = ReportDeviceStatusRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[20] + mi := &file_api_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1435,7 +1629,7 @@ func (x *ReportDeviceStatusRequest) String() string { func (*ReportDeviceStatusRequest) ProtoMessage() {} func (x *ReportDeviceStatusRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[20] + mi := &file_api_proto_msgTypes[23] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1448,7 +1642,7 @@ func (x *ReportDeviceStatusRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ReportDeviceStatusRequest.ProtoReflect.Descriptor instead. func (*ReportDeviceStatusRequest) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{20} + return file_api_proto_rawDescGZIP(), []int{23} } func (x *ReportDeviceStatusRequest) GetDeviceName() string { @@ -1478,7 +1672,7 @@ type DeviceStatus struct { func (x *DeviceStatus) Reset() { *x = DeviceStatus{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[21] + mi := &file_api_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1491,7 +1685,7 @@ func (x *DeviceStatus) String() string { func (*DeviceStatus) ProtoMessage() {} func (x *DeviceStatus) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[21] + mi := &file_api_proto_msgTypes[24] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1504,7 +1698,7 @@ func (x *DeviceStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use DeviceStatus.ProtoReflect.Descriptor instead. func (*DeviceStatus) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{21} + return file_api_proto_rawDescGZIP(), []int{24} } func (x *DeviceStatus) GetTwins() []*Twin { @@ -1531,7 +1725,7 @@ type Twin struct { func (x *Twin) Reset() { *x = Twin{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[22] + mi := &file_api_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1544,7 +1738,7 @@ func (x *Twin) String() string { func (*Twin) ProtoMessage() {} func (x *Twin) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[22] + mi := &file_api_proto_msgTypes[25] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1557,7 +1751,7 @@ func (x *Twin) ProtoReflect() protoreflect.Message { // Deprecated: Use Twin.ProtoReflect.Descriptor instead. func (*Twin) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{22} + return file_api_proto_rawDescGZIP(), []int{25} } func (x *Twin) GetPropertyName() string { @@ -1596,7 +1790,7 @@ type TwinProperty struct { func (x *TwinProperty) Reset() { *x = TwinProperty{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[23] + mi := &file_api_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1609,7 +1803,7 @@ func (x *TwinProperty) String() string { func (*TwinProperty) ProtoMessage() {} func (x *TwinProperty) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[23] + mi := &file_api_proto_msgTypes[26] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1622,7 +1816,7 @@ func (x *TwinProperty) ProtoReflect() protoreflect.Message { // Deprecated: Use TwinProperty.ProtoReflect.Descriptor instead. func (*TwinProperty) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{23} + return file_api_proto_rawDescGZIP(), []int{26} } func (x *TwinProperty) GetValue() string { @@ -1648,7 +1842,7 @@ type ReportDeviceStatusResponse struct { func (x *ReportDeviceStatusResponse) Reset() { *x = ReportDeviceStatusResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[24] + mi := &file_api_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1661,7 +1855,7 @@ func (x *ReportDeviceStatusResponse) String() string { func (*ReportDeviceStatusResponse) ProtoMessage() {} func (x *ReportDeviceStatusResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[24] + mi := &file_api_proto_msgTypes[27] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1674,7 +1868,7 @@ func (x *ReportDeviceStatusResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ReportDeviceStatusResponse.ProtoReflect.Descriptor instead. func (*ReportDeviceStatusResponse) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{24} + return file_api_proto_rawDescGZIP(), []int{27} } type RegisterDeviceRequest struct { @@ -1688,7 +1882,7 @@ type RegisterDeviceRequest struct { func (x *RegisterDeviceRequest) Reset() { *x = RegisterDeviceRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[25] + mi := &file_api_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1701,7 +1895,7 @@ func (x *RegisterDeviceRequest) String() string { func (*RegisterDeviceRequest) ProtoMessage() {} func (x *RegisterDeviceRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[25] + mi := &file_api_proto_msgTypes[28] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1714,7 +1908,7 @@ func (x *RegisterDeviceRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RegisterDeviceRequest.ProtoReflect.Descriptor instead. func (*RegisterDeviceRequest) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{25} + return file_api_proto_rawDescGZIP(), []int{28} } func (x *RegisterDeviceRequest) GetDevice() *Device { @@ -1735,7 +1929,7 @@ type RegisterDeviceResponse struct { func (x *RegisterDeviceResponse) Reset() { *x = RegisterDeviceResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[26] + mi := &file_api_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1748,7 +1942,7 @@ func (x *RegisterDeviceResponse) String() string { func (*RegisterDeviceResponse) ProtoMessage() {} func (x *RegisterDeviceResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[26] + mi := &file_api_proto_msgTypes[29] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1761,7 +1955,7 @@ func (x *RegisterDeviceResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RegisterDeviceResponse.ProtoReflect.Descriptor instead. func (*RegisterDeviceResponse) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{26} + return file_api_proto_rawDescGZIP(), []int{29} } func (x *RegisterDeviceResponse) GetDeviceName() string { @@ -1782,7 +1976,7 @@ type CreateDeviceModelRequest struct { func (x *CreateDeviceModelRequest) Reset() { *x = CreateDeviceModelRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[27] + mi := &file_api_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1795,7 +1989,7 @@ func (x *CreateDeviceModelRequest) String() string { func (*CreateDeviceModelRequest) ProtoMessage() {} func (x *CreateDeviceModelRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[27] + mi := &file_api_proto_msgTypes[30] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1808,7 +2002,7 @@ func (x *CreateDeviceModelRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateDeviceModelRequest.ProtoReflect.Descriptor instead. func (*CreateDeviceModelRequest) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{27} + return file_api_proto_rawDescGZIP(), []int{30} } func (x *CreateDeviceModelRequest) GetModel() *DeviceModel { @@ -1829,7 +2023,7 @@ type CreateDeviceModelResponse struct { func (x *CreateDeviceModelResponse) Reset() { *x = CreateDeviceModelResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[28] + mi := &file_api_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1842,7 +2036,7 @@ func (x *CreateDeviceModelResponse) String() string { func (*CreateDeviceModelResponse) ProtoMessage() {} func (x *CreateDeviceModelResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[28] + mi := &file_api_proto_msgTypes[31] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1855,7 +2049,7 @@ func (x *CreateDeviceModelResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateDeviceModelResponse.ProtoReflect.Descriptor instead. func (*CreateDeviceModelResponse) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{28} + return file_api_proto_rawDescGZIP(), []int{31} } func (x *CreateDeviceModelResponse) GetDeviceModelName() string { @@ -1876,7 +2070,7 @@ type RemoveDeviceRequest struct { func (x *RemoveDeviceRequest) Reset() { *x = RemoveDeviceRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[29] + mi := &file_api_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1889,7 +2083,7 @@ func (x *RemoveDeviceRequest) String() string { func (*RemoveDeviceRequest) ProtoMessage() {} func (x *RemoveDeviceRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[29] + mi := &file_api_proto_msgTypes[32] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1902,7 +2096,7 @@ func (x *RemoveDeviceRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveDeviceRequest.ProtoReflect.Descriptor instead. func (*RemoveDeviceRequest) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{29} + return file_api_proto_rawDescGZIP(), []int{32} } func (x *RemoveDeviceRequest) GetDeviceName() string { @@ -1921,7 +2115,7 @@ type RemoveDeviceResponse struct { func (x *RemoveDeviceResponse) Reset() { *x = RemoveDeviceResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[30] + mi := &file_api_proto_msgTypes[33] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1934,7 +2128,7 @@ func (x *RemoveDeviceResponse) String() string { func (*RemoveDeviceResponse) ProtoMessage() {} func (x *RemoveDeviceResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[30] + mi := &file_api_proto_msgTypes[33] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1947,7 +2141,7 @@ func (x *RemoveDeviceResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveDeviceResponse.ProtoReflect.Descriptor instead. func (*RemoveDeviceResponse) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{30} + return file_api_proto_rawDescGZIP(), []int{33} } type RemoveDeviceModelRequest struct { @@ -1961,7 +2155,7 @@ type RemoveDeviceModelRequest struct { func (x *RemoveDeviceModelRequest) Reset() { *x = RemoveDeviceModelRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[31] + mi := &file_api_proto_msgTypes[34] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1974,7 +2168,7 @@ func (x *RemoveDeviceModelRequest) String() string { func (*RemoveDeviceModelRequest) ProtoMessage() {} func (x *RemoveDeviceModelRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[31] + mi := &file_api_proto_msgTypes[34] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1987,7 +2181,7 @@ func (x *RemoveDeviceModelRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveDeviceModelRequest.ProtoReflect.Descriptor instead. func (*RemoveDeviceModelRequest) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{31} + return file_api_proto_rawDescGZIP(), []int{34} } func (x *RemoveDeviceModelRequest) GetModelName() string { @@ -2006,7 +2200,7 @@ type RemoveDeviceModelResponse struct { func (x *RemoveDeviceModelResponse) Reset() { *x = RemoveDeviceModelResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[32] + mi := &file_api_proto_msgTypes[35] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2019,7 +2213,7 @@ func (x *RemoveDeviceModelResponse) String() string { func (*RemoveDeviceModelResponse) ProtoMessage() {} func (x *RemoveDeviceModelResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[32] + mi := &file_api_proto_msgTypes[35] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2032,7 +2226,7 @@ func (x *RemoveDeviceModelResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveDeviceModelResponse.ProtoReflect.Descriptor instead. func (*RemoveDeviceModelResponse) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{32} + return file_api_proto_rawDescGZIP(), []int{35} } type UpdateDeviceRequest struct { @@ -2046,7 +2240,7 @@ type UpdateDeviceRequest struct { func (x *UpdateDeviceRequest) Reset() { *x = UpdateDeviceRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[33] + mi := &file_api_proto_msgTypes[36] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2059,7 +2253,7 @@ func (x *UpdateDeviceRequest) String() string { func (*UpdateDeviceRequest) ProtoMessage() {} func (x *UpdateDeviceRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[33] + mi := &file_api_proto_msgTypes[36] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2072,7 +2266,7 @@ func (x *UpdateDeviceRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateDeviceRequest.ProtoReflect.Descriptor instead. func (*UpdateDeviceRequest) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{33} + return file_api_proto_rawDescGZIP(), []int{36} } func (x *UpdateDeviceRequest) GetDevice() *Device { @@ -2091,7 +2285,7 @@ type UpdateDeviceResponse struct { func (x *UpdateDeviceResponse) Reset() { *x = UpdateDeviceResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[34] + mi := &file_api_proto_msgTypes[37] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2104,7 +2298,7 @@ func (x *UpdateDeviceResponse) String() string { func (*UpdateDeviceResponse) ProtoMessage() {} func (x *UpdateDeviceResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[34] + mi := &file_api_proto_msgTypes[37] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2117,7 +2311,7 @@ func (x *UpdateDeviceResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateDeviceResponse.ProtoReflect.Descriptor instead. func (*UpdateDeviceResponse) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{34} + return file_api_proto_rawDescGZIP(), []int{37} } type UpdateDeviceModelRequest struct { @@ -2131,7 +2325,7 @@ type UpdateDeviceModelRequest struct { func (x *UpdateDeviceModelRequest) Reset() { *x = UpdateDeviceModelRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[35] + mi := &file_api_proto_msgTypes[38] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2144,7 +2338,7 @@ func (x *UpdateDeviceModelRequest) String() string { func (*UpdateDeviceModelRequest) ProtoMessage() {} func (x *UpdateDeviceModelRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[35] + mi := &file_api_proto_msgTypes[38] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2157,7 +2351,7 @@ func (x *UpdateDeviceModelRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateDeviceModelRequest.ProtoReflect.Descriptor instead. func (*UpdateDeviceModelRequest) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{35} + return file_api_proto_rawDescGZIP(), []int{38} } func (x *UpdateDeviceModelRequest) GetModel() *DeviceModel { @@ -2176,7 +2370,7 @@ type UpdateDeviceModelResponse struct { func (x *UpdateDeviceModelResponse) Reset() { *x = UpdateDeviceModelResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[36] + mi := &file_api_proto_msgTypes[39] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2189,7 +2383,7 @@ func (x *UpdateDeviceModelResponse) String() string { func (*UpdateDeviceModelResponse) ProtoMessage() {} func (x *UpdateDeviceModelResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[36] + mi := &file_api_proto_msgTypes[39] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2202,7 +2396,7 @@ func (x *UpdateDeviceModelResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateDeviceModelResponse.ProtoReflect.Descriptor instead. func (*UpdateDeviceModelResponse) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{36} + return file_api_proto_rawDescGZIP(), []int{39} } type GetDeviceRequest struct { @@ -2216,7 +2410,7 @@ type GetDeviceRequest struct { func (x *GetDeviceRequest) Reset() { *x = GetDeviceRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[37] + mi := &file_api_proto_msgTypes[40] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2229,7 +2423,7 @@ func (x *GetDeviceRequest) String() string { func (*GetDeviceRequest) ProtoMessage() {} func (x *GetDeviceRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[37] + mi := &file_api_proto_msgTypes[40] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2242,7 +2436,7 @@ func (x *GetDeviceRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetDeviceRequest.ProtoReflect.Descriptor instead. func (*GetDeviceRequest) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{37} + return file_api_proto_rawDescGZIP(), []int{40} } func (x *GetDeviceRequest) GetDeviceName() string { @@ -2263,7 +2457,7 @@ type GetDeviceResponse struct { func (x *GetDeviceResponse) Reset() { *x = GetDeviceResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_proto_msgTypes[38] + mi := &file_api_proto_msgTypes[41] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2276,7 +2470,7 @@ func (x *GetDeviceResponse) String() string { func (*GetDeviceResponse) ProtoMessage() {} func (x *GetDeviceResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_proto_msgTypes[38] + mi := &file_api_proto_msgTypes[41] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2289,7 +2483,7 @@ func (x *GetDeviceResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetDeviceResponse.ProtoReflect.Descriptor instead. func (*GetDeviceResponse) Descriptor() ([]byte, []int) { - return file_api_proto_rawDescGZIP(), []int{38} + return file_api_proto_rawDescGZIP(), []int{41} } func (x *GetDeviceResponse) GetDevice() *Device { @@ -2440,41 +2634,77 @@ var file_api_proto_rawDesc = []byte{ 0x52, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x12, 0x10, 0x0a, 0x03, 0x71, 0x6f, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x71, 0x6f, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x74, - 0x61, 0x69, 0x6e, 0x65, 0x64, 0x22, 0x44, 0x0a, 0x08, 0x44, 0x42, 0x4d, 0x65, 0x74, 0x68, 0x6f, - 0x64, 0x12, 0x38, 0x0a, 0x09, 0x69, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x32, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x44, - 0x42, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x49, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x32, - 0x52, 0x09, 0x69, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x32, 0x22, 0xb9, 0x01, 0x0a, 0x11, + 0x61, 0x69, 0x6e, 0x65, 0x64, 0x22, 0x81, 0x01, 0x0a, 0x08, 0x44, 0x42, 0x4d, 0x65, 0x74, 0x68, + 0x6f, 0x64, 0x12, 0x38, 0x0a, 0x09, 0x69, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x32, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x44, 0x42, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x49, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, - 0x32, 0x12, 0x54, 0x0a, 0x15, 0x69, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x32, 0x43, 0x6c, - 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1e, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6c, 0x75, - 0x78, 0x64, 0x62, 0x32, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x52, 0x15, 0x69, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x32, 0x43, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4e, 0x0a, 0x13, 0x69, 0x6e, 0x66, 0x6c, 0x75, - 0x78, 0x64, 0x62, 0x32, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x49, - 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x32, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x52, 0x13, 0x69, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x32, 0x44, 0x61, 0x74, - 0x61, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0xc4, 0x01, 0x0a, 0x13, 0x49, 0x6e, 0x66, 0x6c, - 0x75, 0x78, 0x64, 0x62, 0x32, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, - 0x20, 0x0a, 0x0b, 0x6d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, - 0x74, 0x12, 0x37, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, + 0x32, 0x52, 0x09, 0x69, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x32, 0x12, 0x3b, 0x0a, 0x0a, + 0x6f, 0x70, 0x65, 0x6e, 0x47, 0x65, 0x6d, 0x69, 0x6e, 0x69, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x44, 0x42, 0x4d, 0x65, 0x74, + 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x65, 0x6e, 0x47, 0x65, 0x6d, 0x69, 0x6e, 0x69, 0x52, 0x0a, 0x6f, + 0x70, 0x65, 0x6e, 0x47, 0x65, 0x6d, 0x69, 0x6e, 0x69, 0x22, 0xb9, 0x01, 0x0a, 0x11, 0x44, 0x42, + 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x49, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x32, 0x12, + 0x54, 0x0a, 0x15, 0x69, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x32, 0x43, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, - 0x62, 0x32, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x54, 0x61, 0x67, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, - 0x65, 0x6c, 0x64, 0x4b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, - 0x65, 0x6c, 0x64, 0x4b, 0x65, 0x79, 0x1a, 0x36, 0x0a, 0x08, 0x54, 0x61, 0x67, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x53, - 0x0a, 0x15, 0x49, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x32, 0x43, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x72, 0x67, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6f, 0x72, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x62, - 0x75, 0x63, 0x6b, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x62, 0x75, 0x63, - 0x6b, 0x65, 0x74, 0x22, 0xa7, 0x01, 0x0a, 0x0a, 0x4d, 0x61, 0x70, 0x70, 0x65, 0x72, 0x49, 0x6e, + 0x62, 0x32, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x15, + 0x69, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x32, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4e, 0x0a, 0x13, 0x69, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, + 0x62, 0x32, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x49, 0x6e, 0x66, + 0x6c, 0x75, 0x78, 0x64, 0x62, 0x32, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x52, 0x13, 0x69, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x32, 0x44, 0x61, 0x74, 0x61, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0xc4, 0x01, 0x0a, 0x13, 0x49, 0x6e, 0x66, 0x6c, 0x75, 0x78, + 0x64, 0x62, 0x32, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x20, 0x0a, + 0x0b, 0x6d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0b, 0x6d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, + 0x37, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x32, + 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x54, 0x61, 0x67, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x65, 0x6c, + 0x64, 0x4b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x65, 0x6c, + 0x64, 0x4b, 0x65, 0x79, 0x1a, 0x36, 0x0a, 0x08, 0x54, 0x61, 0x67, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x53, 0x0a, 0x15, + 0x49, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x32, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x72, 0x67, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6f, 0x72, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x75, 0x63, + 0x6b, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x62, 0x75, 0x63, 0x6b, 0x65, + 0x74, 0x22, 0xc0, 0x01, 0x0a, 0x12, 0x44, 0x42, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, + 0x65, 0x6e, 0x47, 0x65, 0x6d, 0x69, 0x6e, 0x69, 0x12, 0x57, 0x0a, 0x16, 0x6f, 0x70, 0x65, 0x6e, + 0x47, 0x65, 0x6d, 0x69, 0x6e, 0x69, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x47, 0x65, 0x6d, 0x69, 0x6e, 0x69, 0x43, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x16, 0x6f, 0x70, 0x65, 0x6e, 0x47, + 0x65, 0x6d, 0x69, 0x6e, 0x69, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x12, 0x51, 0x0a, 0x14, 0x6f, 0x70, 0x65, 0x6e, 0x47, 0x65, 0x6d, 0x69, 0x6e, 0x69, 0x44, + 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1d, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x47, 0x65, + 0x6d, 0x69, 0x6e, 0x69, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x14, + 0x6f, 0x70, 0x65, 0x6e, 0x47, 0x65, 0x6d, 0x69, 0x6e, 0x69, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x22, 0xca, 0x01, 0x0a, 0x14, 0x4f, 0x70, 0x65, 0x6e, 0x47, 0x65, 0x6d, + 0x69, 0x6e, 0x69, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x20, 0x0a, + 0x0b, 0x6d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0b, 0x6d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, + 0x3b, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x47, 0x65, 0x6d, 0x69, + 0x6e, 0x69, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x54, 0x61, 0x67, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x1a, 0x0a, 0x08, + 0x66, 0x69, 0x65, 0x6c, 0x64, 0x4b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x66, 0x69, 0x65, 0x6c, 0x64, 0x4b, 0x65, 0x79, 0x1a, 0x37, 0x0a, 0x09, 0x54, 0x61, 0x67, 0x73, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x22, 0x70, 0x0a, 0x16, 0x4f, 0x70, 0x65, 0x6e, 0x47, 0x65, 0x6d, 0x69, 0x6e, 0x69, 0x43, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x75, + 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x1a, 0x0a, + 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x72, 0x65, 0x74, + 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0f, 0x72, 0x65, 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, + 0x69, 0x63, 0x79, 0x22, 0xa7, 0x01, 0x0a, 0x0a, 0x4d, 0x61, 0x70, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, @@ -2632,7 +2862,7 @@ func file_api_proto_rawDescGZIP() []byte { return file_api_proto_rawDescData } -var file_api_proto_msgTypes = make([]protoimpl.MessageInfo, 42) +var file_api_proto_msgTypes = make([]protoimpl.MessageInfo, 46) var file_api_proto_goTypes = []interface{}{ (*MapperRegisterRequest)(nil), // 0: v1beta1.MapperRegisterRequest (*MapperRegisterResponse)(nil), // 1: v1beta1.MapperRegisterResponse @@ -2653,89 +2883,97 @@ var file_api_proto_goTypes = []interface{}{ (*DBMethodInfluxdb2)(nil), // 16: v1beta1.DBMethodInfluxdb2 (*Influxdb2DataConfig)(nil), // 17: v1beta1.Influxdb2DataConfig (*Influxdb2ClientConfig)(nil), // 18: v1beta1.Influxdb2ClientConfig - (*MapperInfo)(nil), // 19: v1beta1.MapperInfo - (*ReportDeviceStatusRequest)(nil), // 20: v1beta1.ReportDeviceStatusRequest - (*DeviceStatus)(nil), // 21: v1beta1.DeviceStatus - (*Twin)(nil), // 22: v1beta1.Twin - (*TwinProperty)(nil), // 23: v1beta1.TwinProperty - (*ReportDeviceStatusResponse)(nil), // 24: v1beta1.ReportDeviceStatusResponse - (*RegisterDeviceRequest)(nil), // 25: v1beta1.RegisterDeviceRequest - (*RegisterDeviceResponse)(nil), // 26: v1beta1.RegisterDeviceResponse - (*CreateDeviceModelRequest)(nil), // 27: v1beta1.CreateDeviceModelRequest - (*CreateDeviceModelResponse)(nil), // 28: v1beta1.CreateDeviceModelResponse - (*RemoveDeviceRequest)(nil), // 29: v1beta1.RemoveDeviceRequest - (*RemoveDeviceResponse)(nil), // 30: v1beta1.RemoveDeviceResponse - (*RemoveDeviceModelRequest)(nil), // 31: v1beta1.RemoveDeviceModelRequest - (*RemoveDeviceModelResponse)(nil), // 32: v1beta1.RemoveDeviceModelResponse - (*UpdateDeviceRequest)(nil), // 33: v1beta1.UpdateDeviceRequest - (*UpdateDeviceResponse)(nil), // 34: v1beta1.UpdateDeviceResponse - (*UpdateDeviceModelRequest)(nil), // 35: v1beta1.UpdateDeviceModelRequest - (*UpdateDeviceModelResponse)(nil), // 36: v1beta1.UpdateDeviceModelResponse - (*GetDeviceRequest)(nil), // 37: v1beta1.GetDeviceRequest - (*GetDeviceResponse)(nil), // 38: v1beta1.GetDeviceResponse - nil, // 39: v1beta1.CustomizedValue.DataEntry - nil, // 40: v1beta1.Influxdb2DataConfig.TagEntry - nil, // 41: v1beta1.TwinProperty.MetadataEntry - (*anypb.Any)(nil), // 42: google.protobuf.Any + (*DBMethodOpenGemini)(nil), // 19: v1beta1.DBMethodOpenGemini + (*OpenGeminiDataConfig)(nil), // 20: v1beta1.OpenGeminiDataConfig + (*OpenGeminiClientConfig)(nil), // 21: v1beta1.OpenGeminiClientConfig + (*MapperInfo)(nil), // 22: v1beta1.MapperInfo + (*ReportDeviceStatusRequest)(nil), // 23: v1beta1.ReportDeviceStatusRequest + (*DeviceStatus)(nil), // 24: v1beta1.DeviceStatus + (*Twin)(nil), // 25: v1beta1.Twin + (*TwinProperty)(nil), // 26: v1beta1.TwinProperty + (*ReportDeviceStatusResponse)(nil), // 27: v1beta1.ReportDeviceStatusResponse + (*RegisterDeviceRequest)(nil), // 28: v1beta1.RegisterDeviceRequest + (*RegisterDeviceResponse)(nil), // 29: v1beta1.RegisterDeviceResponse + (*CreateDeviceModelRequest)(nil), // 30: v1beta1.CreateDeviceModelRequest + (*CreateDeviceModelResponse)(nil), // 31: v1beta1.CreateDeviceModelResponse + (*RemoveDeviceRequest)(nil), // 32: v1beta1.RemoveDeviceRequest + (*RemoveDeviceResponse)(nil), // 33: v1beta1.RemoveDeviceResponse + (*RemoveDeviceModelRequest)(nil), // 34: v1beta1.RemoveDeviceModelRequest + (*RemoveDeviceModelResponse)(nil), // 35: v1beta1.RemoveDeviceModelResponse + (*UpdateDeviceRequest)(nil), // 36: v1beta1.UpdateDeviceRequest + (*UpdateDeviceResponse)(nil), // 37: v1beta1.UpdateDeviceResponse + (*UpdateDeviceModelRequest)(nil), // 38: v1beta1.UpdateDeviceModelRequest + (*UpdateDeviceModelResponse)(nil), // 39: v1beta1.UpdateDeviceModelResponse + (*GetDeviceRequest)(nil), // 40: v1beta1.GetDeviceRequest + (*GetDeviceResponse)(nil), // 41: v1beta1.GetDeviceResponse + nil, // 42: v1beta1.CustomizedValue.DataEntry + nil, // 43: v1beta1.Influxdb2DataConfig.TagEntry + nil, // 44: v1beta1.OpenGeminiDataConfig.TagsEntry + nil, // 45: v1beta1.TwinProperty.MetadataEntry + (*anypb.Any)(nil), // 46: google.protobuf.Any } var file_api_proto_depIdxs = []int32{ - 19, // 0: v1beta1.MapperRegisterRequest.mapper:type_name -> v1beta1.MapperInfo + 22, // 0: v1beta1.MapperRegisterRequest.mapper:type_name -> v1beta1.MapperInfo 2, // 1: v1beta1.MapperRegisterResponse.modelList:type_name -> v1beta1.DeviceModel 6, // 2: v1beta1.MapperRegisterResponse.deviceList:type_name -> v1beta1.Device 3, // 3: v1beta1.DeviceModel.spec:type_name -> v1beta1.DeviceModelSpec 4, // 4: v1beta1.DeviceModelSpec.properties:type_name -> v1beta1.ModelProperty 5, // 5: v1beta1.DeviceModelSpec.commands:type_name -> v1beta1.DeviceCommand 7, // 6: v1beta1.Device.spec:type_name -> v1beta1.DeviceSpec - 21, // 7: v1beta1.Device.status:type_name -> v1beta1.DeviceStatus + 24, // 7: v1beta1.Device.status:type_name -> v1beta1.DeviceStatus 9, // 8: v1beta1.DeviceSpec.protocol:type_name -> v1beta1.ProtocolConfig 8, // 9: v1beta1.DeviceSpec.properties:type_name -> v1beta1.DeviceProperty - 23, // 10: v1beta1.DeviceProperty.desired:type_name -> v1beta1.TwinProperty + 26, // 10: v1beta1.DeviceProperty.desired:type_name -> v1beta1.TwinProperty 10, // 11: v1beta1.DeviceProperty.visitors:type_name -> v1beta1.VisitorConfig 12, // 12: v1beta1.DeviceProperty.pushMethod:type_name -> v1beta1.PushMethod 11, // 13: v1beta1.ProtocolConfig.configData:type_name -> v1beta1.CustomizedValue 11, // 14: v1beta1.VisitorConfig.configData:type_name -> v1beta1.CustomizedValue - 39, // 15: v1beta1.CustomizedValue.data:type_name -> v1beta1.CustomizedValue.DataEntry + 42, // 15: v1beta1.CustomizedValue.data:type_name -> v1beta1.CustomizedValue.DataEntry 13, // 16: v1beta1.PushMethod.http:type_name -> v1beta1.PushMethodHTTP 14, // 17: v1beta1.PushMethod.mqtt:type_name -> v1beta1.PushMethodMQTT 15, // 18: v1beta1.PushMethod.dbMethod:type_name -> v1beta1.DBMethod 16, // 19: v1beta1.DBMethod.influxdb2:type_name -> v1beta1.DBMethodInfluxdb2 - 18, // 20: v1beta1.DBMethodInfluxdb2.influxdb2ClientConfig:type_name -> v1beta1.Influxdb2ClientConfig - 17, // 21: v1beta1.DBMethodInfluxdb2.influxdb2DataConfig:type_name -> v1beta1.Influxdb2DataConfig - 40, // 22: v1beta1.Influxdb2DataConfig.tag:type_name -> v1beta1.Influxdb2DataConfig.TagEntry - 21, // 23: v1beta1.ReportDeviceStatusRequest.reportedDevice:type_name -> v1beta1.DeviceStatus - 22, // 24: v1beta1.DeviceStatus.twins:type_name -> v1beta1.Twin - 23, // 25: v1beta1.Twin.observedDesired:type_name -> v1beta1.TwinProperty - 23, // 26: v1beta1.Twin.reported:type_name -> v1beta1.TwinProperty - 41, // 27: v1beta1.TwinProperty.metadata:type_name -> v1beta1.TwinProperty.MetadataEntry - 6, // 28: v1beta1.RegisterDeviceRequest.device:type_name -> v1beta1.Device - 2, // 29: v1beta1.CreateDeviceModelRequest.model:type_name -> v1beta1.DeviceModel - 6, // 30: v1beta1.UpdateDeviceRequest.device:type_name -> v1beta1.Device - 2, // 31: v1beta1.UpdateDeviceModelRequest.model:type_name -> v1beta1.DeviceModel - 6, // 32: v1beta1.GetDeviceResponse.device:type_name -> v1beta1.Device - 42, // 33: v1beta1.CustomizedValue.DataEntry.value:type_name -> google.protobuf.Any - 0, // 34: v1beta1.DeviceManagerService.MapperRegister:input_type -> v1beta1.MapperRegisterRequest - 20, // 35: v1beta1.DeviceManagerService.ReportDeviceStatus:input_type -> v1beta1.ReportDeviceStatusRequest - 25, // 36: v1beta1.DeviceMapperService.RegisterDevice:input_type -> v1beta1.RegisterDeviceRequest - 29, // 37: v1beta1.DeviceMapperService.RemoveDevice:input_type -> v1beta1.RemoveDeviceRequest - 33, // 38: v1beta1.DeviceMapperService.UpdateDevice:input_type -> v1beta1.UpdateDeviceRequest - 27, // 39: v1beta1.DeviceMapperService.CreateDeviceModel:input_type -> v1beta1.CreateDeviceModelRequest - 31, // 40: v1beta1.DeviceMapperService.RemoveDeviceModel:input_type -> v1beta1.RemoveDeviceModelRequest - 35, // 41: v1beta1.DeviceMapperService.UpdateDeviceModel:input_type -> v1beta1.UpdateDeviceModelRequest - 37, // 42: v1beta1.DeviceMapperService.GetDevice:input_type -> v1beta1.GetDeviceRequest - 1, // 43: v1beta1.DeviceManagerService.MapperRegister:output_type -> v1beta1.MapperRegisterResponse - 24, // 44: v1beta1.DeviceManagerService.ReportDeviceStatus:output_type -> v1beta1.ReportDeviceStatusResponse - 26, // 45: v1beta1.DeviceMapperService.RegisterDevice:output_type -> v1beta1.RegisterDeviceResponse - 30, // 46: v1beta1.DeviceMapperService.RemoveDevice:output_type -> v1beta1.RemoveDeviceResponse - 34, // 47: v1beta1.DeviceMapperService.UpdateDevice:output_type -> v1beta1.UpdateDeviceResponse - 28, // 48: v1beta1.DeviceMapperService.CreateDeviceModel:output_type -> v1beta1.CreateDeviceModelResponse - 32, // 49: v1beta1.DeviceMapperService.RemoveDeviceModel:output_type -> v1beta1.RemoveDeviceModelResponse - 36, // 50: v1beta1.DeviceMapperService.UpdateDeviceModel:output_type -> v1beta1.UpdateDeviceModelResponse - 38, // 51: v1beta1.DeviceMapperService.GetDevice:output_type -> v1beta1.GetDeviceResponse - 43, // [43:52] is the sub-list for method output_type - 34, // [34:43] is the sub-list for method input_type - 34, // [34:34] is the sub-list for extension type_name - 34, // [34:34] is the sub-list for extension extendee - 0, // [0:34] is the sub-list for field type_name + 19, // 20: v1beta1.DBMethod.openGemini:type_name -> v1beta1.DBMethodOpenGemini + 18, // 21: v1beta1.DBMethodInfluxdb2.influxdb2ClientConfig:type_name -> v1beta1.Influxdb2ClientConfig + 17, // 22: v1beta1.DBMethodInfluxdb2.influxdb2DataConfig:type_name -> v1beta1.Influxdb2DataConfig + 43, // 23: v1beta1.Influxdb2DataConfig.tag:type_name -> v1beta1.Influxdb2DataConfig.TagEntry + 21, // 24: v1beta1.DBMethodOpenGemini.openGeminiClientConfig:type_name -> v1beta1.OpenGeminiClientConfig + 20, // 25: v1beta1.DBMethodOpenGemini.openGeminiDataConfig:type_name -> v1beta1.OpenGeminiDataConfig + 44, // 26: v1beta1.OpenGeminiDataConfig.tags:type_name -> v1beta1.OpenGeminiDataConfig.TagsEntry + 24, // 27: v1beta1.ReportDeviceStatusRequest.reportedDevice:type_name -> v1beta1.DeviceStatus + 25, // 28: v1beta1.DeviceStatus.twins:type_name -> v1beta1.Twin + 26, // 29: v1beta1.Twin.observedDesired:type_name -> v1beta1.TwinProperty + 26, // 30: v1beta1.Twin.reported:type_name -> v1beta1.TwinProperty + 45, // 31: v1beta1.TwinProperty.metadata:type_name -> v1beta1.TwinProperty.MetadataEntry + 6, // 32: v1beta1.RegisterDeviceRequest.device:type_name -> v1beta1.Device + 2, // 33: v1beta1.CreateDeviceModelRequest.model:type_name -> v1beta1.DeviceModel + 6, // 34: v1beta1.UpdateDeviceRequest.device:type_name -> v1beta1.Device + 2, // 35: v1beta1.UpdateDeviceModelRequest.model:type_name -> v1beta1.DeviceModel + 6, // 36: v1beta1.GetDeviceResponse.device:type_name -> v1beta1.Device + 46, // 37: v1beta1.CustomizedValue.DataEntry.value:type_name -> google.protobuf.Any + 0, // 38: v1beta1.DeviceManagerService.MapperRegister:input_type -> v1beta1.MapperRegisterRequest + 23, // 39: v1beta1.DeviceManagerService.ReportDeviceStatus:input_type -> v1beta1.ReportDeviceStatusRequest + 28, // 40: v1beta1.DeviceMapperService.RegisterDevice:input_type -> v1beta1.RegisterDeviceRequest + 32, // 41: v1beta1.DeviceMapperService.RemoveDevice:input_type -> v1beta1.RemoveDeviceRequest + 36, // 42: v1beta1.DeviceMapperService.UpdateDevice:input_type -> v1beta1.UpdateDeviceRequest + 30, // 43: v1beta1.DeviceMapperService.CreateDeviceModel:input_type -> v1beta1.CreateDeviceModelRequest + 34, // 44: v1beta1.DeviceMapperService.RemoveDeviceModel:input_type -> v1beta1.RemoveDeviceModelRequest + 38, // 45: v1beta1.DeviceMapperService.UpdateDeviceModel:input_type -> v1beta1.UpdateDeviceModelRequest + 40, // 46: v1beta1.DeviceMapperService.GetDevice:input_type -> v1beta1.GetDeviceRequest + 1, // 47: v1beta1.DeviceManagerService.MapperRegister:output_type -> v1beta1.MapperRegisterResponse + 27, // 48: v1beta1.DeviceManagerService.ReportDeviceStatus:output_type -> v1beta1.ReportDeviceStatusResponse + 29, // 49: v1beta1.DeviceMapperService.RegisterDevice:output_type -> v1beta1.RegisterDeviceResponse + 33, // 50: v1beta1.DeviceMapperService.RemoveDevice:output_type -> v1beta1.RemoveDeviceResponse + 37, // 51: v1beta1.DeviceMapperService.UpdateDevice:output_type -> v1beta1.UpdateDeviceResponse + 31, // 52: v1beta1.DeviceMapperService.CreateDeviceModel:output_type -> v1beta1.CreateDeviceModelResponse + 35, // 53: v1beta1.DeviceMapperService.RemoveDeviceModel:output_type -> v1beta1.RemoveDeviceModelResponse + 39, // 54: v1beta1.DeviceMapperService.UpdateDeviceModel:output_type -> v1beta1.UpdateDeviceModelResponse + 41, // 55: v1beta1.DeviceMapperService.GetDevice:output_type -> v1beta1.GetDeviceResponse + 47, // [47:56] is the sub-list for method output_type + 38, // [38:47] is the sub-list for method input_type + 38, // [38:38] is the sub-list for extension type_name + 38, // [38:38] is the sub-list for extension extendee + 0, // [0:38] is the sub-list for field type_name } func init() { file_api_proto_init() } @@ -2973,7 +3211,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MapperInfo); i { + switch v := v.(*DBMethodOpenGemini); i { case 0: return &v.state case 1: @@ -2985,7 +3223,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReportDeviceStatusRequest); i { + switch v := v.(*OpenGeminiDataConfig); i { case 0: return &v.state case 1: @@ -2997,7 +3235,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeviceStatus); i { + switch v := v.(*OpenGeminiClientConfig); i { case 0: return &v.state case 1: @@ -3009,7 +3247,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Twin); i { + switch v := v.(*MapperInfo); i { case 0: return &v.state case 1: @@ -3021,7 +3259,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TwinProperty); i { + switch v := v.(*ReportDeviceStatusRequest); i { case 0: return &v.state case 1: @@ -3033,7 +3271,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReportDeviceStatusResponse); i { + switch v := v.(*DeviceStatus); i { case 0: return &v.state case 1: @@ -3045,7 +3283,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RegisterDeviceRequest); i { + switch v := v.(*Twin); i { case 0: return &v.state case 1: @@ -3057,7 +3295,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RegisterDeviceResponse); i { + switch v := v.(*TwinProperty); i { case 0: return &v.state case 1: @@ -3069,7 +3307,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateDeviceModelRequest); i { + switch v := v.(*ReportDeviceStatusResponse); i { case 0: return &v.state case 1: @@ -3081,7 +3319,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateDeviceModelResponse); i { + switch v := v.(*RegisterDeviceRequest); i { case 0: return &v.state case 1: @@ -3093,7 +3331,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RemoveDeviceRequest); i { + switch v := v.(*RegisterDeviceResponse); i { case 0: return &v.state case 1: @@ -3105,7 +3343,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RemoveDeviceResponse); i { + switch v := v.(*CreateDeviceModelRequest); i { case 0: return &v.state case 1: @@ -3117,7 +3355,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RemoveDeviceModelRequest); i { + switch v := v.(*CreateDeviceModelResponse); i { case 0: return &v.state case 1: @@ -3129,7 +3367,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RemoveDeviceModelResponse); i { + switch v := v.(*RemoveDeviceRequest); i { case 0: return &v.state case 1: @@ -3141,7 +3379,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateDeviceRequest); i { + switch v := v.(*RemoveDeviceResponse); i { case 0: return &v.state case 1: @@ -3153,7 +3391,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateDeviceResponse); i { + switch v := v.(*RemoveDeviceModelRequest); i { case 0: return &v.state case 1: @@ -3165,7 +3403,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateDeviceModelRequest); i { + switch v := v.(*RemoveDeviceModelResponse); i { case 0: return &v.state case 1: @@ -3177,7 +3415,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateDeviceModelResponse); i { + switch v := v.(*UpdateDeviceRequest); i { case 0: return &v.state case 1: @@ -3189,7 +3427,7 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetDeviceRequest); i { + switch v := v.(*UpdateDeviceResponse); i { case 0: return &v.state case 1: @@ -3201,6 +3439,42 @@ func file_api_proto_init() { } } file_api_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateDeviceModelRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateDeviceModelResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetDeviceRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetDeviceResponse); i { case 0: return &v.state @@ -3219,7 +3493,7 @@ func file_api_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_api_proto_rawDesc, NumEnums: 0, - NumMessages: 42, + NumMessages: 46, NumExtensions: 0, NumServices: 2, }, diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/dmi-api/api.proto b/mappers/v1beta1-mapper/modbus/pkg/dmi-api/api.proto similarity index 95% rename from mappers/v1beta1-mapper/virtualdevice/pkg/dmi-api/api.proto rename to mappers/v1beta1-mapper/modbus/pkg/dmi-api/api.proto index a6f94859..8040a6bc 100644 --- a/mappers/v1beta1-mapper/virtualdevice/pkg/dmi-api/api.proto +++ b/mappers/v1beta1-mapper/modbus/pkg/dmi-api/api.proto @@ -245,6 +245,7 @@ message PushMethodMQTT { message DBMethod{ // the config of database . DBMethodInfluxdb2 influxdb2 = 1; + DBMethodOpenGemini openGemini = 2; } message DBMethodInfluxdb2{ @@ -269,6 +270,28 @@ message Influxdb2ClientConfig{ string bucket = 3; } +message DBMethodOpenGemini{ + // the config of OpenGemini database. + OpenGeminiClientConfig openGeminiClientConfig = 1; + OpenGeminiDataConfig openGeminiDataConfig = 2; +} + +message OpenGeminiDataConfig{ + // data config when push data to OpenGemini + string measurement = 1; + map tags = 2; + string fieldKey = 3; +} + +message OpenGeminiClientConfig{ + // OpenGemini database url + string url = 1; + // usr database in OpenGemini database + string database = 2; + // data retentionPolicy in OpenGemini database + string retentionPolicy = 3; +} + // MapperInfo is the information of mapper. message MapperInfo { // name of the mapper. diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/dmi-api/api_grpc.pb.go b/mappers/v1beta1-mapper/modbus/pkg/dmi-api/api_grpc.pb.go similarity index 100% rename from mappers/v1beta1-mapper/virtualdevice/pkg/dmi-api/api_grpc.pb.go rename to mappers/v1beta1-mapper/modbus/pkg/dmi-api/api_grpc.pb.go diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/global/global.go b/mappers/v1beta1-mapper/modbus/pkg/global/global.go similarity index 95% rename from mappers/v1beta1-mapper/virtualdevice/pkg/global/global.go rename to mappers/v1beta1-mapper/modbus/pkg/global/global.go index 85480dbd..730e7584 100644 --- a/mappers/v1beta1-mapper/virtualdevice/pkg/global/global.go +++ b/mappers/v1beta1-mapper/modbus/pkg/global/global.go @@ -1,8 +1,8 @@ package global import ( - "github.com/kubeedge/virtualdevice/pkg/common" - "github.com/kubeedge/virtualdevice/pkg/config" + "github.com/kubeedge/modbus/pkg/common" + "github.com/kubeedge/modbus/pkg/config" ) // DevPanel defined operations on devices, manage the lifecycle of devices diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/grpcserver/device.go b/mappers/v1beta1-mapper/modbus/pkg/grpcserver/device.go similarity index 93% rename from mappers/v1beta1-mapper/virtualdevice/pkg/grpcserver/device.go rename to mappers/v1beta1-mapper/modbus/pkg/grpcserver/device.go index ee6e655e..2bb424a3 100644 --- a/mappers/v1beta1-mapper/virtualdevice/pkg/grpcserver/device.go +++ b/mappers/v1beta1-mapper/modbus/pkg/grpcserver/device.go @@ -9,16 +9,14 @@ import ( "k8s.io/klog/v2" "reflect" - "github.com/kubeedge/virtualdevice/pkg/common" - dmiapi "github.com/kubeedge/virtualdevice/pkg/dmi-api" - "github.com/kubeedge/virtualdevice/pkg/util/parse" + "github.com/kubeedge/modbus/pkg/common" + dmiapi "github.com/kubeedge/modbus/pkg/dmi-api" + "github.com/kubeedge/modbus/pkg/util/parse" ) func (s *Server) RegisterDevice(ctx context.Context, request *dmiapi.RegisterDeviceRequest) (*dmiapi.RegisterDeviceResponse, error) { - //klog.V(2).Info("RegisterDevice") + klog.V(3).Info("RegisterDevice") device := request.GetDevice() - //klog.V(1).Infof("In RegisterDevice, device = %v", device) - if device == nil { return nil, errors.New("device is nil") } @@ -67,7 +65,7 @@ func (s *Server) RemoveDevice(ctx context.Context, request *dmiapi.RemoveDeviceR } func (s *Server) UpdateDevice(ctx context.Context, request *dmiapi.UpdateDeviceRequest) (*dmiapi.UpdateDeviceResponse, error) { - klog.V(2).Info("UpdateDevice") + klog.V(3).Info("UpdateDevice") device := request.GetDevice() if device == nil { return nil, errors.New("device is nil") @@ -82,7 +80,7 @@ func (s *Server) UpdateDevice(ctx context.Context, request *dmiapi.UpdateDeviceR return nil, fmt.Errorf("parse device %s protocol failed, err: %s", device.Name, err) } - klog.Infof("model: %+v", model) + klog.V(3).Infof("model: %+v", model) deviceInstance, err := parse.ParseDeviceFromGrpc(device, &model) if err != nil { return nil, fmt.Errorf("parse device %s instance failed, err: %s", device.Name, err) diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/grpcserver/server.go b/mappers/v1beta1-mapper/modbus/pkg/grpcserver/server.go similarity index 88% rename from mappers/v1beta1-mapper/virtualdevice/pkg/grpcserver/server.go rename to mappers/v1beta1-mapper/modbus/pkg/grpcserver/server.go index 41055eac..5f42b21c 100644 --- a/mappers/v1beta1-mapper/virtualdevice/pkg/grpcserver/server.go +++ b/mappers/v1beta1-mapper/modbus/pkg/grpcserver/server.go @@ -9,8 +9,8 @@ import ( "google.golang.org/grpc/reflection" "k8s.io/klog/v2" - dmiapi "github.com/kubeedge/virtualdevice/pkg/dmi-api" - "github.com/kubeedge/virtualdevice/pkg/global" + dmiapi "github.com/kubeedge/modbus/pkg/dmi-api" + "github.com/kubeedge/modbus/pkg/global" ) type Config struct { @@ -47,7 +47,7 @@ func (s *Server) Start() error { grpcServer := grpc.NewServer() dmiapi.RegisterDeviceMapperServiceServer(grpcServer, s) reflection.Register(grpcServer) - klog.Info("start grpc server") + klog.V(2).Info("start grpc server") return grpcServer.Serve(s.lis) } @@ -63,7 +63,7 @@ func (s *Server) Stop() { } func initSock(sockPath string) error { - klog.Infof("init uds socket: %s", sockPath) + klog.V(2).Infof("init uds socket: %s", sockPath) _, err := os.Stat(sockPath) if err == nil { err = os.Remove(sockPath) diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/httpserver/callback.go b/mappers/v1beta1-mapper/modbus/pkg/httpserver/callback.go similarity index 98% rename from mappers/v1beta1-mapper/virtualdevice/pkg/httpserver/callback.go rename to mappers/v1beta1-mapper/modbus/pkg/httpserver/callback.go index 7af92b25..001d8988 100644 --- a/mappers/v1beta1-mapper/virtualdevice/pkg/httpserver/callback.go +++ b/mappers/v1beta1-mapper/modbus/pkg/httpserver/callback.go @@ -6,7 +6,7 @@ import ( "reflect" "strings" - "github.com/kubeedge/virtualdevice/pkg/common" + "github.com/kubeedge/modbus/pkg/common" ) func (rs *RestServer) Ping(writer http.ResponseWriter, request *http.Request) { diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/httpserver/responsetype.go b/mappers/v1beta1-mapper/modbus/pkg/httpserver/responsetype.go similarity index 94% rename from mappers/v1beta1-mapper/virtualdevice/pkg/httpserver/responsetype.go rename to mappers/v1beta1-mapper/modbus/pkg/httpserver/responsetype.go index e844092c..ea830b04 100644 --- a/mappers/v1beta1-mapper/virtualdevice/pkg/httpserver/responsetype.go +++ b/mappers/v1beta1-mapper/modbus/pkg/httpserver/responsetype.go @@ -3,7 +3,7 @@ package httpserver import ( "time" - "github.com/kubeedge/virtualdevice/pkg/common" + "github.com/kubeedge/modbus/pkg/common" ) // BaseResponse the base response struct of all response diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/httpserver/restapi.go b/mappers/v1beta1-mapper/modbus/pkg/httpserver/restapi.go similarity index 100% rename from mappers/v1beta1-mapper/virtualdevice/pkg/httpserver/restapi.go rename to mappers/v1beta1-mapper/modbus/pkg/httpserver/restapi.go diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/httpserver/router.go b/mappers/v1beta1-mapper/modbus/pkg/httpserver/router.go similarity index 100% rename from mappers/v1beta1-mapper/virtualdevice/pkg/httpserver/router.go rename to mappers/v1beta1-mapper/modbus/pkg/httpserver/router.go diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/httpserver/server.go b/mappers/v1beta1-mapper/modbus/pkg/httpserver/server.go similarity index 93% rename from mappers/v1beta1-mapper/virtualdevice/pkg/httpserver/server.go rename to mappers/v1beta1-mapper/modbus/pkg/httpserver/server.go index 8dde5e2e..def1fe9a 100644 --- a/mappers/v1beta1-mapper/virtualdevice/pkg/httpserver/server.go +++ b/mappers/v1beta1-mapper/modbus/pkg/httpserver/server.go @@ -11,7 +11,7 @@ import ( "github.com/gorilla/mux" "k8s.io/klog/v2" - "github.com/kubeedge/virtualdevice/pkg/global" + "github.com/kubeedge/modbus/pkg/global" ) type RestServer struct { @@ -55,7 +55,7 @@ func (rs *RestServer) StartServer() { } if rs.CaCertFilePath == "" && (rs.KeyFilePath == "" || rs.CertFilePath == "") { // insecure - klog.Info("Insecure communication, skipping server verification") + klog.V(3).Info("Insecure communication, skipping server verification") err := rs.server.ListenAndServe() if err != nil { klog.Errorf("insecure http server error: %v", err) @@ -63,7 +63,7 @@ func (rs *RestServer) StartServer() { } } else if rs.CaCertFilePath == "" && rs.KeyFilePath != "" && rs.CertFilePath != "" { // tls - klog.Info("tls communication, https server start") + klog.V(3).Info("tls communication, https server start") err := rs.server.ListenAndServeTLS(rs.CertFilePath, rs.KeyFilePath) if err != nil { klog.Errorf("tls http server error: %v", err) @@ -71,7 +71,7 @@ func (rs *RestServer) StartServer() { } } else if rs.CaCertFilePath != "" && rs.KeyFilePath != "" && rs.CertFilePath != "" { // mtls - klog.Info("mtls communication, please provide client-key and client-cert to access service") + klog.V(3).Info("mtls communication, please provide client-key and client-cert to access service") // Configure the server to trust TLS client cert issued by your CA. certPool := x509.NewCertPool() if caCertPEM, err := ioutil.ReadFile(rs.CaCertFilePath); err != nil { diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/util/grpcclient/config.go b/mappers/v1beta1-mapper/modbus/pkg/util/grpcclient/config.go similarity index 71% rename from mappers/v1beta1-mapper/virtualdevice/pkg/util/grpcclient/config.go rename to mappers/v1beta1-mapper/modbus/pkg/util/grpcclient/config.go index 53c4a813..2ec979b4 100644 --- a/mappers/v1beta1-mapper/virtualdevice/pkg/util/grpcclient/config.go +++ b/mappers/v1beta1-mapper/modbus/pkg/util/grpcclient/config.go @@ -1,7 +1,7 @@ package grpcclient import ( - "github.com/kubeedge/virtualdevice/pkg/config" + "github.com/kubeedge/modbus/pkg/config" ) var cfg *config.Config diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/util/grpcclient/register.go b/mappers/v1beta1-mapper/modbus/pkg/util/grpcclient/register.go similarity index 90% rename from mappers/v1beta1-mapper/virtualdevice/pkg/util/grpcclient/register.go rename to mappers/v1beta1-mapper/modbus/pkg/util/grpcclient/register.go index c0114657..bb539662 100644 --- a/mappers/v1beta1-mapper/virtualdevice/pkg/util/grpcclient/register.go +++ b/mappers/v1beta1-mapper/modbus/pkg/util/grpcclient/register.go @@ -8,9 +8,9 @@ import ( "google.golang.org/grpc" - "github.com/kubeedge/virtualdevice/pkg/common" - "github.com/kubeedge/virtualdevice/pkg/config" - dmiapi "github.com/kubeedge/virtualdevice/pkg/dmi-api" + "github.com/kubeedge/modbus/pkg/common" + "github.com/kubeedge/modbus/pkg/config" + dmiapi "github.com/kubeedge/modbus/pkg/dmi-api" ) // RegisterMapper if withData is true, edgecore will send device and model list. diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/util/grpcclient/report.go b/mappers/v1beta1-mapper/modbus/pkg/util/grpcclient/report.go similarity index 94% rename from mappers/v1beta1-mapper/virtualdevice/pkg/util/grpcclient/report.go rename to mappers/v1beta1-mapper/modbus/pkg/util/grpcclient/report.go index 364eb03b..f430b443 100644 --- a/mappers/v1beta1-mapper/virtualdevice/pkg/util/grpcclient/report.go +++ b/mappers/v1beta1-mapper/modbus/pkg/util/grpcclient/report.go @@ -8,7 +8,7 @@ import ( "google.golang.org/grpc" - dmiapi "github.com/kubeedge/virtualdevice/pkg/dmi-api" + dmiapi "github.com/kubeedge/modbus/pkg/dmi-api" ) // ReportDeviceStatus report device status to edgecore diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/util/parse/grpc.go b/mappers/v1beta1-mapper/modbus/pkg/util/parse/grpc.go similarity index 89% rename from mappers/v1beta1-mapper/virtualdevice/pkg/util/parse/grpc.go rename to mappers/v1beta1-mapper/modbus/pkg/util/parse/grpc.go index 74c2cd2a..328d6d2d 100644 --- a/mappers/v1beta1-mapper/virtualdevice/pkg/util/parse/grpc.go +++ b/mappers/v1beta1-mapper/modbus/pkg/util/parse/grpc.go @@ -6,8 +6,8 @@ import ( "k8s.io/klog/v2" - "github.com/kubeedge/virtualdevice/pkg/common" - dmiapi "github.com/kubeedge/virtualdevice/pkg/dmi-api" + "github.com/kubeedge/modbus/pkg/common" + dmiapi "github.com/kubeedge/modbus/pkg/dmi-api" ) type TwinResultResponse struct { @@ -35,6 +35,8 @@ func getDBMethodFromGrpc(visitor *dmiapi.DeviceProperty) (string, error) { // TODO add more dbMethod if visitor.PushMethod.DBMethod.Influxdb2 != nil { return "influx", nil + } else if visitor.PushMethod.DBMethod.OpenGemini != nil { + return "openGemini", nil } return "", errors.New("can not parse dbMethod") } @@ -109,7 +111,7 @@ func buildPropertiesFromGrpc(device *dmiapi.Device) []common.DeviceProperty { return nil } res := make([]common.DeviceProperty, 0, len(device.Spec.Properties)) - klog.V(1).Infof("In buildPropertiesFromGrpc, PropertyVisitors = %v", device.Spec.Properties) + klog.V(3).Infof("In buildPropertiesFromGrpc, PropertyVisitors = %v", device.Spec.Properties) for _, pptv := range device.Spec.Properties { // get visitorConfig filed by grpc device instance @@ -156,6 +158,21 @@ func buildPropertiesFromGrpc(device *dmiapi.Device) []common.DeviceProperty { Influxdb2ClientConfig: clientconfig, Influxdb2DataConfig: dataconfig, } + case "openGemini": + clientconfig, err := json.Marshal(pptv.PushMethod.DBMethod.OpenGemini.OpenGeminiClientConfig) + if err != nil { + klog.Errorf("err: %+v", err) + return nil + } + dataconfig, err := json.Marshal(pptv.PushMethod.DBMethod.OpenGemini.OpenGeminiDataConfig) + if err != nil { + klog.Errorf("err: %+v", err) + return nil + } + dbconfig = common.DBConfig{ + OpenGeminiClientConfig: clientconfig, + OpenGeminiDataConfig: dataconfig, + } } } @@ -251,8 +268,7 @@ func ParseDeviceFromGrpc(device *dmiapi.Device, commonModel *common.DeviceModel) continue } - // ****这里是想把直接从model.yaml文件中解析出来的modelproperty解析到instance里,主要要看传入的commonModel是不是从yaml文件中 - //解析得到的model数据 + // parse the content of the modelproperty field into instance for _, property := range commonModel.Properties { if property.Name == instance.Properties[i].PropertyName { instance.Properties[i].PProperty = property @@ -266,6 +282,6 @@ func ParseDeviceFromGrpc(device *dmiapi.Device, commonModel *common.DeviceModel) instance.Twins[i].Property = &v } } - klog.V(1).Infof("final instance data from grpc = %v", instance) + klog.V(2).Infof("final instance data from grpc = %v", instance) return instance, nil } diff --git a/mappers/v1beta1-mapper/modbus/pkg/util/parse/parse.go b/mappers/v1beta1-mapper/modbus/pkg/util/parse/parse.go new file mode 100644 index 00000000..86951eb7 --- /dev/null +++ b/mappers/v1beta1-mapper/modbus/pkg/util/parse/parse.go @@ -0,0 +1,68 @@ +/* +Copyright 2023 The KubeEdge Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package parse + +import ( + "errors" + + "k8s.io/klog/v2" + + "github.com/kubeedge/modbus/pkg/common" + "github.com/kubeedge/modbus/pkg/config" + "github.com/kubeedge/modbus/pkg/util/grpcclient" +) + +var ErrEmptyData error = errors.New("device or device model list is empty") + +func ParseByUsingRegister(cfg *config.Config, + devices map[string]*common.DeviceInstance, + dms map[string]common.DeviceModel, + protocols map[string]common.ProtocolConfig) error { + deviceList, deviceModelList, err := grpcclient.RegisterMapper(cfg, true) + if err != nil { + return err + } + + if len(deviceList) == 0 || len(deviceModelList) == 0 { + return ErrEmptyData + } + modelMap := make(map[string]common.DeviceModel) + for _, model := range deviceModelList { + cur := ParseDeviceModelFromGrpc(model) + modelMap[model.Name] = cur + } + + for _, device := range deviceList { + commonModel := modelMap[device.Spec.DeviceModelReference] + protocol, err := BuildProtocolFromGrpc(device) + if err != nil { + return err + } + instance, err := ParseDeviceFromGrpc(device, &commonModel) + if err != nil { + return err + } + instance.PProtocol = protocol + devices[instance.ID] = new(common.DeviceInstance) + devices[instance.ID] = instance + klog.V(4).Info("Instance: ", instance.ID) + dms[instance.Model] = modelMap[instance.Model] + protocols[instance.ProtocolName] = protocol + } + + return nil +} diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/util/parse/type.go b/mappers/v1beta1-mapper/modbus/pkg/util/parse/type.go similarity index 96% rename from mappers/v1beta1-mapper/virtualdevice/pkg/util/parse/type.go rename to mappers/v1beta1-mapper/modbus/pkg/util/parse/type.go index 874aa66d..ce32b43d 100644 --- a/mappers/v1beta1-mapper/virtualdevice/pkg/util/parse/type.go +++ b/mappers/v1beta1-mapper/modbus/pkg/util/parse/type.go @@ -3,8 +3,8 @@ package parse import ( "fmt" - "github.com/kubeedge/virtualdevice/pkg/common" - dmiapi "github.com/kubeedge/virtualdevice/pkg/dmi-api" + "github.com/kubeedge/modbus/pkg/common" + dmiapi "github.com/kubeedge/modbus/pkg/dmi-api" ) func ConvTwinsToGrpc(twins []common.Twin) ([]*dmiapi.Twin, error) { diff --git a/mappers/v1beta1-mapper/modbus/resource/modbus-instance.yaml b/mappers/v1beta1-mapper/modbus/resource/modbus-instance.yaml new file mode 100644 index 00000000..b3599b37 --- /dev/null +++ b/mappers/v1beta1-mapper/modbus/resource/modbus-instance.yaml @@ -0,0 +1,53 @@ +apiVersion: devices.kubeedge.io/v1beta1 +kind: Device +metadata: + name: modbus-instance-01 + labels: + model: modbus-01 +spec: + deviceModelRef: + name: modbus-01 + protocol: + protocolName: modbus + configData: + slaveID: 1 + serialPort: '1' + baudRate: 115200 + dataBits: 8 + parity: even + stopBits: 1 + nodeName: edge-node + properties: + - name: temperature + visitors: + protocolName: modbus + configData: + register: CoilRegister + offset: 2 + limit: 1 + scale: 1 + isSwap: true + isRegisterSwap: true + reportCycle: 10000000000 + collectCycle: 10000000000 + reportToCloud: true + pushMethod: + mqtt: + address: tcp://127.0.0.1:1883 + topic: temperature + qos: 0 + retained: false + +status: + twins: + - propertyName: temperature + reported: + metadata: + timestamp: '1550049403598' + type: int + value: "20" + observedDesired: + metadata: + timestamp: '1550049403598' + type: int + value: "20" \ No newline at end of file diff --git a/mappers/v1beta1-mapper/modbus/resource/modbus-model.yaml b/mappers/v1beta1-mapper/modbus/resource/modbus-model.yaml new file mode 100644 index 00000000..790973a5 --- /dev/null +++ b/mappers/v1beta1-mapper/modbus/resource/modbus-model.yaml @@ -0,0 +1,12 @@ +apiVersion: devices.kubeedge.io/v1beta1 +kind: DeviceModel +metadata: + name: modbus-01 + namespace: default +spec: + protocol: modbus + properties: + - name: temperature + description: temperature in degree celsius + type: INT + accessMode: ReadWrite \ No newline at end of file diff --git a/mappers/v1beta1-mapper/virtualdevice/driver/devicetype.go b/mappers/v1beta1-mapper/virtualdevice/driver/devicetype.go deleted file mode 100644 index 4facf2f8..00000000 --- a/mappers/v1beta1-mapper/virtualdevice/driver/devicetype.go +++ /dev/null @@ -1,46 +0,0 @@ -package driver - -import ( - "sync" - - "github.com/kubeedge/virtualdevice/pkg/common" -) - -// CustomizedDev is the customized device configuration and client information. -type CustomizedDev struct { - Instance common.DeviceInstance - CustomizedClient *CustomizedClient -} - -type CustomizedClient struct { - // TODO add some variables to help you better implement device drivers - intMaxValue int - deviceMutex sync.Mutex - ProtocolConfig -} - -type ProtocolConfig struct { //customizedprotocol字段 - ProtocolName string `json:"protocolName"` - ConfigData `json:"configData"` -} - -type ConfigData struct { - // TODO: add your config data according to configmap - DeviceID int `json:"deviceID,omitempty"` - SerialPort string `json:"serialPort"` - DataBits int `json:"dataBits"` - BaudRate int `json:"baudRate"` - Parity string `json:"parity"` - StopBits int `json:"stopBits"` - ProtocolID int `json:"protocolID"` -} - -type VisitorConfig struct { - ProtocolName string `json:"protocolName"` - VisitorConfigData `json:"configData"` -} - -type VisitorConfigData struct { - // TODO: add your Visitor ConfigData according to configmap - DataType string `json:"dataType"` -} diff --git a/mappers/v1beta1-mapper/virtualdevice/driver/driver.go b/mappers/v1beta1-mapper/virtualdevice/driver/driver.go deleted file mode 100644 index a70b2966..00000000 --- a/mappers/v1beta1-mapper/virtualdevice/driver/driver.go +++ /dev/null @@ -1,59 +0,0 @@ -package driver - -import ( - "fmt" - "k8s.io/klog/v2" - "math/rand" - "sync" -) - -func NewClient(protocol ProtocolConfig) (*CustomizedClient, error) { - client := &CustomizedClient{ - ProtocolConfig: protocol, - deviceMutex: sync.Mutex{}, - // TODO initialize the variables you added - } - return client, nil -} - -func (c *CustomizedClient) InitDevice() error { - // TODO: add init operation - // you can use c.ProtocolConfig and c.ProtocolCommonConfig - klog.Infof("Init device%d successful, protocolID: %v", c.DeviceID, c.ProtocolID) - klog.Infof("I can get Info: %v %v ", c.SerialPort, c.BaudRate) - return nil -} - -func (c *CustomizedClient) GetDeviceData(visitor *VisitorConfig) (interface{}, error) { - // TODO: get device's data - // you can use c.ProtocolConfig,c.ProtocolCommonConfig and visitor - if visitor.VisitorConfigData.DataType == "int" { - if c.intMaxValue <= 0 { - return nil, fmt.Errorf("max value is %d, should > 0", c.intMaxValue) - } - return rand.Intn(c.intMaxValue), nil - } else if visitor.DataType == "float" { - return rand.Float64(), nil - } else { - return nil, fmt.Errorf("unrecognized data type: %s", visitor.DataType) - } - return nil, nil -} - -func (c *CustomizedClient) SetDeviceData(data interface{}, visitor *VisitorConfig) error { - // TODO: set device's data - // you can use c.ProtocolConfig,c.ProtocolCommonConfig and visitor - if visitor.DataType == "int" { - c.intMaxValue = int(data.(int64)) - } else { - return fmt.Errorf("unrecognized data type: %s", visitor.DataType) - } - return nil -} - -func (c *CustomizedClient) StopDevice() error { - // TODO: stop device - // you can use c.ProtocolConfig and c.ProtocolCommonConfig - klog.Infof("Stop device%d successful", c.DeviceID) - return nil -} diff --git a/mappers/v1beta1-mapper/virtualdevice/pkg/util/parse/parse.go b/mappers/v1beta1-mapper/virtualdevice/pkg/util/parse/parse.go deleted file mode 100644 index 1e9f136c..00000000 --- a/mappers/v1beta1-mapper/virtualdevice/pkg/util/parse/parse.go +++ /dev/null @@ -1,169 +0,0 @@ -/* -Copyright 2023 The KubeEdge Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package parse - -import ( - "errors" - - "k8s.io/klog/v2" - - "github.com/kubeedge/virtualdevice/pkg/common" - "github.com/kubeedge/virtualdevice/pkg/config" - "github.com/kubeedge/virtualdevice/pkg/util/grpcclient" -) - -var ErrEmptyData error = errors.New("device or device model list is empty") - -// Parse the configmap which will be removed -//func Parse(path string, -// devices map[string]*common.DeviceInstance, -// dms map[string]common.DeviceModel, -// protocols map[string]common.Protocol) error { -// var deviceProfile common.DeviceProfile -// jsonFile, err := ioutil.ReadFile(path) -// if err != nil { -// err = errors.New("failed to read " + path + " file") -// return err -// } -// //Parse the JSON file and convert it into the data structure of DeviceProfile -// if err = json.Unmarshal(jsonFile, &deviceProfile); err != nil { -// return err -// } -// // loop instIndex : judge whether the configmap definition is correct, and initialize the device instance -// for instIndex := 0; instIndex < len(deviceProfile.DeviceInstances); instIndex++ { -// instance := deviceProfile.DeviceInstances[instIndex] -// // loop protoIndex : judge whether the device's protocol is correct, and initialize the device protocol -// protoIndex := 0 -// for protoIndex = 0; protoIndex < len(deviceProfile.Protocols); protoIndex++ { -// if instance.ProtocolName == deviceProfile.Protocols[protoIndex].Name { -// // Verify that the protocols match -// protocolConfig := make(map[string]interface{}) -// err := json.Unmarshal(deviceProfile.Protocols[protoIndex].ProtocolConfigs, &protocolConfig) -// if err != nil { -// err = errors.New("failed to parse " + deviceProfile.Protocols[protoIndex].Name) -// return err -// } -// protocols[deviceProfile.Protocols[protoIndex].Name] = deviceProfile.Protocols[protoIndex] -// instance.PProtocol = deviceProfile.Protocols[protoIndex] -// } -// } -// // loop propertyIndex : find the device model's properties for each device instance's propertyVisitor -// for propertyIndex := 0; propertyIndex < len(instance.PropertyVisitors); propertyIndex++ { -// modelName := instance.PropertyVisitors[propertyIndex].ModelName -// propertyName := instance.PropertyVisitors[propertyIndex].PropertyName -// modelIndex := 0 -// // loop modelIndex : find a matching device model, and initialize the device model -// for modelIndex = 0; modelIndex < len(deviceProfile.DeviceModels); modelIndex++ { -// if modelName == deviceProfile.DeviceModels[modelIndex].Name { -// dms[deviceProfile.DeviceModels[modelIndex].Name] = deviceProfile.DeviceModels[modelIndex] -// m := 0 -// // loop m : find a matching device model's properties -// for m = 0; m < len(deviceProfile.DeviceModels[modelIndex].Properties); m++ { -// if propertyName == deviceProfile.DeviceModels[modelIndex].Properties[m].Name { -// instance.PropertyVisitors[propertyIndex].PProperty = deviceProfile.DeviceModels[modelIndex].Properties[m] -// break -// } -// } -// if m == len(deviceProfile.DeviceModels[modelIndex].Properties) { -// err = errors.New("property mismatch") -// return err -// } -// break -// } -// } -// if modelIndex == len(deviceProfile.DeviceModels) { -// err = errors.New("device model mismatch") -// return err -// } -// } -// // loop propertyIndex : find propertyVisitors for each instance's twin -// for propertyIndex := 0; propertyIndex < len(instance.Twins); propertyIndex++ { -// name := instance.Twins[propertyIndex].PropertyName -// l := 0 -// // loop l : find a matching propertyName -// for l = 0; l < len(instance.PropertyVisitors); l++ { -// if name == instance.PropertyVisitors[l].PropertyName { -// instance.Twins[propertyIndex].PVisitor = &instance.PropertyVisitors[l] -// break -// } -// } -// if l == len(instance.PropertyVisitors) { -// err = errors.New("propertyVisitor mismatch") -// return err -// } -// } -// // loop propertyIndex : find propertyVisitors for each instance's property -// for propertyIndex := 0; propertyIndex < len(instance.Datas.Properties); propertyIndex++ { -// name := instance.Datas.Properties[propertyIndex].PropertyName -// l := 0 -// // loop l : find a matching propertyName -// for l = 0; l < len(instance.PropertyVisitors); l++ { -// if name == instance.PropertyVisitors[l].PropertyName { -// instance.Datas.Properties[propertyIndex].PVisitor = &instance.PropertyVisitors[l] -// break -// } -// } -// if l == len(instance.PropertyVisitors) { -// err = errors.New("propertyVisitor mismatch") -// return err -// } -// } -// devices[instance.ID] = new(common.DeviceInstance) -// devices[instance.ID] = &instance -// klog.V(4).Infof("Instance:%s Successfully registered", instance.ID) -// } -// return nil -//} - -func ParseByUsingRegister(cfg *config.Config, - devices map[string]*common.DeviceInstance, - dms map[string]common.DeviceModel, - protocols map[string]common.ProtocolConfig) error { - deviceList, deviceModelList, err := grpcclient.RegisterMapper(cfg, true) - if err != nil { - return err - } - - if len(deviceList) == 0 || len(deviceModelList) == 0 { - return ErrEmptyData - } - modelMap := make(map[string]common.DeviceModel) - for _, model := range deviceModelList { - cur := ParseDeviceModelFromGrpc(model) - modelMap[model.Name] = cur - } - - for _, device := range deviceList { - commonModel := modelMap[device.Spec.DeviceModelReference] - protocol, err := BuildProtocolFromGrpc(device) - if err != nil { - return err - } - instance, err := ParseDeviceFromGrpc(device, &commonModel) - if err != nil { - return err - } - instance.PProtocol = protocol - devices[instance.ID] = new(common.DeviceInstance) - devices[instance.ID] = instance - klog.V(4).Info("Instance: ", instance.ID) - dms[instance.Model] = modelMap[instance.Model] - protocols[instance.ProtocolName] = protocol - } - - return nil -} diff --git a/mappers/v1beta1-mapper/virtualdevice/resource/deployment.yaml b/mappers/v1beta1-mapper/virtualdevice/resource/deployment.yaml deleted file mode 100644 index bd3a0073..00000000 --- a/mappers/v1beta1-mapper/virtualdevice/resource/deployment.yaml +++ /dev/null @@ -1,50 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: mapper-test - namespace: default - labels: - app: demo - version: stable -spec: - replicas: 1 - selector: - matchLabels: - app: demo - version: stable - template: - metadata: - annotations: - sidecar.istio.io/inject: "false" - labels: - app: demo - version: stable - spec: - nodeName: edge-node - containers: - - name: demo34 - volumeMounts: - - mountPath: /etc/kubeedge - name: test-volume - env: - - name: TOKEN - valueFrom: - secretKeyRef: - name: mysecret - key: token - image: # Fill in the name of the image you created - imagePullPolicy: IfNotPresent - resources: - limits: - cpu: 300m - memory: 500Mi - requests: - cpu: 100m - memory: 100Mi - command: [ "/bin/sh","-c" ] - args: [ "/kubeedge/main --config-file /kubeedge/config.yaml --v 4" ] - volumes: - - name: test-volume - hostPath: - path: /etc/kubeedge - type: Directory diff --git a/mappers/v1beta1-mapper/virtualdevice/resource/secret.yaml b/mappers/v1beta1-mapper/virtualdevice/resource/secret.yaml deleted file mode 100644 index 0a7da99b..00000000 --- a/mappers/v1beta1-mapper/virtualdevice/resource/secret.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: mysecret -type: Opaque -data: - token: #Fill in the key of your influxdb user token, need base64 encoding diff --git a/mappers/v1beta1-mapper/virtualdevice/resource/virtualdevice-instance.yaml b/mappers/v1beta1-mapper/virtualdevice/resource/virtualdevice-instance.yaml deleted file mode 100644 index 041beb10..00000000 --- a/mappers/v1beta1-mapper/virtualdevice/resource/virtualdevice-instance.yaml +++ /dev/null @@ -1,84 +0,0 @@ -apiVersion: devices.kubeedge.io/v1beta1 -kind: Device -metadata: - name: random-instance-01 - labels: - model: random-01 -spec: - deviceModelRef: - name: random-01 - protocol: - protocolName: virtualProtocol # in your mapper, this should be replaced by the protocol name your use - configData: - deviceID: 2 - serialPort: '/dev/ttyS0' - baudRate: 9600 - dataBits: 8 - parity: even - stopBits: 1 - protocolID: 1 - nodeName: edge-node - properties: - - name: random-int - visitors: - protocolName: virtualProtocol # in your mapper, this should be replaced by the protocol name your use - configData: - dataType: 'INT' - reportCycle: 10000000000 - collectCycle: 10000000000 - reportToCloud: true - pushMethod: - mqtt: - address: tcp://192.168.1.73:1883 # replace it by the url of your mqtt client - topic: random-int - qos: 0 - retained: false - dbMethod: - influxdb2: - influxdb2ClientConfig: - url: http://192.168.1.73:8086 # replace it by the url of your influxdb - org: test-org - bucket: test-bucket - influxdb2DataConfig: - measurement: stat - tag: - unit: temperature - fieldKey: wbctest - - name: random-float - visitors: - protocolName: virtualProtocol - configData: - dataType: 'FLOAT' - reportCycle: 10000000000 - collectCycle: 10000000000 - reportToCloud: true - pushMethod: - mqtt: - address: tcp://192.168.1.73:1883 - topic: random-float - qos: 0 - retained: false -status: - twins: - - propertyName: random-int - reported: - metadata: - timestamp: '1550049403598' - type: integer - value: "100" - observedDesired: - metadata: - timestamp: '1550049403598' - type: integer - value: "100" - - propertyName: random-float - reported: - metadata: - timestamp: '1550049403598' - type: float - value: "30" - observedDesired: - metadata: - timestamp: '1550049403598' - type: float - value: "30" diff --git a/mappers/v1beta1-mapper/virtualdevice/resource/virtualdevice-model.yaml b/mappers/v1beta1-mapper/virtualdevice/resource/virtualdevice-model.yaml deleted file mode 100644 index a02bc20f..00000000 --- a/mappers/v1beta1-mapper/virtualdevice/resource/virtualdevice-model.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: devices.kubeedge.io/v1beta1 -kind: DeviceModel -metadata: - name: random-01 - namespace: default -spec: - protocol: virtualProtocol - properties: - - name: random-int - description: random int - type: INT - accessMode: ReadWrite - - name: random-float - description: random float - type: FLOAT - accessMode: ReadOnly \ No newline at end of file