Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions controlbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,14 @@
fmt.Println("RemoteSKIConnected: " + ski)
h.isConnected[ski] = true

frontend.sendText(SelectService, ski)

Check failure on line 189 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendText` is not checked (errcheck)

Check failure on line 189 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendText` is not checked (errcheck)
}

func (h *controlbox) RemoteSKIDisconnected(service api.ServiceInterface, ski string) {
fmt.Println("RemoteSKIDisconnected: " + ski)
h.isConnected[ski] = false

frontend.sendNotification("", ServiceListChanged, "")

Check failure on line 196 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendNotification` is not checked (errcheck)

Check failure on line 196 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendNotification` is not checked (errcheck)
}

func (h *controlbox) VisibleRemoteServicesUpdated(service api.ServiceInterface, entries []shipapi.RemoteService) {
Expand All @@ -208,7 +208,7 @@

h.currentRemoteServices = entries

frontend.sendNotification("", ServiceListChanged, "")

Check failure on line 211 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendNotification` is not checked (errcheck)

Check failure on line 211 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendNotification` is not checked (errcheck)
}

func (h *controlbox) ServiceShipIDUpdate(ski string, shipdID string) {
Expand All @@ -223,7 +223,7 @@
os.Exit(1)
}

frontend.sendNotification("", ServiceListChanged, "")

Check failure on line 226 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendNotification` is not checked (errcheck)

Check failure on line 226 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendNotification` is not checked (errcheck)
}

func (h *controlbox) AllowWaitingForTrust(ski string) bool {
Expand Down Expand Up @@ -314,10 +314,14 @@
return
}

frontend.sendValue(entity.Device().Ski(), GetConsumptionNominalMax, "LPC", nominal)

Check failure on line 317 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendValue` is not checked (errcheck)

Check failure on line 317 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendValue` is not checked (errcheck)
}

func (h *controlbox) OnLPCEvent(ski string, device spineapi.DeviceRemoteInterface, entity spineapi.EntityRemoteInterface, event api.EventType) {
if entity == nil {
return
}

fmt.Println("--> LPC Event: " + string(event) + " from " + ski)
connected, exists := h.isConnected[ski]
if !exists || !connected {
Expand All @@ -329,9 +333,9 @@
defer h.mutex.Unlock()

h.updateEntityInfos(ski, device, "LPC")
frontend.sendEntityInfo(GetEntityInfos, h.remoteInfos)

Check failure on line 336 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendEntityInfo` is not checked (errcheck)

Check failure on line 336 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendEntityInfo` is not checked (errcheck)
h.updateUseCaseInfos(ski, device)
frontend.sendUseCaseInfo(GetUseCaseInfos, h.useCaseInfos)

Check failure on line 338 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendUseCaseInfo` is not checked (errcheck)

Check failure on line 338 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendUseCaseInfo` is not checked (errcheck)

switch event {
case lpc.UseCaseSupportUpdate:
Expand All @@ -349,7 +353,7 @@
} else {
fmt.Println("New consumption limit received: inactive,", currentLimit.Value, "W,", currentLimit.Duration)
}
frontend.sendLimit(ski, GetConsumptionLimit, "LPC", ucapi.LoadLimit{

Check failure on line 356 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendLimit` is not checked (errcheck)

Check failure on line 356 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendLimit` is not checked (errcheck)
IsActive: currentLimit.IsActive,
Duration: currentLimit.Duration / time.Second,
Value: currentLimit.Value})
Expand All @@ -362,7 +366,7 @@

h.consumptionFailsafeLimits.Value = limit

frontend.sendValue(ski, GetConsumptionFailsafeValue, "LPC", limit)

Check failure on line 369 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendValue` is not checked (errcheck)

Check failure on line 369 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendValue` is not checked (errcheck)
}
}
case lpc.DataUpdateFailsafeDurationMinimum:
Expand All @@ -372,7 +376,7 @@

h.consumptionFailsafeLimits.Duration = duration

frontend.sendValue(ski, GetConsumptionFailsafeDuration, "LPC", float64(duration/time.Second))

Check failure on line 379 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendValue` is not checked (errcheck)

Check failure on line 379 in controlbox.go

View workflow job for this annotation

GitHub Actions / Build

Error return value of `frontend.sendValue` is not checked (errcheck)
}
}
// TODO
Expand Down Expand Up @@ -434,6 +438,10 @@
}

func (h *controlbox) OnLPPEvent(ski string, device spineapi.DeviceRemoteInterface, entity spineapi.EntityRemoteInterface, event api.EventType) {
if entity == nil {
return
}

fmt.Println("--> LPP Event: " + string(event) + " from " + ski)
connected, exists := h.isConnected[ski]
if !exists || !connected {
Expand Down Expand Up @@ -504,6 +512,10 @@
}

func (h *controlbox) OnMGCPEvent(ski string, device spineapi.DeviceRemoteInterface, entity spineapi.EntityRemoteInterface, event api.EventType) {
if entity == nil {
return
}

fmt.Println("--> MGCP Event: " + string(event) + " from " + ski)
connected, exists := h.isConnected[ski]
if !exists || !connected {
Expand Down Expand Up @@ -555,6 +567,10 @@
}

func (h *controlbox) OnMPCEvent(ski string, device spineapi.DeviceRemoteInterface, entity spineapi.EntityRemoteInterface, event api.EventType) {
if entity == nil {
return
}

fmt.Println("--> MPC Event: " + string(event) + " from " + ski)
connected, exists := h.isConnected[ski]
if !exists || !connected {
Expand Down
4 changes: 4 additions & 0 deletions frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ type Message struct {
}

func readData(h *controlbox, entity spineapi.EntityRemoteInterface, ucs []string) {
if entity == nil || entity.Device() == nil {
return
}

ski := entity.Device().Ski()

if (ucs == nil || slices.Contains(ucs, "LPC")) && slices.Contains(h.remoteInfos[ski].UseCases, "LPC") {
Expand Down