2026-06-13 11:56 Grundlogik Server - Relais - Rig - Rotor ohne vernünftige GUI
This commit is contained in:
commit
17e70ec914
21 changed files with 2793 additions and 0 deletions
80
Notizen.txt
Normal file
80
Notizen.txt
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
Funktionsprinzip:
|
||||
|
||||
[ RASPBERRY PI (Server) ] [ CLIENTS (Fyne.io via Tailscale) ]
|
||||
+-------------------+ +-----------------------+ +---------------------------------+
|
||||
|
||||
| Yaesu, Icom, etc. | <---> | rig-service (Go) | <========> | [ Client 1: Rig-Control Window ]
|
||||
| SPID, Yaesu Rotor | <---> | rotor-service (Go) | gRPC / | (Operator: Full control + TX) |
|
||||
| Relais-Boards | <---> | gpio-service (Go) | Protobuf +---------------------------------+
|
||||
+-------------------+ +-----------------------+ +---------------------------------+
|
||||
|
||||
| Soundkarte / TRX | <---> | audio-service (Opus) | <========> | [ Client 2: Rotor Window ] |
|
||||
+-------------------+ +-----------------------+ | (Listener: View only + RX) |
|
||||
+---------------------------------+
|
||||
|
||||
mkdir -p remote-shack/{api,cmd/{server,client-rig,client-rotor,client-relais},internal/{config,driver,audio}}
|
||||
|
||||
remote-shack/
|
||||
├── api/ # Protobuf-Definitionen für gRPC (.proto)
|
||||
├── cmd/
|
||||
│ ├── server/ # Das Hauptprogramm für den Raspberry Pi
|
||||
│ └── client-rig/ # Fyne-Fenster für Funkgerät
|
||||
│ └── client-rotor/ # Fyne-Fenster für Rotor
|
||||
│ └── client-relais/ # Fyne-Fenster für Relais
|
||||
├── internal/
|
||||
│ ├── config/ # Konfigurations-Parser (TOML/YAML)
|
||||
│ ├── driver/ # Native Go-Treiber (CI-V, Kenwood, SPID)
|
||||
│ └── audio/ # Opus/UDP Audio-Streaming-Logik
|
||||
└── go.mod
|
||||
|
||||
|
||||
# Zum Zeichnen der GUI wird fyne verwendet
|
||||
go get fyne.io/fyne/v2
|
||||
go mod tidy
|
||||
|
||||
# Für Cross-Compiling den Grafiktreiber für Windows installieren
|
||||
sudo apt-get install mingw-w64
|
||||
|
||||
# Pakete für Kompilieren der Linux-GUI
|
||||
sudo apt-get update && sudo apt-get install -y \
|
||||
libx11-dev \
|
||||
libxrandr-dev \
|
||||
libxinerama-dev \
|
||||
libxcursor-dev \
|
||||
libxi-dev \
|
||||
libgl1-mesa-dev
|
||||
|
||||
# Header für Alsa
|
||||
sudo apt-get update && sudo apt-get install -y libasound2-dev
|
||||
|
||||
# Alle Bibliotheken automatisch installieren:
|
||||
sudo apt-get update && sudo apt-get install -y libasound2-dev libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl1-mesa-dev pkg-config
|
||||
sudo apt-get update && sudo apt-get install -y libxxf86vm-dev
|
||||
|
||||
"github.com/ebitengine/oto/v3"
|
||||
"github.com/BurntSushi/toml"
|
||||
|
||||
# Neues Projekt:
|
||||
go mod init remote-shack
|
||||
|
||||
#gRPC-Tool installieren
|
||||
sudo apt install protobuf-compiler
|
||||
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
||||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
|
||||
|
||||
#Go-Bin-Verzeichnis muss im PATH liegen
|
||||
export PATH=$PATH:$(go env GOPATH)/bin
|
||||
|
||||
#Go-Code aus der Proto-Datei erzeugen
|
||||
protoc --go_out=. --go_opt=Mapi/shack.proto=remote-shack/api --go-grpc_out=. --go-grpc_opt=Mapi/shack.proto=remote-shack/api api/shack.proto
|
||||
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative api/shack.proto
|
||||
|
||||
|
||||
# Zum Zeichnen der GUI wird fyne verwendet
|
||||
go get fyne.io/fyne/v2
|
||||
go mod tidy
|
||||
|
||||
|
||||
weitermachen:
|
||||
PROJEKT-STATUS Der gRPC-Server und alle drei Einzel-Clients (rig-client, rotor-client, relais-client) sind erfolgreich auf den neuen AuthService mit dynamischer Session-Token-Injektion und die korrigierten Protobuf-Feldnamen (Go 1.21 / Fyne v2.7) umgestellt und fehlerfrei lokal kompiliert. Die Konfigurationsschicht (internal/config/config.go) ist vollständig repariert.NÄCHSTER SCHRITT: Gemeinsamer Live-Test-Start aller vier Komponenten in getrennten Terminals und Überprüfung der flüssigen Vektornadel-Bewegung im Rotor-Kompass bei simulierter Antennenbewegung. Vorher aber noch ein buils.sh wie aus nachfolgendem Beispiel
|
||||
|
||||
608
api/shack.pb.go
Normal file
608
api/shack.pb.go
Normal file
|
|
@ -0,0 +1,608 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.11
|
||||
// protoc v3.21.12
|
||||
// source: api/shack.proto
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type Empty struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Empty) Reset() {
|
||||
*x = Empty{}
|
||||
mi := &file_api_shack_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Empty) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Empty) ProtoMessage() {}
|
||||
|
||||
func (x *Empty) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_shack_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Empty.ProtoReflect.Descriptor instead.
|
||||
func (*Empty) Descriptor() ([]byte, []int) {
|
||||
return file_api_shack_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
type LoginRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *LoginRequest) Reset() {
|
||||
*x = LoginRequest{}
|
||||
mi := &file_api_shack_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *LoginRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*LoginRequest) ProtoMessage() {}
|
||||
|
||||
func (x *LoginRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_shack_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead.
|
||||
func (*LoginRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_shack_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *LoginRequest) GetUsername() string {
|
||||
if x != nil {
|
||||
return x.Username
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type LoginResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *LoginResponse) Reset() {
|
||||
*x = LoginResponse{}
|
||||
mi := &file_api_shack_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *LoginResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*LoginResponse) ProtoMessage() {}
|
||||
|
||||
func (x *LoginResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_shack_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead.
|
||||
func (*LoginResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_shack_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *LoginResponse) GetToken() string {
|
||||
if x != nil {
|
||||
return x.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type RigCommand struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
FrequencyHz int64 `protobuf:"varint,1,opt,name=frequency_hz,json=frequencyHz,proto3" json:"frequency_hz,omitempty"`
|
||||
Mode string `protobuf:"bytes,2,opt,name=mode,proto3" json:"mode,omitempty"`
|
||||
Ptt bool `protobuf:"varint,3,opt,name=ptt,proto3" json:"ptt,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *RigCommand) Reset() {
|
||||
*x = RigCommand{}
|
||||
mi := &file_api_shack_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *RigCommand) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RigCommand) ProtoMessage() {}
|
||||
|
||||
func (x *RigCommand) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_shack_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use RigCommand.ProtoReflect.Descriptor instead.
|
||||
func (*RigCommand) Descriptor() ([]byte, []int) {
|
||||
return file_api_shack_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *RigCommand) GetFrequencyHz() int64 {
|
||||
if x != nil {
|
||||
return x.FrequencyHz
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *RigCommand) GetMode() string {
|
||||
if x != nil {
|
||||
return x.Mode
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RigCommand) GetPtt() bool {
|
||||
if x != nil {
|
||||
return x.Ptt
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type RigStatus struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
FrequencyHz int64 `protobuf:"varint,1,opt,name=frequency_hz,json=frequencyHz,proto3" json:"frequency_hz,omitempty"`
|
||||
Mode string `protobuf:"bytes,2,opt,name=mode,proto3" json:"mode,omitempty"`
|
||||
SMeter int32 `protobuf:"varint,3,opt,name=s_meter,json=sMeter,proto3" json:"s_meter,omitempty"`
|
||||
PowerMeter int32 `protobuf:"varint,4,opt,name=power_meter,json=powerMeter,proto3" json:"power_meter,omitempty"`
|
||||
ActiveOperatorName string `protobuf:"bytes,5,opt,name=active_operator_name,json=activeOperatorName,proto3" json:"active_operator_name,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *RigStatus) Reset() {
|
||||
*x = RigStatus{}
|
||||
mi := &file_api_shack_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *RigStatus) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RigStatus) ProtoMessage() {}
|
||||
|
||||
func (x *RigStatus) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_shack_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use RigStatus.ProtoReflect.Descriptor instead.
|
||||
func (*RigStatus) Descriptor() ([]byte, []int) {
|
||||
return file_api_shack_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *RigStatus) GetFrequencyHz() int64 {
|
||||
if x != nil {
|
||||
return x.FrequencyHz
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *RigStatus) GetMode() string {
|
||||
if x != nil {
|
||||
return x.Mode
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RigStatus) GetSMeter() int32 {
|
||||
if x != nil {
|
||||
return x.SMeter
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *RigStatus) GetPowerMeter() int32 {
|
||||
if x != nil {
|
||||
return x.PowerMeter
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *RigStatus) GetActiveOperatorName() string {
|
||||
if x != nil {
|
||||
return x.ActiveOperatorName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type RotorTarget struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Azimuth float64 `protobuf:"fixed64,1,opt,name=azimuth,proto3" json:"azimuth,omitempty"`
|
||||
Elevation float64 `protobuf:"fixed64,2,opt,name=elevation,proto3" json:"elevation,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *RotorTarget) Reset() {
|
||||
*x = RotorTarget{}
|
||||
mi := &file_api_shack_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *RotorTarget) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RotorTarget) ProtoMessage() {}
|
||||
|
||||
func (x *RotorTarget) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_shack_proto_msgTypes[5]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use RotorTarget.ProtoReflect.Descriptor instead.
|
||||
func (*RotorTarget) Descriptor() ([]byte, []int) {
|
||||
return file_api_shack_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *RotorTarget) GetAzimuth() float64 {
|
||||
if x != nil {
|
||||
return x.Azimuth
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *RotorTarget) GetElevation() float64 {
|
||||
if x != nil {
|
||||
return x.Elevation
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type RotorStatus struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
AzimuthIs float64 `protobuf:"fixed64,1,opt,name=azimuth_is,json=azimuthIs,proto3" json:"azimuth_is,omitempty"`
|
||||
ElevationIs float64 `protobuf:"fixed64,2,opt,name=elevation_is,json=elevationIs,proto3" json:"elevation_is,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *RotorStatus) Reset() {
|
||||
*x = RotorStatus{}
|
||||
mi := &file_api_shack_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *RotorStatus) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RotorStatus) ProtoMessage() {}
|
||||
|
||||
func (x *RotorStatus) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_shack_proto_msgTypes[6]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use RotorStatus.ProtoReflect.Descriptor instead.
|
||||
func (*RotorStatus) Descriptor() ([]byte, []int) {
|
||||
return file_api_shack_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *RotorStatus) GetAzimuthIs() float64 {
|
||||
if x != nil {
|
||||
return x.AzimuthIs
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *RotorStatus) GetElevationIs() float64 {
|
||||
if x != nil {
|
||||
return x.ElevationIs
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type RelaisRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Pin int32 `protobuf:"varint,1,opt,name=pin,proto3" json:"pin,omitempty"`
|
||||
State bool `protobuf:"varint,2,opt,name=state,proto3" json:"state,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *RelaisRequest) Reset() {
|
||||
*x = RelaisRequest{}
|
||||
mi := &file_api_shack_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *RelaisRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RelaisRequest) ProtoMessage() {}
|
||||
|
||||
func (x *RelaisRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_shack_proto_msgTypes[7]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use RelaisRequest.ProtoReflect.Descriptor instead.
|
||||
func (*RelaisRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_shack_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *RelaisRequest) GetPin() int32 {
|
||||
if x != nil {
|
||||
return x.Pin
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *RelaisRequest) GetState() bool {
|
||||
if x != nil {
|
||||
return x.State
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type RelaisResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Pins map[int32]bool `protobuf:"bytes,1,rep,name=pins,proto3" json:"pins,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *RelaisResponse) Reset() {
|
||||
*x = RelaisResponse{}
|
||||
mi := &file_api_shack_proto_msgTypes[8]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *RelaisResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RelaisResponse) ProtoMessage() {}
|
||||
|
||||
func (x *RelaisResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_shack_proto_msgTypes[8]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use RelaisResponse.ProtoReflect.Descriptor instead.
|
||||
func (*RelaisResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_shack_proto_rawDescGZIP(), []int{8}
|
||||
}
|
||||
|
||||
func (x *RelaisResponse) GetPins() map[int32]bool {
|
||||
if x != nil {
|
||||
return x.Pins
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_api_shack_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_api_shack_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x0fapi/shack.proto\x12\x03api\"\a\n" +
|
||||
"\x05Empty\"*\n" +
|
||||
"\fLoginRequest\x12\x1a\n" +
|
||||
"\busername\x18\x01 \x01(\tR\busername\"%\n" +
|
||||
"\rLoginResponse\x12\x14\n" +
|
||||
"\x05token\x18\x01 \x01(\tR\x05token\"U\n" +
|
||||
"\n" +
|
||||
"RigCommand\x12!\n" +
|
||||
"\ffrequency_hz\x18\x01 \x01(\x03R\vfrequencyHz\x12\x12\n" +
|
||||
"\x04mode\x18\x02 \x01(\tR\x04mode\x12\x10\n" +
|
||||
"\x03ptt\x18\x03 \x01(\bR\x03ptt\"\xae\x01\n" +
|
||||
"\tRigStatus\x12!\n" +
|
||||
"\ffrequency_hz\x18\x01 \x01(\x03R\vfrequencyHz\x12\x12\n" +
|
||||
"\x04mode\x18\x02 \x01(\tR\x04mode\x12\x17\n" +
|
||||
"\as_meter\x18\x03 \x01(\x05R\x06sMeter\x12\x1f\n" +
|
||||
"\vpower_meter\x18\x04 \x01(\x05R\n" +
|
||||
"powerMeter\x120\n" +
|
||||
"\x14active_operator_name\x18\x05 \x01(\tR\x12activeOperatorName\"E\n" +
|
||||
"\vRotorTarget\x12\x18\n" +
|
||||
"\aazimuth\x18\x01 \x01(\x01R\aazimuth\x12\x1c\n" +
|
||||
"\televation\x18\x02 \x01(\x01R\televation\"O\n" +
|
||||
"\vRotorStatus\x12\x1d\n" +
|
||||
"\n" +
|
||||
"azimuth_is\x18\x01 \x01(\x01R\tazimuthIs\x12!\n" +
|
||||
"\felevation_is\x18\x02 \x01(\x01R\velevationIs\"7\n" +
|
||||
"\rRelaisRequest\x12\x10\n" +
|
||||
"\x03pin\x18\x01 \x01(\x05R\x03pin\x12\x14\n" +
|
||||
"\x05state\x18\x02 \x01(\bR\x05state\"|\n" +
|
||||
"\x0eRelaisResponse\x121\n" +
|
||||
"\x04pins\x18\x01 \x03(\v2\x1d.api.RelaisResponse.PinsEntryR\x04pins\x1a7\n" +
|
||||
"\tPinsEntry\x12\x10\n" +
|
||||
"\x03key\x18\x01 \x01(\x05R\x03key\x12\x14\n" +
|
||||
"\x05value\x18\x02 \x01(\bR\x05value:\x028\x012=\n" +
|
||||
"\vAuthService\x12.\n" +
|
||||
"\x05Login\x12\x11.api.LoginRequest\x1a\x12.api.LoginResponse2t\n" +
|
||||
"\n" +
|
||||
"RigService\x126\n" +
|
||||
"\x0fOperatorSession\x12\x0f.api.RigCommand\x1a\x0e.api.RigStatus(\x010\x01\x12.\n" +
|
||||
"\x0eMonitorSession\x12\n" +
|
||||
".api.Empty\x1a\x0e.api.RigStatus0\x012n\n" +
|
||||
"\fRotorService\x12.\n" +
|
||||
"\x0eTargetPosition\x12\x10.api.RotorTarget\x1a\n" +
|
||||
".api.Empty\x12.\n" +
|
||||
"\fLivePosition\x12\n" +
|
||||
".api.Empty\x1a\x10.api.RotorStatus0\x012x\n" +
|
||||
"\rRelaisService\x124\n" +
|
||||
"\tSetRelais\x12\x12.api.RelaisRequest\x1a\x13.api.RelaisResponse\x121\n" +
|
||||
"\x0eGetRelaisState\x12\n" +
|
||||
".api.Empty\x1a\x13.api.RelaisResponseB\x12Z\x10remote-shack/apib\x06proto3"
|
||||
|
||||
var (
|
||||
file_api_shack_proto_rawDescOnce sync.Once
|
||||
file_api_shack_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_api_shack_proto_rawDescGZIP() []byte {
|
||||
file_api_shack_proto_rawDescOnce.Do(func() {
|
||||
file_api_shack_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_shack_proto_rawDesc), len(file_api_shack_proto_rawDesc)))
|
||||
})
|
||||
return file_api_shack_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_api_shack_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
|
||||
var file_api_shack_proto_goTypes = []any{
|
||||
(*Empty)(nil), // 0: api.Empty
|
||||
(*LoginRequest)(nil), // 1: api.LoginRequest
|
||||
(*LoginResponse)(nil), // 2: api.LoginResponse
|
||||
(*RigCommand)(nil), // 3: api.RigCommand
|
||||
(*RigStatus)(nil), // 4: api.RigStatus
|
||||
(*RotorTarget)(nil), // 5: api.RotorTarget
|
||||
(*RotorStatus)(nil), // 6: api.RotorStatus
|
||||
(*RelaisRequest)(nil), // 7: api.RelaisRequest
|
||||
(*RelaisResponse)(nil), // 8: api.RelaisResponse
|
||||
nil, // 9: api.RelaisResponse.PinsEntry
|
||||
}
|
||||
var file_api_shack_proto_depIdxs = []int32{
|
||||
9, // 0: api.RelaisResponse.pins:type_name -> api.RelaisResponse.PinsEntry
|
||||
1, // 1: api.AuthService.Login:input_type -> api.LoginRequest
|
||||
3, // 2: api.RigService.OperatorSession:input_type -> api.RigCommand
|
||||
0, // 3: api.RigService.MonitorSession:input_type -> api.Empty
|
||||
5, // 4: api.RotorService.TargetPosition:input_type -> api.RotorTarget
|
||||
0, // 5: api.RotorService.LivePosition:input_type -> api.Empty
|
||||
7, // 6: api.RelaisService.SetRelais:input_type -> api.RelaisRequest
|
||||
0, // 7: api.RelaisService.GetRelaisState:input_type -> api.Empty
|
||||
2, // 8: api.AuthService.Login:output_type -> api.LoginResponse
|
||||
4, // 9: api.RigService.OperatorSession:output_type -> api.RigStatus
|
||||
4, // 10: api.RigService.MonitorSession:output_type -> api.RigStatus
|
||||
0, // 11: api.RotorService.TargetPosition:output_type -> api.Empty
|
||||
6, // 12: api.RotorService.LivePosition:output_type -> api.RotorStatus
|
||||
8, // 13: api.RelaisService.SetRelais:output_type -> api.RelaisResponse
|
||||
8, // 14: api.RelaisService.GetRelaisState:output_type -> api.RelaisResponse
|
||||
8, // [8:15] is the sub-list for method output_type
|
||||
1, // [1:8] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_shack_proto_init() }
|
||||
func file_api_shack_proto_init() {
|
||||
if File_api_shack_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_shack_proto_rawDesc), len(file_api_shack_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 10,
|
||||
NumExtensions: 0,
|
||||
NumServices: 4,
|
||||
},
|
||||
GoTypes: file_api_shack_proto_goTypes,
|
||||
DependencyIndexes: file_api_shack_proto_depIdxs,
|
||||
MessageInfos: file_api_shack_proto_msgTypes,
|
||||
}.Build()
|
||||
File_api_shack_proto = out.File
|
||||
file_api_shack_proto_goTypes = nil
|
||||
file_api_shack_proto_depIdxs = nil
|
||||
}
|
||||
67
api/shack.proto
Normal file
67
api/shack.proto
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package api;
|
||||
option go_package = "remote-shack/api";
|
||||
|
||||
|
||||
service AuthService {
|
||||
rpc Login(LoginRequest) returns (LoginResponse);
|
||||
}
|
||||
|
||||
service RigService {
|
||||
rpc OperatorSession(stream RigCommand) returns (stream RigStatus);
|
||||
rpc MonitorSession(Empty) returns (stream RigStatus);
|
||||
}
|
||||
|
||||
service RotorService {
|
||||
rpc TargetPosition(RotorTarget) returns (Empty);
|
||||
rpc LivePosition(Empty) returns (stream RotorStatus);
|
||||
}
|
||||
|
||||
service RelaisService {
|
||||
rpc SetRelais(RelaisRequest) returns (RelaisResponse);
|
||||
rpc GetRelaisState(Empty) returns (RelaisResponse);
|
||||
}
|
||||
|
||||
message Empty {}
|
||||
|
||||
message LoginRequest {
|
||||
string username = 1;
|
||||
}
|
||||
|
||||
message LoginResponse {
|
||||
string token = 1;
|
||||
}
|
||||
|
||||
message RigCommand {
|
||||
int64 frequency_hz = 1;
|
||||
string mode = 2;
|
||||
bool ptt = 3;
|
||||
}
|
||||
|
||||
message RigStatus {
|
||||
int64 frequency_hz = 1;
|
||||
string mode = 2;
|
||||
int32 s_meter = 3;
|
||||
int32 power_meter = 4;
|
||||
string active_operator_name = 5;
|
||||
}
|
||||
|
||||
message RotorTarget {
|
||||
double azimuth = 1;
|
||||
double elevation = 2;
|
||||
}
|
||||
|
||||
message RotorStatus {
|
||||
double azimuth_is = 1;
|
||||
double elevation_is = 2;
|
||||
}
|
||||
|
||||
message RelaisRequest {
|
||||
int32 pin = 1;
|
||||
bool state = 2;
|
||||
}
|
||||
|
||||
message RelaisResponse {
|
||||
map<int32, bool> pins = 1;
|
||||
}
|
||||
542
api/shack_grpc.pb.go
Normal file
542
api/shack_grpc.pb.go
Normal file
|
|
@ -0,0 +1,542 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.2
|
||||
// - protoc v3.21.12
|
||||
// source: api/shack.proto
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
AuthService_Login_FullMethodName = "/api.AuthService/Login"
|
||||
)
|
||||
|
||||
// AuthServiceClient is the client API for AuthService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type AuthServiceClient interface {
|
||||
Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error)
|
||||
}
|
||||
|
||||
type authServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient {
|
||||
return &authServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *authServiceClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(LoginResponse)
|
||||
err := c.cc.Invoke(ctx, AuthService_Login_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// AuthServiceServer is the server API for AuthService service.
|
||||
// All implementations must embed UnimplementedAuthServiceServer
|
||||
// for forward compatibility.
|
||||
type AuthServiceServer interface {
|
||||
Login(context.Context, *LoginRequest) (*LoginResponse, error)
|
||||
mustEmbedUnimplementedAuthServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedAuthServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedAuthServiceServer struct{}
|
||||
|
||||
func (UnimplementedAuthServiceServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method Login not implemented")
|
||||
}
|
||||
func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {}
|
||||
func (UnimplementedAuthServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeAuthServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to AuthServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeAuthServiceServer interface {
|
||||
mustEmbedUnimplementedAuthServiceServer()
|
||||
}
|
||||
|
||||
func RegisterAuthServiceServer(s grpc.ServiceRegistrar, srv AuthServiceServer) {
|
||||
// If the following call panics, it indicates UnimplementedAuthServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&AuthService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _AuthService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(LoginRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthServiceServer).Login(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AuthService_Login_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthServiceServer).Login(ctx, req.(*LoginRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// AuthService_ServiceDesc is the grpc.ServiceDesc for AuthService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var AuthService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "api.AuthService",
|
||||
HandlerType: (*AuthServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Login",
|
||||
Handler: _AuthService_Login_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/shack.proto",
|
||||
}
|
||||
|
||||
const (
|
||||
RigService_OperatorSession_FullMethodName = "/api.RigService/OperatorSession"
|
||||
RigService_MonitorSession_FullMethodName = "/api.RigService/MonitorSession"
|
||||
)
|
||||
|
||||
// RigServiceClient is the client API for RigService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type RigServiceClient interface {
|
||||
OperatorSession(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[RigCommand, RigStatus], error)
|
||||
MonitorSession(ctx context.Context, in *Empty, opts ...grpc.CallOption) (grpc.ServerStreamingClient[RigStatus], error)
|
||||
}
|
||||
|
||||
type rigServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewRigServiceClient(cc grpc.ClientConnInterface) RigServiceClient {
|
||||
return &rigServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *rigServiceClient) OperatorSession(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[RigCommand, RigStatus], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &RigService_ServiceDesc.Streams[0], RigService_OperatorSession_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &grpc.GenericClientStream[RigCommand, RigStatus]{ClientStream: stream}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type RigService_OperatorSessionClient = grpc.BidiStreamingClient[RigCommand, RigStatus]
|
||||
|
||||
func (c *rigServiceClient) MonitorSession(ctx context.Context, in *Empty, opts ...grpc.CallOption) (grpc.ServerStreamingClient[RigStatus], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &RigService_ServiceDesc.Streams[1], RigService_MonitorSession_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &grpc.GenericClientStream[Empty, RigStatus]{ClientStream: stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := x.ClientStream.CloseSend(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type RigService_MonitorSessionClient = grpc.ServerStreamingClient[RigStatus]
|
||||
|
||||
// RigServiceServer is the server API for RigService service.
|
||||
// All implementations must embed UnimplementedRigServiceServer
|
||||
// for forward compatibility.
|
||||
type RigServiceServer interface {
|
||||
OperatorSession(grpc.BidiStreamingServer[RigCommand, RigStatus]) error
|
||||
MonitorSession(*Empty, grpc.ServerStreamingServer[RigStatus]) error
|
||||
mustEmbedUnimplementedRigServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedRigServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedRigServiceServer struct{}
|
||||
|
||||
func (UnimplementedRigServiceServer) OperatorSession(grpc.BidiStreamingServer[RigCommand, RigStatus]) error {
|
||||
return status.Error(codes.Unimplemented, "method OperatorSession not implemented")
|
||||
}
|
||||
func (UnimplementedRigServiceServer) MonitorSession(*Empty, grpc.ServerStreamingServer[RigStatus]) error {
|
||||
return status.Error(codes.Unimplemented, "method MonitorSession not implemented")
|
||||
}
|
||||
func (UnimplementedRigServiceServer) mustEmbedUnimplementedRigServiceServer() {}
|
||||
func (UnimplementedRigServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeRigServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to RigServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeRigServiceServer interface {
|
||||
mustEmbedUnimplementedRigServiceServer()
|
||||
}
|
||||
|
||||
func RegisterRigServiceServer(s grpc.ServiceRegistrar, srv RigServiceServer) {
|
||||
// If the following call panics, it indicates UnimplementedRigServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&RigService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _RigService_OperatorSession_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
return srv.(RigServiceServer).OperatorSession(&grpc.GenericServerStream[RigCommand, RigStatus]{ServerStream: stream})
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type RigService_OperatorSessionServer = grpc.BidiStreamingServer[RigCommand, RigStatus]
|
||||
|
||||
func _RigService_MonitorSession_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(Empty)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(RigServiceServer).MonitorSession(m, &grpc.GenericServerStream[Empty, RigStatus]{ServerStream: stream})
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type RigService_MonitorSessionServer = grpc.ServerStreamingServer[RigStatus]
|
||||
|
||||
// RigService_ServiceDesc is the grpc.ServiceDesc for RigService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var RigService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "api.RigService",
|
||||
HandlerType: (*RigServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "OperatorSession",
|
||||
Handler: _RigService_OperatorSession_Handler,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "MonitorSession",
|
||||
Handler: _RigService_MonitorSession_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "api/shack.proto",
|
||||
}
|
||||
|
||||
const (
|
||||
RotorService_TargetPosition_FullMethodName = "/api.RotorService/TargetPosition"
|
||||
RotorService_LivePosition_FullMethodName = "/api.RotorService/LivePosition"
|
||||
)
|
||||
|
||||
// RotorServiceClient is the client API for RotorService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type RotorServiceClient interface {
|
||||
TargetPosition(ctx context.Context, in *RotorTarget, opts ...grpc.CallOption) (*Empty, error)
|
||||
LivePosition(ctx context.Context, in *Empty, opts ...grpc.CallOption) (grpc.ServerStreamingClient[RotorStatus], error)
|
||||
}
|
||||
|
||||
type rotorServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewRotorServiceClient(cc grpc.ClientConnInterface) RotorServiceClient {
|
||||
return &rotorServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *rotorServiceClient) TargetPosition(ctx context.Context, in *RotorTarget, opts ...grpc.CallOption) (*Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Empty)
|
||||
err := c.cc.Invoke(ctx, RotorService_TargetPosition_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *rotorServiceClient) LivePosition(ctx context.Context, in *Empty, opts ...grpc.CallOption) (grpc.ServerStreamingClient[RotorStatus], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &RotorService_ServiceDesc.Streams[0], RotorService_LivePosition_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &grpc.GenericClientStream[Empty, RotorStatus]{ClientStream: stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := x.ClientStream.CloseSend(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type RotorService_LivePositionClient = grpc.ServerStreamingClient[RotorStatus]
|
||||
|
||||
// RotorServiceServer is the server API for RotorService service.
|
||||
// All implementations must embed UnimplementedRotorServiceServer
|
||||
// for forward compatibility.
|
||||
type RotorServiceServer interface {
|
||||
TargetPosition(context.Context, *RotorTarget) (*Empty, error)
|
||||
LivePosition(*Empty, grpc.ServerStreamingServer[RotorStatus]) error
|
||||
mustEmbedUnimplementedRotorServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedRotorServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedRotorServiceServer struct{}
|
||||
|
||||
func (UnimplementedRotorServiceServer) TargetPosition(context.Context, *RotorTarget) (*Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method TargetPosition not implemented")
|
||||
}
|
||||
func (UnimplementedRotorServiceServer) LivePosition(*Empty, grpc.ServerStreamingServer[RotorStatus]) error {
|
||||
return status.Error(codes.Unimplemented, "method LivePosition not implemented")
|
||||
}
|
||||
func (UnimplementedRotorServiceServer) mustEmbedUnimplementedRotorServiceServer() {}
|
||||
func (UnimplementedRotorServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeRotorServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to RotorServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeRotorServiceServer interface {
|
||||
mustEmbedUnimplementedRotorServiceServer()
|
||||
}
|
||||
|
||||
func RegisterRotorServiceServer(s grpc.ServiceRegistrar, srv RotorServiceServer) {
|
||||
// If the following call panics, it indicates UnimplementedRotorServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&RotorService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _RotorService_TargetPosition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(RotorTarget)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(RotorServiceServer).TargetPosition(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: RotorService_TargetPosition_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(RotorServiceServer).TargetPosition(ctx, req.(*RotorTarget))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _RotorService_LivePosition_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(Empty)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(RotorServiceServer).LivePosition(m, &grpc.GenericServerStream[Empty, RotorStatus]{ServerStream: stream})
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type RotorService_LivePositionServer = grpc.ServerStreamingServer[RotorStatus]
|
||||
|
||||
// RotorService_ServiceDesc is the grpc.ServiceDesc for RotorService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var RotorService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "api.RotorService",
|
||||
HandlerType: (*RotorServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "TargetPosition",
|
||||
Handler: _RotorService_TargetPosition_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "LivePosition",
|
||||
Handler: _RotorService_LivePosition_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "api/shack.proto",
|
||||
}
|
||||
|
||||
const (
|
||||
RelaisService_SetRelais_FullMethodName = "/api.RelaisService/SetRelais"
|
||||
RelaisService_GetRelaisState_FullMethodName = "/api.RelaisService/GetRelaisState"
|
||||
)
|
||||
|
||||
// RelaisServiceClient is the client API for RelaisService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type RelaisServiceClient interface {
|
||||
SetRelais(ctx context.Context, in *RelaisRequest, opts ...grpc.CallOption) (*RelaisResponse, error)
|
||||
GetRelaisState(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*RelaisResponse, error)
|
||||
}
|
||||
|
||||
type relaisServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewRelaisServiceClient(cc grpc.ClientConnInterface) RelaisServiceClient {
|
||||
return &relaisServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *relaisServiceClient) SetRelais(ctx context.Context, in *RelaisRequest, opts ...grpc.CallOption) (*RelaisResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RelaisResponse)
|
||||
err := c.cc.Invoke(ctx, RelaisService_SetRelais_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *relaisServiceClient) GetRelaisState(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*RelaisResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RelaisResponse)
|
||||
err := c.cc.Invoke(ctx, RelaisService_GetRelaisState_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// RelaisServiceServer is the server API for RelaisService service.
|
||||
// All implementations must embed UnimplementedRelaisServiceServer
|
||||
// for forward compatibility.
|
||||
type RelaisServiceServer interface {
|
||||
SetRelais(context.Context, *RelaisRequest) (*RelaisResponse, error)
|
||||
GetRelaisState(context.Context, *Empty) (*RelaisResponse, error)
|
||||
mustEmbedUnimplementedRelaisServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedRelaisServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedRelaisServiceServer struct{}
|
||||
|
||||
func (UnimplementedRelaisServiceServer) SetRelais(context.Context, *RelaisRequest) (*RelaisResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method SetRelais not implemented")
|
||||
}
|
||||
func (UnimplementedRelaisServiceServer) GetRelaisState(context.Context, *Empty) (*RelaisResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetRelaisState not implemented")
|
||||
}
|
||||
func (UnimplementedRelaisServiceServer) mustEmbedUnimplementedRelaisServiceServer() {}
|
||||
func (UnimplementedRelaisServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeRelaisServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to RelaisServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeRelaisServiceServer interface {
|
||||
mustEmbedUnimplementedRelaisServiceServer()
|
||||
}
|
||||
|
||||
func RegisterRelaisServiceServer(s grpc.ServiceRegistrar, srv RelaisServiceServer) {
|
||||
// If the following call panics, it indicates UnimplementedRelaisServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&RelaisService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _RelaisService_SetRelais_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(RelaisRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(RelaisServiceServer).SetRelais(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: RelaisService_SetRelais_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(RelaisServiceServer).SetRelais(ctx, req.(*RelaisRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _RelaisService_GetRelaisState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(Empty)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(RelaisServiceServer).GetRelaisState(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: RelaisService_GetRelaisState_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(RelaisServiceServer).GetRelaisState(ctx, req.(*Empty))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// RelaisService_ServiceDesc is the grpc.ServiceDesc for RelaisService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var RelaisService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "api.RelaisService",
|
||||
HandlerType: (*RelaisServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "SetRelais",
|
||||
Handler: _RelaisService_SetRelais_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetRelaisState",
|
||||
Handler: _RelaisService_GetRelaisState_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/shack.proto",
|
||||
}
|
||||
BIN
app/clients/client-relais
Executable file
BIN
app/clients/client-relais
Executable file
Binary file not shown.
BIN
app/clients/client-rig
Executable file
BIN
app/clients/client-rig
Executable file
Binary file not shown.
BIN
app/clients/client-rotor
Executable file
BIN
app/clients/client-rotor
Executable file
Binary file not shown.
BIN
app/server/shack-server
Executable file
BIN
app/server/shack-server
Executable file
Binary file not shown.
32
build.sh
Executable file
32
build.sh
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Versionierung (optional, falls jq installiert ist)
|
||||
VERSION="2.5.0"
|
||||
DATE=$(date +'%Y-%m-%d')
|
||||
LDFLAGS="-X 'main.Version=$VERSION' -X 'main.BuildDate=$DATE'"
|
||||
|
||||
echo "🔧 Baue Remote-Shack (Struktur-Sync)..."
|
||||
|
||||
# Clean & Prep
|
||||
rm -rf app
|
||||
mkdir -p app/server app/clients
|
||||
|
||||
# 1. Server bauen
|
||||
echo " -> [Server] Kompiliere Haupt-Server..."
|
||||
go build -ldflags "$LDFLAGS" -o ./app/server/shack-server ./cmd/server/main.go
|
||||
|
||||
# 2. Clients bauen (Pfade exakt nach deinem tree)
|
||||
echo " -> [Client] Rig-Client..."
|
||||
go build -ldflags "$LDFLAGS" -o ./app/clients/client-rig ./cmd/client-rig/main.go
|
||||
|
||||
echo " -> [Client] Relais-Client..."
|
||||
go build -ldflags "$LDFLAGS" -o ./app/clients/client-relais ./cmd/client-relais/main.go
|
||||
|
||||
echo " -> [Client] Rotor-Client (Fyne GUI)..."
|
||||
CGO_ENABLED=1 go build -ldflags "$LDFLAGS" -o ./app/clients/client-rotor ./cmd/client-rotor/main.go
|
||||
|
||||
# Berechtigungen
|
||||
chmod +x ./app/server/* ./app/clients/*
|
||||
|
||||
echo "✅ Build fertig. Binaries in ./app/"
|
||||
4
client-config.toml
Normal file
4
client-config.toml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[client]
|
||||
station_name = "DL1ABC"
|
||||
server_address = "127.0.0.1:50051" # Im Live-Betrieb dann die Tailscale-IP
|
||||
refresh_rate_ms = 250
|
||||
224
cmd/client-relais/main.go
Normal file
224
cmd/client-relais/main.go
Normal file
|
|
@ -0,0 +1,224 @@
|
|||
// Package main implementiert das eigenständige Fyne-GUI-Fenster für die Relaissteuerung.
|
||||
// Es erlaubt das Schalten von Ausgängen und authentifiziert sich über das dynamische Token.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/app"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
||||
shack "remote-shack/api"
|
||||
"remote-shack/internal/config"
|
||||
)
|
||||
|
||||
// RelaisClientGUI verwaltet die Schaltflächen für die digitalen Ausgänge.
|
||||
type RelaisClientGUI struct {
|
||||
window fyne.Window
|
||||
grpcClient shack.RelaisServiceClient
|
||||
buttons map[int32]*widget.Button
|
||||
statusLabel *widget.Label
|
||||
token string // Speichert das dynamisch geladene Session-Token
|
||||
lastLoggedState bool // FIX: Speichert den letzten Log-Zustand zur Vermeidung von Log-Spam
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||
log.Println("=== Starte Remote-Shack Relais-Client ===")
|
||||
|
||||
// Läuft auf der Client-Maschine und liest die client-config.toml
|
||||
cfg, err := config.LoadClientConfig("client-config.toml")
|
||||
if err != nil {
|
||||
log.Fatalf("Fehler beim Laden der client-config.toml: %v", err)
|
||||
}
|
||||
|
||||
var token string
|
||||
tokenBytes, err := os.ReadFile(".shack_session")
|
||||
if err == nil && len(tokenBytes) > 0 {
|
||||
token = string(tokenBytes)
|
||||
log.Printf("[Auth] Geteiltes Session-Token erfolgreich geladen: %s", token)
|
||||
} else {
|
||||
log.Println("[Auth] Keine active Sitzung vorhanden. Starte im Nur-Lesen-Modus...")
|
||||
token = ""
|
||||
}
|
||||
|
||||
unaryInterceptor := func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
if token != "" {
|
||||
ctx = metadata.AppendToOutgoingContext(ctx, "operator-token", token)
|
||||
}
|
||||
return invoker(ctx, method, req, reply, cc, opts...)
|
||||
}
|
||||
|
||||
conn, err := grpc.Dial(cfg.Client.ServerAddress,
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
grpc.WithUnaryInterceptor(unaryInterceptor),
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatalf("Verbindung zum Relais-Server fehlgeschlagen: %v", err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
grpcClient := shack.NewRelaisServiceClient(conn)
|
||||
|
||||
myApp := app.NewWithID("de.remote-shack.client.relais")
|
||||
myWindow := myApp.NewWindow("Remote-Shack: Relais-Control")
|
||||
|
||||
gui := &RelaisClientGUI{
|
||||
window: myWindow,
|
||||
grpcClient: grpcClient,
|
||||
buttons: make(map[int32]*widget.Button),
|
||||
token: token,
|
||||
lastLoggedState: (token != ""), // Initialen Log-Zustand setzen
|
||||
}
|
||||
|
||||
gui.buildUI()
|
||||
|
||||
// Hintergrund-Schleife startet, um den Zustand der Relais regelmäßig zu pollen
|
||||
go gui.startStatusPollLoop(cfg.Client.RefreshRateMs)
|
||||
|
||||
myWindow.Resize(fyne.NewSize(250, 300))
|
||||
myWindow.ShowAndRun()
|
||||
}
|
||||
|
||||
// buildUI generiert die Schaltflächen für die Kanäle 1 bis 4.
|
||||
func (g *RelaisClientGUI) buildUI() {
|
||||
g.statusLabel = widget.NewLabelWithStyle("Status: Synchronisiere...", fyne.TextAlignCenter, fyne.TextStyle{Italic: true})
|
||||
|
||||
relaisContainer := container.NewVBox()
|
||||
relaisContainer.Add(widget.NewLabelWithStyle("--- RELAISSTEUERUNG ---", fyne.TextAlignCenter, fyne.TextStyle{Bold: true}))
|
||||
|
||||
var i int32
|
||||
for i = 1; i <= 4; i++ {
|
||||
channel := i
|
||||
btn := widget.NewButton(fmt.Sprintf("Relais %d: [ AUS ]", channel), func() {
|
||||
g.toggleRelais(channel)
|
||||
})
|
||||
g.buttons[channel] = btn
|
||||
btn.Enable()
|
||||
relaisContainer.Add(btn)
|
||||
}
|
||||
|
||||
relaisContainer.Add(widget.NewSeparator())
|
||||
relaisContainer.Add(g.statusLabel)
|
||||
|
||||
g.window.SetContent(relaisContainer)
|
||||
}
|
||||
|
||||
// startStatusPollLoop fragt den Server zyklisch nach dem Zustand aller Relais ab.
|
||||
func (g *RelaisClientGUI) startStatusPollLoop(intervalMs int) {
|
||||
ticker := time.NewTicker(time.Duration(intervalMs) * time.Millisecond)
|
||||
defer ticker.Stop()
|
||||
|
||||
for range ticker.C {
|
||||
res, err := g.grpcClient.GetRelaisState(context.Background(), &shack.Empty{})
|
||||
if err != nil {
|
||||
fyne.Do(func() {
|
||||
g.statusLabel.SetText("Fehler: Keine Verbindung")
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
tokenBytes, err := os.ReadFile(".shack_session")
|
||||
hasRights := err == nil && len(tokenBytes) > 0
|
||||
|
||||
// FIX: Statuswechsel in der Log-Datei dokumentieren, falls er sich geändert hat
|
||||
if hasRights != g.lastLoggedState {
|
||||
if hasRights {
|
||||
log.Printf("[Statuswechsel] Relais-Client gewechselt zu: AKTIV (Operator-Rechte freigeschaltet, Token: %s)", string(tokenBytes))
|
||||
} else {
|
||||
log.Println("[Statuswechsel] Relais-Client gewechselt zu: INAKTIV (Nur-Lesen-Modus, Steuerung freigegeben)")
|
||||
}
|
||||
g.lastLoggedState = hasRights // Neuen Zustand speichern, um Mehrfach-Logs zu blockieren
|
||||
}
|
||||
|
||||
fyne.Do(func() {
|
||||
if hasRights {
|
||||
g.statusLabel.SetText("Verbindung: Aktiv (Operator)")
|
||||
} else {
|
||||
g.statusLabel.SetText("Verbindung: Nur Lesen (Keine Rechte)")
|
||||
}
|
||||
|
||||
var channel int32
|
||||
for channel = 1; channel <= 4; channel++ {
|
||||
if btn, ok := g.buttons[channel]; ok {
|
||||
var state bool
|
||||
if res.Pins != nil {
|
||||
state = res.Pins[channel]
|
||||
}
|
||||
|
||||
if state {
|
||||
btn.SetText(fmt.Sprintf("Relais %d: [ EIN ]", channel))
|
||||
} else {
|
||||
btn.SetText(fmt.Sprintf("Relais %d: [ AUS ]", channel))
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// toggleRelais setzt die visuelle Rückmeldung sofort auf "Warten" und schaltet erst nach Server-Antwort um.
|
||||
func (g *RelaisClientGUI) toggleRelais(channel int32) {
|
||||
tokenBytes, err := os.ReadFile(".shack_session")
|
||||
if err != nil || len(tokenBytes) == 0 {
|
||||
fyne.Do(func() {
|
||||
g.statusLabel.SetText("⚠️ Blockiert: Keine Operator-Rechte!")
|
||||
})
|
||||
log.Printf("[Sicherheit] Schaltversuch auf Kanal %d blockiert: Keine aktive Sitzung.", channel)
|
||||
return
|
||||
}
|
||||
g.token = string(tokenBytes)
|
||||
|
||||
fyne.Do(func() {
|
||||
g.statusLabel.SetText("Status: Warte auf Serverantwort...")
|
||||
})
|
||||
|
||||
ctx := metadata.AppendToOutgoingContext(context.Background(), "operator-token", g.token)
|
||||
resState, err := g.grpcClient.GetRelaisState(ctx, &shack.Empty{})
|
||||
if err != nil {
|
||||
fyne.Do(func() { g.statusLabel.SetText("Fehler: Keine Serververbindung") })
|
||||
return
|
||||
}
|
||||
|
||||
var currentState bool
|
||||
if resState.Pins != nil {
|
||||
currentState = resState.Pins[channel]
|
||||
}
|
||||
|
||||
ctx = metadata.AppendToOutgoingContext(context.Background(), "operator-token", g.token)
|
||||
resUpdate, err := g.grpcClient.SetRelais(ctx, &shack.RelaisRequest{
|
||||
Pin: channel,
|
||||
State: !currentState,
|
||||
})
|
||||
if err != nil {
|
||||
fyne.Do(func() { g.statusLabel.SetText("Fehler: Keine Operator-Rechte / Abgewiesen") })
|
||||
return
|
||||
}
|
||||
|
||||
fyne.Do(func() {
|
||||
g.statusLabel.SetText("Verbindung: Aktiv (Geschaltet)")
|
||||
var ch int32
|
||||
for ch = 1; ch <= 4; ch++ {
|
||||
if btn, ok := g.buttons[ch]; ok {
|
||||
var state bool
|
||||
if resUpdate.Pins != nil {
|
||||
state = resUpdate.Pins[ch]
|
||||
}
|
||||
if state {
|
||||
btn.SetText(fmt.Sprintf("Relais %d: [ EIN ]", ch))
|
||||
} else {
|
||||
btn.SetText(fmt.Sprintf("Relais %d: [ AUS ]", ch))
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
301
cmd/client-rig/main.go
Normal file
301
cmd/client-rig/main.go
Normal file
|
|
@ -0,0 +1,301 @@
|
|||
// Package main implementiert das eigenständige Fyne-GUI-Fenster für die Funkgerätesteuerung (Rig Control).
|
||||
// Es nutzt Fyne Data Binding für die UI und gRPC-Metadaten zur tokenbasierten Authentifizierung.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/app"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/data/binding"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
||||
shack "remote-shack/api"
|
||||
"remote-shack/internal/config"
|
||||
)
|
||||
|
||||
// RigClientGUI verwaltet alle UI-Komponenten und gRPC-Verbindungen des Funkgerätes.
|
||||
type RigClientGUI struct {
|
||||
// window repräsentiert das Fyne OS-Fenster.
|
||||
window fyne.Window
|
||||
// grpcClient hält die generierte Netzwerkschnittstelle zum Haupt-Server.
|
||||
grpcClient shack.RigServiceClient
|
||||
// opStream hält den aktiven, bidirektionalen Stream bei Operator-Rechten.
|
||||
opStream shack.RigService_OperatorSessionClient
|
||||
// streamCtx steuert den Lebenszyklus des Operator-Streams.
|
||||
streamCtx context.Context
|
||||
// streamCancel bricht den Stream bei einer Abmeldung ab.
|
||||
streamCancel context.CancelFunc
|
||||
|
||||
// freqBind kapselt die Frequenzdaten thread-sicher für die UI.
|
||||
freqBind binding.String
|
||||
// modeBind kapselt Betriebsart und S-Meter für die UI.
|
||||
modeBind binding.String
|
||||
// opBind steuert das Textfeld bezüglich des aktuellen Operator-Namens.
|
||||
opBind binding.String
|
||||
|
||||
actionBtn *widget.Button
|
||||
upBtn *widget.Button
|
||||
downBtn *widget.Button
|
||||
|
||||
currentFreq int64
|
||||
currentMode string
|
||||
isOperator bool
|
||||
stationName string
|
||||
sessionToken string // Speichert das vom AuthService erhaltene Token
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||
log.Println("=== Starte Remote-Shack Rig-Client ===")
|
||||
|
||||
// Läuft auf der Client-Maschine und lädt die client-config.toml
|
||||
cfg, err := config.LoadClientConfig("client-config.toml")
|
||||
if err != nil {
|
||||
log.Fatalf("Fehler beim Laden der client-config.toml: %v", err)
|
||||
}
|
||||
|
||||
// 1. Temporäre gRPC-Verbindung für den AuthService-Login aufbauen
|
||||
tempConn, err := grpc.Dial(cfg.Client.ServerAddress, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
log.Fatalf("Konnte keine Verbindung für Login aufbauen: %v", err)
|
||||
}
|
||||
authClient := shack.NewAuthServiceClient(tempConn)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
loginRes, err := authClient.Login(ctx, &shack.LoginRequest{Username: cfg.Client.StationName})
|
||||
cancel()
|
||||
tempConn.Close()
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Login am gRPC-AuthService fehlgeschlagen: %v", err)
|
||||
}
|
||||
token := loginRes.Token
|
||||
log.Printf("[Auth] Login erfolgreich. Sitzungstoken erhalten: %s", token)
|
||||
|
||||
// KORREKTUR: Beim Starten wird die Datei explizit gelöscht, da noch keine Steuerung aktiv ist!
|
||||
_ = os.Remove(".shack_session")
|
||||
|
||||
// Interceptor injiziert das dynamische Session-Token automatisch in gRPC Unary-Aufrufe
|
||||
unaryInterceptor := func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
ctx = metadata.AppendToOutgoingContext(ctx, "operator-token", token)
|
||||
return invoker(ctx, method, req, reply, cc, opts...)
|
||||
}
|
||||
|
||||
// Interceptor injiziert das dynamische Session-Token automatisch in gRPC Stream-Aufrufe
|
||||
streamInterceptor := func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
|
||||
ctx = metadata.AppendToOutgoingContext(ctx, "operator-token", token)
|
||||
return streamer(ctx, desc, cc, method, opts...)
|
||||
}
|
||||
|
||||
conn, err := grpc.Dial(cfg.Client.ServerAddress,
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
grpc.WithUnaryInterceptor(unaryInterceptor),
|
||||
grpc.WithStreamInterceptor(streamInterceptor),
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatalf("Konnte keine Hauptverbindung zum Server aufbauen: %v", err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
grpcClient := shack.NewRigServiceClient(conn)
|
||||
|
||||
myApp := app.NewWithID("de.remote-shack.client.rig")
|
||||
myWindow := myApp.NewWindow("Remote-Shack: Rig-Control")
|
||||
|
||||
gui := &RigClientGUI{
|
||||
window: myWindow,
|
||||
grpcClient: grpcClient,
|
||||
stationName: cfg.Client.StationName,
|
||||
sessionToken: token,
|
||||
freqBind: binding.NewString(),
|
||||
modeBind: binding.NewString(),
|
||||
opBind: binding.NewString(),
|
||||
}
|
||||
|
||||
_ = gui.freqBind.Set("00.000.000 MHz")
|
||||
_ = gui.modeBind.Set("Betriebsart: --")
|
||||
_ = gui.opBind.Set("Status: Verbinde...")
|
||||
|
||||
gui.buildUI()
|
||||
go gui.startStatusMonitorLoop()
|
||||
|
||||
myWindow.Resize(fyne.NewSize(350, 380))
|
||||
myWindow.ShowAndRun()
|
||||
}
|
||||
|
||||
// buildUI erzeugt alle visuellen Komponenten und verknüpft sie mit den Data-Bindings.
|
||||
func (g *RigClientGUI) buildUI() {
|
||||
freqLabel := widget.NewLabelWithData(g.freqBind)
|
||||
freqLabel.Alignment = fyne.TextAlignCenter
|
||||
freqLabel.TextStyle = fyne.TextStyle{Bold: true}
|
||||
|
||||
modeLabel := widget.NewLabelWithData(g.modeBind)
|
||||
modeLabel.Alignment = fyne.TextAlignCenter
|
||||
|
||||
opLabel := widget.NewLabelWithData(g.opBind)
|
||||
opLabel.TextStyle = fyne.TextStyle{Italic: true}
|
||||
|
||||
g.upBtn = widget.NewButton("▲ +1 kHz", func() { g.changeFrequency(1000) })
|
||||
g.downBtn = widget.NewButton("▼ -1 kHz", func() { g.changeFrequency(-1000) })
|
||||
g.actionBtn = widget.NewButton("Steuerung übernehmen", func() { g.handleOperatorToggle() })
|
||||
|
||||
g.upBtn.Disable()
|
||||
g.downBtn.Disable()
|
||||
|
||||
content := container.NewVBox(
|
||||
widget.NewLabelWithStyle("--- FREQUENZANZEIGE ---", fyne.TextAlignCenter, fyne.TextStyle{Bold: true}),
|
||||
freqLabel,
|
||||
modeLabel,
|
||||
container.NewGridWithColumns(2, g.upBtn, g.downBtn),
|
||||
widget.NewSeparator(),
|
||||
opLabel,
|
||||
g.actionBtn,
|
||||
)
|
||||
g.window.SetContent(content)
|
||||
}
|
||||
|
||||
// startStatusMonitorLoop liest den Server-Status im Hintergrund und stößt UI-Updates via fyne.Do an.
|
||||
func (g *RigClientGUI) startStatusMonitorLoop() {
|
||||
for {
|
||||
stream, err := g.grpcClient.MonitorSession(context.Background(), &shack.Empty{})
|
||||
if err != nil {
|
||||
_ = g.opBind.Set("Server nicht erreichbar. Reconnect...")
|
||||
_ = os.Remove(".shack_session")
|
||||
fyne.Do(func() {
|
||||
g.actionBtn.SetText("Verbindung verloren")
|
||||
g.actionBtn.Disable()
|
||||
})
|
||||
time.Sleep(2 * time.Second)
|
||||
continue
|
||||
}
|
||||
|
||||
for {
|
||||
status, err := stream.Recv()
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
g.currentFreq = status.FrequencyHz
|
||||
g.currentMode = status.Mode
|
||||
|
||||
_ = g.freqBind.Set(fmt.Sprintf("%.3f MHz", float64(g.currentFreq)/1000000.0))
|
||||
_ = g.modeBind.Set(fmt.Sprintf("Betriebsart: %s | S-Meter: S%d", g.currentMode, status.SMeter))
|
||||
|
||||
fyne.Do(func() {
|
||||
if g.isOperator {
|
||||
_ = g.opBind.Set("Status: Sie sind der aktive OPERATOR")
|
||||
g.actionBtn.SetText("Abmelden / Freigeben")
|
||||
g.actionBtn.Enable()
|
||||
g.upBtn.Enable()
|
||||
g.downBtn.Enable()
|
||||
return
|
||||
}
|
||||
|
||||
if status.ActiveOperatorName == "FREI" || status.ActiveOperatorName == "" {
|
||||
_ = g.opBind.Set("Status: Steuerung ist FREI")
|
||||
g.actionBtn.SetText("Steuerung übernehmen")
|
||||
g.actionBtn.Enable()
|
||||
g.upBtn.Disable()
|
||||
g.downBtn.Disable()
|
||||
} else {
|
||||
if status.ActiveOperatorName == g.stationName {
|
||||
_ = g.opBind.Set("Status: Sie sind der aktive OPERATOR")
|
||||
g.actionBtn.SetText("Abmelden / Freigeben")
|
||||
g.actionBtn.Enable()
|
||||
g.upBtn.Enable()
|
||||
g.downBtn.Enable()
|
||||
} else {
|
||||
_ = g.opBind.Set(fmt.Sprintf("Operator: %s", status.ActiveOperatorName))
|
||||
g.actionBtn.SetText("Steuerung blockiert")
|
||||
g.actionBtn.Disable()
|
||||
g.upBtn.Disable()
|
||||
g.downBtn.Disable()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
// changeFrequency übermittelt Abstimmbefehle via hocheffizientem gRPC-Streaming.
|
||||
func (g *RigClientGUI) changeFrequency(deltaHz int64) {
|
||||
if !g.isOperator || g.opStream == nil {
|
||||
return
|
||||
}
|
||||
_ = g.opStream.Send(&shack.RigCommand{
|
||||
FrequencyHz: g.currentFreq + deltaHz,
|
||||
Mode: g.currentMode,
|
||||
})
|
||||
}
|
||||
|
||||
// handleOperatorToggle öffnet oder schließt die OperatorSession (Änderungen via fyne.Do gekapselt).
|
||||
func (g *RigClientGUI) handleOperatorToggle() {
|
||||
if !g.isOperator {
|
||||
g.streamCtx, g.streamCancel = context.WithCancel(context.Background())
|
||||
stream, err := g.grpcClient.OperatorSession(g.streamCtx)
|
||||
if err != nil {
|
||||
log.Printf("Fehler beim Öffnen der Operator Session: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
g.opStream = stream
|
||||
g.isOperator = true
|
||||
|
||||
// KORREKTUR: Datei wird erst JETZT bei echtem Tastendruck geschrieben!
|
||||
_ = os.WriteFile(".shack_session", []byte(g.sessionToken), 0600)
|
||||
|
||||
fyne.Do(func() {
|
||||
g.actionBtn.SetText("Abmelden / Freigeben")
|
||||
g.upBtn.Enable()
|
||||
g.downBtn.Enable()
|
||||
})
|
||||
|
||||
_ = g.opStream.Send(&shack.RigCommand{})
|
||||
|
||||
go func() {
|
||||
for {
|
||||
_, err := g.opStream.Recv()
|
||||
if err != nil {
|
||||
fyne.Do(func() {
|
||||
g.resetOperatorState()
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
} else {
|
||||
if g.opStream != nil {
|
||||
_ = g.opStream.Send(&shack.RigCommand{
|
||||
FrequencyHz: 0,
|
||||
Mode: "DISCONNECT",
|
||||
})
|
||||
}
|
||||
fyne.Do(func() {
|
||||
g.resetOperatorState()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// resetOperatorState überführt die Widgets wieder in den passiven Zuhörermodus.
|
||||
func (g *RigClientGUI) resetOperatorState() {
|
||||
if g.streamCancel != nil {
|
||||
g.streamCancel()
|
||||
}
|
||||
g.opStream = nil
|
||||
g.isOperator = false
|
||||
_ = os.Remove(".shack_session")
|
||||
g.actionBtn.SetText("Steuerung übernehmen")
|
||||
g.actionBtn.Enable()
|
||||
g.upBtn.Disable()
|
||||
g.downBtn.Disable()
|
||||
}
|
||||
190
cmd/client-rotor/main.go
Normal file
190
cmd/client-rotor/main.go
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
// Package main implementiert das eigenständige Fyne-GUI-Fenster für die Rotorsteuerung (Rotor Control).
|
||||
// Es nutzt Fyne Data Binding für die UI und gRPC-Metadaten zur tokenbasierten Authentifizierung.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/app"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/data/binding"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
||||
shack "remote-shack/api"
|
||||
"remote-shack/internal/config"
|
||||
)
|
||||
|
||||
// RotorClientGUI verwaltet alle UI-Komponenten und gRPC-Verbindungen des Rotor-Kompasses.
|
||||
type RotorClientGUI struct {
|
||||
window fyne.Window
|
||||
grpcClient shack.RotorServiceClient
|
||||
azBind binding.String
|
||||
azNeedle *canvas.Line
|
||||
azInput *widget.Entry
|
||||
statusLabel *widget.Label // FIX: Neues Status-Label für konsistente Rechteanzeige
|
||||
token string
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||
log.Println("=== Starte Remote-Shack Rotor-Client ===")
|
||||
|
||||
// Läuft auf der Client-Maschine und lädt die client-config.toml
|
||||
cfg, err := config.LoadClientConfig("client-config.toml")
|
||||
if err != nil { log.Fatalf("Config Fehler: %v", err) }
|
||||
|
||||
var token string
|
||||
tokenBytes, err := os.ReadFile(".shack_session")
|
||||
if err == nil && len(tokenBytes) > 0 {
|
||||
token = string(tokenBytes)
|
||||
log.Printf("[Auth] Geteiltes Session-Token erfolgreich geladen: %s", token)
|
||||
} else {
|
||||
log.Println("[Auth] Keine aktive Sitzung vorhanden. Starte im Nur-Lesen-Modus...")
|
||||
token = ""
|
||||
}
|
||||
|
||||
unaryInterceptor := func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
if token != "" {
|
||||
ctx = metadata.AppendToOutgoingContext(ctx, "operator-token", token)
|
||||
}
|
||||
return invoker(ctx, method, req, reply, cc, opts...)
|
||||
}
|
||||
|
||||
streamInterceptor := func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
|
||||
if token != "" {
|
||||
ctx = metadata.AppendToOutgoingContext(ctx, "operator-token", token)
|
||||
}
|
||||
return streamer(ctx, desc, cc, method, opts...)
|
||||
}
|
||||
|
||||
conn, err := grpc.Dial(cfg.Client.ServerAddress,
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
grpc.WithUnaryInterceptor(unaryInterceptor),
|
||||
grpc.WithStreamInterceptor(streamInterceptor),
|
||||
)
|
||||
if err != nil { log.Fatalf("Hauptverbindung Fehler: %v", err) }
|
||||
defer conn.Close()
|
||||
|
||||
gui := &RotorClientGUI{
|
||||
grpcClient: shack.NewRotorServiceClient(conn),
|
||||
azBind: binding.NewString(),
|
||||
token: token,
|
||||
}
|
||||
|
||||
myApp := app.NewWithID("de.remote-shack.client.rotor")
|
||||
gui.window = myApp.NewWindow("Remote-Shack: Rotor Control")
|
||||
gui.buildUI()
|
||||
|
||||
gui.window.Resize(fyne.NewSize(300, 420)) // Höhe minimal angepasst für das neue Label
|
||||
|
||||
go gui.startLivePositionLoop()
|
||||
gui.window.ShowAndRun()
|
||||
}
|
||||
|
||||
// buildUI erzeugt alle visuellen Komponenten und verknüpft sie mit den Data-Bindings.
|
||||
func (g *RotorClientGUI) buildUI() {
|
||||
g.azNeedle = canvas.NewLine(theme.ForegroundColor())
|
||||
g.azNeedle.StrokeWidth = 3
|
||||
g.azNeedle.Position1 = fyne.NewPos(100, 100)
|
||||
g.azNeedle.Position2 = fyne.NewPos(100, 20)
|
||||
|
||||
g.azInput = widget.NewEntry()
|
||||
g.azInput.SetPlaceHolder("Ziel-Azimut (z.B. 145)")
|
||||
btn := widget.NewButton("Position Setzen", g.sendTargetPosition)
|
||||
|
||||
// FIX: Status-Label analog zum Relais-Client initialisieren
|
||||
g.statusLabel = widget.NewLabelWithStyle("Status: Synchronisiere...", fyne.TextAlignCenter, fyne.TextStyle{Italic: true})
|
||||
|
||||
compassContainer := container.NewWithoutLayout(g.azNeedle)
|
||||
compassContainer.Resize(fyne.NewSize(200, 200))
|
||||
|
||||
g.window.SetContent(container.NewVBox(
|
||||
widget.NewLabelWithStyle("--- ROTOR COMPASS ---", fyne.TextAlignCenter, fyne.TextStyle{Bold: true}),
|
||||
widget.NewLabelWithData(g.azBind),
|
||||
container.NewCenter(compassContainer),
|
||||
g.azInput,
|
||||
btn,
|
||||
widget.NewSeparator(),
|
||||
g.statusLabel, // Konsistente Platzierung ganz unten im Fenster
|
||||
))
|
||||
}
|
||||
|
||||
// startLivePositionLoop liest den Server-Status im Hintergrund und stößt UI-Updates via fyne.Do an.
|
||||
func (g *RotorClientGUI) startLivePositionLoop() {
|
||||
for {
|
||||
stream, err := g.grpcClient.LivePosition(context.Background(), &shack.Empty{})
|
||||
if err != nil {
|
||||
fyne.Do(func() {
|
||||
g.statusLabel.SetText("Fehler: Keine Verbindung")
|
||||
})
|
||||
time.Sleep(2 * time.Second)
|
||||
continue
|
||||
}
|
||||
for {
|
||||
status, err := stream.Recv()
|
||||
if err != nil { break }
|
||||
_ = g.azBind.Set(fmt.Sprintf("Azimut: %.1f°", status.AzimuthIs))
|
||||
|
||||
// Dynamische Überprüfung der Rechte im Hintergrund-Loop für das Status-Label
|
||||
tokenBytes, err := os.ReadFile(".shack_session")
|
||||
hasRights := err == nil && len(tokenBytes) > 0
|
||||
|
||||
fyne.Do(func() {
|
||||
if hasRights {
|
||||
g.statusLabel.SetText("Verbindung: Aktiv (Operator)")
|
||||
} else {
|
||||
g.statusLabel.SetText("Verbindung: Nur Lesen (Keine Rechte)")
|
||||
}
|
||||
|
||||
rad := (status.AzimuthIs - 90) * math.Pi / 180.0
|
||||
g.azNeedle.Position2 = fyne.NewPos(
|
||||
float32(100.0+80.0*math.Cos(rad)),
|
||||
float32(100.0+80.0*math.Sin(rad)),
|
||||
)
|
||||
g.azNeedle.Refresh()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sendTargetPosition übermittelt den eingegebenen Richtwert an den gRPC-Server.
|
||||
func (g *RotorClientGUI) sendTargetPosition() {
|
||||
// FIX: Rechte-Prüfung direkt beim Klick abfangen und Senden softwareseitig blockieren
|
||||
tokenBytes, err := os.ReadFile(".shack_session")
|
||||
if err != nil || len(tokenBytes) == 0 {
|
||||
fyne.Do(func() {
|
||||
g.statusLabel.SetText("⚠️ Blockiert: Keine Operator-Rechte!")
|
||||
})
|
||||
log.Println("[Sicherheit] Sendeversuch blockiert: Keine aktive Operator-Sitzung vorhanden.")
|
||||
return
|
||||
}
|
||||
g.token = string(tokenBytes)
|
||||
|
||||
val, err := strconv.ParseFloat(g.azInput.Text, 64)
|
||||
if err != nil {
|
||||
log.Printf("Ungültige Eingabe: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx := metadata.AppendToOutgoingContext(context.Background(), "operator-token", g.token)
|
||||
_, err = g.grpcClient.TargetPosition(ctx, &shack.RotorTarget{Azimuth: val})
|
||||
if err != nil {
|
||||
log.Printf("Fehler beim Senden der Zielposition: %v", err)
|
||||
} else {
|
||||
fyne.Do(func() {
|
||||
g.statusLabel.SetText("Verbindung: Aktiv (Positioniert)")
|
||||
})
|
||||
}
|
||||
}
|
||||
193
cmd/server/main.go
Normal file
193
cmd/server/main.go
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
||||
"remote-shack/api"
|
||||
"remote-shack/internal/config"
|
||||
"remote-shack/internal/driver"
|
||||
)
|
||||
|
||||
type ShackServer struct {
|
||||
api.UnimplementedAuthServiceServer
|
||||
api.UnimplementedRigServiceServer
|
||||
api.UnimplementedRotorServiceServer
|
||||
api.UnimplementedRelaisServiceServer
|
||||
|
||||
rig driver.RigDriver
|
||||
rotor driver.RotorDriver
|
||||
relais driver.RelaisDriver
|
||||
|
||||
mu sync.Mutex
|
||||
activeOperator string
|
||||
tokenToName map[string]string
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||
log.Println("=== Starte Remote-Shack Server v2.5 ===")
|
||||
|
||||
cfg, err := config.LoadServerConfig("server-config.toml")
|
||||
if err != nil {
|
||||
log.Printf("server-config.toml fehlt, nutze Default-Werte")
|
||||
cfg = &config.ServerConfig{Server: config.ServerSettings{ListenAddress: "0.0.0.0:50051"}}
|
||||
}
|
||||
|
||||
server := &ShackServer{
|
||||
rig: driver.NewDummyRig(),
|
||||
rotor: driver.NewDummyRotor(),
|
||||
relais: driver.NewDummyRelais(),
|
||||
tokenToName: make(map[string]string),
|
||||
}
|
||||
|
||||
lis, err := net.Listen("tcp", cfg.Server.ListenAddress)
|
||||
if err != nil {
|
||||
log.Fatalf("Listen Fehler: %v", err)
|
||||
}
|
||||
|
||||
grpcServer := grpc.NewServer()
|
||||
api.RegisterAuthServiceServer(grpcServer, server)
|
||||
api.RegisterRigServiceServer(grpcServer, server)
|
||||
api.RegisterRotorServiceServer(grpcServer, server)
|
||||
api.RegisterRelaisServiceServer(grpcServer, server)
|
||||
|
||||
go func() {
|
||||
if err := grpcServer.Serve(lis); err != nil {
|
||||
log.Printf("Server-Fehler: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
stop := make(chan os.Signal, 1)
|
||||
signal.Notify(stop, os.Interrupt, syscall.SIGTERM)
|
||||
<-stop
|
||||
grpcServer.GracefulStop()
|
||||
}
|
||||
|
||||
// --- AUTH SERVICE ---
|
||||
func (s *ShackServer) Login(ctx context.Context, req *api.LoginRequest) (*api.LoginResponse, error) {
|
||||
if req.Username == "" {
|
||||
return nil, fmt.Errorf("username darf nicht leer sein")
|
||||
}
|
||||
b := make([]byte, 16)
|
||||
rand.Read(b)
|
||||
token := fmt.Sprintf("shack-tok-%x", b)
|
||||
|
||||
s.mu.Lock()
|
||||
s.tokenToName[token] = req.Username
|
||||
s.mu.Unlock()
|
||||
|
||||
log.Printf("[Auth] Login: '%s' -> %s", req.Username, token)
|
||||
return &api.LoginResponse{Token: token}, nil
|
||||
}
|
||||
|
||||
// --- HELPER ---
|
||||
func (s *ShackServer) getVirtualOperator(ctx context.Context) string {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok { return "" }
|
||||
tokens := md.Get("operator-token")
|
||||
if len(tokens) == 0 { return "" }
|
||||
return tokens[0]
|
||||
}
|
||||
|
||||
func (s *ShackServer) checkAccess(token string) bool {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if token == "" { return false }
|
||||
if _, valid := s.tokenToName[token]; !valid { return false }
|
||||
if s.activeOperator == "" {
|
||||
s.activeOperator = token
|
||||
log.Printf("[Rechte] %s ist nun aktiver Operator.", s.tokenToName[token])
|
||||
}
|
||||
return s.activeOperator == token
|
||||
}
|
||||
|
||||
// --- RIG SERVICE ---
|
||||
func (s *ShackServer) OperatorSession(stream api.RigService_OperatorSessionServer) error {
|
||||
token := s.getVirtualOperator(stream.Context())
|
||||
if !s.checkAccess(token) {
|
||||
return fmt.Errorf("zugriff verweigert: nicht aktiver operator")
|
||||
}
|
||||
|
||||
for {
|
||||
cmd, err := stream.Recv()
|
||||
if err != nil {
|
||||
s.mu.Lock()
|
||||
if s.activeOperator == token { s.activeOperator = "" }
|
||||
s.mu.Unlock()
|
||||
return err
|
||||
}
|
||||
if cmd.FrequencyHz > 0 { _ = s.rig.SetFrequency(cmd.FrequencyHz) }
|
||||
if cmd.Mode != "" { _ = s.rig.SetMode(cmd.Mode) }
|
||||
_ = s.rig.SetPTT(cmd.Ptt)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ShackServer) MonitorSession(req *api.Empty, stream api.RigService_MonitorSessionServer) error {
|
||||
ticker := time.NewTicker(250 * time.Millisecond)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-stream.Context().Done(): return nil
|
||||
case <-ticker.C:
|
||||
f, _ := s.rig.GetFrequency()
|
||||
m, _ := s.rig.GetMode()
|
||||
s_meter, _ := s.rig.GetSMeter()
|
||||
_ = stream.Send(&api.RigStatus{FrequencyHz: f, Mode: m, SMeter: int32(s_meter)})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- ROTOR SERVICE ---
|
||||
func (s *ShackServer) TargetPosition(ctx context.Context, req *api.RotorTarget) (*api.Empty, error) {
|
||||
token := s.getVirtualOperator(ctx)
|
||||
if !s.checkAccess(token) {
|
||||
return &api.Empty{}, fmt.Errorf("zugriff verweigert")
|
||||
}
|
||||
_ = s.rotor.SetPosition(req.Azimuth, req.Elevation)
|
||||
return &api.Empty{}, nil
|
||||
}
|
||||
|
||||
func (s *ShackServer) LivePosition(req *api.Empty, stream api.RotorService_LivePositionServer) error {
|
||||
ticker := time.NewTicker(150 * time.Millisecond)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-stream.Context().Done(): return nil
|
||||
case <-ticker.C:
|
||||
az, el, _ := s.rotor.GetPosition()
|
||||
_ = stream.Send(&api.RotorStatus{AzimuthIs: az, ElevationIs: el})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- RELAIS SERVICE ---
|
||||
func (s *ShackServer) SetRelais(ctx context.Context, req *api.RelaisRequest) (*api.RelaisResponse, error) {
|
||||
token := s.getVirtualOperator(ctx)
|
||||
if !s.checkAccess(token) {
|
||||
return &api.RelaisResponse{}, fmt.Errorf("zugriff verweigert")
|
||||
}
|
||||
_ = s.relais.SetPin(int(req.Pin), req.State)
|
||||
pins, _ := s.relais.GetAllPins()
|
||||
res := make(map[int32]bool)
|
||||
for k, v := range pins { res[int32(k)] = v }
|
||||
return &api.RelaisResponse{Pins: res}, nil
|
||||
}
|
||||
|
||||
func (s *ShackServer) GetRelaisState(ctx context.Context, req *api.Empty) (*api.RelaisResponse, error) {
|
||||
pins, _ := s.relais.GetAllPins()
|
||||
res := make(map[int32]bool)
|
||||
for k, v := range pins { res[int32(k)] = v }
|
||||
return &api.RelaisResponse{Pins: res}, nil
|
||||
}
|
||||
32
deploy.sh
Executable file
32
deploy.sh
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
PI_USER="afu"
|
||||
PI_HOST="100.64.0.1"
|
||||
TARGET_DIR="remote-shack/app/server"
|
||||
|
||||
# Namen der Services (müssen mit den .service Dateinamen in app/server übereinstimmen)
|
||||
SERVICES="remoteshack-server.service remoteshack-rig.service remoteshack-relais.service"
|
||||
|
||||
echo "🚀 Deployment auf $PI_HOST..."
|
||||
|
||||
# Files übertragen
|
||||
ssh "$PI_USER@$PI_HOST" "mkdir -p $TARGET_DIR"
|
||||
scp -r app/server/* "$PI_USER@$PI_HOST:$TARGET_DIR/"
|
||||
|
||||
# Systemd Setup auf dem Pi
|
||||
ssh -t "$PI_USER@$PI_HOST" "
|
||||
cd $TARGET_DIR
|
||||
REAL_PATH=\$(pwd)
|
||||
|
||||
# Pfade in Service-Files fixen
|
||||
sed -i \"s|TARGET_HOME_DIR/remote-shack/app/server|\$REAL_PATH|g\" ./*.service
|
||||
|
||||
sudo cp ./*.service /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable $SERVICES
|
||||
sudo systemctl restart $SERVICES
|
||||
"
|
||||
|
||||
echo "✅ Fertig! Zeige Logs..."
|
||||
ssh -t "$PI_USER@$PI_HOST" "sudo journalctl -f -u remoteshack-server.service -u remoteshack-rig.service"
|
||||
47
go.mod
Normal file
47
go.mod
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
module remote-shack
|
||||
|
||||
go 1.25.0
|
||||
|
||||
require (
|
||||
fyne.io/fyne/v2 v2.7.4
|
||||
google.golang.org/grpc v1.81.1
|
||||
google.golang.org/protobuf v1.36.11
|
||||
)
|
||||
|
||||
require (
|
||||
fyne.io/systray v1.12.1 // indirect
|
||||
github.com/BurntSushi/toml v1.5.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/fredbi/uri v1.1.1 // indirect
|
||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||
github.com/fyne-io/gl-js v0.2.0 // indirect
|
||||
github.com/fyne-io/glfw-js v0.3.0 // indirect
|
||||
github.com/fyne-io/image v0.1.1 // indirect
|
||||
github.com/fyne-io/oksvg v0.2.0 // indirect
|
||||
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71 // indirect
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a // indirect
|
||||
github.com/go-text/render v0.2.1 // indirect
|
||||
github.com/go-text/typesetting v0.3.4 // indirect
|
||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
github.com/hack-pad/go-indexeddb v0.3.2 // indirect
|
||||
github.com/hack-pad/safejs v0.1.0 // indirect
|
||||
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade // indirect
|
||||
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.17 // indirect
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
|
||||
github.com/nicksnyder/go-i18n/v2 v2.5.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/rivo/uniseg v0.2.0 // indirect
|
||||
github.com/rymdport/portal v0.4.2 // indirect
|
||||
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect
|
||||
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect
|
||||
github.com/stretchr/testify v1.11.1 // indirect
|
||||
github.com/yuin/goldmark v1.7.8 // indirect
|
||||
golang.org/x/image v0.24.0 // indirect
|
||||
golang.org/x/net v0.51.0 // indirect
|
||||
golang.org/x/sys v0.42.0 // indirect
|
||||
golang.org/x/text v0.34.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260226221140-a57be14db171 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
116
go.sum
Normal file
116
go.sum
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
fyne.io/fyne/v2 v2.7.4 h1:OVCI5mT+Onb2kA4wlmGA5pLCqKik9f4NDb5jiR1OMTc=
|
||||
fyne.io/fyne/v2 v2.7.4/go.mod h1:ZD1mmhBY75mSa97IXl3MPlICd1uNHfCXYh5hKIlVOII=
|
||||
fyne.io/systray v1.12.1 h1:ygBD6aZXwiOmZoY5N+ukbH9pih0Kq6fYgVeMYbr5skQ=
|
||||
fyne.io/systray v1.12.1/go.mod h1:RVwqP9nYMo7h5zViCBHri2FgjXF7H2cub7MAq4NSoLs=
|
||||
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
|
||||
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
|
||||
github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw=
|
||||
github.com/fredbi/uri v1.1.1 h1:xZHJC08GZNIUhbP5ImTHnt5Ya0T8FI2VAwI/37kh2Ko=
|
||||
github.com/fredbi/uri v1.1.1/go.mod h1:4+DZQ5zBjEwQCDmXW5JdIjz0PUA+yJbvtBv+u+adr5o=
|
||||
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/fyne-io/gl-js v0.2.0 h1:+EXMLVEa18EfkXBVKhifYB6OGs3HwKO3lUElA0LlAjs=
|
||||
github.com/fyne-io/gl-js v0.2.0/go.mod h1:ZcepK8vmOYLu96JoxbCKJy2ybr+g1pTnaBDdl7c3ajI=
|
||||
github.com/fyne-io/glfw-js v0.3.0 h1:d8k2+Y7l+zy2pc7wlGRyPfTgZoqDf3AI4G+2zOWhWUk=
|
||||
github.com/fyne-io/glfw-js v0.3.0/go.mod h1:Ri6te7rdZtBgBpxLW19uBpp3Dl6K9K/bRaYdJ22G8Jk=
|
||||
github.com/fyne-io/image v0.1.1 h1:WH0z4H7qfvNUw5l4p3bC1q70sa5+YWVt6HCj7y4VNyA=
|
||||
github.com/fyne-io/image v0.1.1/go.mod h1:xrfYBh6yspc+KjkgdZU/ifUC9sPA5Iv7WYUBzQKK7JM=
|
||||
github.com/fyne-io/oksvg v0.2.0 h1:mxcGU2dx6nwjJsSA9PCYZDuoAcsZ/OuJlvg/Q9Njfo8=
|
||||
github.com/fyne-io/oksvg v0.2.0/go.mod h1:dJ9oEkPiWhnTFNCmRgEze+YNprJF7YRbpjgpWS4kzoI=
|
||||
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71 h1:5BVwOaUSBTlVZowGO6VZGw2H/zl9nrd3eCZfYV+NfQA=
|
||||
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a h1:vxnBhFDDT+xzxf1jTJKMKZw3H0swfWk9RpWbBbDK5+0=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-text/render v0.2.1 h1:qwHhxqGUjjg4L0XyJWj7M7bpY75NZM+kBpv2Yfw5mcg=
|
||||
github.com/go-text/render v0.2.1/go.mod h1:HCCAq8MUlm/WRcXshBb4K/n+IkjeXQ1c2Ba+yICSm0A=
|
||||
github.com/go-text/typesetting v0.3.4 h1:YYurUOtEb9kGSOz4uE3k4OpBGsp1dDL8+fjCeaFamAU=
|
||||
github.com/go-text/typesetting v0.3.4/go.mod h1:4qZCQphq4KSgGTAeI0uMEkVbROgfah8BuyF5LRYr7XY=
|
||||
github.com/go-text/typesetting-utils v0.0.0-20260223113751-2d88ac90dae3 h1:drBZzMgdYPbmyXqOto4YhhJGrFIQCX94FpR4MzTCsos=
|
||||
github.com/go-text/typesetting-utils v0.0.0-20260223113751-2d88ac90dae3/go.mod h1:3/62I4La/HBRX9TcTpBj4eipLiwzf+vhI+7whTc9V7o=
|
||||
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
|
||||
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y=
|
||||
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hack-pad/go-indexeddb v0.3.2 h1:DTqeJJYc1usa45Q5r52t01KhvlSN02+Oq+tQbSBI91A=
|
||||
github.com/hack-pad/go-indexeddb v0.3.2/go.mod h1:QvfTevpDVlkfomY498LhstjwbPW6QC4VC/lxYb0Kom0=
|
||||
github.com/hack-pad/safejs v0.1.0 h1:qPS6vjreAqh2amUqj4WNG1zIw7qlRQJ9K10eDKMCnE8=
|
||||
github.com/hack-pad/safejs v0.1.0/go.mod h1:HdS+bKF1NrE72VoXZeWzxFOVQVUSqZJAG0xNCnb+Tio=
|
||||
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade h1:FmusiCI1wHw+XQbvL9M+1r/C3SPqKrmBaIOYwVfQoDE=
|
||||
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade/go.mod h1:ZDXo8KHryOWSIqnsb/CiDq7hQUYryCgdVnxbj8tDG7o=
|
||||
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 h1:YLvr1eE6cdCqjOe972w/cYF+FjW34v27+9Vo5106B4M=
|
||||
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25/go.mod h1:kLgvv7o6UM+0QSf0QjAse3wReFDsb9qbZJdfexWlrQw=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/mattn/go-runewidth v0.0.17 h1:78v8ZlW0bP43XfmAfPsdXcoNCelfMHsDmd/pkENfrjQ=
|
||||
github.com/mattn/go-runewidth v0.0.17/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/nicksnyder/go-i18n/v2 v2.5.1 h1:IxtPxYsR9Gp60cGXjfuR/llTqV8aYMsC472zD0D1vHk=
|
||||
github.com/nicksnyder/go-i18n/v2 v2.5.1/go.mod h1:DrhgsSDZxoAfvVrBVLXoxZn/pN5TXqaDbq7ju94viiQ=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/pkg/profile v1.7.0 h1:hnbDkaNWPCLMO9wGLdBFTIZvzDrDfBM2072E1S9gJkA=
|
||||
github.com/pkg/profile v1.7.0/go.mod h1:8Uer0jas47ZQMJ7VD+OHknK4YDY07LPUC6dEvqDjvNo=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rymdport/portal v0.4.2 h1:7jKRSemwlTyVHHrTGgQg7gmNPJs88xkbKcIL3NlcmSU=
|
||||
github.com/rymdport/portal v0.4.2/go.mod h1:kFF4jslnJ8pD5uCi17brj/ODlfIidOxlgUDTO5ncnC4=
|
||||
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c h1:km8GpoQut05eY3GiYWEedbTT0qnSxrCjsVbb7yKY1KE=
|
||||
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c/go.mod h1:cNQ3dwVJtS5Hmnjxy6AgTPd0Inb3pW05ftPSX7NZO7Q=
|
||||
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef h1:Ch6Q+AZUxDBCVqdkI8FSpFyZDtCVBc2VmejdNrm5rRQ=
|
||||
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef/go.mod h1:nXTWP6+gD5+LUJ8krVhhoeHjvHTutPxMYl5SvkcnJNE=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic=
|
||||
github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||
go.opentelemetry.io/otel v1.43.0 h1:mYIM03dnh5zfN7HautFE4ieIig9amkNANT+xcVxAj9I=
|
||||
go.opentelemetry.io/otel v1.43.0/go.mod h1:JuG+u74mvjvcm8vj8pI5XiHy1zDeoCS2LB1spIq7Ay0=
|
||||
go.opentelemetry.io/otel/metric v1.43.0 h1:d7638QeInOnuwOONPp4JAOGfbCEpYb+K6DVWvdxGzgM=
|
||||
go.opentelemetry.io/otel/metric v1.43.0/go.mod h1:RDnPtIxvqlgO8GRW18W6Z/4P462ldprJtfxHxyKd2PY=
|
||||
go.opentelemetry.io/otel/sdk v1.43.0 h1:pi5mE86i5rTeLXqoF/hhiBtUNcrAGHLKQdhg4h4V9Dg=
|
||||
go.opentelemetry.io/otel/sdk v1.43.0/go.mod h1:P+IkVU3iWukmiit/Yf9AWvpyRDlUeBaRg6Y+C58QHzg=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.43.0 h1:S88dyqXjJkuBNLeMcVPRFXpRw2fuwdvfCGLEo89fDkw=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.43.0/go.mod h1:C/RJtwSEJ5hzTiUz5pXF1kILHStzb9zFlIEe85bhj6A=
|
||||
go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09nk+3A=
|
||||
go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0=
|
||||
golang.org/x/image v0.24.0 h1:AN7zRgVsbvmTfNyqIbbOraYL8mSwcKncEj8ofjgzcMQ=
|
||||
golang.org/x/image v0.24.0/go.mod h1:4b/ITuLfqYq1hqZcjofwctIhi7sZh2WaCjvsBNjjya8=
|
||||
golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
|
||||
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
|
||||
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
|
||||
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=
|
||||
golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
|
||||
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
||||
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260226221140-a57be14db171 h1:ggcbiqK8WWh6l1dnltU4BgWGIGo+EVYxCaAPih/zQXQ=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260226221140-a57be14db171/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
||||
google.golang.org/grpc v1.81.1 h1:VnnIIZ88UzOOKLukQi+ImGz8O1Wdp8nAGGnvOfEIWQQ=
|
||||
google.golang.org/grpc v1.81.1/go.mod h1:xGH9GfzOyMTGIOXBJmXt+BX/V0kcdQbdcuwQ/zNw42I=
|
||||
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
||||
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
71
internal/config/config.go
Normal file
71
internal/config/config.go
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
// Package config verwaltet das Laden und Parsen der TOML-Konfigurationsdateien
|
||||
// für den Server-Daemon und alle angeschlossenen GUI-Clients.
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
||||
// ServerSettings definiert die Netzwerkparameter des Server-Daemons.
|
||||
type ServerSettings struct {
|
||||
ListenAddress string `toml:"listen_address"`
|
||||
}
|
||||
|
||||
// ServerConfig bündelt alle Konfigurationseinstellungen des Servers.
|
||||
type ServerConfig struct {
|
||||
Server ServerSettings `toml:"server"`
|
||||
}
|
||||
|
||||
// ClientSettings definiert die Verbindungsparameter für die Fyne-GUIs.
|
||||
type ClientSettings struct {
|
||||
ServerAddress string `toml:"server_address"`
|
||||
StationName string `toml:"station_name"`
|
||||
RefreshRateMs int `toml:"refresh_rate_ms"`
|
||||
}
|
||||
|
||||
// ClientConfig bündelt alle Konfigurationseinstellungen des GUI-Clients.
|
||||
type ClientConfig struct {
|
||||
Client ClientSettings `toml:"client"`
|
||||
}
|
||||
|
||||
// LoadServerConfig lädt die Konfiguration für den Server-Daemon aus einer TOML-Datei.
|
||||
func LoadServerConfig(path string) (*ServerConfig, error) {
|
||||
cfg := &ServerConfig{
|
||||
Server: ServerSettings{
|
||||
ListenAddress: "0.0.0.0:50051",
|
||||
},
|
||||
}
|
||||
|
||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
if _, err := toml.DecodeFile(path, cfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
// LoadClientConfig lädt die Konfiguration für die GUI-Clients aus einer TOML-Datei.
|
||||
func LoadClientConfig(path string) (*ClientConfig, error) {
|
||||
cfg := &ClientConfig{
|
||||
Client: ClientSettings{
|
||||
ServerAddress: "127.0.0.1:50051",
|
||||
StationName: "DL-UNKNOWN",
|
||||
RefreshRateMs: 250,
|
||||
},
|
||||
}
|
||||
|
||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
if _, err := toml.DecodeFile(path, cfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
217
internal/driver/dummy.go
Normal file
217
internal/driver/dummy.go
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
// Package driver implementiert herstellerunabhängige Hardware-Treiber.
|
||||
// Diese Datei enthält die Dummy-Implementierungen zur Simulation von Hardware ohne physische Geräte.
|
||||
package driver
|
||||
|
||||
import (
|
||||
"log"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// DummyRig simuliert ein Funkgerät im Arbeitsspeicher.
|
||||
type DummyRig struct {
|
||||
mu sync.Mutex
|
||||
connected bool
|
||||
freq int64
|
||||
mode string
|
||||
ptt bool
|
||||
}
|
||||
|
||||
// NewDummyRig erstellt eine neue Instanz eines simulierten Funkgeräts mit Standardwerten.
|
||||
func NewDummyRig() *DummyRig {
|
||||
return &DummyRig{
|
||||
freq: 14250000, // 20m Band Standardfrequenz (14.250 MHz)
|
||||
mode: "USB",
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DummyRig) Connect(port string, baud int) error {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
d.connected = true
|
||||
log.Printf("[Dummy-Rig] Erfolgreich verbunden via %s (%d Baud)", port, baud)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DummyRig) Disconnect() error {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
d.connected = false
|
||||
log.Println("[Dummy-Rig] Verbindung sauber getrennt.")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DummyRig) SetFrequency(hz int64) error {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
d.freq = hz
|
||||
log.Printf("[Dummy-Rig] Frequenz geändert auf: %d Hz", hz)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DummyRig) GetFrequency() (int64, error) {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
return d.freq, nil
|
||||
}
|
||||
|
||||
func (d *DummyRig) SetMode(mode string) error {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
d.mode = mode
|
||||
log.Printf("[Dummy-Rig] Betriebsart geändert auf: %s", mode)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DummyRig) GetMode() (string, error) {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
return d.mode, nil
|
||||
}
|
||||
|
||||
func (d *DummyRig) SetPTT(active bool) error {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
d.ptt = active
|
||||
log.Printf("[Dummy-Rig] PTT Status geändert: %t (TX = %t)", active, active)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DummyRig) GetSMeter() (int, error) {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
// Simuliert ein leichtes Rauschen um S3, wenn kein TX aktiv ist
|
||||
if d.ptt {
|
||||
return 0, nil
|
||||
}
|
||||
return 3, nil
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// DummyRotor simuliert einen Antennenrotor mit einer Trägheits-Animation.
|
||||
type DummyRotor struct {
|
||||
mu sync.Mutex
|
||||
azTarget float64
|
||||
elTarget float64
|
||||
azCurrent float64
|
||||
elCurrent float64
|
||||
}
|
||||
|
||||
// NewDummyRotor erstellt einen simulierten Rotor und startet die Hintergrund-Bewegung.
|
||||
func NewDummyRotor() *DummyRotor {
|
||||
r := &DummyRotor{
|
||||
azCurrent: 180.0, // Startet im Süden
|
||||
elCurrent: 0.0, // Flach am Horizont
|
||||
}
|
||||
r.azTarget = r.azCurrent
|
||||
r.elTarget = r.elCurrent
|
||||
|
||||
// Startet die flüssige Bewegungssimulation im Hintergrund
|
||||
go r.startMovementSimulation()
|
||||
return r
|
||||
}
|
||||
|
||||
func (d *DummyRotor) Connect(port string, baud int) error {
|
||||
log.Printf("[Dummy-Rotor] Erfolgreich verbunden via %s (%d Baud)", port, baud)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DummyRotor) Disconnect() error {
|
||||
log.Println("[Dummy-Rotor] Verbindung getrennt.")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DummyRotor) SetPosition(azimuth, elevation float64) error {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
d.azTarget = azimuth
|
||||
d.elTarget = elevation
|
||||
log.Printf("[Dummy-Rotor] Fahre auf Soll-Position -> Az: %.1f°, El: %.1f°", azimuth, elevation)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DummyRotor) GetPosition() (az, el float64, err error) {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
return d.azCurrent, d.elCurrent, nil
|
||||
}
|
||||
|
||||
// startMovementSimulation nähert die Ist-Werte alle 100ms Schritt für Schritt an die Soll-Werte an.
|
||||
func (d *DummyRotor) startMovementSimulation() {
|
||||
ticker := time.NewTicker(100 * time.Millisecond)
|
||||
for range ticker.C {
|
||||
d.mu.Lock()
|
||||
// Azimut bewegen (Simuliert 4 Grad pro Sekunde -> 0.4 Grad pro 100ms)
|
||||
if d.azCurrent < d.azTarget {
|
||||
d.azCurrent += 0.4
|
||||
if d.azCurrent > d.azTarget {
|
||||
d.azCurrent = d.azTarget
|
||||
}
|
||||
} else if d.azCurrent > d.azTarget {
|
||||
d.azCurrent -= 0.4
|
||||
if d.azCurrent < d.azTarget {
|
||||
d.azCurrent = d.azTarget
|
||||
}
|
||||
}
|
||||
|
||||
// Elevation bewegen (Simuliert 2 Grad pro Sekunde -> 0.2 Grad pro 100ms)
|
||||
if d.elCurrent < d.elTarget {
|
||||
d.elCurrent += 0.2
|
||||
if d.elCurrent > d.elTarget {
|
||||
d.elCurrent = d.elTarget
|
||||
}
|
||||
} else if d.elCurrent > d.elTarget {
|
||||
d.elCurrent -= 0.2
|
||||
if d.elCurrent < d.elTarget {
|
||||
d.elCurrent = d.elTarget
|
||||
}
|
||||
}
|
||||
d.mu.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// DummyRelais simuliert ein Relais-Board im Arbeitsspeicher.
|
||||
type DummyRelais struct {
|
||||
mu sync.Mutex
|
||||
pins map[int]bool
|
||||
}
|
||||
|
||||
// NewDummyRelais erstellt eine neue Instanz einer simulierten Relaiskarte.
|
||||
func NewDummyRelais() *DummyRelais {
|
||||
return &DummyRelais{
|
||||
pins: make(map[int]bool),
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DummyRelais) Connect(address string) error {
|
||||
log.Printf("[Dummy-Relais] Board an Adresse %s initialisiert.", address)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DummyRelais) SetPin(pin int, state bool) error {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
d.pins[pin] = state
|
||||
log.Printf("[Dummy-Relais] Pin %d geschaltet auf: %t", pin, state)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DummyRelais) GetPin(pin int) (bool, error) {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
return d.pins[pin], nil
|
||||
}
|
||||
|
||||
func (d *DummyRelais) GetAllPins() (map[int]bool, error) {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
// Kopie der Map zurückgeben, um Race-Conditions außerhalb zu verhindern
|
||||
copyMap := make(map[int]bool)
|
||||
for k, v := range d.pins {
|
||||
copyMap[k] = v
|
||||
}
|
||||
return copyMap, nil
|
||||
}
|
||||
67
internal/driver/interfaces.go
Normal file
67
internal/driver/interfaces.go
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
// Package driver definiert die Hardware-Abstraktionsschicht (HAL) für das Remote-Shack System.
|
||||
// Es stellt herstellerunabhängige Schnittstellen für Funkgeräte, Rotoren und Relaissteuerungen bereit.
|
||||
package driver
|
||||
|
||||
// RigDriver definiert die standardisierte Hardware-Steuerung für ein Funkgerät (Transceiver).
|
||||
// Jeder gerätespezifische Treiber (z.B. Yaesu FT-897, Icom IC-7300) muss dieses Interface erfüllen.
|
||||
type RigDriver interface {
|
||||
// Connect initialisiert die serielle Schnittstelle (RS232/CI-V) zum Funkgerät.
|
||||
// Übergibt den Portpfad (z.B. "/dev/ttyUSB0") und die Baudrate (z.B. 9600).
|
||||
Connect(port string, baud int) error
|
||||
|
||||
// Disconnect schließt die serielle Schnittstelle und gibt die Ressourcen sauber frei.
|
||||
Disconnect() error
|
||||
|
||||
// SetFrequency stellt die Betriebsfrequenz des Funkgeräts in Hertz (Hz) ein.
|
||||
SetFrequency(hz int64) error
|
||||
|
||||
// GetFrequency liest die aktuelle Betriebsfrequenz des Funkgeräts in Hertz (Hz) aus.
|
||||
GetFrequency() (int64, error)
|
||||
|
||||
// SetMode ändert die Betriebsart des Funkgeräts (z.B. "LSB", "USB", "FM", "AM", "CW").
|
||||
SetMode(mode string) error
|
||||
|
||||
// GetMode liest die aktuell am Funkgerät eingestellte Betriebsart aus.
|
||||
GetMode() (string, error)
|
||||
|
||||
// SetPTT schaltet den Sender des Funkgeräts ein (true = Transmit) oder aus (false = Receive).
|
||||
SetPTT(active bool) error
|
||||
|
||||
// GetSMeter liest den aktuellen S-Meter-Wert des Empfängers aus (skaliert von 0 bis 9, danach in dB).
|
||||
GetSMeter() (int, error)
|
||||
}
|
||||
|
||||
// RotorDriver definiert die standardisierte Hardware-Steuerung für einen Antennenrotor.
|
||||
// Unterstützt die azimuthale und elevationale Ausrichtung von Antennenanlagen.
|
||||
type RotorDriver interface {
|
||||
// Connect initialisiert die serielle oder Netzwerkschnittstelle zum Rotor-Controller.
|
||||
Connect(port string, baud int) error
|
||||
|
||||
// Disconnect schließt die Verbindung zum Rotor-Controller.
|
||||
Disconnect() error
|
||||
|
||||
// SetPosition sendet die Zielkoordinaten (Soll-Werte) an den Rotor.
|
||||
// Azimut und Elevation werden in Grad (0.0 bis 360.0 bzw. 0.0 bis 90.0) angegeben.
|
||||
SetPosition(azimuth, elevation float64) error
|
||||
|
||||
// GetPosition liest die aktuellen Echtzeitkoordinaten (Ist-Werte) des Rotors aus.
|
||||
// Liefert Azimut und Elevation in Grad zurück.
|
||||
GetPosition() (az, el float64, err error)
|
||||
}
|
||||
|
||||
// RelaisDriver definiert die Steuerung für digitale Schaltkontakte (Relais, GPIOs).
|
||||
// Wird für die Steuerung von Antennenumschaltern, Endstufen oder Stromversorgungen genutzt.
|
||||
type RelaisDriver interface {
|
||||
// Connect initialisiert die Schnittstelle zum Relais-Board (z.B. I2C-Adresse oder GPIO-Subsystem).
|
||||
Connect(address string) error
|
||||
|
||||
// SetPin schaltet ein spezifisches Relais (Pin-Nummer) ein (true) oder aus (false).
|
||||
SetPin(pin int, state bool) error
|
||||
|
||||
// GetPin liest den aktuellen Schaltzustand eines spezifischen Relais aus.
|
||||
GetPin(pin int) (bool, error)
|
||||
|
||||
// GetAllPins liest die Schaltzustände aller verfügbaren Kanäle gleichzeitig aus.
|
||||
// Gibt eine Map zurück, bei der der Schlüssel die Pin-Nummer und der Wert den Zustand darstellt.
|
||||
GetAllPins() (map[int]bool, error)
|
||||
}
|
||||
2
server-config.toml
Normal file
2
server-config.toml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[server]
|
||||
listen_address = "0.0.0.0:50051"
|
||||
Loading…
Reference in a new issue