generated from thinkode/modelRepository
fixed saved peripherals for a new project
This commit is contained in:
28
app.go
28
app.go
@@ -5,7 +5,9 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -18,8 +20,6 @@ type App struct {
|
||||
wmiMutex sync.Mutex // Avoid some WMI operations at the same time
|
||||
projectInfo ProjectInfo // The project information structure
|
||||
projectSave string // The file name of the project
|
||||
// FOR TESTING PURPOSE ONLY
|
||||
ftdi *hardware.FTDIPeripheral
|
||||
}
|
||||
|
||||
// NewApp creates a new App application struct
|
||||
@@ -40,15 +40,33 @@ func NewApp() *App {
|
||||
|
||||
// startup is called when the app starts. The context is saved
|
||||
// so we can call the runtime methods
|
||||
func (a *App) startup(ctx context.Context) {
|
||||
func (a *App) onStartup(ctx context.Context) {
|
||||
a.ctx = ctx
|
||||
err := a.hardwareManager.Start(ctx)
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to start the device manager: %s", err)
|
||||
log.Err(err).Str("file", "app").Msg("unable to start the hardware manager")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// onReady is called when the DOM is ready
|
||||
// We get the current peripherals connected
|
||||
func (a *App) onReady(ctx context.Context) {
|
||||
log.Debug().Str("file", "peripherals").Msg("getting peripherals...")
|
||||
err := a.hardwareManager.Scan(a.ctx)
|
||||
if err != nil {
|
||||
log.Err(err).Str("file", "app").Msg("unable to get the peripherals")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// onShutdown is called when the app is closing
|
||||
// We stop all the pending processes
|
||||
func (a *App) onShutdown(ctx context.Context) {
|
||||
log.Warn().Str("file", "app").Msg("app is closing")
|
||||
return
|
||||
}
|
||||
|
||||
func formatString(input string) string {
|
||||
// Convertir en minuscules
|
||||
lowerCaseString := strings.ToLower(input)
|
||||
|
||||
Reference in New Issue
Block a user