#telescope #astronomy

gmt_dos-clients

Giant Magellan Telescope Dynamic Optical Simulation Actor Clients

8 stable releases

3.0.0 Sep 14, 2023
2.4.0 Sep 12, 2023
2.2.0 Jun 9, 2023
2.1.0 May 16, 2023
1.0.0 Mar 10, 2023

#686 in Science

Download history 104/week @ 2023-06-03 74/week @ 2023-06-10 132/week @ 2023-06-17 90/week @ 2023-06-24 138/week @ 2023-07-01 189/week @ 2023-07-08 120/week @ 2023-07-15 106/week @ 2023-07-22 38/week @ 2023-07-29 84/week @ 2023-08-05 83/week @ 2023-08-12 42/week @ 2023-08-19 68/week @ 2023-08-26 88/week @ 2023-09-02 207/week @ 2023-09-09 52/week @ 2023-09-16

415 downloads per month
Used in 9 crates (7 directly)

MIT license

64KB
1.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};

// Original UID
#[derive(UID)]
#[uid(data = u8)]
pub enum A {}
pub struct 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–14MB
~143K SLoC