// SetData sets data by pathes
SetData sets data by pathes
// SetData sets data by pathes
func (adapter *BaseAdapter) SetData(data map[string]interface{}) (err error) {
	adapter.Lock()
	defer adapter.Unlock()
	changedData := make(map[string]interface{})
	for path, value := range data {
		if _, ok := adapter.Data[path]; !ok {
			return fmt.Errorf("path %s doesn't exits", path)
		}
		if adapter.Data[path].ReadOnly {
			return fmt.Errorf("signal %s cannot be set since it is a read only signal", path)
		}
		oldValue := adapter.Data[path].Value
		adapter.Data[path].Value = value
		if !reflect.DeepEqual(oldValue, value) && adapter.Data[path].subscribe {
			changedData[path] = value
		}
	}
	if len(changedData) > 0 {
		adapter.SubscribeChannel <- changedData
	}
	return nil
}
func ( adapter * BaseAdapter ) SetData ( data map [ string ] interface { } ) ( err error ) { adapter . Lock ( ) defer adapter . Unlock ( ) changedData := make ( map [ string ] interface { } ) for path , value := range data { if _ , ok := adapter . Data [ path ] ; ! ok { return fmt . Errorf ( " " , path ) } if adapter . Data [ path ] . ReadOnly { return fmt . Errorf ( " " , path ) } oldValue := adapter . Data [ path ] . Value adapter . Data [ path ] . Value = value if ! reflect . DeepEqual ( oldValue , value ) && adapter . Data [ path ] . subscribe { changedData [ path ] = value } } if len ( changedData ) > 0 { adapter . SubscribeChannel <- changedData } return nil }
SetData sets data by pathes
SetData sets data by pathes