diff options
| author | luomengY <2938893385@qq.com> | 2023-11-06 11:45:11 +0800 |
|---|---|---|
| committer | luomengY <2938893385@qq.com> | 2023-11-28 00:34:06 +0800 |
| commit | 8ce463ce11c8c455d155d86e438d68d970091c57 (patch) | |
| tree | b58908da208d1e0ec85ec85fec61f83568aed9c4 /staging/src | |
| parent | Merge pull request #5128 from testwill/typo (diff) | |
| download | kubeedge-8ce463ce11c8c455d155d86e438d68d970091c57.tar.gz | |
Define Twin based on properties in mapper.
Signed-off-by: luomengY <2938893385@qq.com>
Diffstat (limited to 'staging/src')
| -rw-r--r-- | staging/src/github.com/kubeedge/mapper-framework/pkg/util/parse/grpc.go | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/staging/src/github.com/kubeedge/mapper-framework/pkg/util/parse/grpc.go b/staging/src/github.com/kubeedge/mapper-framework/pkg/util/parse/grpc.go index 8f6e89254..db505e983 100644 --- a/staging/src/github.com/kubeedge/mapper-framework/pkg/util/parse/grpc.go +++ b/staging/src/github.com/kubeedge/mapper-framework/pkg/util/parse/grpc.go @@ -72,26 +72,18 @@ func BuildProtocolFromGrpc(device *dmiapi.Device) (common.ProtocolConfig, error) } func buildTwinsFromGrpc(device *dmiapi.Device) []common.Twin { - if len(device.Status.Twins) == 0 { + if len(device.Spec.Properties) == 0 { return nil } - res := make([]common.Twin, 0, len(device.Status.Twins)) - for _, twin := range device.Status.Twins { + res := make([]common.Twin, 0, len(device.Spec.Properties)) + for _, property := range device.Spec.Properties { cur := common.Twin{ - PropertyName: twin.PropertyName, - + PropertyName: property.Name, ObservedDesired: common.TwinProperty{ - Value: twin.ObservedDesired.Value, - Metadata: common.Metadata{ - Timestamp: twin.ObservedDesired.Metadata["timestamp"], - Type: twin.ObservedDesired.Metadata["type"], - }, - }, - Reported: common.TwinProperty{ - Value: twin.Reported.Value, + Value: property.Desired.Value, Metadata: common.Metadata{ - Timestamp: twin.ObservedDesired.Metadata["timestamp"], - Type: twin.ObservedDesired.Metadata["type"], + Timestamp: property.Desired.Metadata["timestamp"], + Type: property.Desired.Metadata["type"], }, }, } @@ -183,14 +175,14 @@ func buildPropertiesFromGrpc(device *dmiapi.Device) []common.DeviceProperty { // get the final Properties cur := common.DeviceProperty{ - Name: pptv.GetName(), - PropertyName: pptv.GetName(), - ModelName: device.Spec.DeviceModelReference, - CollectCycle: pptv.GetCollectCycle(), - ReportCycle: pptv.GetReportCycle(), + Name: pptv.GetName(), + PropertyName: pptv.GetName(), + ModelName: device.Spec.DeviceModelReference, + CollectCycle: pptv.GetCollectCycle(), + ReportCycle: pptv.GetReportCycle(), ReportToCloud: pptv.GetReportToCloud(), - Protocol: protocolName, - Visitors: visitorConfig, + Protocol: protocolName, + Visitors: visitorConfig, PushMethod: common.PushMethodConfig{ MethodName: pushMethodName, MethodConfig: pushMethod, |
