tdaq

package module
v0.14.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2023 License: BSD-3-Clause Imports: 29 Imported by: 2

README

tdaq

GitHub release Build Status codecov Go Report Card GoDoc License DOI

tdaq is a toolkit to create distributed DAQ systems, over TCP/IP.

Installation

$> go get github.com/go-daq/tdaq/...

Example

In a terminal, launch the run-control:

$> tdaq-runctl -web=:8080 -i -lvl dbg
tdaq-runctl          INFO listening on ":44000"...

::::::::::::::::::::::::::
:::  RunControl shell  :::
::::::::::::::::::::::::::

- /config -> configure tdaq processes
- /init   -> initialize tdaq processes
- /run    -> start a new run
- /stop   -> stop current run
- /reset  -> reset tdaq processes
- /status -> display status of all tdaq processes
- /quit   -> terminate tdaq processes (and quit)

tdaq-runctl          INFO waiting for commands...
tdaq-runctl>>
tdaq-runctl          INFO starting web run-ctl server on ":8080"...
tdaq-runctl          INFO received /join from conn 127.0.0.1:44066
tdaq-runctl          INFO   proc: "tdaq-datasrc"
tdaq-runctl          INFO    - outputs:
tdaq-runctl          INFO      - name: "/adc"
tdaq-runctl          INFO        addr: "[::]:34373"
tdaq-runctl          INFO received /join from conn 127.0.0.1:44112
tdaq-runctl          INFO   proc: "tdaq-datasink"
tdaq-runctl          INFO    - inputs:
tdaq-runctl          INFO      - name: "/adc"
tdaq-runctl>> /config
tdaq-runctl          INFO /config processes...
tdaq-runctl          DBG  sending /config to "tdaq-datasrc"...
tdaq-runctl          DBG  sending /config to "tdaq-datasink"...
tdaq-runctl          DBG  sending /config to "tdaq-datasrc"... [ok]
tdaq-runctl          DBG  sending /config to "tdaq-datasink"... [ok]
tdaq-runctl>> /init
tdaq-runctl          INFO /init processes...
tdaq-runctl          DBG  sending cmd CmdInit to "tdaq-datasrc"...
tdaq-runctl          DBG  sending cmd CmdInit... [ok]
tdaq-runctl          DBG  sending cmd CmdInit to "tdaq-datasrc"... [ok]
tdaq-runctl          DBG  sending cmd CmdInit to "tdaq-datasink"...
tdaq-runctl          DBG  sending cmd CmdInit... [ok]
tdaq-runctl          DBG  sending cmd CmdInit to "tdaq-datasink"... [ok]
tdaq-runctl>> /run
tdaq-runctl          INFO /start processes...
tdaq-runctl          DBG  sending cmd CmdStart to "tdaq-datasrc"...
tdaq-runctl          DBG  sending cmd CmdStart... [ok]
tdaq-runctl          DBG  sending cmd CmdStart to "tdaq-datasrc"... [ok]
tdaq-runctl          DBG  sending cmd CmdStart to "tdaq-datasink"...
tdaq-runctl          DBG  sending cmd CmdStart... [ok]
tdaq-runctl          DBG  sending cmd CmdStart to "tdaq-datasink"... [ok]
tdaq-runctl>> /stop
tdaq-runctl          INFO /stop processes...
tdaq-runctl          DBG  sending cmd CmdStop to "tdaq-datasrc"...
tdaq-runctl          DBG  sending cmd CmdStop... [ok]
tdaq-runctl          DBG  sending cmd CmdStop to "tdaq-datasrc"... [ok]
tdaq-runctl          DBG  sending cmd CmdStop to "tdaq-datasink"...
tdaq-runctl          DBG  sending cmd CmdStop... [ok]
tdaq-runctl          DBG  sending cmd CmdStop to "tdaq-datasink"... [ok]
tdaq-runctl>> /run
tdaq-runctl          INFO /start processes...
tdaq-runctl          DBG  sending cmd CmdStart to "tdaq-datasrc"...
tdaq-runctl          DBG  sending cmd CmdStart... [ok]
tdaq-runctl          DBG  sending cmd CmdStart to "tdaq-datasrc"... [ok]
tdaq-runctl          DBG  sending cmd CmdStart to "tdaq-datasink"...
tdaq-runctl          DBG  sending cmd CmdStart... [ok]
tdaq-runctl          DBG  sending cmd CmdStart to "tdaq-datasink"... [ok]
tdaq-runctl>> /stop
tdaq-runctl          INFO /stop processes...
tdaq-runctl          DBG  sending cmd CmdStop to "tdaq-datasink"...
tdaq-runctl          DBG  sending cmd CmdStop... [ok]
tdaq-runctl          DBG  sending cmd CmdStop to "tdaq-datasink"... [ok]
tdaq-runctl          DBG  sending cmd CmdStop to "tdaq-datasrc"...
tdaq-runctl          DBG  sending cmd CmdStop... [ok]
tdaq-runctl          DBG  sending cmd CmdStop to "tdaq-datasrc"... [ok]
tdaq-runctl>> /quit
tdaq-runctl          INFO /quit processes...
tdaq-runctl          DBG  sending cmd CmdQuit to "tdaq-datasrc"...
tdaq-runctl          DBG  sending cmd CmdQuit... [ok]
tdaq-runctl          DBG  sending cmd CmdQuit to "tdaq-datasrc"... [ok]
tdaq-runctl          DBG  sending cmd CmdQuit to "tdaq-datasink"...
tdaq-runctl          DBG  sending cmd CmdQuit... [ok]
tdaq-runctl          DBG  sending cmd CmdQuit to "tdaq-datasink"... [ok]
tdaq-runctl          INFO shutting down...
tdaq-runctl          INFO closing...

