Changed the naming of mk2if to mk2driver

This commit is contained in:
Nicholas Thompson
2019-03-10 11:48:56 +02:00
committed by ncthompson
parent 9236d6fa86
commit d02de285d9
10 changed files with 35 additions and 33 deletions

View File

@@ -35,11 +35,11 @@ import (
"fmt"
"net/http"
"github.com/diebietse/invertergui/mk2if"
"github.com/diebietse/invertergui/mk2driver"
)
type muninData struct {
status mk2if.Mk2Info
status mk2driver.Mk2Info
timesUpdated int
}
@@ -171,7 +171,7 @@ freqout.label Out frequency (Hz)
}
//Munin only samples once every 5 minutes so averages have to be calculated for some values.
func calcMuninValues(muninDat *muninData, newStatus *mk2if.Mk2Info) {
func calcMuninValues(muninDat *muninData, newStatus *mk2driver.Mk2Info) {
muninDat.timesUpdated++
muninVal := &muninDat.status
muninVal.OutCurrent += newStatus.OutCurrent

View File

@@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package webgui
import (
"github.com/diebietse/invertergui/mk2if"
"github.com/diebietse/invertergui/mk2driver"
"github.com/prometheus/client_golang/prometheus"
)
@@ -117,7 +117,7 @@ func newPrometheusUpdater() *prometheusUpdater {
return tmp
}
func (pu *prometheusUpdater) updatePrometheus(newStatus *mk2if.Mk2Info) {
func (pu *prometheusUpdater) updatePrometheus(newStatus *mk2driver.Mk2Info) {
s := newStatus
pu.batteryVoltage.Set(s.BatVoltage)
pu.batteryCharge.Set(newStatus.ChargeState * 100)

View File

@@ -37,7 +37,7 @@ import (
"sync"
"time"
"github.com/diebietse/invertergui/mk2if"
"github.com/diebietse/invertergui/mk2driver"
"github.com/diebietse/invertergui/websocket"
)
@@ -53,14 +53,14 @@ type WebGui struct {
stopChan chan struct{}
muninRespChan chan muninData
poller mk2if.Mk2If
poller mk2driver.Mk2
wg sync.WaitGroup
hub *websocket.Hub
pu *prometheusUpdater
}
func NewWebGui(source mk2if.Mk2If) *WebGui {
func NewWebGui(source mk2driver.Mk2) *WebGui {
w := new(WebGui)
w.muninRespChan = make(chan muninData)
w.stopChan = make(chan struct{})
@@ -111,15 +111,15 @@ func (w *WebGui) ServeHub(rw http.ResponseWriter, r *http.Request) {
w.hub.ServeHTTP(rw, r)
}
func ledName(led mk2if.Led) string {
name, ok := mk2if.LedNames[led]
func ledName(led mk2driver.Led) string {
name, ok := mk2driver.LedNames[led]
if !ok {
return "Unknown led"
}
return name
}
func buildTemplateInput(status *mk2if.Mk2Info) *templateInput {
func buildTemplateInput(status *mk2driver.Mk2Info) *templateInput {
outPower := status.OutVoltage * status.OutCurrent
inPower := status.InCurrent * status.InVoltage
@@ -145,20 +145,20 @@ func buildTemplateInput(status *mk2if.Mk2Info) *templateInput {
LedMap: map[string]string{},
}
for k, v := range status.LEDs {
if k == mk2if.LedOverload || k == mk2if.LedTemperature || k == mk2if.LedLowBattery {
if k == mk2driver.LedOverload || k == mk2driver.LedTemperature || k == mk2driver.LedLowBattery {
switch v {
case mk2if.LedOn:
case mk2driver.LedOn:
tmpInput.LedMap[ledName(k)] = LedRed
case mk2if.LedBlink:
case mk2driver.LedBlink:
tmpInput.LedMap[ledName(k)] = BlinkRed
default:
tmpInput.LedMap[ledName(k)] = LedOff
}
} else {
switch v {
case mk2if.LedOn:
case mk2driver.LedOn:
tmpInput.LedMap[ledName(k)] = LedGreen
case mk2if.LedBlink:
case mk2driver.LedBlink:
tmpInput.LedMap[ledName(k)] = BlinkGreen
default:
tmpInput.LedMap[ledName(k)] = LedOff

View File

@@ -36,7 +36,7 @@ import (
"testing"
"time"
"github.com/diebietse/invertergui/mk2if"
"github.com/diebietse/invertergui/mk2driver"
)
func TestWebGui(t *testing.T) {
@@ -45,14 +45,14 @@ func TestWebGui(t *testing.T) {
}
type templateTest struct {
input *mk2if.Mk2Info
input *mk2driver.Mk2Info
output *templateInput
}
var fakenow = time.Date(2017, 1, 2, 3, 4, 5, 6, time.UTC)
var templateInputTests = []templateTest{
{
input: &mk2if.Mk2Info{
input: &mk2driver.Mk2Info{
OutCurrent: 2.0,
InCurrent: 2.3,
OutVoltage: 230.0,
@@ -62,7 +62,7 @@ var templateInputTests = []templateTest{
InFrequency: 50,
OutFrequency: 50,
ChargeState: 1,
LEDs: map[mk2if.Led]mk2if.LEDstate{mk2if.LedMain: mk2if.LedOn},
LEDs: map[mk2driver.Led]mk2driver.LEDstate{mk2driver.LedMain: mk2driver.LedOn},
Errors: nil,
Timestamp: fakenow,
},