Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d6db85b8c | ||
|
|
8e742ba1d3 | ||
|
|
2dc3baca3c | ||
|
|
274a80d605 | ||
|
|
3b38be8de5 |
@@ -10,7 +10,7 @@ type Get struct {
|
||||
Drivers *Drivers `json:"drivers,omitempty"` // assigned drivers
|
||||
Type Type `json:"type,omitempty"` // dbm datatype
|
||||
Value any `json:"value,omitempty"` // dbm value
|
||||
HasChild bool `json:"hasChild,omitempty"` // inidicates path has child/ren
|
||||
HasChild bool `json:"hasChild,omitempty"` // inidicates path has children
|
||||
Rights Rights `json:"rights,omitempty"` // dbm read /write rights
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,16 @@ import "github.com/google/uuid"
|
||||
|
||||
// Set model
|
||||
type Set struct {
|
||||
Uuid uuid.UUID `json:"uuid,omitempty"` // universally unique identifier
|
||||
Path string `json:"path"` // dbm path
|
||||
Driver *Driver `json:"driver,omitempty"` // assign new driver
|
||||
Drivers *Drivers `json:"drivers,omitempty"` // assigned drivers
|
||||
Type Type `json:"type,omitempty"` // dbm datatype
|
||||
Value any `json:"value,omitempty"` // dbm value
|
||||
Rights Rights `json:"rights,omitempty"` // dbm read /write rights
|
||||
Create bool `json:"create,omitempty"` // dbm create new datapoint
|
||||
Updated bool `json:"-"`
|
||||
Uuid uuid.UUID `json:"uuid,omitempty"` // universally unique identifier
|
||||
Path string `json:"path"` // dbm path
|
||||
Driver *Driver `json:"driver,omitempty"` // assign new driver
|
||||
Drivers *Drivers `json:"drivers,omitempty"` // assigned drivers
|
||||
Type Type `json:"type,omitempty"` // dbm datatype
|
||||
Value any `json:"value,omitempty"` // dbm value
|
||||
Rights Rights `json:"rights,omitempty"` // dbm read /write rights
|
||||
Create bool `json:"create,omitempty"` // dbm create new datapoint
|
||||
HasChild bool `json:"hasChild,omitempty"` // inidicates path has children
|
||||
Updated bool `json:"-"`
|
||||
}
|
||||
|
||||
// sets value and path
|
||||
|
||||
@@ -8,7 +8,8 @@ type Subscription struct {
|
||||
Path string `json:"path,omitempty"` // dbm path
|
||||
Depth uint `json:"depth,omitempty"` // depth of subscriptions from found path or uuid
|
||||
Value any `json:"value,omitempty"` // current value
|
||||
HasChild bool `json:"hasChild,omitempty"` // inidicates path has child/ren
|
||||
Rights Rights `json:"rights,omitempty"` // read /write rights
|
||||
HasChild bool `json:"hasChild,omitempty"` // inidicates path has children
|
||||
Drivers *Drivers `json:"drivers,omitempty"` // assigned drivers
|
||||
Driver string `json:"driver,omitempty"` // driver type to assign this subscription
|
||||
OnCreate bool `json:"onCreate,omitempty"` // notify at datapoint creation
|
||||
|
||||
@@ -9,18 +9,18 @@ import (
|
||||
// all avaiable datatypes of dbm
|
||||
const (
|
||||
NONE Type = "NONE"
|
||||
BIT Type = "BIT" // BOOL
|
||||
BYU Type = "BYU" // UINT8
|
||||
BYS Type = "BYS" // INT8
|
||||
WOS Type = "WOS" // INT16
|
||||
WOU Type = "WOU" // UINT16
|
||||
DWS Type = "DWS" // INT32
|
||||
DWU Type = "DWU" // UINT32
|
||||
LOS Type = "LOS" // INT64
|
||||
LOU Type = "LOU" // UINT64
|
||||
F32 Type = "F32" // FLOAT32
|
||||
F64 Type = "F64" // FLOAT64
|
||||
STR Type = "STRING" // STRING
|
||||
BIT Type = "BIT" // BOOL
|
||||
BYU Type = "BYU" // UINT8
|
||||
BYS Type = "BYS" // INT8
|
||||
WOS Type = "WOS" // INT16
|
||||
WOU Type = "WOU" // UINT16
|
||||
DWS Type = "DWS" // INT32
|
||||
DWU Type = "DWU" // UINT32
|
||||
LOS Type = "LOS" // INT64
|
||||
LOU Type = "LOU" // UINT64
|
||||
F32 Type = "F32" // FLOAT32
|
||||
F64 Type = "F64" // FLOAT64
|
||||
STR Type = "STR" // STRING
|
||||
)
|
||||
|
||||
// dbm datatype model
|
||||
|
||||
@@ -36,8 +36,8 @@ func Float32From(v any) float32 {
|
||||
case uint64:
|
||||
return float32(val)
|
||||
case string:
|
||||
if i, err := strconv.Atoi(val); err == nil {
|
||||
return float32(i)
|
||||
if f64, err := strconv.ParseFloat(val, 32); err == nil {
|
||||
return float32(f64)
|
||||
}
|
||||
return 0
|
||||
default:
|
||||
@@ -76,8 +76,8 @@ func Float64From(v any) float64 {
|
||||
case uint64:
|
||||
return float64(val)
|
||||
case string:
|
||||
if i, err := strconv.Atoi(val); err == nil {
|
||||
return float64(i)
|
||||
if f64, err := strconv.ParseFloat(val, 32); err == nil {
|
||||
return f64
|
||||
}
|
||||
return 0
|
||||
default:
|
||||
@@ -433,7 +433,14 @@ func BoolFrom(v any) bool {
|
||||
case float64:
|
||||
return val >= 1
|
||||
case string:
|
||||
return strings.ToLower(val) == "false" || v == "0"
|
||||
if strings.ToLower(val) == "true" {
|
||||
return true
|
||||
} else if strings.ToLower(val) == "false" {
|
||||
return false
|
||||
} else if i, err := strconv.Atoi(val); err == nil {
|
||||
return i > 0
|
||||
}
|
||||
return false
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user