edgexfoundry / device-sdk-go

Owner: Device WG

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When device resource sets mapping, the Tags content will be lost after transformation

gq-tang opened this issue Β· comments

commented

🐞 Bug Report

Affected Services [REQUIRED]

The issue is located in:

https://github.com/edgexfoundry/device-sdk-go/blob/main/internal/transformer/transform.go

Is this a regression?

Yes, the previous version in which this bug was not present was: ....

Description and Minimal Reproduction [REQUIRED]

When device resource sets mapping, the Tags content will be lost after transformation.
I set the Tags in AsyncValues.
CommandValues: []*sdkModels.CommandValue{
{
DeviceResourceName: resourceName,
Type: typ,
Value: pro.DataValue,
Origin: time.Now().UnixNano(),
Tags: map[string]string{
"gatewayId": req.GatewayId,
},
},
}

But there is no tag information in the received event

πŸ”₯ Exception or Error




		// ResourceOperation mapping
		ro, err := cache.Profiles().ResourceOperation(device.ProfileName, cv.DeviceResourceName)
		if err != nil {
			// this allows SDK to directly read deviceResource without deviceCommands defined.
			lc.Debugf("failed to read ResourceOperation: %v", err)
		} else if len(ro.Mappings) > 0 {
			newCV, ok := mapCommandValue(cv, ro.Mappings)
			if ok {
				cv = newCV    // cv is override, tags is empty now
			}
		}

		for key, value := range cv.Tags {  // 
			tags[key] = value
		}

🌍 Your Environment

Deployment Environment:

EdgeX Version [REQUIRED]:
github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.38

Anything else relevant?