Beispiel #1
0
func (config *ProductConfig) EventToMap(event *protocol.Event) (map[string][]interface{}, error) {
	result := make(map[string][]interface{})

	name := ""
	for _, ev := range config.Events {
		if ev.No == int(event.Head.No) {
			name = ev.Name
		}
	}
	val, err := tlv.ReadTLVs(event.Params)
	if err != nil {
		return nil, err
	}

	result[name] = val

	return result, nil
}
Beispiel #2
0
func (config *ProductConfig) StatusToMap(status []protocol.SubData) (map[string][]interface{}, error) {
	result := make(map[string][]interface{})

	for _, sub := range status {
		val, err := tlv.ReadTLVs(sub.Params)
		if err != nil {
			return nil, err
		}
		label := ""
		for _, obj := range config.Objects {
			if obj.No == int(sub.Head.PropertyNum) {
				label = obj.Label
			}
		}
		result[label] = val
	}

	return result, nil
}