eulumdat/
bug_rating.rs

1//! BUG rating types for Python bindings
2
3use pyo3::prelude::*;
4
5/// BUG (Backlight-Uplight-Glare) rating per IESNA TM-15-11.
6#[pyclass]
7#[derive(Clone)]
8pub struct BugRating {
9    /// Backlight rating (0-5).
10    #[pyo3(get)]
11    pub b: u8,
12    /// Uplight rating (0-5).
13    #[pyo3(get)]
14    pub u: u8,
15    /// Glare rating (0-5).
16    #[pyo3(get)]
17    pub g: u8,
18}
19
20#[pymethods]
21impl BugRating {
22    fn __repr__(&self) -> String {
23        format!("B{} U{} G{}", self.b, self.u, self.g)
24    }
25
26    fn __str__(&self) -> String {
27        format!("B{} U{} G{}", self.b, self.u, self.g)
28    }
29}
30
31/// Zone lumens breakdown for BUG rating calculation.
32#[pyclass]
33#[derive(Clone)]
34pub struct ZoneLumens {
35    /// Backlight Low: 0-30°
36    #[pyo3(get)]
37    pub bl: f64,
38    /// Backlight Mid: 30-60°
39    #[pyo3(get)]
40    pub bm: f64,
41    /// Backlight High: 60-80°
42    #[pyo3(get)]
43    pub bh: f64,
44    /// Backlight Very High: 80-90°
45    #[pyo3(get)]
46    pub bvh: f64,
47    /// Forward Low: 0-30°
48    #[pyo3(get)]
49    pub fl: f64,
50    /// Forward Mid: 30-60°
51    #[pyo3(get)]
52    pub fm: f64,
53    /// Forward High: 60-80°
54    #[pyo3(get)]
55    pub fh: f64,
56    /// Forward Very High: 80-90°
57    #[pyo3(get)]
58    pub fvh: f64,
59    /// Uplight Low: 90-100°
60    #[pyo3(get)]
61    pub ul: f64,
62    /// Uplight High: 100-180°
63    #[pyo3(get)]
64    pub uh: f64,
65}
66
67#[pymethods]
68impl ZoneLumens {
69    fn __repr__(&self) -> String {
70        format!(
71            "ZoneLumens(BL={:.1}, BM={:.1}, BH={:.1}, BVH={:.1}, FL={:.1}, FM={:.1}, FH={:.1}, FVH={:.1}, UL={:.1}, UH={:.1})",
72            self.bl, self.bm, self.bh, self.bvh, self.fl, self.fm, self.fh, self.fvh, self.ul, self.uh
73        )
74    }
75}