99
1010use anyhow:: Result ;
1111use rocket:: serde:: { Deserialize , Serialize } ;
12+ use rocket_okapi:: JsonSchema ;
1213use std:: collections:: { HashMap , VecDeque } ;
1314use std:: time:: { SystemTime , UNIX_EPOCH } ;
1415use tokio:: sync:: RwLock ;
15-
1616/// Maximum number of historical data points per regulator (1 day at 1Hz)
1717pub const MAX_HISTORY_SIZE : usize = 86400 ;
1818
1919/// Single data point in thermal regulation history
20- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
20+ #[ derive( Debug , Clone , Serialize , Deserialize , JsonSchema ) ]
2121pub struct ThermalDataPoint {
2222 /// Timestamp in Unix seconds
2323 pub timestamp : u64 ,
@@ -32,7 +32,7 @@ pub struct ThermalDataPoint {
3232}
3333
3434/// PID controller components for analysis
35- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
35+ #[ derive( Debug , Clone , Serialize , Deserialize , JsonSchema ) ]
3636pub struct PidComponents {
3737 /// Proportional term value
3838 pub proportional : f64 ,
@@ -45,7 +45,7 @@ pub struct PidComponents {
4545}
4646
4747/// Historical data for a single thermal regulator
48- #[ derive( Debug , Clone ) ]
48+ #[ derive( Debug , Clone , Serialize , Deserialize , JsonSchema ) ]
4949pub struct ThermalRegulatorHistory {
5050 /// Regulator unique identifier
5151 pub id : String ,
@@ -64,7 +64,7 @@ pub struct ThermalRegulatorHistory {
6464}
6565
6666/// Current status of a thermal regulator
67- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
67+ #[ derive( Debug , Clone , Serialize , Deserialize , JsonSchema ) ]
6868pub enum RegulatorStatus {
6969 /// Regulator is not initialized
7070 Uninitialized ,
@@ -79,7 +79,7 @@ pub enum RegulatorStatus {
7979}
8080
8181/// Current PID parameters for a regulator
82- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
82+ #[ derive( Debug , Clone , Serialize , Deserialize , JsonSchema ) ]
8383pub struct CurrentPidParams {
8484 /// Proportional gain
8585 pub kp : f64 ,
@@ -95,7 +95,7 @@ pub struct CurrentPidParams {
9595}
9696
9797/// Shared thermal regulation state across the entire system
98- #[ derive( Debug ) ]
98+ #[ derive( Clone , Debug , Serialize , Deserialize , JsonSchema ) ]
9999pub struct SharedThermalRegulationState {
100100 /// Map of regulator ID to its historical data
101101 regulators : HashMap < String , ThermalRegulatorHistory > ,
@@ -106,7 +106,7 @@ pub struct SharedThermalRegulationState {
106106}
107107
108108/// Global thermal regulation system status
109- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
109+ #[ derive( Debug , Clone , Serialize , Deserialize , JsonSchema ) ]
110110pub struct ThermalSystemStatus {
111111 /// Total number of configured regulators
112112 pub total_regulators : usize ,
0 commit comments