From ab9a43908153a84aecf5dad9483ede6c9b4b521f Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Sun, 3 Dec 2023 21:57:27 +0100 Subject: [PATCH] changes --- src/udi/database/abstract_database.go | 8 ++++---- src/udi/dispatcher/dispatcher.go | 1 + src/udi/handlers/mbgw3/mbgw3.go | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/udi/database/abstract_database.go b/src/udi/database/abstract_database.go index 3afffb5..7fcc086 100644 --- a/src/udi/database/abstract_database.go +++ b/src/udi/database/abstract_database.go @@ -15,14 +15,14 @@ type Measurement struct { Time time.Time `gorm:"not null;primary_key"` Application string `gorm:"not null"` Device string - Attributes map[string]string `gorm:"serializer:json;type:jsonb"` + Attributes map[string]interface{} `gorm:"serializer:json;type:jsonb"` Values map[string]VariableType `gorm:"serializer:json;type:jsonb"` } type Application struct { gorm.Model Label string `gorm:"not null"` - Attributes map[string]string `gorm:"serializer:json;type:jsonb"` + Attributes map[string]interface{} `gorm:"serializer:json;type:jsonb"` } @@ -30,7 +30,7 @@ type DeviceType struct { gorm.Model Label string `gorm:"not null"` ModelIdentifier string - Attributes map[string]string `gorm:"serializer:json;type:jsonb"` + Attributes map[string]interface{} `gorm:"serializer:json;type:jsonb"` } type Device struct { @@ -40,7 +40,7 @@ type Device struct { Application Application DeviceTypeID int `gorm:"not null"` DeviceType DeviceType - Attributes map[string]string `gorm:"serializer:json;type:jsonb"` + Attributes map[string]interface{} `gorm:"serializer:json;type:jsonb"` } diff --git a/src/udi/dispatcher/dispatcher.go b/src/udi/dispatcher/dispatcher.go index 8a6cf27..1bc8e7c 100644 --- a/src/udi/dispatcher/dispatcher.go +++ b/src/udi/dispatcher/dispatcher.go @@ -97,6 +97,7 @@ func InputDispatcher() { handler, exists := handlerMap[mapping.Handler] if exists { handler.Handle(message) + break } else { log.Printf("Handler not found, message is lost") } diff --git a/src/udi/handlers/mbgw3/mbgw3.go b/src/udi/handlers/mbgw3/mbgw3.go index 31bc10c..402f559 100644 --- a/src/udi/handlers/mbgw3/mbgw3.go +++ b/src/udi/handlers/mbgw3/mbgw3.go @@ -23,6 +23,7 @@ type Observation struct { RequestId string `json:"RequestId"` Device string `json:"Device"` Errors string `json:"Errors"` + ErrorRatio string `json:"ErrorRatio"` Requests string `json:"Requests"` Values map[string]string } @@ -49,8 +50,8 @@ func (self *Mbgw3Handler) Handle(message handler.MessageT) { } log.Printf("Parsed observation: %s", observation) - attributes := make(map[string]string - if v, err := strconv.Atoi(observation.RequestId), err == nil { + attributes := make(map[string]interface{}) + if v, err := strconv.Atoi(observation.RequestId); err == nil { attributes["RequestId"] = v }