From 737ae78c34f46c438fe04b81b84626ae1c6df504 Mon Sep 17 00:00:00 2001 From: William Clark Date: Mon, 5 Dec 2022 13:19:54 +0000 Subject: [PATCH] expose ratio table to web --- core/dummy.go | 1 + core/th7/th7.go | 5 +++++ ports/core.go | 5 ++++- web/gin.go | 5 +++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/core/dummy.go b/core/dummy.go index 03705a4..d4704ed 100644 --- a/core/dummy.go +++ b/core/dummy.go @@ -1,5 +1,6 @@ package core +// NOT IN USE import ( "th7/data/core" "th7/ports" diff --git a/core/th7/th7.go b/core/th7/th7.go index 99eb928..40a2a2e 100644 --- a/core/th7/th7.go +++ b/core/th7/th7.go @@ -79,3 +79,8 @@ func (t *TH7Adapter) GetPivdd() float64 { return t.table.Pivdd } + +// Ratio table +func (t *TH7Adapter) GetRatio() core.Ratio { + return t.table +} diff --git a/ports/core.go b/ports/core.go index 4912acd..3a54942 100644 --- a/ports/core.go +++ b/ports/core.go @@ -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 } diff --git a/web/gin.go b/web/gin.go index bbe4be8..3704575 100644 --- a/web/gin.go +++ b/web/gin.go @@ -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)