use printobserver_types::contract::Sample;
use printobserver_types::schemars::JsonSchema;
use printobserver_types::serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", rename_all = "snake_case")]
#[schemars(crate = "printobserver_types::schemars")]
pub enum ImageKind {
ThreePanel,
WholeFrame,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", rename_all = "snake_case")]
#[schemars(crate = "printobserver_types::schemars")]
pub enum WholeFrameReasonCode {
NoPrint,
NoCalibration,
NoStream,
NoPosition,
NoObject,
NoLayer,
ToolpathUnread,
AlignmentPending,
AlignmentInconclusive,
AlignmentUnavailable,
AlignmentFailed,
LandmarksNotFound,
ViewRefitRejected,
CalibrationStale,
FrameMismatch,
Paused,
Refused,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct ImageFallback {
pub code: WholeFrameReasonCode,
pub message: String,
}
impl Sample for ImageFallback {
fn sample_full() -> Self {
Self {
code: WholeFrameReasonCode::AlignmentInconclusive,
message: "the print's first-layer alignment is inconclusive on the frame judged last: the toolhead covers the part, so a later check's frame is judged again".to_owned(),
}
}
fn sample_minimal() -> Self {
Self {
code: WholeFrameReasonCode::Paused,
message: "the printer reports the print paused".to_owned(),
}
}
}
impl Sample for ImageKind {
fn sample_full() -> Self {
Self::ThreePanel
}
fn sample_alternates() -> Vec<Self> {
vec![Self::WholeFrame]
}
}
impl Sample for WholeFrameReasonCode {
fn sample_full() -> Self {
Self::AlignmentInconclusive
}
fn sample_alternates() -> Vec<Self> {
vec![
Self::NoPrint,
Self::NoCalibration,
Self::NoStream,
Self::NoPosition,
Self::NoObject,
Self::NoLayer,
Self::ToolpathUnread,
Self::AlignmentPending,
Self::AlignmentUnavailable,
Self::AlignmentFailed,
Self::LandmarksNotFound,
Self::ViewRefitRejected,
Self::CalibrationStale,
Self::FrameMismatch,
Self::Paused,
Self::Refused,
]
}
}