Skip to content

Commit

Permalink
Merge pull request kubeedge#5305 from wbc6080/remove-protocol
Browse files Browse the repository at this point in the history
remove unused protocol field
  • Loading branch information
kubeedge-bot authored Dec 13, 2023
2 parents 1e49343 + 757b500 commit 6416d28
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ type DevPanel struct {
deviceMuxs map[string]context.CancelFunc
devices map[string]*driver.CustomizedDev
models map[string]common.DeviceModel
protocols map[string]common.ProtocolConfig
wg sync.WaitGroup
serviceMutex sync.Mutex
quitChan chan os.Signal
Expand All @@ -47,7 +46,6 @@ func NewDevPanel() *DevPanel {
deviceMuxs: make(map[string]context.CancelFunc),
devices: make(map[string]*driver.CustomizedDev),
models: make(map[string]common.DeviceModel),
protocols: make(map[string]common.ProtocolConfig),
wg: sync.WaitGroup{},
serviceMutex: sync.Mutex{},
quitChan: make(chan os.Signal),
Expand Down Expand Up @@ -367,7 +365,7 @@ func (d *DevPanel) DevInit(cfg *config.Config) error {
// return err
// }
case common.DevInitModeRegister:
if err := parse.ParseByUsingRegister(devs, d.models, d.protocols); err != nil {
if err := parse.ParseByUsingRegister(devs, d.models); err != nil {
return err
}
}
Expand All @@ -381,7 +379,7 @@ func (d *DevPanel) DevInit(cfg *config.Config) error {
}

// UpdateDev stop old device, then update and start new device
func (d *DevPanel) UpdateDev(model *common.DeviceModel, device *common.DeviceInstance, protocol *common.ProtocolConfig) {
func (d *DevPanel) UpdateDev(model *common.DeviceModel, device *common.DeviceInstance) {
d.serviceMutex.Lock()
defer d.serviceMutex.Unlock()

Expand All @@ -395,7 +393,6 @@ func (d *DevPanel) UpdateDev(model *common.DeviceModel, device *common.DeviceIns
d.devices[device.ID] = new(driver.CustomizedDev)
d.devices[device.ID].Instance = *device
d.models[device.ID] = *model
d.protocols[device.ID] = *protocol

ctx, cancelFunc := context.WithCancel(context.Background())
d.deviceMuxs[device.ID] = cancelFunc
Expand All @@ -413,8 +410,7 @@ func (d *DevPanel) UpdateDevTwins(deviceID string, twins []common.Twin) error {
}
dev.Instance.Twins = twins
model := d.models[dev.Instance.Model]
protocol := d.protocols[dev.Instance.ProtocolName]
d.UpdateDev(&model, &dev.Instance, &protocol)
d.UpdateDev(&model, &dev.Instance)
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type DevPanel interface {
// DevInit get device info by dmi interface
DevInit(cfg *config.Config) error
// UpdateDev update device's config and restart the device
UpdateDev(model *common.DeviceModel, device *common.DeviceInstance, protocol *common.ProtocolConfig)
UpdateDev(model *common.DeviceModel, device *common.DeviceInstance)
// UpdateDevTwins update device twin's config and restart the device
UpdateDevTwins(deviceID string, twins []common.Twin) error
// DealDeviceTwinGet get device's twin data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ import (
var ErrEmptyData error = errors.New("device or device model list is empty")

func ParseByUsingRegister(devices map[string]*common.DeviceInstance,
dms map[string]common.DeviceModel,
protocols map[string]common.ProtocolConfig) error {
dms map[string]common.DeviceModel) error {
deviceList, deviceModelList, err := grpcclient.RegisterMapper(true)
if err != nil {
return err
Expand Down Expand Up @@ -59,7 +58,6 @@ func ParseByUsingRegister(devices map[string]*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
Expand Down

0 comments on commit 6416d28

Please sign in to comment.