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
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
//
// Copyright (C) 2019 Kubos Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

//! Data returned by `daughterboardTelemetry` telemetry query

use crate::schema::Context;
use clyde_3g_eps_api::DaughterboardTelemetry::Type as DaughterboardTelemetryType;
use juniper::FieldResult;

/// Daughterboard telemetry structure
pub struct Telemetry;

macro_rules! make_telemetry {
    (
        $($type: ident,)+
    ) => {
        /// Daughterboard telemetry values
        ///
        /// See Table 11-8 in the EPS' User Manual for more information
        #[derive(Clone, Hash, Debug, Eq, GraphQLEnum, PartialEq)]
        pub enum Type {
            $(
                /// $type
                $type,
            )+
        }

        impl Into<DaughterboardTelemetryType> for Type {
            fn into(self) -> DaughterboardTelemetryType {
                match self {
                    $(Type::$type => DaughterboardTelemetryType::$type,)+
                }
            }
        }

        graphql_object!(Telemetry: Context as "daughterboard" |&self| {
            $(
                field $type(&executor) -> FieldResult<f64>
                {
                    Ok(executor.context().subsystem().get_daughterboard_telemetry(Type::$type)? as f64)
                }
            )+
        });
    }
}

make_telemetry!(
    VoltageFeedingBcr4,
    CurrentBcr4Sa4a,
    CurrentBcr4Sa4b,
    ArrayTempSa4a,
    ArrayTempSa4b,
    SunDetectorSa4a,
    SunDetectorSa4b,
    VoltageFeedingBcr5,
    CurrentBcr5Sa5a,
    CurrentBcr5Sa5b,
    ArrayTempSa5a,
    ArrayTempSa5b,
    SunDetectorSa5a,
    SunDetectorSa5b,
    VoltageFeedingBcr6,
    CurrentBcr6Sa6a,
    CurrentBcr6Sa6b,
    ArrayTempSa6a,
    ArrayTempSa6b,
    SunDetectorSa6a,
    SunDetectorSa6b,
    VoltageFeedingBcr7,
    CurrentBcr7Sa7a,
    CurrentBcr7Sa7b,
    ArrayTempSa7a,
    ArrayTempSa7b,
    SunDetectorSa7a,
    SunDetectorSa7b,
    VoltageFeedingBcr8,
    CurrentBcr8Sa8a,
    CurrentBcr8Sa8b,
    ArrayTempSa8a,
    ArrayTempSa8b,
    SunDetectorSa8a,
    SunDetectorSa8b,
    VoltageFeedingBcr9,
    CurrentBcr9Sa9a,
    CurrentBcr9Sa9b,
    ArrayTempSa9a,
    ArrayTempSa9b,
    SunDetectorSa9a,
    SunDetectorSa9b,
    BoardTemperature,
);