# StreamGenerator

The StreamGenerator, is an Epics module that almost completely implements the
same interface as the [sinqDAQ](https://gitea.psi.ch/lin-epics-modules/sinqDAQ)
Epics module, as an attempt to maintain a consistent interface across all our
data acquisition systems. Sitting behind the interface, however, is different
electronics and firmware, specifically, a multi-readout module "Correlation
Unit" system, which was developed at MLZ.

## Correlation Unit Documentation

The UDP based interface, as well as many other specifics of the detector system
are described in the first file, and within the `doc` directory of the
`qmesydaq` repository.

- [20220608\_ErwiN\_Detector.pdf](./docs/20220608_ErwiN_Detector.pdf)
- [qmesydaq/doc](https://gitea.psi.ch/lin-controls/qmesydaq/src/branch/master/doc/)

## Retrieving Code

Clone the repository to a local directory via:

```
git clone --recurse-submodules -j8 git@gitea.psi.ch:lin-epics-modules/StreamGenerator.git
```

## Dependencies

Currently, this project requires a system install of librdkafka. On Redhat,
this means you should run:

```bash
dnf install -y librdkafka-devel
```

Additionally, you must first build Google's *flatbuffers* and ESS's
**streaming-data-types** libraries, which are both included in this project as
submodules under the `dep` directory and which are both necessary to build this
project.

First, you should enter the *flatbuffers* directory and run the following:

```bash
cmake -G "Unix Makefiles"
make -j
```

After these steps, you will find the program `flatc` has been built and placed
in the directory.

Next, you should return to the top of this project's directory tree, and create
the flatbuffers from ESS's schema files. This you can do as follows:

```bash
./dep/flatbuffers/flatc -o schemas/ --cpp --gen-mutable --gen-name-strings --scoped-enums ./dep/streaming-data-types/schemas/*
```

This generates header files from each of ESS's schemas and places them in a
schemas directory.
