wiki/Web-app-startup.md
2025-02-12 22:29:12 +01:00

133 lines
5.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Startup Options on the Web Server
Several tools are available on the web server to **initialize and restore camera and spectrometer settings efficiently**. These tools ensure that **EPICS settings match the configurations stored in the camera server**, preventing data acquisition issues due to misconfigurations.
---
## Save and Restore for Camera Settings
SwissFEL cameras **do not** have a built-in save-and-restore function for settings. This tool allows **Basler** and **PCO edge** cameras to be **configured with predefined settings stored in the camera server**.
> **⚠️ Important:** Applying saved settings **momentarily stops running cameras (~1 second)** and **overwrites current settings**.
### Operation
The **Camera Settings Panel** is accessible via **[https://sf-photodiag-test.psi.ch/](https://sf-photodiag-test.psi.ch/)** under the **Startup** tab.
Cameras are **grouped by beamline** (e.g., **Beamline Aramis, Beamline Athos, etc.**). **Pressing the relevant button applies settings to all cameras in the selected group**, provided that their configuration file contains a `hardware_configuration` dictionary.
### Camera Grouping
The tool uses the **`group` field** in the camera configuration to organize cameras into logical groups for easier bulk operations. Currently used groups include:
- **Beamline Aramis**
- **Beamline Athos**
Other groups **can be added** by modifying the camera configurations.
### Database and Configuration Structure
The tool retrieves camera settings from configuration files stored on the **camera server**, accessible via **CSM or API**. Settings are stored in a dictionary called **`"hardware_configuration"`**, which contains key-value pairs corresponding to **EPICS process variables (PVs)**.
#### Example Camera Configuration
```json
"hardware_configuration": {
"EXPOSURE": 9.9,
"HSSPEED": 1,
"REGIONX_START": 1,
"REGIONY_START": 500
}
```
Each key in `"hardware_configuration"` corresponds to a **PV suffix** for the respective camera. For example, for the camera **`SARFE10-PSSS059`**, the `"EXPOSURE"` setting will update the EPICS PV:
```plaintext
SARFE10-PSSS059:EXPOSURE → 9.9
```
> **Adding New Settings:**
To include additional settings for a camera, **edit its configuration file** in the camera server, ensure the `"hardware_configuration"` dictionary is present, and add the required EPICS parameters.
---
## Spectrometer Setup Panel
The **Spectrometer Setup Panel** ensures that **spectrometers operate with the correct EPICS settings** and that the **energy axis is calibrated** to match the cameras current image dimensions.
### What Happens When a Setup Button is Pressed?
When a **Setup** button is pressed for a spectrometer, the following process takes place:
1. **Retrieve Stored Configuration**
- The system **loads the predefined EPICS settings** from the camera server.
- **Key parameters such as exposure time, binning, and trigger settings are retrieved**.
2. **Prepare the Camera for Update**
- The camera is **set to idle mode (`CAMERASTATUS = 1`)** to allow safe modifications.
- The system **waits for the camera to stop acquiring data** before proceeding.
3. **Apply Configuration Settings to EPICS**
- Each stored setting is **written to the corresponding EPICS PV**.
4. **Apply Settings Using `SET_PARAM`**
- Once all values are updated, the system **triggers `SET_PARAM`**, instructing the camera to apply the new settings.
5. **Update the Energy Axis Calibration**
- The system **determines the correct energy axis length** based on **camera image width or height**.
- A new **energy axis array** is generated and written to **`SPECTRUM_X`**.
6. **Restore Camera Status**
- The system **returns the camera to its original state (`CAMERASTATUS` is restored)** after updating.
7. **User Feedback**
- A **status message** below each button confirms whether the update was **successful** or if an **error occurred**.
---
### When Should These Buttons Be Used?
Use these buttons in the following cases:
- **Spectrometer data is not updating** or is missing from the display.
- **Values appear incorrect** or **not aligned with expectations**.
- **Camera or spectrometer settings were changed and need to be restored**.
- **After a system reboot or power cycle** to ensure proper configuration.
---
## Example: Camera and Spectrometer Configuration Process
This example illustrates how settings are applied to an EPICS-controlled camera and spectrometer.
#### Example Configuration for a Spectrometer (`SARFE10-PSSS059`)
```json
"hardware_configuration": {
"EXPOSURE": 12.5,
"TRIGGER": 1,
"BINX": 2,
"BINY": 2
}
```
When the **setup button is pressed**, the following EPICS PVs are updated:
```plaintext
SARFE10-PSSS059:EXPOSURE → 12.5
SARFE10-PSSS059:TRIGGER → 1
SARFE10-PSSS059:BINX → 2
SARFE10-PSSS059:BINY → 2
```
The system then applies `SET_PARAM`, recalibrates the **energy axis**, and **restores the camera to its original state**.
---
## User Interface Overview
Below is a preview of the interface, showing the Camera Settings Panel and Spectrometer Setup Panel:
![Interface Preview](https://docs.google.com/drawings/d/138H9Jph71I3xpSsGuAYB4wlwvoDWJgVUTBsgNFMNrdo/pub?w=960&h=720)
---