In a second terminal, launch the tdaq-datasrc data producer application:

$> tdaq-datasrc -lvl dbg
tdaq-datasrc         DBG  received /config command...
tdaq-datasrc         DBG  received /init command...
tdaq-datasrc         DBG  received /start command...
tdaq-datasrc         DBG  received /stop command... -> n=57
tdaq-datasrc         DBG  received /start command...
tdaq-datasrc         DBG  received /stop command... -> n=457
tdaq-datasrc         DBG  received "/quit" command...

In a third terminal, launch the tdaq-datasink data consumer application:

$> tdaq-datasink -lvl dbg
tdaq-datasink        DBG  received /config command...
tdaq-datasink        DBG  received /init command...
tdaq-datasink        DBG  received /start command...
tdaq-datasink        DBG  received /stop command... -> n=57
tdaq-datasink        DBG  received /start command...
tdaq-datasink        DBG  received /stop command... -> n=457
tdaq-datasink        DBG  received "/quit" command...

One has also access to a web-based control UI for the run-ctl:

web-ui

Documentation

Overview

Package tdaq is a minimal toolkit to implement a tiny data acquisition system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendCmd

func SendCmd(ctx context.Context, sck Sender, cmd Cmder) error

func SendFrame

func SendFrame(ctx context.Context, sck Sender, frame Frame) error

func SendMsg

func SendMsg(ctx context.Context, sck Sender, msg MsgFrame) error

Types

type Cmd

type Cmd struct {
	Type CmdType
	Body []byte
}

type CmdHandler

type CmdHandler func(ctx Context, resp *Frame, req Frame) error

type CmdType

type CmdType byte

CmdType describes the type of a command frame.

const (
	CmdUnknown CmdType = iota
	CmdJoin
	CmdConfig
	CmdInit
	CmdReset
	CmdStart
	CmdStop
	CmdQuit
	CmdStatus
)

func (CmdType) String

func (cmd CmdType) String() string

type Cmder

type Cmder interface {
	Marshaler
	Unmarshaler

	CmdType() CmdType
}

type ConfigCmd

type ConfigCmd struct {
	Name         string
	InEndPoints  []EndPoint
	OutEndPoints []EndPoint
}

func (ConfigCmd) CmdType

func (cmd ConfigCmd) CmdType() CmdType

func (ConfigCmd) MarshalTDAQ

func (cmd ConfigCmd) MarshalTDAQ() ([]byte, error)

func (*ConfigCmd) UnmarshalTDAQ

func (cmd *ConfigCmd) UnmarshalTDAQ(p []byte) error

type Context

type Context struct {
	Ctx context.Context
	Msg log.MsgStream
}

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder decodes values from the underlying io.Reader, according to the TDAQ wire protocol.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder creates a new decoder connected to the provided io.Reader.

func (*Decoder) Decode

func (dec *Decoder) Decode(ptr interface{}) error

Decode decodes a value from the underlying io.Reader into the provided pointer.

func (*Decoder) Err

func (dec *Decoder) Err() error

func (*Decoder) ReadBool

func (dec *Decoder) ReadBool() bool

func (*Decoder) ReadF32

func (dec *Decoder) ReadF32() float32

func (*Decoder) ReadF64

func (dec *Decoder) ReadF64() float64

func (*Decoder) ReadI16

func (dec *Decoder) ReadI16() int16

func (*Decoder) ReadI32

func (dec *Decoder) ReadI32() int32

