Phase 6
This commit is contained in:
+32
-12
@@ -15,7 +15,9 @@ import (
|
||||
"github.com/uopi/uopi/internal/config"
|
||||
"github.com/uopi/uopi/internal/datasource/epics"
|
||||
"github.com/uopi/uopi/internal/datasource/stub"
|
||||
"github.com/uopi/uopi/internal/datasource/synthetic"
|
||||
"github.com/uopi/uopi/internal/server"
|
||||
"github.com/uopi/uopi/internal/storage"
|
||||
"github.com/uopi/uopi/web"
|
||||
)
|
||||
|
||||
@@ -40,6 +42,12 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
store, err := storage.New(cfg.Server.StorageDir)
|
||||
if err != nil {
|
||||
log.Error("failed to open interface store", "err", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
webFS, err := fs.Sub(web.FS, "dist")
|
||||
if err != nil {
|
||||
log.Error("failed to sub web dist", "err", err)
|
||||
@@ -51,18 +59,30 @@ func main() {
|
||||
|
||||
brk := broker.New(ctx, log)
|
||||
|
||||
// Register data sources
|
||||
if cfg.Synthetic.Enabled {
|
||||
ds := stub.New()
|
||||
if err := ds.Connect(ctx); err != nil {
|
||||
log.Error("stub connect", "err", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
brk.Register(ds)
|
||||
// Stub data source is always registered — it provides synthetic test signals
|
||||
// used by demo interfaces and unit tests.
|
||||
stubDS := stub.New()
|
||||
if err := stubDS.Connect(ctx); err != nil {
|
||||
log.Error("stub connect", "err", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
// Register EPICS Channel Access data source (Phase 2).
|
||||
// epics.Available() returns false when built without -tags epics so that
|
||||
// machines without EPICS Base installed still compile and run correctly.
|
||||
brk.Register(stubDS)
|
||||
|
||||
// Synthetic data source: computes derived signals from upstream sources via
|
||||
// configurable DSP pipelines defined in synthetic.json inside the storage dir.
|
||||
var synthDS *synthetic.Synthetic
|
||||
if cfg.Synthetic.Enabled {
|
||||
synthDS = synthetic.New(cfg.Server.StorageDir, brk, log)
|
||||
if err := synthDS.Connect(ctx); err != nil {
|
||||
log.Warn("synthetic connect failed — continuing without synthetic signals", "err", err)
|
||||
synthDS = nil
|
||||
} else {
|
||||
brk.Register(synthDS)
|
||||
}
|
||||
}
|
||||
|
||||
// EPICS Channel Access data source (requires -tags epics build).
|
||||
// epics.Available() returns false when built without the tag.
|
||||
if cfg.EPICS.Enabled && epics.Available() {
|
||||
ds := epics.New(cfg.EPICS.CAAddrList, cfg.EPICS.ArchiveURL)
|
||||
if err := ds.Connect(ctx); err != nil {
|
||||
@@ -72,7 +92,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
srv := server.New(cfg.Server.Listen, webFS, brk, log)
|
||||
srv := server.New(cfg.Server.Listen, webFS, brk, synthDS, store, log)
|
||||
|
||||
if err := srv.Start(ctx); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "server error: %v\n", err)
|
||||
|
||||
Reference in New Issue
Block a user