Metadata-Version: 2.5
Name: smart-emulator
Version: 1.0.1
Summary: Smart Emulator for DT4810 Python Library
Project-URL: Homepage, https://gitlab.nuclearinstruments.eu/public-repo/dt4810/smart-emulator-library
Project-URL: Documentation, https://public-repo.pages.nuclearinstruments.eu/dt4810/smart-emulator-library/
Project-URL: Bug Tracker, https://support.nuclearinstruments.eu
Author-email: Nuclear Instruments <info@nuclearinstruments.eu>
License: MIT
License-File: LICENSE
Keywords: CAEN,DT4810,Emulator,Nuclear Instruments,firmware,fpga
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Requires-Dist: requests
Description-Content-Type: text/markdown

# Smart Emulator — DT4810 Python Library

The full user documentation is available [here](https://public-repo.pages.nuclearinstruments.eu/dt4810/smart-emulator-library/).

## Features

- Simple connection handling (login/logout, session cookie, error reporting via `DT4810Error`)
- Pythonic configuration objects mirroring the device's REST API
- Enumerations for all categorical parameters (shape mode, amplitude mode, rate format, clock source, etc.)
- High-level acquisition control (turn on/off, reset, statistics, saved configurations)
- Readout of statistics, spectrum histograms, oscilloscope traces, and the reference spectrum catalog
- Equivalent client libraries are also available for [C++](../smart_emulator_cpp) and [C#](../smart_emulator_csharp)


## Quick start

```python
from smart_emulator import Emulator, ConfigTime, ConfigAmplitude

dt = Emulator()
dt.connect("http://192.168.50.20", "password")

print(dt.get_system_info())

# Configure rate and amplitude
dt.set_time_config(ConfigTime(
    mode=ConfigTime.Mode.POISSON,
    rate_format=ConfigTime.RateFormat.KHZ,
    rate=10.0,
))
dt.set_amplitude_config(ConfigAmplitude.fixed(lsb=8000))

# Run acquisition
dt.turn_on()
import time; time.sleep(5)
dt.turn_off()

spectrum = dt.get_spectrum_data()
print(spectrum)          # SpectrumData(bins=16384, total=...)

dt.disconnect()
```

## Documentation

The documentation is shared by the Python, C++ and C# libraries and lives at
the root of the repository. To build it locally:

```bash
# From the repository root (one level up from this folder)
pip install -r requirements-mkdocs.txt
mkdocs serve
```

Then open <http://127.0.0.1:8000/> in your browser.

The documentation is organized as:

- **Home** – overview and installation
- **Connection & System** – connection helpers and system information
- **Configuration** – digital I/O, shape/amplitude, time, noise and settings configuration
- **Acquisition & Data** – statistics, acquisition control and readout
- **Spectrum & Catalog** – spectrum histograms, uploads and the reference catalog
- **Config Library** – saved configuration management

## API overview

### `Emulator` — main class

| Group | Methods |
|---|---|
| Connection | `connect`, `disconnect` |
| System | `get_system_info`, `get_eth0`, `get_usb0`, `set_eth_config_dynamic`, `set_eth_config_static`, `reboot`, `set_password` |
| Output | `turn_on`, `turn_off`, `toggle_output`, `get_output_status`, `get_quick_status` |
| Configuration | `get/set_digital_io_configuration`, `set_inverter`, `get/set_shape_config`, `get/set_amplitude_config`, `get/set_time_config`, `get/set_noise_config`, `get/set_pulse_height` |
| Statistics | `get_statistics`, `get_home_statistics`, `reset_statistics`, `get_display_info` |
| Spectrum | `get_spectrum_data`, `reset_spectrum`, `start/stop_spectrum`, `get_spectrum_status`, `upload_spectrum`, `get_last_spectra_list`, `get_last_spectrum_data`, `delete_last_spectrum`, `delete_all_last_spectra` |
| Oscilloscope | `get_oscilloscope_data` |
| Config library | `get_config_list`, `get_saved_configs`, `get_configuration_by_id`, `get_loaded_config`, `save_config`, `update_config`, `load_config_by_id`, `load_config_from_file`, `check_config_name`, `rename_config`, `delete_config`, `get_global_config` |
| Catalog | `get_elements`, `get_catalog_spectrum` |

### Configuration classes

| Class | Parameters |
|---|---|
| `ConfigDigitalIO` | `digital_in`, `digital_out`, `pulse_delay`, `pulse_width`, `inverter`, `offset`, `gain` |
| `ConfigShape` | `mode` (exponential / pulse), `tau`, `rc_risetime`, `rise_time`, `fall_time`, `flat` |
| `ConfigAmplitude` | `mode` (fixed / spectrum), `lsb`, `spectrum_name`, `spectrum_data` |
| `ConfigTime` | `mode` (constant / poisson), `rate_format` (hz / khz), `rate` |
| `ConfigNoise` | `white_noise_enabled/v/lsb` (the only noise the device actually applies) |

## Versioning

This library follows [Semantic Versioning](https://semver.org/):

- **MAJOR** – incompatible API changes
- **MINOR** – new functionality in a backwards-compatible manner
- **PATCH** – backwards-compatible bug fixes

Tag releases in Git and publish the same version to PyPI and GitLab Pages when appropriate.

## Contact / Support

Issues: <https://support.nuclearinstruments.eu>

## License

MIT — see [LICENSE](LICENSE).
