diff options
| author | Jeff Carr <[email protected]> | 2024-01-06 11:12:10 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-06 11:12:10 -0600 |
| commit | f6f5bdba4e982595ad1c12041d39f75e11792ef8 (patch) | |
| tree | 89c5c4856fcec28bb28fe0be4a4706559b6a3979 /linuxstatus/update.go | |
| parent | c59247824f22cf62b1625f5eeea11b809374d7a0 (diff) | |
stepping through init on a window with state
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'linuxstatus/update.go')
| -rw-r--r-- | linuxstatus/update.go | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/linuxstatus/update.go b/linuxstatus/update.go index 1ab8cee..0de7cf9 100644 --- a/linuxstatus/update.go +++ b/linuxstatus/update.go @@ -1,31 +1,40 @@ package linuxstatus import ( - "errors" "fmt" "time" + "errors" "go.wit.com/log" ) func (ls *LinuxStatus) Update() { - log.Info("linuxStatus() Update() START") - if ls == nil { - log.Error(errors.New("linuxStatus() Update() ls == nil")) + if ! ls.Ready() { + log.Warn("can't update yet. ready is false") + log.Error(errors.New("Update() is not ready yet")) return } + log.Log(INFO, "Update() START") duration := timeFunction(func () { linuxLoop() }) + ls.SetSpeed(duration) + log.Info("linuxStatus() Update() END") +} + +func (ls *LinuxStatus) SetSpeed(duration time.Duration) { s := fmt.Sprint(duration) + if ls.speedActual == nil { + log.Warn("can't actually warn") + return + } ls.speedActual.Set(s) if (duration > 500 * time.Millisecond ) { - // ls.speed, "SLOW") + ls.speed.Set("SLOW") } else if (duration > 100 * time.Millisecond ) { - // ls.speed, "OK") + ls.speed.Set("OK") } else { - // ls.speed, "FAST") + ls.speed.Set("FAST") } - log.Info("linuxStatus() Update() END") } |
