#telescope #simulation #optical #actors #dynamic #interface #clients

gmt_dos-clients

Giant Magellan Telescope Dynamic Optical Simulation Actor Clients

17 stable releases (3 major)

4.2.0 Mar 20, 2024
4.0.1 Feb 22, 2024
3.3.2 Jan 15, 2024
3.3.1 Dec 6, 2023
1.0.0 Mar 10, 2023

#924 in Science

Download history 26/week @ 2024-01-15 21/week @ 2024-01-22 136/week @ 2024-02-19 116/week @ 2024-02-26 20/week @ 2024-03-04 238/week @ 2024-03-11 168/week @ 2024-03-18 11/week @ 2024-03-25 154/week @ 2024-04-01

575 downloads per month
Used in 12 crates (10 directly)

MIT license

88KB
2K SLoC

gmt_dos-clients

Crates.io Documentation

The crate defines the client-to-actor interface and a set of "generic" clients.

If the crate is required solely to implement the interface for a new client, add it to the list of dependencies like so:

cargo add --no-default-features --features interface gmt_dos-clients

lib.rs:

Actors clients

The module holds the implementation of the different clients that can be assigned to Actors.

Any structure can become a client to an Actor if it implements the Update trait with either or both Read and Write traits.

Example

Logging

A simple logger with a single entry:

use gmt_dos_clients::Logging;
let logging = Logging::<f64>::default();

A logger with 2 entries and pre-allocated with 1000 elements:

use gmt_dos_clients::Logging;
let logging = Logging::<f64>::default().n_entry(2).capacity(1_000);

Signals

A constant signal for 100 steps

use gmt_dos_clients::{Signals, Signal};
let signal: Signals = Signals::new(1, 100).signals(Signal::Constant(3.14));

A 2 outputs signal made of a constant and a sinusoid for 100 steps

use gmt_dos_clients::{Signals, Signal};
let signal: Signals = Signals::new(2, 100)
.output_signal(0, Signal::Constant(3.14))
.output_signal(1, Signal::Sinusoid{
amplitude: 1f64,
sampling_frequency_hz: 1000f64,
frequency_hz: 20f64,
phase_s: 0f64
});

Rate transitionner

A rate transition actor for a named output/input pair sampling a [Vec]

use gmt_dos_clients::Sampler;
#[derive(interface::UID)]
enum MyIO {};
let sampler = Sampler::<Vec<f64>, MyIO>::default();

Alias to input/output UID

Creating an alias to an already existing UniqueIdentifier (UID)

use std::sync::Arc;
use interface::{Data, Write, UniqueIdentifier,Size, UID, Update};

// Original UID
#[derive(UID)]
#[uid(data = u8)]
pub enum A {}
pub struct Client {}
impl Update for Client {}
impl Write<A> for Client {
fn write(&mut self) -> Option<Data<A>> {
Some(Data::new(10u8))
}
}
impl Size<A> for Client {
fn len(&self) -> usize {
123
}
}

// A alias with `Write` and `Size` trait implementation for `Client`
#[derive(UID)]
#[uid(data = u8)]
#[alias(name = A, client = Client, traits = Write ,Size)]
pub enum B {}

let _: <A as UniqueIdentifier>::DataType = 1u8;
let _: <B as UniqueIdentifier>::DataType = 2u8;

let mut client = Client {};
println!(
"Client Write<B>: {:?}",
<Client as Write<B>>::write(&mut client)
);
println!(
"Client Size<B>: {:?}",
<Client as Size<B>>::len(&mut client)
);

Dependencies

~2–13MB
~115K SLoC