1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * File: amplitude.rs
 * Project: src
 * Created Date: 07/11/2022
 * Author: Shun Suzuki
 * -----
 * Last Modified: 05/09/2023
 * Modified By: Shun Suzuki (suzuki@hapis.k.u-tokyo.ac.jp)
 * -----
 * Copyright (c) 2022-2023 Shun Suzuki. All rights reserved.
 *
 */

use crate::{datagram::*, defined::float, error::AUTDInternalError, geometry::*};

/// Amplitudes settings for AdvancedPhase mode
pub struct Amplitudes {
    amp: float,
}

impl Amplitudes {
    /// Constructor. Set amplitude uniformally.
    ///
    /// # Arguments
    ///
    /// * `amp` - Amplitude
    ///
    pub const fn uniform(amp: float) -> Self {
        Self { amp }
    }

    /// Constructor. Set amplitude to 0.
    pub const fn none() -> Self {
        Self::uniform(0.0)
    }

    pub const fn amp(&self) -> float {
        self.amp
    }
}

impl Datagram<AdvancedPhaseTransducer> for Amplitudes {
    type O1 = crate::operation::AmplitudeOp;
    type O2 = crate::operation::NullOp;

    fn operation(self) -> Result<(Self::O1, Self::O2), AUTDInternalError> {
        Ok((Self::O1::new(self.amp), Self::O2::default()))
    }
}