Implemented epics read/write

This commit is contained in:
Martino Ferrari
2026-04-27 12:42:10 +02:00
parent b76b7f0ba8
commit 1bda25454b
32 changed files with 1553 additions and 281 deletions
+13 -11
View File
@@ -59,19 +59,21 @@ func main() {
brk := broker.New(ctx, log)
// 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)
// Stub data source: built-in simulated signals (sine, ramp, noise, setpoint).
// Enabled by default; disable via [datasource.stub] enabled = false in config.
if cfg.Datasource.Stub.Enabled {
stubDS := stub.New()
if err := stubDS.Connect(ctx); err != nil {
log.Error("stub connect", "err", err)
os.Exit(1)
}
brk.Register(stubDS)
}
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 {
if cfg.Datasource.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)
@@ -83,8 +85,8 @@ func main() {
// 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 cfg.Datasource.EPICS.Enabled && epics.Available() {
ds := epics.New(cfg.Datasource.EPICS.CAAddrList, cfg.Datasource.EPICS.ArchiveURL)
if err := ds.Connect(ctx); err != nil {
log.Error("epics connect", "err", err)
} else {
@@ -92,7 +94,7 @@ func main() {
}
}
srv := server.New(cfg.Server.Listen, webFS, brk, synthDS, store, cfg.EPICS.ChannelFinderURL, log)
srv := server.New(cfg.Server.Listen, webFS, brk, synthDS, store, cfg.Datasource.EPICS.ChannelFinderURL, log)
if err := srv.Start(ctx); err != nil {
fmt.Fprintf(os.Stderr, "server error: %v\n", err)