github.com/stampzilla/stampzilla-go@v2.0.0-rc9+incompatible/nodes/stampzilla-knx/compare.go (about)

     1  package main
     2  
     3  import "fmt"
     4  
     5  func boolDiff(target interface{}, current interface{}) (diff bool, value bool, err error) {
     6  	value, ok1 := target.(bool)
     7  	currentBool, ok2 := current.(bool)
     8  
     9  	if !ok1 {
    10  		return false, false, fmt.Errorf("Could not cast target value to bool")
    11  	}
    12  
    13  	diff = !ok2 || value != currentBool
    14  	return
    15  }
    16  
    17  func scalingDiff(target interface{}, current interface{}) (diff bool, value float64, err error) {
    18  	value, ok1 := target.(float64)
    19  	currentFloat, ok2 := current.(float64)
    20  
    21  	if !ok1 {
    22  		return false, 0, fmt.Errorf("Could not cast target value to bool")
    23  	}
    24  
    25  	diff = !ok2 || value != currentFloat
    26  	return
    27  }