Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Aug 3, 2024
1 parent 3572c6c commit f55d3b3
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 71 deletions.
64 changes: 46 additions & 18 deletions bambulabs/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Message {
pub fn sequence_id(&self) -> Option<SequenceId> {
match self {
Message::Print(print) => Some(print.sequence_id()),
Message::Info(info) => Some(info.sequence_id.clone()),
Message::Info(info) => Some(info.sequence_id()),
Message::System(system) => Some(system.sequence_id()),
Message::Json(_) | Message::Unknown(_) => None,
}
Expand Down Expand Up @@ -205,10 +205,16 @@ pub struct ExtrusionCaliGet {
pub struct PushStatus {
/// The sequence id.
pub sequence_id: SequenceId,
/// The aux part fan.
pub aux_part_fan: Option<bool>,
/// The upload.
pub upload: Option<PrintUpload>,
/// The nozzle diameter.
pub nozzle_diameter: Option<String>,
/// The nozzle temperature.
pub nozzle_temper: Option<f64>,
/// The nozzle type.
pub nozzle_type: Option<NozzleType>,
/// The target nozzle temperature.
pub nozzle_target_temper: Option<f64>,
/// The bed temperature.
Expand Down Expand Up @@ -326,6 +332,8 @@ pub struct PrintUpload {
pub progress: i64,
/// The message.
pub message: String,
#[serde(flatten)]
other: BTreeMap<String, Value>,
}

/// The print online.
Expand All @@ -337,6 +345,8 @@ pub struct PrintOnline {
pub rfid: Option<bool>,
/// The version.
pub version: i64,
#[serde(flatten)]
other: BTreeMap<String, Value>,
}

/// The print ams.
Expand Down Expand Up @@ -366,6 +376,8 @@ pub struct PrintAms {
pub insert_flag: Option<bool>,
/// The power on flag.
pub power_on_flag: Option<bool>,
#[serde(flatten)]
other: BTreeMap<String, Value>,
}

/// The print ams data.
Expand All @@ -379,6 +391,8 @@ pub struct PrintAmsData {
pub temp: String,
/// The tray.
pub tray: Vec<PrintTray>,
#[serde(flatten)]
other: BTreeMap<String, Value>,
}

/// The print tray.
Expand Down Expand Up @@ -424,6 +438,8 @@ pub struct PrintTray {
pub k: Option<f64>,
/// The tray n.
pub n: Option<i64>,
#[serde(flatten)]
other: BTreeMap<String, Value>,
}

/// The print ipcam.
Expand All @@ -437,15 +453,19 @@ pub struct PrintIpcam {
pub timelapse: Option<String>,
/// The mode bits.
pub mode_bits: Option<i64>,
#[serde(flatten)]
other: BTreeMap<String, Value>,
}

/// A print lights report.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
pub struct PrintLightsReport {
/// The node.
pub node: String,
pub node: LedNode,
/// The mode.
pub mode: String,
pub mode: LedMode,
#[serde(flatten)]
other: BTreeMap<String, Value>,
}

/// A print upgrade state.
Expand Down Expand Up @@ -473,34 +493,42 @@ pub struct PrintUpgradeState {
pub new_version_state: Option<i64>,
/// The new version list.
pub new_ver_list: Option<Vec<Value>>,
#[serde(flatten)]
other: BTreeMap<String, Value>,
}

/// An info command.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case", tag = "command")]
pub enum Info {
/// Get the version.
GetVersion(GetVersion),
}

impl Info {
/// Returns the sequence id of the message.
pub fn sequence_id(&self) -> SequenceId {
match self {
Info::GetVersion(get_version) => get_version.sequence_id.clone(),
}
}
}

/// A info message.
/// A get version message.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
pub struct Info {
pub struct GetVersion {
/// The sequence id.
pub sequence_id: SequenceId,
/// The info command.
pub command: InfoCommand,
/// The info module.
pub module: Vec<InfoModule>,
/// The result of the info command.
pub result: Option<String>,
pub result: Result,
/// The reason of the info command.
pub reason: Option<String>,
pub reason: Option<Reason>,
#[serde(flatten)]
other: BTreeMap<String, Value>,
}

/// An info command.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Display, FromStr)]
#[serde(rename_all = "snake_case")]
#[display(style = "snake_case")]
pub enum InfoCommand {
/// Get the version.
GetVersion,
}

/// An info module.
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
pub struct InfoModule {
Expand Down
138 changes: 86 additions & 52 deletions openapi/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,59 +45,58 @@
"type": "object"
},
"Info": {
"additionalProperties": true,
"description": "A info message.",
"properties": {
"command": {
"allOf": [
{
"$ref": "#/components/schemas/InfoCommand"
}
],
"description": "The info command."
},
"module": {
"description": "The info module.",
"items": {
"$ref": "#/components/schemas/InfoModule"
},
"type": "array"
},
"reason": {
"description": "The reason of the info command.",
"nullable": true,
"type": "string"
},
"result": {
"description": "The result of the info command.",
"nullable": true,
"type": "string"
},
"sequence_id": {
"allOf": [
{
"$ref": "#/components/schemas/SequenceId"
}
],
"description": "The sequence id."
}
},
"required": [
"command",
"module",
"sequence_id"
],
"type": "object"
},
"InfoCommand": {
"description": "An info command.",
"oneOf": [
{
"additionalProperties": true,
"description": "Get the version.",
"enum": [
"get_version"
"properties": {
"command": {
"enum": [
"get_version"
],
"type": "string"
},
"module": {
"description": "The info module.",
"items": {
"$ref": "#/components/schemas/InfoModule"
},
"type": "array"
},
"reason": {
"allOf": [
{
"$ref": "#/components/schemas/Reason"
}
],
"description": "The reason of the info command.",
"nullable": true
},
"result": {
"allOf": [
{
"$ref": "#/components/schemas/Result"
}
],
"description": "The result of the info command."
},
"sequence_id": {
"allOf": [
{
"$ref": "#/components/schemas/SequenceId"
}
],
"description": "The sequence id."
}
},
"required": [
"command",
"module",
"result",
"sequence_id"
],
"type": "string"
"type": "object"
}
]
},
Expand Down Expand Up @@ -490,6 +489,11 @@
"nullable": true,
"type": "integer"
},
"aux_part_fan": {
"description": "The aux part fan.",
"nullable": true,
"type": "boolean"
},
"bed_target_temper": {
"description": "The target bed temperature.",
"format": "double",
Expand Down Expand Up @@ -645,6 +649,11 @@
"nullable": true,
"type": "integer"
},
"nozzle_diameter": {
"description": "The nozzle diameter.",
"nullable": true,
"type": "string"
},
"nozzle_target_temper": {
"description": "The target nozzle temperature.",
"format": "double",
Expand All @@ -657,6 +666,15 @@
"nullable": true,
"type": "number"
},
"nozzle_type": {
"allOf": [
{
"$ref": "#/components/schemas/NozzleType"
}
],
"description": "The nozzle type.",
"nullable": true
},
"online": {
"allOf": [
{
Expand Down Expand Up @@ -1038,6 +1056,7 @@
]
},
"PrintAms": {
"additionalProperties": true,
"description": "The print ams.",
"properties": {
"ams": {
Expand Down Expand Up @@ -1108,6 +1127,7 @@
"type": "object"
},
"PrintAmsData": {
"additionalProperties": true,
"description": "The print ams data.",
"properties": {
"humidity": {
Expand Down Expand Up @@ -1139,6 +1159,7 @@
"type": "object"
},
"PrintIpcam": {
"additionalProperties": true,
"description": "The print ipcam.",
"properties": {
"ipcam_dev": {
Expand Down Expand Up @@ -1188,15 +1209,24 @@
"type": "object"
},
"PrintLightsReport": {
"additionalProperties": true,
"description": "A print lights report.",
"properties": {
"mode": {
"description": "The mode.",
"type": "string"
"allOf": [
{
"$ref": "#/components/schemas/LedMode"
}
],
"description": "The mode."
},
"node": {
"description": "The node.",
"type": "string"
"allOf": [
{
"$ref": "#/components/schemas/LedNode"
}
],
"description": "The node."
}
},
"required": [
Expand All @@ -1206,6 +1236,7 @@
"type": "object"
},
"PrintOnline": {
"additionalProperties": true,
"description": "The print online.",
"properties": {
"ahb": {
Expand Down Expand Up @@ -1248,6 +1279,7 @@
"type": "object"
},
"PrintTray": {
"additionalProperties": true,
"description": "The print tray.",
"properties": {
"bed_temp": {
Expand Down Expand Up @@ -1359,6 +1391,7 @@
"type": "object"
},
"PrintUpgradeState": {
"additionalProperties": true,
"description": "A print upgrade state.",
"properties": {
"consistency_request": {
Expand Down Expand Up @@ -1425,6 +1458,7 @@
"type": "object"
},
"PrintUpload": {
"additionalProperties": true,
"description": "The print upload.",
"properties": {
"message": {
Expand Down
Loading

0 comments on commit f55d3b3

Please sign in to comment.