https://github.com/stephtr/experiment-framework
https://github.com/stephtr/experiment-framework
Last synced: 29 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/stephtr/experiment-framework
- Owner: stephtr
- Created: 2022-08-17T22:06:50.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-08T16:25:18.000Z (over 1 year ago)
- Last Synced: 2025-03-02T22:18:06.714Z (over 1 year ago)
- Language: C#
- Size: 85.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Experiment Framework
This framework is specifically made for apps controlling physical experiments.
Its purpose is to manage external components and provide a layer of abstraction which makes switching between different implementations (devices surving a specific purpose, for example different lasers) easy.
Implementations exist for Lasers (TOPTICA), Cameras (Andor, Baumer, FLIR Grasshopper, Photonfocus) and Stages (MadCityLabs, SmarAct), although the source code can't be put under Open Source.
## Example usage
For a working example (including the UI components), see the [TestApp](TestApp).
```c#
var Components = ExperimentContainer.Singleton;
```
Add component classes:
```c#
Components.AddComponentClass();
Components.AddComponentClass();
```
Add all available implementations:
```c#
Components.AddComponent();
Components.AddComponent();
Components.AddComponent();
Components.AddComponent();
```
Make the component settings persistent:
```c#
Components.UseWinUISettingsStore();
Components.LoadFromSettings();
```
Initialize a component (if not anyway being done by `LoadFromSettings` or by the [ExperimentSettings](#experimentsettings) component):
```c#
Components.ActivateComponentAsync(typeof(LaserComponent), null, typeof(FakeLaser).Name, new FakeLaserSettings());
```
Get & use a component:
```c#
var laser = Components.GetActiveComponent();
laser.IsOn = true;
```
Get notified on component changes:
```c#
// either (for a specific component):
Components.AddComponentChangeHandler((newLaser) => { ... });
// or (for all component changes):
Components.ComponentChanged += (componentClass, id, newComponent) => { ... };
```
## WinUI 3 components
The framework comes with a few WinUI components:
### ExperimentSettings
Displays controls to change between different component class implementations and change their respective settings:

### ExperimentStatusBar
Shows a statusbar which displays all loaded components and their state (double click to reload a component):