# BunchLengthMonitor
This is the EPICS 7 application for running ATCA-based Bunch Length Monitors for 
LCLS, LCLS-II and FACET-II

## About
### Table of Contents
1. [Common](#common)
2. [LCLS-II](#lcls2)
3. [LCLS (MR)](#lcls)
4. [FACET-II](#facet2)


<a name="common"></a>
## Common
### Directory Structure
In general, the directory structure follows the standard EPICS IOC directory structure. Below you can find a tree with a short description
of each folder.


### Startup Scripts
Effort has been made to make startup scripts modular. The idea is that in order to bring up an IOC a few macros need to be defined with values
and then common startup scripts should be called. This should make deploying a new IOC as simple as copy/pasting an existing IOC in the facility. 
if new features are desired in existing IOCs then only one common startup script should need to be edited unless new macros are introduced.


### Triggers
Triggers are based on assignments from the firmware engineer (leosap@ as of Jan 14, 2021). You can 
find them on his confluence page ( 
<a href="https://confluence.slac.stanford.edu/display/~leosap/Trigger+assignment+map+in+tprTrigger+on+CPFW">MR (LCLS + FACET-II),</a>, 
<a href="https://confluence.slac.stanford.edu/display/~leosap/Trigger+assignment+map+in+tprTrigger+on+CPFW+for+LCLS2+BLEN">LCLS-II</a>). 
In general, the triggers/channels are mapped 1-to-1. For example, channel 1 corresponds to trigger 1, channel 15 to trigger 15, etc.


<a name="lcls2"></a>
## LCLS-II


<a name="lcls"></a>
## LCLS (MR)
The best resource is Marcio's documentation on Confluence:
<a href="https://confluence.slac.stanford.edu/display/~marcio/BLEN+MR+IOC+Application">Marcio's BLEN Page</a>
Some of it may be slightly out of date (esp. with regards to the C++ implementation details) but it is overall
a high quality document.


<a name="facet2"></a>
## FACET-II
The FACET-II configuration is a hybrid of LCLS-II and LCLS (MR). It uses the Mission Readiness firmware but
it has some features from the LCLS-II design as well as some differences that are specific to the FACET-II facility.


Some key differences:
    * No signal conditioning chassis
    * No motion control (Pyrodetector)
    * Only two channels (Gap Diode)


### FCOM
The LCLS FCOM Network uses external hardware as the multicast routing infrastructure. In FACET-II however, the only
sources and sinks are BPMs and BLEN, respectively. Also unique to FACET-II is the BPM and BLEN installations that need
to communicate over FCOM are running as processes on the same CPU. So the CPUs loopback interface in IN10/LI11/LI14 areas
are configured for multicast. BPMs will broadcast data to the loopback interface which is then passed on by the BLEN software
to the firmware in the same way as is done in LCLS (MR) BLEN.
