Skip to content

Commit

Permalink
Add float handling (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanG100 authored Oct 13, 2022
1 parent 8d22029 commit f63b191
Show file tree
Hide file tree
Showing 33 changed files with 1,802 additions and 609 deletions.
9 changes: 9 additions & 0 deletions exampleoc/exampleocpath/exampleocpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/openconfig/ygnmi/exampleoc/simple"
"github.com/openconfig/ygnmi/exampleoc/withlistval"
"github.com/openconfig/ygnmi/ygnmi"
"github.com/openconfig/ygot/ygot"
"github.com/openconfig/ygot/ytypes"
)

Expand Down Expand Up @@ -160,6 +161,14 @@ func (b *Batch) Config() ygnmi.SingletonQuery[*oc.Root] {
)
}

func binarySliceToFloatSlice(in []oc.Binary) []float32 {
converted := make([]float32, 0, len(in))
for _, binary := range in {
converted = append(converted, ygot.BinaryToFloat32(binary))
}
return converted
}

// State returns a Query that can be used in gNMI operations.
func (n *RootPath) State() ygnmi.SingletonQuery[*oc.Root] {
return ygnmi.NewNonLeafSingletonQuery[*oc.Root](
Expand Down
8 changes: 8 additions & 0 deletions exampleoc/nested/nested-0.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ func (n *APathAny) B() *A_BPathAny {
}
}

func binarySliceToFloatSlice(in []oc.Binary) []float32 {
converted := make([]float32, 0, len(in))
for _, binary := range in {
converted = append(converted, ygot.BinaryToFloat32(binary))
}
return converted
}

// State returns a Query that can be used in gNMI operations.
func (n *APath) State() ygnmi.SingletonQuery[*oc.A] {
return ygnmi.NewNonLeafSingletonQuery[*oc.A](
Expand Down
311 changes: 161 additions & 150 deletions exampleoc/schema.go

Large diffs are not rendered by default.

Loading

0 comments on commit f63b191

Please sign in to comment.