Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
274a80d605 | ||
|
|
3b38be8de5 | ||
|
|
83bf855485 | ||
|
|
9d4d417856 | ||
|
|
0446a160e1 | ||
|
|
640604c06d |
@@ -4,13 +4,14 @@ import "github.com/google/uuid"
|
|||||||
|
|
||||||
// Get model
|
// Get model
|
||||||
type Get struct {
|
type Get struct {
|
||||||
Uuid uuid.UUID `json:"uuid"` // universally unique identifier
|
Uuid uuid.UUID `json:"uuid"` // universally unique identifier
|
||||||
Path string `json:"path"` // dbm path
|
Path string `json:"path"` // dbm path
|
||||||
Query *Query `json:"query,omitempty"` // query paramater
|
Query *Query `json:"query,omitempty"` // query paramater
|
||||||
Drivers *Drivers `json:"driver,omitempty"` // assigned drivers
|
Drivers *Drivers `json:"drivers,omitempty"` // assigned drivers
|
||||||
Type Type `json:"type,omitempty"` // dbm datatype
|
Type Type `json:"type,omitempty"` // dbm datatype
|
||||||
Value any `json:"value,omitempty"` // dbm value
|
Value any `json:"value,omitempty"` // dbm value
|
||||||
Rights Rights `json:"rights,omitempty"` // dbm read /write rights
|
HasChild bool `json:"hasChild,omitempty"` // inidicates path has child/ren
|
||||||
|
Rights Rights `json:"rights,omitempty"` // dbm read /write rights
|
||||||
}
|
}
|
||||||
|
|
||||||
// search dbm datapoints by path
|
// search dbm datapoints by path
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ func (r *Response) AddUnsubscription(sub Subscription) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add new data publish to response
|
// Add new data publish to response
|
||||||
func (r *Response) AddUPublish(pub Publish) {
|
func (r *Response) AddPublish(pub Publish) {
|
||||||
r.Publish = append(r.Publish, pub)
|
r.Publish = append(r.Publish, pub)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ type Set struct {
|
|||||||
Type Type `json:"type,omitempty"` // dbm datatype
|
Type Type `json:"type,omitempty"` // dbm datatype
|
||||||
Value any `json:"value,omitempty"` // dbm value
|
Value any `json:"value,omitempty"` // dbm value
|
||||||
Rights Rights `json:"rights,omitempty"` // dbm read /write rights
|
Rights Rights `json:"rights,omitempty"` // dbm read /write rights
|
||||||
|
Create bool `json:"create,omitempty"` // dbm create new datapoint
|
||||||
Updated bool `json:"-"`
|
Updated bool `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ type Subscription struct {
|
|||||||
Path string `json:"path,omitempty"` // dbm path
|
Path string `json:"path,omitempty"` // dbm path
|
||||||
Depth uint `json:"depth,omitempty"` // depth of subscriptions from found path or uuid
|
Depth uint `json:"depth,omitempty"` // depth of subscriptions from found path or uuid
|
||||||
Value any `json:"value,omitempty"` // current value
|
Value any `json:"value,omitempty"` // current value
|
||||||
|
HasChild bool `json:"hasChild,omitempty"` // inidicates path has child/ren
|
||||||
Drivers *Drivers `json:"drivers,omitempty"` // assigned drivers
|
Drivers *Drivers `json:"drivers,omitempty"` // assigned drivers
|
||||||
Driver string `json:"driver,omitempty"` // driver type to assign this subscription
|
Driver string `json:"driver,omitempty"` // driver type to assign this subscription
|
||||||
OnCreate bool `json:"onCreate,omitempty"` // notify at datapoint creation
|
OnCreate bool `json:"onCreate,omitempty"` // notify at datapoint creation
|
||||||
|
|||||||
@@ -9,18 +9,18 @@ import (
|
|||||||
// all avaiable datatypes of dbm
|
// all avaiable datatypes of dbm
|
||||||
const (
|
const (
|
||||||
NONE Type = "NONE"
|
NONE Type = "NONE"
|
||||||
BIT Type = "BIT" // BOOL
|
BIT Type = "BIT" // BOOL
|
||||||
BYU Type = "BYU" // UINT8
|
BYU Type = "BYU" // UINT8
|
||||||
BYS Type = "BYS" // INT8
|
BYS Type = "BYS" // INT8
|
||||||
WOS Type = "WOS" // INT16
|
WOS Type = "WOS" // INT16
|
||||||
WOU Type = "WOU" // UINT16
|
WOU Type = "WOU" // UINT16
|
||||||
DWS Type = "DWS" // INT32
|
DWS Type = "DWS" // INT32
|
||||||
DWU Type = "DWU" // UINT32
|
DWU Type = "DWU" // UINT32
|
||||||
LOS Type = "LOS" // INT64
|
LOS Type = "LOS" // INT64
|
||||||
LOU Type = "LOU" // UINT64
|
LOU Type = "LOU" // UINT64
|
||||||
F32 Type = "F32" // FLOAT32
|
F32 Type = "F32" // FLOAT32
|
||||||
F64 Type = "F64" // FLOAT64
|
F64 Type = "F64" // FLOAT64
|
||||||
STR Type = "STRING" // STRING
|
STR Type = "STR" // STRING
|
||||||
)
|
)
|
||||||
|
|
||||||
// dbm datatype model
|
// dbm datatype model
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ func Float32From(v any) float32 {
|
|||||||
case uint64:
|
case uint64:
|
||||||
return float32(val)
|
return float32(val)
|
||||||
case string:
|
case string:
|
||||||
if i, err := strconv.Atoi(val); err == nil {
|
if f64, err := strconv.ParseFloat(val, 32); err == nil {
|
||||||
return float32(i)
|
return float32(f64)
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
default:
|
default:
|
||||||
@@ -76,8 +76,8 @@ func Float64From(v any) float64 {
|
|||||||
case uint64:
|
case uint64:
|
||||||
return float64(val)
|
return float64(val)
|
||||||
case string:
|
case string:
|
||||||
if i, err := strconv.Atoi(val); err == nil {
|
if f64, err := strconv.ParseFloat(val, 32); err == nil {
|
||||||
return float64(i)
|
return f64
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
default:
|
default:
|
||||||
@@ -433,7 +433,14 @@ func BoolFrom(v any) bool {
|
|||||||
case float64:
|
case float64:
|
||||||
return val >= 1
|
return val >= 1
|
||||||
case string:
|
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:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user