Пример #1
0
func (s ScalarSensor) Decode(bits data.Bitset) interface{} {
	found := bits.Any(func(int) bool {
		return true
	})

	return (0.5+float64(found))*s.BucketSize + s.MinValue
}
Пример #2
0
func (s *PeriodicSensor) Decode(bits data.Bitset) interface{} {
	found := bits.Any(func(int) bool {
		return true
	})
	if bits.IsSet(found + 2) {
		return found + 1 + s.First
	} else if bits.IsSet(found + 1) {
		// found is the center bit, so first.
		return s.First
	} else {
		// found is center bit + 1, so last.
		return s.Last
	}
}
Пример #3
0
func (s *CategorySensor) Decode(bits data.Bitset) interface{} {
	found := bits.Any(func(int) bool {
		return true
	})
	return s.reverse[found/s.W]
}