func (*Decoder) ReadI64

func (dec *Decoder) ReadI64() int64

func (*Decoder) ReadI8

func (dec *Decoder) ReadI8() int8

func (*Decoder) ReadStr

func (dec *Decoder) ReadStr() string

func (*Decoder) ReadU16

func (dec *Decoder) ReadU16() uint16

func (*Decoder) ReadU32

func (dec *Decoder) ReadU32() uint32

func (*Decoder) ReadU64

func (dec *Decoder) ReadU64() uint64

func (*Decoder) ReadU8

func (dec *Decoder) ReadU8() uint8

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder encodes values to the underlying io.Writer, according to the TDAQ wire protocol.

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder creates a new encoder, connected to the provided io.Writer.

func (*Encoder) Encode

func (enc *Encoder) Encode(v interface{}) error

Encode encodes the provided value to the underlying io.Writer.

func (*Encoder) Err

func (enc *Encoder) Err() error

func (*Encoder) WriteBool

func (enc *Encoder) WriteBool(v bool)

func (*Encoder) WriteF32

func (enc *Encoder) WriteF32(v float32)

func (*Encoder) WriteF64

func (enc *Encoder) WriteF64(v float64)

func (*Encoder) WriteI16

func (enc *Encoder) WriteI16(v int16)

func (*Encoder) WriteI32

func (enc *Encoder) WriteI32(v int32)

func (*Encoder) WriteI64

func (enc *Encoder) WriteI64(v int64)

func (*Encoder) WriteI8

func (enc *Encoder) WriteI8(v int8)

func (*Encoder) WriteStr

func (enc *Encoder) WriteStr(v string)

func (*Encoder) WriteU16

func (enc *Encoder) WriteU16(v uint16)

func (*Encoder) WriteU32

func (enc *Encoder) WriteU32(v uint32)

func (*Encoder) WriteU64

func (enc *Encoder) WriteU64(v uint64)

func (*Encoder) WriteU8

func (enc *Encoder) WriteU8(v uint8)

type EndPoint

type EndPoint struct {
	Name string
	Addr string
	Type string
}

func (EndPoint) MarshalTDAQ

func (ep EndPoint) MarshalTDAQ() ([]byte, error)

func (*EndPoint) UnmarshalTDAQ

func (ep *EndPoint) UnmarshalTDAQ(b []byte) error

type Event

type Event struct {
	Type    uint32 // event type
	Version uint32 // event version
	Flags   uint32

	DeviceID uint32 // device or stream number
	RunNbr   uint32
	EvtNbr   uint32
	TrigNbr  uint32

	Timestamp struct {
		Beg uint64
		End uint64
	}

	Descr  string                 // description
	Tags   map[string]interface{} // tags associated with that event
	Blocks map[uint32][]byte      // blocks of raw data

	Subs []Event // sub events
	// contains filtered or unexported fields
}

type Frame

type Frame struct {
	Type FrameType // type of frame (cmd,data,err,ok)
	Path string    // end-point path
	Body []byte    // frame payload
}

Frame is the datum being exchanged between tdaq processes.

func RecvFrame

func RecvFrame(ctx context.Context, sck Recver) (frame Frame, err error)

type FrameType

type FrameType byte

FrameType describes the type of a Frame.

const (
	FrameUnknown FrameType = iota
	FrameCmd
	FrameData
	FrameMsg
	FrameOK
	FrameEOF
	FrameErr
)

func (FrameType) String

func (ft FrameType) String() string

type InputHandler

type InputHandler func(ctx Context, src Frame) error

type JoinCmd

type JoinCmd struct {
	Name         string // name of the process placing the /join command
	Ctl          string // address of ctl-REP socket of the process
	HBeat        string // address of hbeat-REP socket of the process
	Log          string // address of log-PUB socket of the process
	InEndPoints  []EndPoint
	OutEndPoints []EndPoint
}

func (JoinCmd) CmdType

func (cmd JoinCmd) CmdType() CmdType

func (JoinCmd) MarshalTDAQ

func (cmd JoinCmd) MarshalTDAQ() ([]byte, error)

func (*JoinCmd) UnmarshalTDAQ

func (cmd *JoinCmd) UnmarshalTDAQ(p []byte) error

type Marshaler

type Marshaler interface {
	MarshalTDAQ() ([]byte, error)
}

type MsgFrame

type MsgFrame struct {
	Name  string
	Level log.Level
	Msg   string
}

func (MsgFrame) MarshalTDAQ

func (frame MsgFrame) MarshalTDAQ() ([]byte, error)

func (*MsgFrame) UnmarshalTDAQ

