#telescope #simulation #optical #dynamic #actor #giant #magellan

gmt_dos-clients

Giant Magellan Telescope Dynamic Optical Simulation Actor Clients

19 stable releases (3 major)

4.4.0 Oct 30, 2024
4.3.0 May 3, 2024
4.2.0 Mar 20, 2024
3.3.2 Jan 15, 2024
1.0.0 Mar 10, 2023

#906 in Science

Download history 12/week @ 2024-08-17 14/week @ 2024-08-24 9/week @ 2024-08-31 16/week @ 2024-09-07 12/week @ 2024-09-14 49/week @ 2024-09-21 14/week @ 2024-09-28 11/week @ 2024-10-12 6/week @ 2024-10-19 135/week @ 2024-10-26 33/week @ 2024-11-02 8/week @ 2024-11-09 20/week @ 2024-11-16 23/week @ 2024-11-23 26/week @ 2024-11-30

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

MIT license

420KB
2.5K 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

~3–14MB
~156K SLoC