expose ratio table to web

This commit is contained in:
William Clark 2022-12-05 13:19:54 +00:00
parent 376727840c
commit 737ae78c34
4 changed files with 15 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package core
// NOT IN USE
import (
"th7/data/core"
"th7/ports"

View File

@ -79,3 +79,8 @@ func (t *TH7Adapter) GetPivdd() float64 {
return t.table.Pivdd
}
// Ratio table
func (t *TH7Adapter) GetRatio() core.Ratio {
return t.table
}

View File

@ -1,6 +1,8 @@
package ports
import "th7/data/core"
import (
"th7/data/core"
)
type CorePort interface {
GetChannel(int) (core.Channel, error)
@ -8,4 +10,5 @@ type CorePort interface {
GetVref() float64
GetVadj() float64
GetPivdd() float64
GetRatio() core.Ratio
}

View File

@ -16,6 +16,11 @@ type GinAdapter struct {
func (g GinAdapter) registerEndpoints() {
g.router.GET("/ratio", func(c *gin.Context) {
table := g.corePort.GetRatio()
c.JSON(http.StatusOK, table)
})
g.router.GET("/channels", func(c *gin.Context) {
channels := g.corePort.GetChannels()
c.JSON(http.StatusOK, channels)