func (frame *MsgFrame) UnmarshalTDAQ(p []byte) error

type OutputHandler

type OutputHandler func(ctx Context, dst *Frame) error

type Recver

type Recver interface {
	Recv() ([]byte, error)
}

type RunControl

type RunControl struct {
	// contains filtered or unexported fields
}

func NewRunControl

func NewRunControl(cfg config.RunCtl, stdout io.Writer) (*RunControl, error)

func (*RunControl) Do

func (rc *RunControl) Do(ctx context.Context, cmd CmdType) error

Do sends the provided command to all connected TDAQ processes.

func (*RunControl) NumClients

func (rc *RunControl) NumClients() int

NumClients returns the number of TDAQ processes connected to this run control.

func (*RunControl) Run

func (rc *RunControl) Run(ctx context.Context) error

type RunHandler

type RunHandler func(ctx Context) error

type Sender

type Sender interface {
	Send(msg []byte) error
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(cfg config.Process, stdout io.Writer) *Server

func (*Server) CmdHandle

func (srv *Server) CmdHandle(name string, h CmdHandler)

func (*Server) InputHandle

func (srv *Server) InputHandle(name string, h InputHandler)

func (*Server) OutputHandle

func (srv *Server) OutputHandle(name string, h OutputHandler)

func (*Server) Run

func (srv *Server) Run(ctx context.Context) error

func (*Server) RunHandle

func (srv *Server) RunHandle(f RunHandler)

type StatusCmd

type StatusCmd struct {
	Name   string
	Status fsm.Status
}

func (StatusCmd) CmdType

func (cmd StatusCmd) CmdType() CmdType

func (StatusCmd) MarshalTDAQ

func (cmd StatusCmd) MarshalTDAQ() ([]byte, error)

func (*StatusCmd) UnmarshalTDAQ

func (cmd *StatusCmd) UnmarshalTDAQ(p []byte) error

type Unmarshaler

type Unmarshaler interface {
	UnmarshalTDAQ(p []byte) error
}

Directories

Path Synopsis
cmd
tdaq-datasink
Command tdaq-datasink is a simple program that consumes data.
Command tdaq-datasink is a simple program that consumes data.
tdaq-datasrc
Command tdaq-datasrc is a simple program that generates data.
Command tdaq-datasrc is a simple program that generates data.
tdaq-i64-adder
Command tdaq-i64-adder is a simple program that consumes 2 streams of int64 data, add them together and passes the result on downstream.
Command tdaq-i64-adder is a simple program that consumes 2 streams of int64 data, add them together and passes the result on downstream.
tdaq-i64-dump
Command tdaq-i64-dump is a simple program that consumes int64 data and dumps it on screen.
Command tdaq-i64-dump is a simple program that consumes int64 data and dumps it on screen.
tdaq-i64-gen
Command tdaq-i64-gen is a simple program that generates int64 data.
Command tdaq-i64-gen is a simple program that generates int64 data.
tdaq-i64-process
Command tdaq-i64-process is a simple program that consumes int64 data, doubles it and passes it on downstream.
Command tdaq-i64-process is a simple program that consumes int64 data, doubles it and passes it on downstream.
tdaq-scaler
Command tdaq-scaler is a simple program that consumes data, applies some random pre-scaler filtering and passes it on downstream.
Command tdaq-scaler is a simple program that consumes data, applies some random pre-scaler filtering and passes it on downstream.
tdaq-splitter
Command tdaq-splitter is a simple program that consumes data, applies some random filtering and passes it on either the left- or right-downstream.
Command tdaq-splitter is a simple program that consumes data, applies some random filtering and passes it on either the left- or right-downstream.
Package config
Package config
Package flags provides an easy creation of standard tdaq flag parameters for tdaq processes
Package flags provides an easy creation of standard tdaq flag parameters for tdaq processes
internal
dflow
Package dflow exposes functions and types to represent a data-flow dependency graph.
Package dflow exposes functions and types to represent a data-flow dependency graph.
iomux
Package iomux provides simple goroutine safe I/O primitives.
Package iomux provides simple goroutine safe I/O primitives.
tcputil
Package tcputil provides functions for tcp.
Package tcputil provides functions for tcp.
Package job provides a high-level API to create and schedule a pool of run-ctl and tdaq servers together.
Package job provides a high-level API to create and schedule a pool of run-ctl and tdaq servers together.
Package log provides routines for logging messages.
Package log provides routines for logging messages.
Package xdaq provides components for filtering and exercizing TDAQ sequences.
Package xdaq provides components for filtering and exercizing TDAQ sequences.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL