up
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -13,6 +15,9 @@ import (
|
|||||||
"git.rouggy.com/rouggy/ShackMaster/internal/config"
|
"git.rouggy.com/rouggy/ShackMaster/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:embed web/dist
|
||||||
|
var webFS embed.FS
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.Println("Starting ShackMaster server...")
|
log.Println("Starting ShackMaster server...")
|
||||||
|
|
||||||
@@ -39,10 +44,17 @@ func main() {
|
|||||||
log.Fatalf("Failed to start device manager: %v", err)
|
log.Fatalf("Failed to start device manager: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create HTTP server
|
// Create HTTP server with embedded files
|
||||||
server := api.NewServer(deviceManager, hub, cfg)
|
server := api.NewServer(deviceManager, hub, cfg)
|
||||||
mux := server.SetupRoutes()
|
mux := server.SetupRoutes()
|
||||||
|
|
||||||
|
// Serve embedded static files
|
||||||
|
distFS, err := fs.Sub(webFS, "web/dist")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Failed to access embedded files: %v", err)
|
||||||
|
}
|
||||||
|
mux.Handle("/", http.FileServer(http.FS(distFS)))
|
||||||
|
|
||||||
// Setup HTTP server
|
// Setup HTTP server
|
||||||
addr := fmt.Sprintf("%s:%d", cfg.Server.Host, cfg.Server.Port)
|
addr := fmt.Sprintf("%s:%d", cfg.Server.Host, cfg.Server.Port)
|
||||||
httpServer := &http.Server{
|
httpServer := &http.Server{
|
||||||
|
|||||||
8
cmd/server/web/dist/assets/index-DY7RBkJT.js
vendored
Normal file
8
cmd/server/web/dist/assets/index-DY7RBkJT.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
cmd/server/web/dist/assets/index-PFp0U9rZ.css
vendored
Normal file
1
cmd/server/web/dist/assets/index-PFp0U9rZ.css
vendored
Normal file
File diff suppressed because one or more lines are too long
16
cmd/server/web/dist/index.html
vendored
Normal file
16
cmd/server/web/dist/index.html
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>ShackMaster - F4BPO Shack</title>
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
|
||||||
|
<script type="module" crossorigin src="/assets/index-DY7RBkJT.js"></script>
|
||||||
|
<link rel="stylesheet" crossorigin href="/assets/index-PFp0U9rZ.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
|
||||||
|
</body>
|
||||||
@@ -79,10 +79,7 @@ func (dm *DeviceManager) Initialize() error {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Initialize Rotator Genius
|
// Initialize Rotator Genius
|
||||||
<<<<<<< HEAD
|
|
||||||
log.Printf("Initializing RotatorGenius: host=%s port=%d", dm.config.Devices.RotatorGenius.Host, dm.config.Devices.RotatorGenius.Port)
|
log.Printf("Initializing RotatorGenius: host=%s port=%d", dm.config.Devices.RotatorGenius.Host, dm.config.Devices.RotatorGenius.Port)
|
||||||
=======
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
dm.rotatorGenius = rotatorgenius.New(
|
dm.rotatorGenius = rotatorgenius.New(
|
||||||
dm.config.Devices.RotatorGenius.Host,
|
dm.config.Devices.RotatorGenius.Host,
|
||||||
dm.config.Devices.RotatorGenius.Port,
|
dm.config.Devices.RotatorGenius.Port,
|
||||||
@@ -98,7 +95,6 @@ func (dm *DeviceManager) Initialize() error {
|
|||||||
dm.config.Location.Longitude,
|
dm.config.Location.Longitude,
|
||||||
)
|
)
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
// Start device polling in background (non-blocking)
|
// Start device polling in background (non-blocking)
|
||||||
go func() {
|
go func() {
|
||||||
if err := dm.powerGenius.Start(); err != nil {
|
if err := dm.powerGenius.Start(); err != nil {
|
||||||
@@ -126,12 +122,6 @@ func (dm *DeviceManager) Initialize() error {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
log.Println("RotatorGenius goroutine launched")
|
log.Println("RotatorGenius goroutine launched")
|
||||||
=======
|
|
||||||
// Start PowerGenius continuous polling
|
|
||||||
if err := dm.powerGenius.Start(); err != nil {
|
|
||||||
log.Printf("Warning: Failed to start PowerGenius polling: %v", err)
|
|
||||||
}
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
|
|
||||||
log.Println("Device manager initialized")
|
log.Println("Device manager initialized")
|
||||||
return nil
|
return nil
|
||||||
@@ -196,7 +186,6 @@ func (dm *DeviceManager) updateStatus() {
|
|||||||
log.Printf("Power Genius error: %v", err)
|
log.Printf("Power Genius error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
// Tuner Genius
|
// Tuner Genius
|
||||||
if tgStatus, err := dm.tunerGenius.GetStatus(); err == nil {
|
if tgStatus, err := dm.tunerGenius.GetStatus(); err == nil {
|
||||||
status.TunerGenius = tgStatus
|
status.TunerGenius = tgStatus
|
||||||
@@ -217,28 +206,6 @@ func (dm *DeviceManager) updateStatus() {
|
|||||||
} else {
|
} else {
|
||||||
log.Printf("Rotator Genius error: %v", err)
|
log.Printf("Rotator Genius error: %v", err)
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
// // Tuner Genius
|
|
||||||
// if tgStatus, err := dm.tunerGenius.GetStatus(); err == nil {
|
|
||||||
// status.TunerGenius = tgStatus
|
|
||||||
// } else {
|
|
||||||
// log.Printf("Tuner Genius error: %v", err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Antenna Genius
|
|
||||||
// if agStatus, err := dm.antennaGenius.GetStatus(); err == nil {
|
|
||||||
// status.AntennaGenius = agStatus
|
|
||||||
// } else {
|
|
||||||
// log.Printf("Antenna Genius error: %v", err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Rotator Genius
|
|
||||||
// if rgStatus, err := dm.rotatorGenius.GetStatus(); err == nil {
|
|
||||||
// status.RotatorGenius = rgStatus
|
|
||||||
// } else {
|
|
||||||
// log.Printf("Rotator Genius error: %v", err)
|
|
||||||
// }
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
|
|
||||||
// Solar Data (fetched every 15 minutes, cached)
|
// Solar Data (fetched every 15 minutes, cached)
|
||||||
if solarData, err := dm.solarClient.GetSolarData(); err == nil {
|
if solarData, err := dm.solarClient.GetSolarData(); err == nil {
|
||||||
|
|||||||
@@ -49,18 +49,13 @@ func (s *Server) SetupRoutes() *http.ServeMux {
|
|||||||
mux.HandleFunc("/api/webswitch/all/off", s.handleWebSwitchAllOff)
|
mux.HandleFunc("/api/webswitch/all/off", s.handleWebSwitchAllOff)
|
||||||
|
|
||||||
// Rotator endpoints
|
// Rotator endpoints
|
||||||
<<<<<<< HEAD
|
|
||||||
mux.HandleFunc("/api/rotator/heading", s.handleRotatorHeading)
|
mux.HandleFunc("/api/rotator/heading", s.handleRotatorHeading)
|
||||||
=======
|
|
||||||
mux.HandleFunc("/api/rotator/move", s.handleRotatorMove)
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
mux.HandleFunc("/api/rotator/cw", s.handleRotatorCW)
|
mux.HandleFunc("/api/rotator/cw", s.handleRotatorCW)
|
||||||
mux.HandleFunc("/api/rotator/ccw", s.handleRotatorCCW)
|
mux.HandleFunc("/api/rotator/ccw", s.handleRotatorCCW)
|
||||||
mux.HandleFunc("/api/rotator/stop", s.handleRotatorStop)
|
mux.HandleFunc("/api/rotator/stop", s.handleRotatorStop)
|
||||||
|
|
||||||
// Tuner endpoints
|
// Tuner endpoints
|
||||||
mux.HandleFunc("/api/tuner/operate", s.handleTunerOperate)
|
mux.HandleFunc("/api/tuner/operate", s.handleTunerOperate)
|
||||||
<<<<<<< HEAD
|
|
||||||
mux.HandleFunc("/api/tuner/bypass", s.handleTunerBypass)
|
mux.HandleFunc("/api/tuner/bypass", s.handleTunerBypass)
|
||||||
mux.HandleFunc("/api/tuner/autotune", s.handleTunerAutoTune)
|
mux.HandleFunc("/api/tuner/autotune", s.handleTunerAutoTune)
|
||||||
|
|
||||||
@@ -71,19 +66,8 @@ func (s *Server) SetupRoutes() *http.ServeMux {
|
|||||||
// Power Genius endpoints
|
// Power Genius endpoints
|
||||||
mux.HandleFunc("/api/power/fanmode", s.handlePowerFanMode)
|
mux.HandleFunc("/api/power/fanmode", s.handlePowerFanMode)
|
||||||
mux.HandleFunc("/api/power/operate", s.handlePowerOperate)
|
mux.HandleFunc("/api/power/operate", s.handlePowerOperate)
|
||||||
=======
|
|
||||||
mux.HandleFunc("/api/tuner/tune", s.handleTunerAutoTune)
|
|
||||||
mux.HandleFunc("/api/tuner/antenna", s.handleTunerAntenna)
|
|
||||||
|
|
||||||
// Antenna Genius endpoints
|
// Note: Static files are now served from embedded FS in main.go
|
||||||
mux.HandleFunc("/api/antenna/set", s.handleAntennaSet)
|
|
||||||
|
|
||||||
// Power Genius endpoints
|
|
||||||
mux.HandleFunc("/api/power/fanmode", s.handlePowerFanMode)
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
|
|
||||||
// Static files (will be frontend)
|
|
||||||
mux.Handle("/", http.FileServer(http.Dir("./web/dist")))
|
|
||||||
|
|
||||||
return mux
|
return mux
|
||||||
}
|
}
|
||||||
@@ -196,23 +180,14 @@ func (s *Server) handleWebSwitchAllOff(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rotator handlers
|
// Rotator handlers
|
||||||
<<<<<<< HEAD
|
|
||||||
func (s *Server) handleRotatorHeading(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) handleRotatorHeading(w http.ResponseWriter, r *http.Request) {
|
||||||
=======
|
|
||||||
func (s *Server) handleRotatorMove(w http.ResponseWriter, r *http.Request) {
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
if r.Method != http.MethodPost {
|
if r.Method != http.MethodPost {
|
||||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var req struct {
|
var req struct {
|
||||||
<<<<<<< HEAD
|
|
||||||
Heading int `json:"heading"`
|
Heading int `json:"heading"`
|
||||||
=======
|
|
||||||
Rotator int `json:"rotator"`
|
|
||||||
Azimuth int `json:"azimuth"`
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
@@ -220,11 +195,7 @@ func (s *Server) handleRotatorMove(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if err := s.deviceManager.RotatorGenius().SetHeading(req.Heading); err != nil {
|
if err := s.deviceManager.RotatorGenius().SetHeading(req.Heading); err != nil {
|
||||||
=======
|
|
||||||
if err := s.deviceManager.RotatorGenius().MoveToAzimuth(req.Rotator, req.Azimuth); err != nil {
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -238,17 +209,7 @@ func (s *Server) handleRotatorCW(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if err := s.deviceManager.RotatorGenius().RotateCW(); err != nil {
|
if err := s.deviceManager.RotatorGenius().RotateCW(); err != nil {
|
||||||
=======
|
|
||||||
rotator, err := strconv.Atoi(r.URL.Query().Get("rotator"))
|
|
||||||
if err != nil || rotator < 1 || rotator > 2 {
|
|
||||||
http.Error(w, "Invalid rotator number", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := s.deviceManager.RotatorGenius().RotateCW(rotator); err != nil {
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -262,17 +223,7 @@ func (s *Server) handleRotatorCCW(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if err := s.deviceManager.RotatorGenius().RotateCCW(); err != nil {
|
if err := s.deviceManager.RotatorGenius().RotateCCW(); err != nil {
|
||||||
=======
|
|
||||||
rotator, err := strconv.Atoi(r.URL.Query().Get("rotator"))
|
|
||||||
if err != nil || rotator < 1 || rotator > 2 {
|
|
||||||
http.Error(w, "Invalid rotator number", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := s.deviceManager.RotatorGenius().RotateCCW(rotator); err != nil {
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -302,11 +253,7 @@ func (s *Server) handleTunerOperate(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var req struct {
|
var req struct {
|
||||||
<<<<<<< HEAD
|
|
||||||
Value int `json:"value"`
|
Value int `json:"value"`
|
||||||
=======
|
|
||||||
Operate bool `json:"operate"`
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
@@ -314,7 +261,6 @@ func (s *Server) handleTunerOperate(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if err := s.deviceManager.TunerGenius().SetOperate(req.Value); err != nil {
|
if err := s.deviceManager.TunerGenius().SetOperate(req.Value); err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@@ -339,9 +285,6 @@ func (s *Server) handleTunerBypass(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := s.deviceManager.TunerGenius().SetBypass(req.Value); err != nil {
|
if err := s.deviceManager.TunerGenius().SetBypass(req.Value); err != nil {
|
||||||
=======
|
|
||||||
if err := s.deviceManager.TunerGenius().SetOperate(req.Operate); err != nil {
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -363,22 +306,15 @@ func (s *Server) handleTunerAutoTune(w http.ResponseWriter, r *http.Request) {
|
|||||||
s.sendJSON(w, map[string]string{"status": "ok"})
|
s.sendJSON(w, map[string]string{"status": "ok"})
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
// Antenna Genius handlers
|
// Antenna Genius handlers
|
||||||
func (s *Server) handleAntennaSelect(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) handleAntennaSelect(w http.ResponseWriter, r *http.Request) {
|
||||||
=======
|
|
||||||
func (s *Server) handleTunerAntenna(w http.ResponseWriter, r *http.Request) {
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
if r.Method != http.MethodPost {
|
if r.Method != http.MethodPost {
|
||||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var req struct {
|
var req struct {
|
||||||
<<<<<<< HEAD
|
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
=======
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
Antenna int `json:"antenna"`
|
Antenna int `json:"antenna"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,11 +323,7 @@ func (s *Server) handleTunerAntenna(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if err := s.deviceManager.AntennaGenius().SetAntenna(req.Port, req.Antenna); err != nil {
|
if err := s.deviceManager.AntennaGenius().SetAntenna(req.Port, req.Antenna); err != nil {
|
||||||
=======
|
|
||||||
if err := s.deviceManager.TunerGenius().ActivateAntenna(req.Antenna); err != nil {
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -399,32 +331,13 @@ func (s *Server) handleTunerAntenna(w http.ResponseWriter, r *http.Request) {
|
|||||||
s.sendJSON(w, map[string]string{"status": "ok"})
|
s.sendJSON(w, map[string]string{"status": "ok"})
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
func (s *Server) handleAntennaReboot(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) handleAntennaReboot(w http.ResponseWriter, r *http.Request) {
|
||||||
=======
|
|
||||||
// Antenna Genius handlers
|
|
||||||
func (s *Server) handleAntennaSet(w http.ResponseWriter, r *http.Request) {
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
if r.Method != http.MethodPost {
|
if r.Method != http.MethodPost {
|
||||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if err := s.deviceManager.AntennaGenius().Reboot(); err != nil {
|
if err := s.deviceManager.AntennaGenius().Reboot(); err != nil {
|
||||||
=======
|
|
||||||
var req struct {
|
|
||||||
Radio int `json:"radio"`
|
|
||||||
Antenna int `json:"antenna"`
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
|
||||||
http.Error(w, "Invalid request body", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := s.deviceManager.AntennaGenius().SetRadioAntenna(req.Radio, req.Antenna); err != nil {
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -456,7 +369,6 @@ func (s *Server) handlePowerFanMode(w http.ResponseWriter, r *http.Request) {
|
|||||||
s.sendJSON(w, map[string]string{"status": "ok"})
|
s.sendJSON(w, map[string]string{"status": "ok"})
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
func (s *Server) handlePowerOperate(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) handlePowerOperate(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != http.MethodPost {
|
if r.Method != http.MethodPost {
|
||||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||||
@@ -480,8 +392,6 @@ func (s *Server) handlePowerOperate(w http.ResponseWriter, r *http.Request) {
|
|||||||
s.sendJSON(w, map[string]string{"status": "ok"})
|
s.sendJSON(w, map[string]string{"status": "ok"})
|
||||||
}
|
}
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
func (s *Server) sendJSON(w http.ResponseWriter, data interface{}) {
|
func (s *Server) sendJSON(w http.ResponseWriter, data interface{}) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(data)
|
json.NewEncoder(w).Encode(data)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package antennagenius
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
<<<<<<< HEAD
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -53,43 +52,17 @@ type Antenna struct {
|
|||||||
RX string `json:"rx"`
|
RX string `json:"rx"`
|
||||||
InBand string `json:"in_band"`
|
InBand string `json:"in_band"`
|
||||||
Hotkey int `json:"hotkey"`
|
Hotkey int `json:"hotkey"`
|
||||||
=======
|
|
||||||
"net"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
. "git.rouggy.com/rouggy/ShackMaster/internal/devices"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
host string
|
|
||||||
port int
|
|
||||||
conn net.Conn
|
|
||||||
}
|
|
||||||
|
|
||||||
type Status struct {
|
|
||||||
Radio1Antenna int `json:"radio1_antenna"` // 0-7 (antenna index)
|
|
||||||
Radio2Antenna int `json:"radio2_antenna"` // 0-7 (antenna index)
|
|
||||||
Connected bool `json:"connected"`
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(host string, port int) *Client {
|
func New(host string, port int) *Client {
|
||||||
return &Client{
|
return &Client{
|
||||||
<<<<<<< HEAD
|
|
||||||
host: host,
|
host: host,
|
||||||
port: port,
|
port: port,
|
||||||
stopChan: make(chan struct{}),
|
stopChan: make(chan struct{}),
|
||||||
=======
|
|
||||||
host: host,
|
|
||||||
port: port,
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) Connect() error {
|
func (c *Client) Connect() error {
|
||||||
<<<<<<< HEAD
|
|
||||||
c.connMu.Lock()
|
c.connMu.Lock()
|
||||||
defer c.connMu.Unlock()
|
defer c.connMu.Unlock()
|
||||||
|
|
||||||
@@ -97,26 +70,20 @@ func (c *Client) Connect() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
conn, err := net.DialTimeout("tcp", fmt.Sprintf("%s:%d", c.host, c.port), 5*time.Second)
|
conn, err := net.DialTimeout("tcp", fmt.Sprintf("%s:%d", c.host, c.port), 5*time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to connect: %w", err)
|
return fmt.Errorf("failed to connect: %w", err)
|
||||||
}
|
}
|
||||||
c.conn = conn
|
c.conn = conn
|
||||||
<<<<<<< HEAD
|
|
||||||
c.reader = bufio.NewReader(c.conn)
|
c.reader = bufio.NewReader(c.conn)
|
||||||
|
|
||||||
// Read and discard banner
|
// Read and discard banner
|
||||||
_, _ = c.reader.ReadString('\n')
|
_, _ = c.reader.ReadString('\n')
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) Close() error {
|
func (c *Client) Close() error {
|
||||||
<<<<<<< HEAD
|
|
||||||
c.connMu.Lock()
|
c.connMu.Lock()
|
||||||
defer c.connMu.Unlock()
|
defer c.connMu.Unlock()
|
||||||
|
|
||||||
@@ -124,15 +91,12 @@ func (c *Client) Close() error {
|
|||||||
close(c.stopChan)
|
close(c.stopChan)
|
||||||
}
|
}
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
if c.conn != nil {
|
if c.conn != nil {
|
||||||
return c.conn.Close()
|
return c.conn.Close()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
func (c *Client) Start() error {
|
func (c *Client) Start() error {
|
||||||
if c.running {
|
if c.running {
|
||||||
return nil
|
return nil
|
||||||
@@ -299,46 +263,10 @@ func (c *Client) sendCommand(cmd string) (string, error) {
|
|||||||
|
|
||||||
func (c *Client) getAntennaList() ([]Antenna, error) {
|
func (c *Client) getAntennaList() ([]Antenna, error) {
|
||||||
resp, err := c.sendCommand("antenna list")
|
resp, err := c.sendCommand("antenna list")
|
||||||
=======
|
|
||||||
func (c *Client) sendCommand(cmd string) (string, error) {
|
|
||||||
if c.conn == nil {
|
|
||||||
if err := c.Connect(); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get next command ID from global counter
|
|
||||||
cmdID := GetGlobalCommandID().GetNextID()
|
|
||||||
|
|
||||||
// Format command with ID: C<id>|<command>
|
|
||||||
fullCmd := fmt.Sprintf("C%d|%s\n", cmdID, cmd)
|
|
||||||
|
|
||||||
// Send command
|
|
||||||
_, err := c.conn.Write([]byte(fullCmd))
|
|
||||||
if err != nil {
|
|
||||||
c.conn = nil
|
|
||||||
return "", fmt.Errorf("failed to send command: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read response
|
|
||||||
reader := bufio.NewReader(c.conn)
|
|
||||||
response, err := reader.ReadString('\n')
|
|
||||||
if err != nil {
|
|
||||||
c.conn = nil
|
|
||||||
return "", fmt.Errorf("failed to read response: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return strings.TrimSpace(response), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) GetStatus() (*Status, error) {
|
|
||||||
resp, err := c.sendCommand("status")
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
var antennas []Antenna
|
var antennas []Antenna
|
||||||
|
|
||||||
// Response format: R<id>|0|antenna <num> name=<name> tx=<hex> rx=<hex> inband=<hex> hotkey=<num>
|
// Response format: R<id>|0|antenna <num> name=<name> tx=<hex> rx=<hex> inband=<hex> hotkey=<num>
|
||||||
@@ -405,58 +333,10 @@ func (c *Client) parseAntennaLine(line string) Antenna {
|
|||||||
|
|
||||||
func (c *Client) subscribeToPortUpdates() error {
|
func (c *Client) subscribeToPortUpdates() error {
|
||||||
resp, err := c.sendCommand("sub port all")
|
resp, err := c.sendCommand("sub port all")
|
||||||
=======
|
|
||||||
return c.parseStatus(resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) parseStatus(resp string) (*Status, error) {
|
|
||||||
status := &Status{
|
|
||||||
Connected: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse response format from 4O3A API
|
|
||||||
// Expected format will vary - this is a basic parser
|
|
||||||
pairs := strings.Fields(resp)
|
|
||||||
|
|
||||||
for _, pair := range pairs {
|
|
||||||
parts := strings.SplitN(pair, "=", 2)
|
|
||||||
if len(parts) != 2 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
key := parts[0]
|
|
||||||
value := parts[1]
|
|
||||||
|
|
||||||
switch key {
|
|
||||||
case "radio1", "r1":
|
|
||||||
status.Radio1Antenna, _ = strconv.Atoi(value)
|
|
||||||
case "radio2", "r2":
|
|
||||||
status.Radio2Antenna, _ = strconv.Atoi(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return status, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetRadioAntenna sets which antenna a radio should use
|
|
||||||
// radio: 1 or 2
|
|
||||||
// antenna: 0-7 (antenna index)
|
|
||||||
func (c *Client) SetRadioAntenna(radio int, antenna int) error {
|
|
||||||
if radio < 1 || radio > 2 {
|
|
||||||
return fmt.Errorf("radio must be 1 or 2")
|
|
||||||
}
|
|
||||||
if antenna < 0 || antenna > 7 {
|
|
||||||
return fmt.Errorf("antenna must be between 0 and 7")
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := fmt.Sprintf("set radio%d=%d", radio, antenna)
|
|
||||||
resp, err := c.sendCommand(cmd)
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
// Parse initial port status from subscription response
|
// Parse initial port status from subscription response
|
||||||
// The response may contain S0|port messages with current status
|
// The response may contain S0|port messages with current status
|
||||||
lines := strings.Split(resp, "\n")
|
lines := strings.Split(resp, "\n")
|
||||||
@@ -465,18 +345,11 @@ func (c *Client) SetRadioAntenna(radio int, antenna int) error {
|
|||||||
if strings.HasPrefix(line, "S0|port") {
|
if strings.HasPrefix(line, "S0|port") {
|
||||||
c.parsePortStatus(line)
|
c.parsePortStatus(line)
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
// Check response for success
|
|
||||||
if !strings.Contains(strings.ToLower(resp), "ok") && resp != "" {
|
|
||||||
// If response doesn't contain "ok" but isn't empty, assume success
|
|
||||||
// (some devices may return the new state instead of "ok")
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
func (c *Client) parsePortStatus(line string) {
|
func (c *Client) parsePortStatus(line string) {
|
||||||
// Format: S0|port <id> auto=<0|1> source=<src> band=<n> freq=<f> nickname=<name> rxant=<n> txant=<n> inband=<n> tx=<0|1> inhibit=<n>
|
// Format: S0|port <id> auto=<0|1> source=<src> band=<n> freq=<f> nickname=<name> rxant=<n> txant=<n> inband=<n> tx=<0|1> inhibit=<n>
|
||||||
|
|
||||||
@@ -561,21 +434,4 @@ func (c *Client) SetAntenna(port, antenna int) error {
|
|||||||
func (c *Client) Reboot() error {
|
func (c *Client) Reboot() error {
|
||||||
_, err := c.sendCommand("reboot")
|
_, err := c.sendCommand("reboot")
|
||||||
return err
|
return err
|
||||||
=======
|
|
||||||
// GetRadioAntenna gets which antenna a radio is currently using
|
|
||||||
func (c *Client) GetRadioAntenna(radio int) (int, error) {
|
|
||||||
if radio < 1 || radio > 2 {
|
|
||||||
return -1, fmt.Errorf("radio must be 1 or 2")
|
|
||||||
}
|
|
||||||
|
|
||||||
status, err := c.GetStatus()
|
|
||||||
if err != nil {
|
|
||||||
return -1, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if radio == 1 {
|
|
||||||
return status.Radio1Antenna, nil
|
|
||||||
}
|
|
||||||
return status.Radio2Antenna, nil
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,7 @@ package powergenius
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
"log"
|
"log"
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
"math"
|
"math"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -26,6 +23,10 @@ type Client struct {
|
|||||||
statusMu sync.RWMutex
|
statusMu sync.RWMutex
|
||||||
stopChan chan struct{}
|
stopChan chan struct{}
|
||||||
running bool
|
running bool
|
||||||
|
|
||||||
|
// Auto fan management
|
||||||
|
autoFanEnabled bool
|
||||||
|
lastFanMode string // Remember last manual mode
|
||||||
}
|
}
|
||||||
|
|
||||||
type Status struct {
|
type Status struct {
|
||||||
@@ -45,10 +46,10 @@ type Status struct {
|
|||||||
BandB string `json:"band_b"`
|
BandB string `json:"band_b"`
|
||||||
FaultPresent bool `json:"fault_present"`
|
FaultPresent bool `json:"fault_present"`
|
||||||
Connected bool `json:"connected"`
|
Connected bool `json:"connected"`
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
// Peak hold for display (internal)
|
||||||
Meffa string `json:"meffa"`
|
displayPower float64
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
peakTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(host string, port int) *Client {
|
func New(host string, port int) *Client {
|
||||||
@@ -56,6 +57,8 @@ func New(host string, port int) *Client {
|
|||||||
host: host,
|
host: host,
|
||||||
port: port,
|
port: port,
|
||||||
stopChan: make(chan struct{}),
|
stopChan: make(chan struct{}),
|
||||||
|
autoFanEnabled: true, // Auto fan management enabled by default
|
||||||
|
lastFanMode: "Contest", // Default to Contest mode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,24 +99,14 @@ func (c *Client) Close() error {
|
|||||||
|
|
||||||
// Start begins continuous polling of the device
|
// Start begins continuous polling of the device
|
||||||
func (c *Client) Start() error {
|
func (c *Client) Start() error {
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
if err := c.Connect(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
if c.running {
|
if c.running {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
// Try to connect, but don't fail if it doesn't work
|
// Try to connect, but don't fail if it doesn't work
|
||||||
// The poll loop will keep trying
|
// The poll loop will keep trying
|
||||||
_ = c.Connect()
|
_ = c.Connect()
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
c.running = true
|
c.running = true
|
||||||
go c.pollLoop()
|
go c.pollLoop()
|
||||||
|
|
||||||
@@ -128,7 +121,6 @@ func (c *Client) pollLoop() {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
<<<<<<< HEAD
|
|
||||||
// Try to reconnect if not connected
|
// Try to reconnect if not connected
|
||||||
c.connMu.Lock()
|
c.connMu.Lock()
|
||||||
if c.conn == nil {
|
if c.conn == nil {
|
||||||
@@ -152,12 +144,6 @@ func (c *Client) pollLoop() {
|
|||||||
status, err := c.queryStatus()
|
status, err := c.queryStatus()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Connection lost, close and retry next tick
|
// Connection lost, close and retry next tick
|
||||||
=======
|
|
||||||
status, err := c.queryStatus()
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("PowerGenius query error: %v", err)
|
|
||||||
// Try to reconnect
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
c.connMu.Lock()
|
c.connMu.Lock()
|
||||||
if c.conn != nil {
|
if c.conn != nil {
|
||||||
c.conn.Close()
|
c.conn.Close()
|
||||||
@@ -165,7 +151,6 @@ func (c *Client) pollLoop() {
|
|||||||
}
|
}
|
||||||
c.connMu.Unlock()
|
c.connMu.Unlock()
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
// Mark as disconnected and reset all values
|
// Mark as disconnected and reset all values
|
||||||
c.statusMu.Lock()
|
c.statusMu.Lock()
|
||||||
c.lastStatus = &Status{
|
c.lastStatus = &Status{
|
||||||
@@ -178,21 +163,37 @@ func (c *Client) pollLoop() {
|
|||||||
// Mark as connected
|
// Mark as connected
|
||||||
status.Connected = true
|
status.Connected = true
|
||||||
|
|
||||||
=======
|
// Peak hold logic - keep highest power for 1 second
|
||||||
if err := c.Connect(); err != nil {
|
now := time.Now()
|
||||||
log.Printf("PowerGenius reconnect failed: %v", err)
|
if c.lastStatus != nil {
|
||||||
|
// If new power is higher, update peak
|
||||||
|
if status.PowerForward > c.lastStatus.displayPower {
|
||||||
|
status.displayPower = status.PowerForward
|
||||||
|
status.peakTime = now
|
||||||
|
} else {
|
||||||
|
// Check if peak has expired (1 second)
|
||||||
|
if now.Sub(c.lastStatus.peakTime) < 1*time.Second {
|
||||||
|
// Keep old peak
|
||||||
|
status.displayPower = c.lastStatus.displayPower
|
||||||
|
status.peakTime = c.lastStatus.peakTime
|
||||||
|
} else {
|
||||||
|
// Peak expired, use current value
|
||||||
|
status.displayPower = status.PowerForward
|
||||||
|
status.peakTime = now
|
||||||
}
|
}
|
||||||
continue
|
}
|
||||||
|
} else {
|
||||||
|
status.displayPower = status.PowerForward
|
||||||
|
status.peakTime = now
|
||||||
}
|
}
|
||||||
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
// Override PowerForward with display power for frontend
|
||||||
|
status.PowerForward = status.displayPower
|
||||||
|
|
||||||
// Merge with existing status (spontaneous messages may only update some fields)
|
// Merge with existing status (spontaneous messages may only update some fields)
|
||||||
c.statusMu.Lock()
|
c.statusMu.Lock()
|
||||||
if c.lastStatus != nil {
|
if c.lastStatus != nil {
|
||||||
// Keep existing values for fields not in the new status
|
// Keep existing values for fields not in the new status
|
||||||
if status.PowerForward == 0 && c.lastStatus.PowerForward != 0 {
|
|
||||||
status.PowerForward = c.lastStatus.PowerForward
|
|
||||||
}
|
|
||||||
if status.Temperature == 0 && c.lastStatus.Temperature != 0 {
|
if status.Temperature == 0 && c.lastStatus.Temperature != 0 {
|
||||||
status.Temperature = c.lastStatus.Temperature
|
status.Temperature = c.lastStatus.Temperature
|
||||||
}
|
}
|
||||||
@@ -215,6 +216,32 @@ func (c *Client) pollLoop() {
|
|||||||
c.lastStatus = status
|
c.lastStatus = status
|
||||||
c.statusMu.Unlock()
|
c.statusMu.Unlock()
|
||||||
|
|
||||||
|
// Auto fan management based on temperature
|
||||||
|
if c.autoFanEnabled {
|
||||||
|
temp := status.Temperature
|
||||||
|
currentMode := status.FanMode
|
||||||
|
|
||||||
|
// If temp >= 60°C, switch to Broadcast
|
||||||
|
if temp >= 60.0 && currentMode != "Broadcast" {
|
||||||
|
log.Printf("PowerGenius: Temperature %.1f°C >= 60°C, switching fan to Broadcast mode", temp)
|
||||||
|
if err := c.SetFanMode("Broadcast"); err != nil {
|
||||||
|
log.Printf("PowerGenius: Failed to set fan mode: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If temp <= 55°C, switch back to Contest (or last manual mode)
|
||||||
|
if temp <= 55.0 && currentMode == "Broadcast" {
|
||||||
|
targetMode := c.lastFanMode
|
||||||
|
if targetMode == "" || targetMode == "Broadcast" {
|
||||||
|
targetMode = "Contest"
|
||||||
|
}
|
||||||
|
log.Printf("PowerGenius: Temperature %.1f°C <= 55°C, switching fan back to %s mode", temp, targetMode)
|
||||||
|
if err := c.SetFanMode(targetMode); err != nil {
|
||||||
|
log.Printf("PowerGenius: Failed to set fan mode: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case <-c.stopChan:
|
case <-c.stopChan:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -361,11 +388,6 @@ func (c *Client) parseStatus(resp string) (*Status, error) {
|
|||||||
}
|
}
|
||||||
case "vac":
|
case "vac":
|
||||||
status.Voltage, _ = strconv.ParseFloat(value, 64)
|
status.Voltage, _ = strconv.ParseFloat(value, 64)
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
case "meffa":
|
|
||||||
status.Meffa = value
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
case "vdd":
|
case "vdd":
|
||||||
status.VDD, _ = strconv.ParseFloat(value, 64)
|
status.VDD, _ = strconv.ParseFloat(value, 64)
|
||||||
case "id":
|
case "id":
|
||||||
@@ -430,15 +452,20 @@ func (c *Client) SetFanMode(mode string) error {
|
|||||||
"BROADCAST": true,
|
"BROADCAST": true,
|
||||||
}
|
}
|
||||||
|
|
||||||
if !validModes[mode] {
|
// Normalize mode to title case for comparison
|
||||||
|
modeUpper := strings.ToUpper(mode)
|
||||||
|
if !validModes[modeUpper] {
|
||||||
return fmt.Errorf("invalid fan mode: %s (must be STANDARD, CONTEST, or BROADCAST)", mode)
|
return fmt.Errorf("invalid fan mode: %s (must be STANDARD, CONTEST, or BROADCAST)", mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := fmt.Sprintf("setup fanmode=%s", mode)
|
// Remember last manual mode (if not triggered by auto-fan)
|
||||||
|
// We store it in title case: "Standard", "Contest", "Broadcast"
|
||||||
|
c.lastFanMode = strings.Title(strings.ToLower(mode))
|
||||||
|
|
||||||
|
cmd := fmt.Sprintf("setup fanmode=%s", modeUpper)
|
||||||
_, err := c.sendCommand(cmd)
|
_, err := c.sendCommand(cmd)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
// SetOperate sets the operate mode
|
// SetOperate sets the operate mode
|
||||||
// value can be: 0 (STANDBY) or 1 (OPERATE)
|
// value can be: 0 (STANDBY) or 1 (OPERATE)
|
||||||
@@ -451,5 +478,3 @@ func (c *Client) SetOperate(value int) error {
|
|||||||
_, err := c.sendCommand(cmd)
|
_, err := c.sendCommand(cmd)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
. "git.rouggy.com/rouggy/ShackMaster/internal/devices"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
@@ -151,18 +149,7 @@ func (c *Client) sendCommand(cmd string) error {
|
|||||||
return fmt.Errorf("not connected")
|
return fmt.Errorf("not connected")
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
_, err := c.conn.Write([]byte(cmd))
|
_, err := c.conn.Write([]byte(cmd))
|
||||||
=======
|
|
||||||
// Get next command ID from global counter
|
|
||||||
cmdID := GetGlobalCommandID().GetNextID()
|
|
||||||
|
|
||||||
// Format command with ID: C<id>|<command>
|
|
||||||
fullCmd := fmt.Sprintf("C%d%s", cmdID, cmd)
|
|
||||||
|
|
||||||
// Send command
|
|
||||||
_, err := c.conn.Write([]byte(fullCmd))
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.conn = nil
|
c.conn = nil
|
||||||
c.reader = nil
|
c.reader = nil
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
<<<<<<< HEAD
|
|
||||||
host string
|
host string
|
||||||
port int
|
port int
|
||||||
conn net.Conn
|
conn net.Conn
|
||||||
@@ -23,11 +22,6 @@ type Client struct {
|
|||||||
statusMu sync.RWMutex
|
statusMu sync.RWMutex
|
||||||
stopChan chan struct{}
|
stopChan chan struct{}
|
||||||
running bool
|
running bool
|
||||||
=======
|
|
||||||
host string
|
|
||||||
port int
|
|
||||||
conn net.Conn
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Status struct {
|
type Status struct {
|
||||||
@@ -54,18 +48,17 @@ type Status struct {
|
|||||||
RelayC2 int `json:"c2"`
|
RelayC2 int `json:"c2"`
|
||||||
TuningStatus string `json:"tuning_status"`
|
TuningStatus string `json:"tuning_status"`
|
||||||
Connected bool `json:"connected"`
|
Connected bool `json:"connected"`
|
||||||
|
|
||||||
|
// Peak hold for display (internal)
|
||||||
|
displayPower float64
|
||||||
|
peakTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(host string, port int) *Client {
|
func New(host string, port int) *Client {
|
||||||
return &Client{
|
return &Client{
|
||||||
<<<<<<< HEAD
|
|
||||||
host: host,
|
host: host,
|
||||||
port: port,
|
port: port,
|
||||||
stopChan: make(chan struct{}),
|
stopChan: make(chan struct{}),
|
||||||
=======
|
|
||||||
host: host,
|
|
||||||
port: port,
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +103,6 @@ func (c *Client) Start() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
// Try to connect, but don't fail if it doesn't work
|
// Try to connect, but don't fail if it doesn't work
|
||||||
// The poll loop will keep trying
|
// The poll loop will keep trying
|
||||||
_ = c.Connect()
|
_ = c.Connect()
|
||||||
@@ -171,6 +163,33 @@ func (c *Client) pollLoop() {
|
|||||||
// Mark as connected
|
// Mark as connected
|
||||||
status.Connected = true
|
status.Connected = true
|
||||||
|
|
||||||
|
// Peak hold logic - keep highest power for 1 second
|
||||||
|
now := time.Now()
|
||||||
|
if c.lastStatus != nil {
|
||||||
|
// If new power is higher, update peak
|
||||||
|
if status.PowerForward > c.lastStatus.displayPower {
|
||||||
|
status.displayPower = status.PowerForward
|
||||||
|
status.peakTime = now
|
||||||
|
} else {
|
||||||
|
// Check if peak has expired (1 second)
|
||||||
|
if now.Sub(c.lastStatus.peakTime) < 1*time.Second {
|
||||||
|
// Keep old peak
|
||||||
|
status.displayPower = c.lastStatus.displayPower
|
||||||
|
status.peakTime = c.lastStatus.peakTime
|
||||||
|
} else {
|
||||||
|
// Peak expired, use current value
|
||||||
|
status.displayPower = status.PowerForward
|
||||||
|
status.peakTime = now
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
status.displayPower = status.PowerForward
|
||||||
|
status.peakTime = now
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override PowerForward with display power for frontend
|
||||||
|
status.PowerForward = status.displayPower
|
||||||
|
|
||||||
c.statusMu.Lock()
|
c.statusMu.Lock()
|
||||||
c.lastStatus = status
|
c.lastStatus = status
|
||||||
c.statusMu.Unlock()
|
c.statusMu.Unlock()
|
||||||
@@ -221,8 +240,6 @@ func (c *Client) sendCommand(cmd string) (string, error) {
|
|||||||
return "", fmt.Errorf("not connected")
|
return "", fmt.Errorf("not connected")
|
||||||
}
|
}
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
// Get next command ID from global counter
|
// Get next command ID from global counter
|
||||||
cmdID := GetGlobalCommandID().GetNextID()
|
cmdID := GetGlobalCommandID().GetNextID()
|
||||||
|
|
||||||
|
|||||||
@@ -142,12 +142,8 @@ func (c *Client) GetStatus() (*Status, error) {
|
|||||||
|
|
||||||
// Parse response format: "1,1\n2,1\n3,1\n4,1\n5,0\n"
|
// Parse response format: "1,1\n2,1\n3,1\n4,1\n5,0\n"
|
||||||
status := &Status{
|
status := &Status{
|
||||||
<<<<<<< HEAD
|
|
||||||
Relays: make([]RelayState, 0, 5),
|
Relays: make([]RelayState, 0, 5),
|
||||||
Connected: true,
|
Connected: true,
|
||||||
=======
|
|
||||||
Relays: make([]RelayState, 0, 5),
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lines := strings.Split(strings.TrimSpace(string(body)), "\n")
|
lines := strings.Split(strings.TrimSpace(string(body)), "\n")
|
||||||
|
|||||||
@@ -3,11 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<<<<<<< HEAD
|
|
||||||
<title>ShackMaster - F4BPO Shack</title>
|
<title>ShackMaster - F4BPO Shack</title>
|
||||||
=======
|
|
||||||
<title>ShackMaster - XV9Q Shack</title>
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
|
||||||
|
|||||||
129
web/src/app.css
129
web/src/app.css
@@ -1,5 +1,4 @@
|
|||||||
:root {
|
:root {
|
||||||
<<<<<<< HEAD
|
|
||||||
/* Modern dark theme inspired by FlexDXCluster */
|
/* Modern dark theme inspired by FlexDXCluster */
|
||||||
--bg-primary: #0a1628;
|
--bg-primary: #0a1628;
|
||||||
--bg-secondary: #1a2332;
|
--bg-secondary: #1a2332;
|
||||||
@@ -436,132 +435,4 @@ select:focus {
|
|||||||
order: 3;
|
order: 3;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
--bg-primary: #1a1a1a;
|
|
||||||
--bg-secondary: #2a2a2a;
|
|
||||||
--bg-card: #333333;
|
|
||||||
--text-primary: #ffffff;
|
|
||||||
--text-secondary: #b0b0b0;
|
|
||||||
--accent-teal: #00bcd4;
|
|
||||||
--accent-green: #4caf50;
|
|
||||||
--accent-red: #f44336;
|
|
||||||
--accent-blue: #2196f3;
|
|
||||||
--border-color: #444444;
|
|
||||||
}
|
|
||||||
|
|
||||||
* {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
||||||
background-color: var(--bg-primary);
|
|
||||||
color: var(--text-primary);
|
|
||||||
overflow-x: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
#app {
|
|
||||||
min-height: 100vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
|
||||||
font-family: inherit;
|
|
||||||
cursor: pointer;
|
|
||||||
border: none;
|
|
||||||
outline: none;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
button:hover {
|
|
||||||
transform: translateY(-1px);
|
|
||||||
}
|
|
||||||
|
|
||||||
button:active {
|
|
||||||
transform: translateY(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
input, select {
|
|
||||||
font-family: inherit;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card {
|
|
||||||
background: var(--bg-card);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-indicator {
|
|
||||||
display: inline-block;
|
|
||||||
width: 12px;
|
|
||||||
height: 12px;
|
|
||||||
border-radius: 50%;
|
|
||||||
margin-right: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-online {
|
|
||||||
background-color: var(--accent-green);
|
|
||||||
box-shadow: 0 0 8px var(--accent-green);
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-offline {
|
|
||||||
background-color: var(--text-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn {
|
|
||||||
padding: 12px 24px;
|
|
||||||
border-radius: 6px;
|
|
||||||
font-weight: 500;
|
|
||||||
font-size: 14px;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary {
|
|
||||||
background: var(--accent-green);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary:hover {
|
|
||||||
background: #45a049;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-danger {
|
|
||||||
background: var(--accent-red);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-danger:hover {
|
|
||||||
background: #da190b;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-secondary {
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
color: var(--text-primary);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-secondary:hover {
|
|
||||||
background: var(--bg-card);
|
|
||||||
}
|
|
||||||
|
|
||||||
.value-display {
|
|
||||||
font-size: 24px;
|
|
||||||
font-weight: 300;
|
|
||||||
color: var(--accent-teal);
|
|
||||||
}
|
|
||||||
|
|
||||||
.label {
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 1px;
|
|
||||||
margin-bottom: 4px;
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import { api } from '../lib/api.js';
|
import { api } from '../lib/api.js';
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
export let status;
|
export let status;
|
||||||
|
|
||||||
@@ -21,7 +20,7 @@
|
|||||||
|
|
||||||
async function selectAntenna(port, antennaNum) {
|
async function selectAntenna(port, antennaNum) {
|
||||||
try {
|
try {
|
||||||
await api.antenna.selectAntenna(port, antennaNum, antennaNum);
|
await api.antenna.selectAntenna(port, antennaNum);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to select antenna:', err);
|
console.error('Failed to select antenna:', err);
|
||||||
alert('Failed to select antenna');
|
alert('Failed to select antenna');
|
||||||
@@ -37,25 +36,10 @@
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to reboot:', err);
|
console.error('Failed to reboot:', err);
|
||||||
alert('Failed to reboot');
|
alert('Failed to reboot');
|
||||||
=======
|
|
||||||
|
|
||||||
export let status;
|
|
||||||
|
|
||||||
$: radio1Antenna = status?.radio1_antenna || 0;
|
|
||||||
$: radio2Antenna = status?.radio2_antenna || 0;
|
|
||||||
$: connected = status?.connected || false;
|
|
||||||
|
|
||||||
async function setRadioAntenna(radio, antenna) {
|
|
||||||
try {
|
|
||||||
await api.antenna.set(radio, antenna);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to set antenna:', err);
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h2>Antenna Genius</h2>
|
<h2>Antenna Genius</h2>
|
||||||
@@ -88,29 +72,30 @@
|
|||||||
{#each antennas as antenna}
|
{#each antennas as antenna}
|
||||||
{@const isPortATx = portA.tx && portA.tx_ant === antenna.number}
|
{@const isPortATx = portA.tx && portA.tx_ant === antenna.number}
|
||||||
{@const isPortBTx = portB.tx && portB.tx_ant === antenna.number}
|
{@const isPortBTx = portB.tx && portB.tx_ant === antenna.number}
|
||||||
{@const isPortARx = !portA.tx && (portA.rx_ant === antenna.number || portA.tx_ant === antenna.number)}
|
{@const isPortARx = !portA.tx && portA.rx_ant === antenna.number}
|
||||||
{@const isPortBRx = !portB.tx && (portB.rx_ant === antenna.number || portB.tx_ant === antenna.number)}
|
{@const isPortBRx = !portB.tx && portB.rx_ant === antenna.number}
|
||||||
{@const isTx = isPortATx || isPortBTx}
|
{@const isTx = isPortATx || isPortBTx}
|
||||||
{@const isActive = isPortARx || isPortBRx}
|
{@const isActiveA = isPortARx || isPortATx}
|
||||||
|
{@const isActiveB = isPortBRx || isPortBTx}
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="antenna-card"
|
class="antenna-card"
|
||||||
class:tx={isTx}
|
class:tx={isTx}
|
||||||
class:active-a={isPortARx}
|
class:active-a={isActiveA}
|
||||||
class:active-b={isPortBRx}
|
class:active-b={isActiveB}
|
||||||
>
|
>
|
||||||
<div class="antenna-name">{antenna.name}</div>
|
<div class="antenna-name">{antenna.name}</div>
|
||||||
<div class="antenna-ports">
|
<div class="antenna-ports">
|
||||||
<button
|
<button
|
||||||
class="port-btn"
|
class="port-btn"
|
||||||
class:active={portA.tx_ant === antenna.number || portA.rx_ant === antenna.number}
|
class:active={isActiveA}
|
||||||
on:click={() => selectAntenna(1, antenna.number)}
|
on:click={() => selectAntenna(1, antenna.number)}
|
||||||
>
|
>
|
||||||
A
|
A
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="port-btn"
|
class="port-btn"
|
||||||
class:active={portB.tx_ant === antenna.number || portB.rx_ant === antenna.number}
|
class:active={isActiveB}
|
||||||
on:click={() => selectAntenna(2, antenna.number)}
|
on:click={() => selectAntenna(2, antenna.number)}
|
||||||
>
|
>
|
||||||
B
|
B
|
||||||
@@ -125,53 +110,10 @@
|
|||||||
<span class="reboot-icon">🔄</span>
|
<span class="reboot-icon">🔄</span>
|
||||||
REBOOT
|
REBOOT
|
||||||
</button>
|
</button>
|
||||||
=======
|
|
||||||
<div class="antenna-card card">
|
|
||||||
<h2>
|
|
||||||
AG 8X2
|
|
||||||
<span class="status-indicator" class:status-online={connected} class:status-offline={!connected}></span>
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<div class="radio-section">
|
|
||||||
<div class="radio-label">Radio 1 / Radio 2</div>
|
|
||||||
|
|
||||||
<div class="radio-grid">
|
|
||||||
<div class="radio-column">
|
|
||||||
<div class="radio-title">Radio 1</div>
|
|
||||||
<div class="antenna-slots">
|
|
||||||
{#each Array(4) as _, i}
|
|
||||||
<button
|
|
||||||
class="slot"
|
|
||||||
class:active={radio1Antenna === i}
|
|
||||||
on:click={() => setRadioAntenna(1, i)}
|
|
||||||
>
|
|
||||||
{i + 1}
|
|
||||||
</button>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="radio-column">
|
|
||||||
<div class="radio-title">Radio 2</div>
|
|
||||||
<div class="antenna-slots">
|
|
||||||
{#each Array(4) as _, i}
|
|
||||||
<button
|
|
||||||
class="slot"
|
|
||||||
class:active={radio2Antenna === i}
|
|
||||||
on:click={() => setRadioAntenna(2, i)}
|
|
||||||
>
|
|
||||||
{i + 1}
|
|
||||||
</button>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
<<<<<<< HEAD
|
|
||||||
.card {
|
.card {
|
||||||
background: linear-gradient(135deg, #1a2332 0%, #0f1923 100%);
|
background: linear-gradient(135deg, #1a2332 0%, #0f1923 100%);
|
||||||
border: 1px solid #2d3748;
|
border: 1px solid #2d3748;
|
||||||
@@ -365,72 +307,5 @@
|
|||||||
|
|
||||||
.reboot-icon {
|
.reboot-icon {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
=======
|
|
||||||
.antenna-card {
|
|
||||||
min-width: 300px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--accent-teal);
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-section {
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-label {
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-grid {
|
|
||||||
display: flex;
|
|
||||||
gap: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-column {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-title {
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 500;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.antenna-slots {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.slot {
|
|
||||||
padding: 16px;
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
color: var(--text-primary);
|
|
||||||
border: 2px solid var(--border-color);
|
|
||||||
border-radius: 6px;
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 500;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.slot:hover {
|
|
||||||
border-color: var(--accent-blue);
|
|
||||||
}
|
|
||||||
|
|
||||||
.slot.active {
|
|
||||||
background: var(--accent-blue);
|
|
||||||
border-color: var(--accent-blue);
|
|
||||||
color: white;
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<script>
|
<script>
|
||||||
<<<<<<< HEAD
|
|
||||||
import { api } from '../lib/api.js';
|
import { api } from '../lib/api.js';
|
||||||
|
|
||||||
export let status;
|
export let status;
|
||||||
@@ -234,160 +233,11 @@
|
|||||||
|
|
||||||
.metrics {
|
.metrics {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
=======
|
|
||||||
export let status;
|
|
||||||
|
|
||||||
$: powerForward = status?.power_forward || 0;
|
|
||||||
$: powerReflected = status?.power_reflected || 0;
|
|
||||||
$: swr = status?.swr || 1.0;
|
|
||||||
$: voltage = status?.voltage || 0;
|
|
||||||
$: vdd = status?.vdd || 0;
|
|
||||||
$: current = status?.current || 0;
|
|
||||||
$: peakCurrent = status?.peak_current || 0;
|
|
||||||
$: temperature = status?.temperature || 0;
|
|
||||||
$: harmonicLoadTemp = status?.harmonic_load_temp || 0;
|
|
||||||
$: fanMode = status?.fan_mode || 'CONTEST';
|
|
||||||
$: state = status?.state || 'IDLE';
|
|
||||||
$: bandA = status?.band_a || '0';
|
|
||||||
$: bandB = status?.band_b || '0';
|
|
||||||
$: connected = status?.connected || false;
|
|
||||||
$: displayState = state.replace('TRANSMIT_A', 'TRANSMIT').replace('TRANSMIT_B', 'TRANSMIT');
|
|
||||||
$: meffa = status?.meffa || 'STANDBY';
|
|
||||||
|
|
||||||
async function setFanMode(mode) {
|
|
||||||
try {
|
|
||||||
await api.power.setFanMode(mode);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to set fan mode:', err);
|
|
||||||
alert('Failed to set fan mode');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="powergenius-card card">
|
|
||||||
<h2>
|
|
||||||
PGXL
|
|
||||||
<span class="status-indicator" class:status-online={connected} class:status-offline={!connected}></span>
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<div class="status-row">
|
|
||||||
<div class="status-label" class:normal={state === 'IDLE'} class:warning={state.includes('TRANSMIT')}>
|
|
||||||
{displayState}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="metrics">
|
|
||||||
<div class="metric">
|
|
||||||
<div class="label">FWD PWR (W)</div>
|
|
||||||
<div class="value">{powerForward.toFixed(1)}</div>
|
|
||||||
<div class="bar">
|
|
||||||
<div class="bar-fill" style="width: {Math.min(100, (powerForward / 1500) * 100)}%"></div>
|
|
||||||
</div>
|
|
||||||
<div class="scale">
|
|
||||||
<span>0</span>
|
|
||||||
<span>1000</span>
|
|
||||||
<span>2000</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="metric">
|
|
||||||
<div class="label">PG XL SWR 1:1.00 use</div>
|
|
||||||
<div class="value">{swr.toFixed(2)}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="metric">
|
|
||||||
<div class="label">Temp / HL Temp</div>
|
|
||||||
<div class="value">{temperature.toFixed(0)}°C / {harmonicLoadTemp.toFixed(1)}°C</div>
|
|
||||||
<div class="bar">
|
|
||||||
<div class="bar-fill" style="width: {(temperature / 80) * 100}%"></div>
|
|
||||||
</div>
|
|
||||||
<div class="scale">
|
|
||||||
<span>25</span>
|
|
||||||
<span>55</span>
|
|
||||||
<span>80</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="metric-row">
|
|
||||||
<div class="metric small">
|
|
||||||
<div class="label">VAC</div>
|
|
||||||
<div class="value">{voltage.toFixed(0)}</div>
|
|
||||||
</div>
|
|
||||||
<div class="metric small">
|
|
||||||
<div class="label">VDD</div>
|
|
||||||
<div class="value">{vdd.toFixed(1)}</div>
|
|
||||||
</div>
|
|
||||||
<div class="metric small">
|
|
||||||
<div class="label">ID peak</div>
|
|
||||||
<div class="value">{peakCurrent.toFixed(1)}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="fan-speed">
|
|
||||||
<div class="label">Fan Speed</div>
|
|
||||||
<select value={fanMode} on:change={(e) => setFanMode(e.target.value)}>
|
|
||||||
<option value="STANDARD">STANDARD</option>
|
|
||||||
<option value="CONTEST">CONTEST</option>
|
|
||||||
<option value="BROADCAST">BROADCAST</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="band-info">
|
|
||||||
<div class="label">Band A</div>
|
|
||||||
<div class="value">{bandA}</div>
|
|
||||||
</div>
|
|
||||||
<div class="band-info">
|
|
||||||
<div class="label">Band B</div>
|
|
||||||
<div class="value">{bandB}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.powergenius-card {
|
|
||||||
min-width: 350px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--accent-teal);
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-label {
|
|
||||||
display: inline-block;
|
|
||||||
padding: 8px 16px;
|
|
||||||
border-radius: 4px;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 500;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-label.normal {
|
|
||||||
background: var(--accent-green);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-label.warning {
|
|
||||||
background: var(--accent-red);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.metrics {
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 16px;
|
gap: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
/* Power Display */
|
/* Power Display */
|
||||||
.power-display {
|
.power-display {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -589,65 +439,10 @@ async function setFanMode(mode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.band-item {
|
.band-item {
|
||||||
=======
|
|
||||||
.metric {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.metric-row {
|
|
||||||
display: flex;
|
|
||||||
gap: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.metric.small {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.value {
|
|
||||||
font-size: 20px;
|
|
||||||
font-weight: 300;
|
|
||||||
color: var(--accent-teal);
|
|
||||||
}
|
|
||||||
|
|
||||||
.bar {
|
|
||||||
width: 100%;
|
|
||||||
height: 8px;
|
|
||||||
background: #555;
|
|
||||||
border-radius: 4px;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bar-fill {
|
|
||||||
height: 100%;
|
|
||||||
background: linear-gradient(90deg, var(--accent-green), var(--accent-red));
|
|
||||||
transition: width 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.scale {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
font-size: 10px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.fan-speed select {
|
|
||||||
width: 100%;
|
|
||||||
padding: 8px;
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
color: var(--text-primary);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.band-info {
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
.band-label {
|
.band-label {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
@@ -694,6 +489,4 @@ async function setFanMode(mode) {
|
|||||||
border-color: var(--accent-cyan);
|
border-color: var(--accent-cyan);
|
||||||
box-shadow: 0 0 0 2px rgba(79, 195, 247, 0.2);
|
box-shadow: 0 0 0 2px rgba(79, 195, 247, 0.2);
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
</style>
|
</style>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<script>
|
<script>
|
||||||
<<<<<<< HEAD
|
|
||||||
import { api } from '../lib/api.js';
|
import { api } from '../lib/api.js';
|
||||||
|
|
||||||
export let status;
|
export let status;
|
||||||
@@ -27,163 +26,19 @@
|
|||||||
async function rotateCW() {
|
async function rotateCW() {
|
||||||
try {
|
try {
|
||||||
await api.rotator.rotateCW();
|
await api.rotator.rotateCW();
|
||||||
=======
|
|
||||||
import { onMount } from 'svelte';
|
|
||||||
import { api } from '../lib/api.js';
|
|
||||||
|
|
||||||
export let status;
|
|
||||||
|
|
||||||
$: rotator1 = status?.rotator1 || {};
|
|
||||||
$: rotator2 = status?.rotator2 || {};
|
|
||||||
$: currentHeading = rotator1.current_azimuth || 0;
|
|
||||||
$: targetHeading = rotator1.target_azimuth || 0;
|
|
||||||
$: moving = rotator1.moving || 0;
|
|
||||||
$: connected = rotator1.connected || false;
|
|
||||||
|
|
||||||
let targetInput = currentHeading;
|
|
||||||
let canvas;
|
|
||||||
let ctx;
|
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
if (canvas) {
|
|
||||||
ctx = canvas.getContext('2d');
|
|
||||||
drawGlobe();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$: if (ctx && currentHeading !== undefined) {
|
|
||||||
drawGlobe();
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawGlobe() {
|
|
||||||
if (!ctx) return;
|
|
||||||
|
|
||||||
const width = canvas.width;
|
|
||||||
const height = canvas.height;
|
|
||||||
const centerX = width / 2;
|
|
||||||
const centerY = height / 2;
|
|
||||||
const radius = Math.min(width, height) / 2 - 20;
|
|
||||||
|
|
||||||
// Clear canvas
|
|
||||||
ctx.clearRect(0, 0, width, height);
|
|
||||||
|
|
||||||
// Draw globe circle
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.arc(centerX, centerY, radius, 0, 2 * Math.PI);
|
|
||||||
ctx.strokeStyle = '#444';
|
|
||||||
ctx.lineWidth = 2;
|
|
||||||
ctx.stroke();
|
|
||||||
|
|
||||||
// Draw grid lines (latitude/longitude)
|
|
||||||
ctx.strokeStyle = '#333';
|
|
||||||
ctx.lineWidth = 1;
|
|
||||||
|
|
||||||
// Latitude lines
|
|
||||||
for (let i = 1; i < 4; i++) {
|
|
||||||
const y = centerY - radius + (radius * 2 * i / 4);
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.moveTo(centerX - radius, y);
|
|
||||||
ctx.lineTo(centerX + radius, y);
|
|
||||||
ctx.stroke();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Longitude lines
|
|
||||||
for (let i = 1; i < 4; i++) {
|
|
||||||
const x = centerX - radius + (radius * 2 * i / 4);
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.moveTo(x, centerY - radius);
|
|
||||||
ctx.lineTo(x, centerY + radius);
|
|
||||||
ctx.stroke();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw cardinal directions
|
|
||||||
ctx.fillStyle = '#888';
|
|
||||||
ctx.font = '14px Roboto';
|
|
||||||
ctx.textAlign = 'center';
|
|
||||||
ctx.textBaseline = 'middle';
|
|
||||||
|
|
||||||
ctx.fillText('N', centerX, centerY - radius - 10);
|
|
||||||
ctx.fillText('S', centerX, centerY + radius + 10);
|
|
||||||
ctx.fillText('E', centerX + radius + 10, centerY);
|
|
||||||
ctx.fillText('W', centerX - radius - 10, centerY);
|
|
||||||
|
|
||||||
// Draw heading indicator
|
|
||||||
const angle = (currentHeading - 90) * Math.PI / 180;
|
|
||||||
const lineLength = radius - 10;
|
|
||||||
const endX = centerX + Math.cos(angle) * lineLength;
|
|
||||||
const endY = centerY + Math.sin(angle) * lineLength;
|
|
||||||
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.moveTo(centerX, centerY);
|
|
||||||
ctx.lineTo(endX, endY);
|
|
||||||
ctx.strokeStyle = '#00bcd4';
|
|
||||||
ctx.lineWidth = 3;
|
|
||||||
ctx.stroke();
|
|
||||||
|
|
||||||
// Draw arrow head
|
|
||||||
const arrowSize = 15;
|
|
||||||
const arrowAngle1 = angle + Math.PI * 0.85;
|
|
||||||
const arrowAngle2 = angle - Math.PI * 0.85;
|
|
||||||
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.moveTo(endX, endY);
|
|
||||||
ctx.lineTo(endX + Math.cos(arrowAngle1) * arrowSize, endY + Math.sin(arrowAngle1) * arrowSize);
|
|
||||||
ctx.moveTo(endX, endY);
|
|
||||||
ctx.lineTo(endX + Math.cos(arrowAngle2) * arrowSize, endY + Math.sin(arrowAngle2) * arrowSize);
|
|
||||||
ctx.strokeStyle = '#00bcd4';
|
|
||||||
ctx.lineWidth = 3;
|
|
||||||
ctx.stroke();
|
|
||||||
|
|
||||||
// Draw center dot
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.arc(centerX, centerY, 5, 0, 2 * Math.PI);
|
|
||||||
ctx.fillStyle = '#f44336';
|
|
||||||
ctx.fill();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function moveToHeading() {
|
|
||||||
const heading = parseInt(targetInput);
|
|
||||||
if (isNaN(heading) || heading < 0 || heading > 360) {
|
|
||||||
alert('Please enter a valid heading (0-360)');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await api.rotator.move(1, heading);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to move rotator:', err);
|
|
||||||
alert('Failed to move rotator');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function rotateCW() {
|
|
||||||
try {
|
|
||||||
await api.rotator.cw(1);
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to rotate CW:', err);
|
console.error('Failed to rotate CW:', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
async function rotateCCW() {
|
async function rotateCCW() {
|
||||||
try {
|
try {
|
||||||
await api.rotator.rotateCCW();
|
await api.rotator.rotateCCW();
|
||||||
=======
|
|
||||||
|
|
||||||
async function rotateCCW() {
|
|
||||||
try {
|
|
||||||
await api.rotator.ccw(1);
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to rotate CCW:', err);
|
console.error('Failed to rotate CCW:', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
async function stop() {
|
async function stop() {
|
||||||
try {
|
try {
|
||||||
await api.rotator.stop();
|
await api.rotator.stop();
|
||||||
@@ -191,7 +46,6 @@
|
|||||||
console.error('Failed to stop:', err);
|
console.error('Failed to stop:', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@@ -209,7 +63,7 @@
|
|||||||
|
|
||||||
<!-- Map with Beam -->
|
<!-- Map with Beam -->
|
||||||
<div class="map-container">
|
<div class="map-container">
|
||||||
<svg viewBox="0 0 500 500" class="map-svg">
|
<svg viewBox="0 0 300 300" class="map-svg">
|
||||||
<defs>
|
<defs>
|
||||||
<!-- Gradient for beam -->
|
<!-- Gradient for beam -->
|
||||||
<radialGradient id="beamGradient">
|
<radialGradient id="beamGradient">
|
||||||
@@ -219,137 +73,59 @@
|
|||||||
</defs>
|
</defs>
|
||||||
|
|
||||||
<!-- Ocean background -->
|
<!-- Ocean background -->
|
||||||
<circle cx="250" cy="250" r="240" fill="rgba(30, 64, 175, 0.2)" stroke="rgba(79, 195, 247, 0.4)" stroke-width="3"/>
|
<circle cx="150" cy="150" r="140" fill="rgba(30, 64, 175, 0.15)" stroke="rgba(79, 195, 247, 0.4)" stroke-width="2"/>
|
||||||
|
|
||||||
<!-- Simplified world map (Azimuthal centered on France ~46°N 6°E) -->
|
|
||||||
<g transform="translate(250, 250)" opacity="0.5">
|
|
||||||
|
|
||||||
<!-- Europe (enlarged and centered) -->
|
|
||||||
<!-- France -->
|
|
||||||
<path d="M -20,-15 L -15,-25 L -5,-28 L 5,-25 L 10,-18 L 8,-8 L 0,-5 L -10,-8 L -18,-12 Z"
|
|
||||||
fill="#4CAF50" stroke="#81C784" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- Spain/Portugal -->
|
|
||||||
<path d="M -30,-8 L -22,-12 L -18,-8 L -20,0 L -25,5 L -32,3 L -35,-2 Z"
|
|
||||||
fill="#4CAF50" stroke="#81C784" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- Italy -->
|
|
||||||
<path d="M 5,-10 L 10,-12 L 15,-8 L 18,5 L 15,15 L 10,12 L 8,0 Z"
|
|
||||||
fill="#4CAF50" stroke="#81C784" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- Germany/Central Europe -->
|
|
||||||
<path d="M -5,-28 L 5,-32 L 15,-30 L 20,-22 L 15,-18 L 5,-20 L 0,-25 Z"
|
|
||||||
fill="#4CAF50" stroke="#81C784" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- UK/Ireland -->
|
|
||||||
<path d="M -45,-25 L -40,-32 L -32,-35 L -28,-28 L -32,-20 L -40,-22 Z"
|
|
||||||
fill="#4CAF50" stroke="#81C784" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- Scandinavia -->
|
|
||||||
<path d="M 0,-40 L 10,-50 L 20,-48 L 25,-38 L 20,-32 L 10,-35 L 5,-38 Z"
|
|
||||||
fill="#66BB6A" stroke="#81C784" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- Eastern Europe/Russia West -->
|
|
||||||
<path d="M 20,-35 L 35,-40 L 50,-35 L 55,-20 L 50,-10 L 35,-8 L 25,-15 Z"
|
|
||||||
fill="#66BB6A" stroke="#81C784" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- North Africa -->
|
|
||||||
<path d="M -35,10 L -20,8 L 0,12 L 15,18 L 10,35 L -5,40 L -25,35 L -35,25 Z"
|
|
||||||
fill="#FFA726" stroke="#FFB74D" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- Sub-Saharan Africa -->
|
|
||||||
<path d="M -20,42 L 0,45 L 15,50 L 20,70 L 10,95 L -10,100 L -30,90 L -35,70 L -30,50 Z"
|
|
||||||
fill="#FF9800" stroke="#FFB74D" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- Middle East -->
|
|
||||||
<path d="M 25,0 L 40,5 L 55,10 L 60,25 L 55,38 L 42,42 L 30,35 L 22,20 Z"
|
|
||||||
fill="#FFEB3B" stroke="#FFF176" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- Russia East/Central Asia -->
|
|
||||||
<path d="M 60,-30 L 90,-35 L 120,-25 L 135,-10 L 140,15 L 130,30 L 105,35 L 80,28 L 65,10 L 62,-10 Z"
|
|
||||||
fill="#AB47BC" stroke="#BA68C8" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- India/South Asia -->
|
|
||||||
<path d="M 70,40 L 85,38 L 95,45 L 98,60 L 92,75 L 78,80 L 68,72 L 65,55 Z"
|
|
||||||
fill="#EC407A" stroke="#F06292" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- China/East Asia -->
|
|
||||||
<path d="M 110,0 L 135,5 L 150,18 L 155,35 L 145,52 L 125,58 L 105,50 L 95,32 L 100,15 Z"
|
|
||||||
fill="#7E57C2" stroke="#9575CD" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- Japan -->
|
|
||||||
<path d="M 165,25 L 172,22 L 178,28 L 175,40 L 168,45 L 162,42 L 160,32 Z"
|
|
||||||
fill="#E91E63" stroke="#F06292" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- North America -->
|
|
||||||
<path d="M -140,-40 L -110,-50 L -80,-48 L -60,-35 L -55,-15 L -65,5 L -85,15 L -110,12 L -135,-5 L -145,-25 Z"
|
|
||||||
fill="#42A5F5" stroke="#64B5F6" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- Central America -->
|
|
||||||
<path d="M -75,20 L -65,18 L -55,25 L -58,35 L -68,38 L -78,32 Z"
|
|
||||||
fill="#29B6F6" stroke="#4FC3F7" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- South America -->
|
|
||||||
<path d="M -70,45 L -60,42 L -48,50 L -45,70 L -50,100 L -60,120 L -75,125 L -88,115 L -92,90 L -85,65 L -78,52 Z"
|
|
||||||
fill="#26C6DA" stroke="#4DD0E1" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
<!-- Australia -->
|
|
||||||
<path d="M 130,95 L 155,92 L 175,100 L 180,120 L 170,135 L 145,138 L 125,128 L 122,110 Z"
|
|
||||||
fill="#66BB6A" stroke="#81C784" stroke-width="1.5"/>
|
|
||||||
|
|
||||||
</g>
|
|
||||||
|
|
||||||
<!-- Distance circles -->
|
<!-- Distance circles -->
|
||||||
<circle cx="250" cy="250" r="180" fill="none" stroke="rgba(79,195,247,0.2)" stroke-width="1" stroke-dasharray="4,4"/>
|
<circle cx="150" cy="150" r="105" fill="none" stroke="rgba(79,195,247,0.2)" stroke-width="1" stroke-dasharray="3,3"/>
|
||||||
<circle cx="250" cy="250" r="120" fill="none" stroke="rgba(79,195,247,0.2)" stroke-width="1" stroke-dasharray="4,4"/>
|
<circle cx="150" cy="150" r="70" fill="none" stroke="rgba(79,195,247,0.2)" stroke-width="1" stroke-dasharray="3,3"/>
|
||||||
<circle cx="250" cy="250" r="60" fill="none" stroke="rgba(79,195,247,0.2)" stroke-width="1" stroke-dasharray="4,4"/>
|
<circle cx="150" cy="150" r="35" fill="none" stroke="rgba(79,195,247,0.2)" stroke-width="1" stroke-dasharray="3,3"/>
|
||||||
|
|
||||||
<!-- Rotated group for beam -->
|
<!-- Rotated group for beam -->
|
||||||
<g transform="translate(250, 250)">
|
<g transform="translate(150, 150)">
|
||||||
<!-- Beam (rotates with heading) -->
|
<!-- Beam (rotates with heading) -->
|
||||||
<g transform="rotate({heading})">
|
<g transform="rotate({heading})">
|
||||||
<!-- Beam sector (±15° = 30° total beamwidth) -->
|
<!-- Beam sector (±15° = 30° total beamwidth) -->
|
||||||
<path d="M 0,0 L {-Math.sin(15 * Math.PI/180) * 220},{-Math.cos(15 * Math.PI/180) * 220}
|
<path d="M 0,0 L {-Math.sin(15 * Math.PI/180) * 130},{-Math.cos(15 * Math.PI/180) * 130}
|
||||||
A 220,220 0 0,1 {Math.sin(15 * Math.PI/180) * 220},{-Math.cos(15 * Math.PI/180) * 220} Z"
|
A 130,130 0 0,1 {Math.sin(15 * Math.PI/180) * 130},{-Math.cos(15 * Math.PI/180) * 130} Z"
|
||||||
fill="url(#beamGradient)"
|
fill="url(#beamGradient)"
|
||||||
opacity="0.85"/>
|
opacity="0.85"/>
|
||||||
|
|
||||||
<!-- Beam outline -->
|
<!-- Beam outline -->
|
||||||
<line x1="0" y1="0" x2={-Math.sin(15 * Math.PI/180) * 220} y2={-Math.cos(15 * Math.PI/180) * 220}
|
<line x1="0" y1="0" x2={-Math.sin(15 * Math.PI/180) * 130} y2={-Math.cos(15 * Math.PI/180) * 130}
|
||||||
stroke="#4fc3f7" stroke-width="3" opacity="0.9"/>
|
stroke="#4fc3f7" stroke-width="2" opacity="0.9"/>
|
||||||
<line x1="0" y1="0" x2={Math.sin(15 * Math.PI/180) * 220} y2={-Math.cos(15 * Math.PI/180) * 220}
|
<line x1="0" y1="0" x2={Math.sin(15 * Math.PI/180) * 130} y2={-Math.cos(15 * Math.PI/180) * 130}
|
||||||
stroke="#4fc3f7" stroke-width="3" opacity="0.9"/>
|
stroke="#4fc3f7" stroke-width="2" opacity="0.9"/>
|
||||||
|
|
||||||
<!-- Direction arrow -->
|
<!-- Direction arrow -->
|
||||||
<g transform="translate(0, -190)">
|
<g transform="translate(0, -110)">
|
||||||
<polygon points="0,-30 -12,8 0,0 12,8"
|
<polygon points="0,-20 -8,5 0,0 8,5"
|
||||||
fill="#4fc3f7"
|
fill="#4fc3f7"
|
||||||
stroke="#0288d1"
|
stroke="#0288d1"
|
||||||
stroke-width="3"
|
stroke-width="2"
|
||||||
style="filter: drop-shadow(0 0 15px rgba(79, 195, 247, 1))"/>
|
style="filter: drop-shadow(0 0 10px rgba(79, 195, 247, 1))"/>
|
||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
|
|
||||||
<!-- Center dot (your QTH - JN36dg) -->
|
<!-- Center dot (your QTH - JN36dg) -->
|
||||||
<circle cx="0" cy="0" r="6" fill="#f44336" stroke="#fff" stroke-width="3">
|
<circle cx="0" cy="0" r="5" fill="#f44336" stroke="#fff" stroke-width="2">
|
||||||
<animate attributeName="r" values="6;9;6" dur="2s" repeatCount="indefinite"/>
|
<animate attributeName="r" values="5;7;5" dur="2s" repeatCount="indefinite"/>
|
||||||
</circle>
|
</circle>
|
||||||
<circle cx="0" cy="0" r="12" fill="none" stroke="#f44336" stroke-width="2" opacity="0.5">
|
<circle cx="0" cy="0" r="10" fill="none" stroke="#f44336" stroke-width="1.5" opacity="0.5">
|
||||||
<animate attributeName="r" values="12;20;12" dur="2s" repeatCount="indefinite"/>
|
<animate attributeName="r" values="10;16;10" dur="2s" repeatCount="indefinite"/>
|
||||||
<animate attributeName="opacity" values="0.5;0;0.5" dur="2s" repeatCount="indefinite"/>
|
<animate attributeName="opacity" values="0.5;0;0.5" dur="2s" repeatCount="indefinite"/>
|
||||||
</circle>
|
</circle>
|
||||||
</g>
|
</g>
|
||||||
|
|
||||||
<!-- Cardinal points -->
|
<!-- Cardinal points -->
|
||||||
<text x="250" y="30" text-anchor="middle" class="cardinal">N</text>
|
<text x="150" y="20" text-anchor="middle" class="cardinal">N</text>
|
||||||
<text x="470" y="255" text-anchor="middle" class="cardinal">E</text>
|
<text x="280" y="155" text-anchor="middle" class="cardinal">E</text>
|
||||||
<text x="250" y="480" text-anchor="middle" class="cardinal">S</text>
|
<text x="150" y="285" text-anchor="middle" class="cardinal">S</text>
|
||||||
<text x="30" y="255" text-anchor="middle" class="cardinal">W</text>
|
<text x="20" y="155" text-anchor="middle" class="cardinal">W</text>
|
||||||
|
|
||||||
<!-- Degree markers every 30° -->
|
<!-- Degree markers every 45° -->
|
||||||
{#each [30, 60, 120, 150, 210, 240, 300, 330] as angle}
|
{#each [45, 135, 225, 315] as angle}
|
||||||
{@const x = 250 + 215 * Math.sin(angle * Math.PI / 180)}
|
{@const x = 150 + 125 * Math.sin(angle * Math.PI / 180)}
|
||||||
{@const y = 250 - 215 * Math.cos(angle * Math.PI / 180)}
|
{@const y = 150 - 125 * Math.cos(angle * Math.PI / 180)}
|
||||||
<text x={x} y={y} text-anchor="middle" dominant-baseline="middle" class="degree-label">{angle}°</text>
|
<text x={x} y={y} text-anchor="middle" dominant-baseline="middle" class="degree-label">{angle}°</text>
|
||||||
{/each}
|
{/each}
|
||||||
</svg>
|
</svg>
|
||||||
@@ -467,7 +243,7 @@
|
|||||||
|
|
||||||
.map-svg {
|
.map-svg {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 500px;
|
max-width: 300px;
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,187 +345,5 @@
|
|||||||
.arrow {
|
.arrow {
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
=======
|
|
||||||
|
|
||||||
// Preset directions
|
|
||||||
const presets = [
|
|
||||||
{ name: 'EU-0', heading: 0 },
|
|
||||||
{ name: 'JA-35', heading: 35 },
|
|
||||||
{ name: 'AS-75', heading: 75 },
|
|
||||||
{ name: 'VK-120', heading: 120 },
|
|
||||||
{ name: 'AF-180', heading: 180 },
|
|
||||||
{ name: 'SA-230', heading: 230 },
|
|
||||||
{ name: 'WI-270', heading: 270 },
|
|
||||||
{ name: 'NA-300', heading: 300 }
|
|
||||||
];
|
|
||||||
|
|
||||||
async function gotoPreset(heading) {
|
|
||||||
try {
|
|
||||||
await api.rotator.move(1, heading);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to move to preset:', err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="rotator-card card">
|
|
||||||
<h2>
|
|
||||||
ROTATOR GENIUS
|
|
||||||
<span class="status-indicator" class:status-online={connected} class:status-offline={!connected}></span>
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<div class="heading-display">
|
|
||||||
CURRENT HEADING: <span class="heading-value">{currentHeading}°</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{#if moving > 0}
|
|
||||||
<div class="moving-indicator">
|
|
||||||
{moving === 1 ? '↻ ROTATING CW' : '↺ ROTATING CCW'}
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<canvas bind:this={canvas} width="300" height="300"></canvas>
|
|
||||||
|
|
||||||
<div class="controls">
|
|
||||||
<div class="heading-input">
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
min="0"
|
|
||||||
max="360"
|
|
||||||
bind:value={targetInput}
|
|
||||||
placeholder="Enter heading"
|
|
||||||
/>
|
|
||||||
<button class="btn btn-primary" on:click={moveToHeading}>GO</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="rotation-controls">
|
|
||||||
<button class="btn btn-secondary" on:click={rotateCCW}>↺ CCW</button>
|
|
||||||
<button class="btn btn-danger" on:click={stop}>STOP</button>
|
|
||||||
<button class="btn btn-secondary" on:click={rotateCW}>CW ↻</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="presets">
|
|
||||||
{#each presets as preset}
|
|
||||||
<button
|
|
||||||
class="preset-btn"
|
|
||||||
class:active={Math.abs(currentHeading - preset.heading) < 5}
|
|
||||||
on:click={() => gotoPreset(preset.heading)}
|
|
||||||
>
|
|
||||||
{preset.name}
|
|
||||||
</button>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.rotator-card {
|
|
||||||
min-width: 350px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--accent-teal);
|
|
||||||
}
|
|
||||||
|
|
||||||
.heading-display {
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 500;
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
padding: 12px;
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
border-radius: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.heading-value {
|
|
||||||
color: var(--accent-blue);
|
|
||||||
font-size: 24px;
|
|
||||||
margin-left: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.moving-indicator {
|
|
||||||
text-align: center;
|
|
||||||
padding: 8px;
|
|
||||||
background: var(--accent-green);
|
|
||||||
color: white;
|
|
||||||
border-radius: 4px;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
font-weight: 500;
|
|
||||||
animation: pulse 1.5s ease-in-out infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes pulse {
|
|
||||||
0%, 100% { opacity: 1; }
|
|
||||||
50% { opacity: 0.7; }
|
|
||||||
}
|
|
||||||
|
|
||||||
canvas {
|
|
||||||
display: block;
|
|
||||||
margin: 16px auto;
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.controls {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 12px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.heading-input {
|
|
||||||
display: flex;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.heading-input input {
|
|
||||||
flex: 1;
|
|
||||||
padding: 12px;
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
color: var(--text-primary);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: 4px;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rotation-controls {
|
|
||||||
display: flex;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rotation-controls button {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.presets {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(4, 1fr);
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.preset-btn {
|
|
||||||
padding: 12px 8px;
|
|
||||||
background: var(--accent-blue);
|
|
||||||
color: white;
|
|
||||||
border-radius: 4px;
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 500;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.preset-btn:hover {
|
|
||||||
background: #1976d2;
|
|
||||||
transform: translateY(-2px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.preset-btn.active {
|
|
||||||
background: var(--accent-green);
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import { api } from '../lib/api.js';
|
import { api } from '../lib/api.js';
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
export let status;
|
export let status;
|
||||||
|
|
||||||
@@ -44,53 +43,10 @@
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to set operate:', err);
|
console.error('Failed to set operate:', err);
|
||||||
alert('Failed to set operate');
|
alert('Failed to set operate');
|
||||||
=======
|
|
||||||
|
|
||||||
export let status;
|
|
||||||
|
|
||||||
$: operate = status?.operate || false;
|
|
||||||
$: activeAntenna = status?.active_antenna || 0;
|
|
||||||
$: tuningStatus = status?.tuning_status || 'READY';
|
|
||||||
$: frequencyA = status?.frequency_a || 0;
|
|
||||||
$: frequencyB = status?.frequency_b || 0;
|
|
||||||
$: c1 = status?.c1 || 0;
|
|
||||||
$: l = status?.l || 0;
|
|
||||||
$: c2 = status?.c2 || 0;
|
|
||||||
$: connected = status?.connected || false;
|
|
||||||
|
|
||||||
let tuning = false;
|
|
||||||
|
|
||||||
async function toggleOperate() {
|
|
||||||
try {
|
|
||||||
await api.tuner.operate(!operate);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to toggle operate:', err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function startTune() {
|
|
||||||
tuning = true;
|
|
||||||
try {
|
|
||||||
await api.tuner.tune();
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to tune:', err);
|
|
||||||
alert('Tuning failed');
|
|
||||||
} finally {
|
|
||||||
tuning = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function setAntenna(ant) {
|
|
||||||
try {
|
|
||||||
await api.tuner.antenna(ant);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to set antenna:', err);
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h2>Tuner Genius XL</h2>
|
<h2>Tuner Genius XL</h2>
|
||||||
@@ -484,218 +440,10 @@
|
|||||||
border-color: var(--accent-cyan);
|
border-color: var(--accent-cyan);
|
||||||
color: #000;
|
color: #000;
|
||||||
box-shadow: 0 0 15px rgba(79, 195, 247, 0.5);
|
box-shadow: 0 0 15px rgba(79, 195, 247, 0.5);
|
||||||
=======
|
|
||||||
<div class="tuner-card card">
|
|
||||||
<h2>
|
|
||||||
TGXL
|
|
||||||
<span class="status-indicator" class:status-online={connected} class:status-offline={!connected}></span>
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<div class="power-status">
|
|
||||||
<div class="label">Power 0.0w</div>
|
|
||||||
<div class="status-badge">1500</div>
|
|
||||||
<div class="status-badge">1650</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="tuning-controls">
|
|
||||||
<div class="tuning-row">
|
|
||||||
<div class="tuning-label">TG XL SWR 1.00 use</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="antenna-buttons">
|
|
||||||
<button
|
|
||||||
class="antenna-btn"
|
|
||||||
class:active={activeAntenna === 0}
|
|
||||||
on:click={() => setAntenna(0)}
|
|
||||||
>
|
|
||||||
C1
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="antenna-btn"
|
|
||||||
class:active={activeAntenna === 1}
|
|
||||||
on:click={() => setAntenna(1)}
|
|
||||||
>
|
|
||||||
L
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="antenna-btn"
|
|
||||||
class:active={activeAntenna === 2}
|
|
||||||
on:click={() => setAntenna(2)}
|
|
||||||
>
|
|
||||||
C2
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="tuning-values">
|
|
||||||
<div class="value-box">
|
|
||||||
<div class="value">{c1}</div>
|
|
||||||
<div class="label">C1</div>
|
|
||||||
</div>
|
|
||||||
<div class="value-box">
|
|
||||||
<div class="value">{l}</div>
|
|
||||||
<div class="label">L</div>
|
|
||||||
</div>
|
|
||||||
<div class="value-box">
|
|
||||||
<div class="value">{c2}</div>
|
|
||||||
<div class="label">C2</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="status-row">
|
|
||||||
<div class="metric">
|
|
||||||
<div class="label">Tuning Status</div>
|
|
||||||
<div class="status-badge" class:tuning={tuningStatus === 'TUNING'}>
|
|
||||||
{tuningStatus}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="frequency-row">
|
|
||||||
<div class="metric">
|
|
||||||
<div class="label">Frequency A</div>
|
|
||||||
<div class="value-display">{(frequencyA / 1000).toFixed(3)}</div>
|
|
||||||
</div>
|
|
||||||
<div class="metric">
|
|
||||||
<div class="label">Frequency B</div>
|
|
||||||
<div class="value-display">{(frequencyB / 1000).toFixed(3)}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="action-buttons">
|
|
||||||
<button
|
|
||||||
class="btn"
|
|
||||||
class:btn-primary={!operate}
|
|
||||||
class:btn-danger={operate}
|
|
||||||
on:click={toggleOperate}
|
|
||||||
>
|
|
||||||
{operate ? 'STANDBY' : 'OPERATE'}
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-secondary" disabled>BYPASS</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button
|
|
||||||
class="btn btn-danger tune-btn"
|
|
||||||
disabled={tuning || !operate}
|
|
||||||
on:click={startTune}
|
|
||||||
>
|
|
||||||
{tuning ? 'TUNING...' : 'TUNE'}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.tuner-card {
|
|
||||||
min-width: 350px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--accent-teal);
|
|
||||||
}
|
|
||||||
|
|
||||||
.power-status {
|
|
||||||
display: flex;
|
|
||||||
gap: 12px;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-badge {
|
|
||||||
padding: 4px 12px;
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: 4px;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-badge.tuning {
|
|
||||||
background: var(--accent-green);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tuning-controls {
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tuning-label {
|
|
||||||
font-size: 12px;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.antenna-buttons {
|
|
||||||
display: flex;
|
|
||||||
gap: 8px;
|
|
||||||
margin: 12px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.antenna-btn {
|
|
||||||
flex: 1;
|
|
||||||
padding: 12px;
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
color: var(--text-primary);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: 4px;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.antenna-btn.active {
|
|
||||||
background: var(--accent-blue);
|
|
||||||
border-color: var(--accent-blue);
|
|
||||||
}
|
|
||||||
|
|
||||||
.tuning-values {
|
|
||||||
display: flex;
|
|
||||||
gap: 12px;
|
|
||||||
margin: 16px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.value-box {
|
|
||||||
flex: 1;
|
|
||||||
text-align: center;
|
|
||||||
padding: 12px;
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.value-box .value {
|
|
||||||
font-size: 20px;
|
|
||||||
font-weight: 300;
|
|
||||||
color: var(--accent-teal);
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-row {
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.frequency-row {
|
|
||||||
display: flex;
|
|
||||||
gap: 16px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.metric {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-buttons {
|
|
||||||
display: flex;
|
|
||||||
gap: 12px;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-buttons button {
|
|
||||||
flex: 1;
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tune-btn {
|
.tune-btn {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
<<<<<<< HEAD
|
|
||||||
padding: 14px;
|
padding: 14px;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
@@ -725,7 +473,5 @@
|
|||||||
|
|
||||||
.tune-icon {
|
.tune-icon {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
=======
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -4,10 +4,7 @@
|
|||||||
export let status;
|
export let status;
|
||||||
|
|
||||||
$: relays = status?.relays || [];
|
$: relays = status?.relays || [];
|
||||||
<<<<<<< HEAD
|
|
||||||
$: connected = status?.connected || false;
|
$: connected = status?.connected || false;
|
||||||
=======
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
|
|
||||||
const relayNames = {
|
const relayNames = {
|
||||||
1: 'Power Supply',
|
1: 'Power Supply',
|
||||||
@@ -55,7 +52,6 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h2>WebSwitch</h2>
|
<h2>WebSwitch</h2>
|
||||||
@@ -99,40 +95,10 @@
|
|||||||
ALL OFF
|
ALL OFF
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
=======
|
|
||||||
<div class="webswitch-card card">
|
|
||||||
<h2>
|
|
||||||
1216RH
|
|
||||||
<span class="status-indicator" class:status-online={relays.length > 0} class:status-offline={relays.length === 0}></span>
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<div class="relays">
|
|
||||||
{#each [1, 2, 3, 4, 5] as relayNum}
|
|
||||||
{@const relay = relays.find(r => r.number === relayNum)}
|
|
||||||
{@const isOn = relay?.state || false}
|
|
||||||
<div class="relay-row">
|
|
||||||
<span class="relay-name">{relayNames[relayNum]}</span>
|
|
||||||
<button
|
|
||||||
class="relay-toggle"
|
|
||||||
class:active={isOn}
|
|
||||||
disabled={loading[relayNum]}
|
|
||||||
on:click={() => toggleRelay(relayNum)}
|
|
||||||
>
|
|
||||||
<div class="toggle-icon"></div>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="controls">
|
|
||||||
<button class="btn btn-primary" on:click={allOn}>ALL ON</button>
|
|
||||||
<button class="btn btn-danger" on:click={allOff}>ALL OFF</button>
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
<<<<<<< HEAD
|
|
||||||
.card {
|
.card {
|
||||||
background: linear-gradient(135deg, #1a2332 0%, #0f1923 100%);
|
background: linear-gradient(135deg, #1a2332 0%, #0f1923 100%);
|
||||||
border: 1px solid #2d3748;
|
border: 1px solid #2d3748;
|
||||||
@@ -335,73 +301,5 @@
|
|||||||
|
|
||||||
.all-off:hover {
|
.all-off:hover {
|
||||||
box-shadow: 0 6px 16px rgba(244, 67, 54, 0.5);
|
box-shadow: 0 6px 16px rgba(244, 67, 54, 0.5);
|
||||||
=======
|
|
||||||
.webswitch-card {
|
|
||||||
min-width: 280px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--accent-teal);
|
|
||||||
}
|
|
||||||
|
|
||||||
.relays {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 12px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.relay-row {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.relay-name {
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.relay-toggle {
|
|
||||||
width: 60px;
|
|
||||||
height: 32px;
|
|
||||||
background: #555;
|
|
||||||
border-radius: 16px;
|
|
||||||
position: relative;
|
|
||||||
transition: background 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.relay-toggle.active {
|
|
||||||
background: var(--accent-green);
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle-icon {
|
|
||||||
width: 24px;
|
|
||||||
height: 24px;
|
|
||||||
background: white;
|
|
||||||
border-radius: 50%;
|
|
||||||
position: absolute;
|
|
||||||
top: 4px;
|
|
||||||
left: 4px;
|
|
||||||
transition: transform 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.relay-toggle.active .toggle-icon {
|
|
||||||
transform: translateX(28px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.controls {
|
|
||||||
display: flex;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.controls button {
|
|
||||||
flex: 1;
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -47,7 +47,6 @@ export const api = {
|
|||||||
|
|
||||||
// Tuner
|
// Tuner
|
||||||
tuner: {
|
tuner: {
|
||||||
<<<<<<< HEAD
|
|
||||||
setOperate: (value) => request('/tuner/operate', {
|
setOperate: (value) => request('/tuner/operate', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ value }),
|
body: JSON.stringify({ value }),
|
||||||
@@ -57,33 +56,15 @@ export const api = {
|
|||||||
body: JSON.stringify({ value }),
|
body: JSON.stringify({ value }),
|
||||||
}),
|
}),
|
||||||
autoTune: () => request('/tuner/autotune', { method: 'POST' }),
|
autoTune: () => request('/tuner/autotune', { method: 'POST' }),
|
||||||
=======
|
|
||||||
operate: (operate) => request('/tuner/operate', {
|
|
||||||
method: 'POST',
|
|
||||||
body: JSON.stringify({ operate }),
|
|
||||||
}),
|
|
||||||
tune: () => request('/tuner/tune', { method: 'POST' }),
|
|
||||||
antenna: (antenna) => request('/tuner/antenna', {
|
|
||||||
method: 'POST',
|
|
||||||
body: JSON.stringify({ antenna }),
|
|
||||||
}),
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Antenna Genius
|
// Antenna Genius
|
||||||
antenna: {
|
antenna: {
|
||||||
<<<<<<< HEAD
|
|
||||||
selectAntenna: (port, antenna) => request('/antenna/select', {
|
selectAntenna: (port, antenna) => request('/antenna/select', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ port, antenna }),
|
body: JSON.stringify({ port, antenna }),
|
||||||
}),
|
}),
|
||||||
reboot: () => request('/antenna/reboot', { method: 'POST' }),
|
reboot: () => request('/antenna/reboot', { method: 'POST' }),
|
||||||
=======
|
|
||||||
set: (radio, antenna) => request('/antenna/set', {
|
|
||||||
method: 'POST',
|
|
||||||
body: JSON.stringify({ radio, antenna }),
|
|
||||||
}),
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Power Genius
|
// Power Genius
|
||||||
@@ -92,7 +73,6 @@ export const api = {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ mode }),
|
body: JSON.stringify({ mode }),
|
||||||
}),
|
}),
|
||||||
<<<<<<< HEAD
|
|
||||||
setOperate: (value) => request('/power/operate', {
|
setOperate: (value) => request('/power/operate', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ value }),
|
body: JSON.stringify({ value }),
|
||||||
@@ -108,7 +88,5 @@ export const api = {
|
|||||||
rotateCW: () => request('/rotator/cw', { method: 'POST' }),
|
rotateCW: () => request('/rotator/cw', { method: 'POST' }),
|
||||||
rotateCCW: () => request('/rotator/ccw', { method: 'POST' }),
|
rotateCCW: () => request('/rotator/ccw', { method: 'POST' }),
|
||||||
stop: () => request('/rotator/stop', { method: 'POST' }),
|
stop: () => request('/rotator/stop', { method: 'POST' }),
|
||||||
=======
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -28,10 +28,7 @@ class WebSocketService {
|
|||||||
const message = JSON.parse(event.data);
|
const message = JSON.parse(event.data);
|
||||||
|
|
||||||
if (message.type === 'update') {
|
if (message.type === 'update') {
|
||||||
<<<<<<< HEAD
|
|
||||||
console.log('System status updated:', message.data);
|
console.log('System status updated:', message.data);
|
||||||
=======
|
|
||||||
>>>>>>> 4ab192418e21065c68d59777493ea03b76c061e7
|
|
||||||
systemStatus.set(message.data);
|
systemStatus.set(message.data);
|
||||||
lastUpdate.set(new Date(message.timestamp));
|
lastUpdate.set(new Date(message.timestamp));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user