Document goo format header info
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use common::serde::SizedString;
|
||||
|
||||
use crate::{HeaderInfo, LayerContent, PreviewImage};
|
||||
use crate::{header_info::ExposureDelayMode, HeaderInfo, LayerContent, PreviewImage};
|
||||
|
||||
impl Default for HeaderInfo {
|
||||
fn default() -> Self {
|
||||
@@ -27,7 +27,7 @@ impl Default for HeaderInfo {
|
||||
z_size: 260.0,
|
||||
layer_thickness: 0.05,
|
||||
exposure_time: 3.0,
|
||||
exposure_delay_mode: true,
|
||||
exposure_delay_mode: ExposureDelayMode::StaticTime,
|
||||
turn_off_time: 0.0,
|
||||
bottom_before_lift_time: 0.0,
|
||||
bottom_after_lift_time: 0.0,
|
||||
@@ -55,7 +55,7 @@ impl Default for HeaderInfo {
|
||||
second_retract_speed: 0.0,
|
||||
bottom_light_pwm: 255,
|
||||
light_pwm: 255,
|
||||
advance_mode: false,
|
||||
per_layer_settings: false,
|
||||
printing_time: 2659,
|
||||
total_volume: 526.507,
|
||||
total_weight: 0.684,
|
||||
@@ -70,7 +70,7 @@ impl Default for HeaderInfo {
|
||||
impl Default for LayerContent {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
pause_flag: 0,
|
||||
pause: false,
|
||||
pause_position_z: 200.0,
|
||||
layer_position_z: 0.05,
|
||||
layer_exposure_time: 50.0,
|
||||
|
@@ -6,67 +6,142 @@ use common::serde::{Deserializer, Serializer, SizedString};
|
||||
|
||||
use crate::{PreviewImage, DELIMITER, MAGIC_TAG};
|
||||
|
||||
/// The header section of a `.goo` file.
|
||||
pub struct HeaderInfo {
|
||||
/// Format version, should be "V3.0".
|
||||
pub version: SizedString<4>,
|
||||
/// Name of software that generated the file.
|
||||
pub software_info: SizedString<32>,
|
||||
/// Version of the slicer software.
|
||||
pub software_version: SizedString<24>,
|
||||
/// Time the file was created, recommended format is "%Y-%m-%d %H:%M:%S".
|
||||
pub file_time: SizedString<24>,
|
||||
/// Name of the printer the file was generated for.
|
||||
/// The default is "standard", but I don't think this field is used for anything.
|
||||
pub printer_name: SizedString<32>,
|
||||
/// Type of printer the file was generated for.
|
||||
/// The default is "Default", but I don't think this field is used for anything.
|
||||
pub printer_type: SizedString<32>,
|
||||
/// Name of the profile used to generate the file.
|
||||
/// I don't think this field is used for anything.
|
||||
pub profile_name: SizedString<32>,
|
||||
/// The anti-aliasing level used when generating the file.
|
||||
pub anti_aliasing_level: u16,
|
||||
/// Honestly not sure what this is.
|
||||
pub grey_level: u16,
|
||||
/// The blur level used when generating the file.
|
||||
pub blur_level: u16,
|
||||
/// 116 by 116 preview image.
|
||||
pub small_preview: PreviewImage<116, 116>,
|
||||
/// 290 by 290 preview image.
|
||||
pub big_preview: PreviewImage<290, 290>,
|
||||
/// Number of layers in the file.
|
||||
pub layer_count: u32,
|
||||
/// X resolution of the printer, in pixels.
|
||||
/// The sliced file will not print if the printer's resolution does not match this value.
|
||||
pub x_resolution: u16,
|
||||
/// Y resolution of the printer, in pixels.
|
||||
/// The sliced file will not print if the printer's resolution does not match this value.
|
||||
pub y_resolution: u16,
|
||||
/// Indicates if the print should be mirrored in the X direction.
|
||||
/// Not tested, so this might be wrong.
|
||||
pub x_mirror: bool,
|
||||
/// Indicates if the print should be mirrored in the Y direction.
|
||||
/// Not tested, so this might be wrong.
|
||||
pub y_mirror: bool,
|
||||
/// Size of the print area in the X direction, in mm.
|
||||
pub x_size: f32,
|
||||
/// Size of the print area in the Y direction, in mm.
|
||||
pub y_size: f32,
|
||||
/// Size of the print area in the Z direction, in mm.
|
||||
pub z_size: f32,
|
||||
/// Thickness of each layer, in mm.
|
||||
pub layer_thickness: f32,
|
||||
/// Default exposure time for each layer, in seconds.
|
||||
pub exposure_time: f32,
|
||||
pub exposure_delay_mode: bool,
|
||||
/// The exposure delay mode to use.
|
||||
/// ('turn off time' confuses me)
|
||||
pub exposure_delay_mode: ExposureDelayMode,
|
||||
/// Layer exposure delay when in seconds when in [`ExposureDelayMode::TurnOffTime`].
|
||||
pub turn_off_time: f32,
|
||||
/// Time to wait before lifting the platform after exposing the bottom layers, in seconds.
|
||||
/// When exposure delay mode is [`ExposureDelayMode::StaticTime`].
|
||||
pub bottom_before_lift_time: f32,
|
||||
/// Time to wait after lifting the platform after exposing the bottom layers, in seconds.
|
||||
pub bottom_after_lift_time: f32,
|
||||
/// Time to wait after retracting the platform after exposing the bottom layers, in seconds.
|
||||
pub bottom_after_retract_time: f32,
|
||||
/// Time to wait before lifting the platform after exposing each regular layer, in seconds.
|
||||
pub before_lift_time: f32,
|
||||
/// Time to wait after lifting the platform after exposing each regular layer, in seconds.
|
||||
pub after_lift_time: f32,
|
||||
/// Time to wait after retracting the platform after exposing each regular layer, in seconds.
|
||||
pub after_retract_time: f32,
|
||||
/// Exposure time for the bottom layers, in seconds.
|
||||
pub bottom_exposure_time: f32,
|
||||
/// Number of bottom layers.
|
||||
pub bottom_layers: u32,
|
||||
/// Distance to lift the platform after exposing each bottom layer, in mm.
|
||||
pub bottom_lift_distance: f32,
|
||||
/// The speed to lift the platform after exposing each bottom layer, in mm/min.
|
||||
pub bottom_lift_speed: f32,
|
||||
/// Distance to lift the platform after exposing each regular layer, in mm.
|
||||
pub lift_distance: f32,
|
||||
/// The speed to lift the platform after exposing each regular layer, in mm/min.
|
||||
pub lift_speed: f32,
|
||||
/// Distance to retract (move down) the platform after exposing each bottom layer, in mm.
|
||||
pub bottom_retract_distance: f32,
|
||||
/// The speed to retract (move down) the platform after exposing each bottom layer, in mm/min.
|
||||
pub bottom_retract_speed: f32,
|
||||
/// Distance to retract (move down) the platform after exposing each regular layer, in mm.
|
||||
pub retract_distance: f32,
|
||||
/// The speed to retract (move down) the platform after exposing each regular layer, in mm/min.
|
||||
pub retract_speed: f32,
|
||||
/// Second distance to lift the platform after exposing each bottom layer, in mm.
|
||||
pub bottom_second_lift_distance: f32,
|
||||
/// The speed to lift the platform after exposing each bottom layer, in mm/min.
|
||||
pub bottom_second_lift_speed: f32,
|
||||
/// Second distance to lift the platform after exposing each regular layer, in mm.
|
||||
pub second_lift_distance: f32,
|
||||
/// The speed to lift the platform after exposing each regular layer, in mm/min.
|
||||
pub second_lift_speed: f32,
|
||||
/// Second distance to retract (move down) the platform after exposing each bottom layer, in mm.
|
||||
pub bottom_second_retract_distance: f32,
|
||||
/// The speed to retract (move down) the platform after exposing each bottom layer, in mm/min.
|
||||
pub bottom_second_retract_speed: f32,
|
||||
/// Second distance to retract (move down) the platform after exposing each regular layer, in mm.
|
||||
pub second_retract_distance: f32,
|
||||
/// The speed to retract (move down) the platform after exposing each regular layer, in mm/min.
|
||||
pub second_retract_speed: f32,
|
||||
pub bottom_light_pwm: u16,
|
||||
pub light_pwm: u16,
|
||||
pub advance_mode: bool,
|
||||
/// The power of the light for the bottom layers, 0-255.
|
||||
pub bottom_light_pwm: u8,
|
||||
/// The power of the light for the regular layers, 0-255.
|
||||
pub light_pwm: u8,
|
||||
/// If these global settings should be overwritten by each layers settings. Aka "Advanced Mode".
|
||||
pub per_layer_settings: bool,
|
||||
/// Estimated time to print the file, in seconds.
|
||||
pub printing_time: u32,
|
||||
/// Estimated volume of resin used, in mm^3.
|
||||
pub total_volume: f32,
|
||||
/// Estimated weight of resin used, in grams.
|
||||
pub total_weight: f32,
|
||||
/// Estimated price of resin used, in the currency specified by `price_unit`.
|
||||
pub total_price: f32,
|
||||
/// The currency symbol used for the price.
|
||||
pub price_unit: SizedString<8>,
|
||||
/// If false, layer gray values range from 0x00 to 0x0f, otherwise 0x00 to 0xff.
|
||||
pub grey_scale_level: bool,
|
||||
/// The number of layers to transition between bottom and regular exposure settings.
|
||||
pub transition_layers: u16,
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum ExposureDelayMode {
|
||||
TurnOffTime,
|
||||
StaticTime,
|
||||
}
|
||||
|
||||
impl HeaderInfo {
|
||||
pub const SIZE: usize = 0x2FB95;
|
||||
}
|
||||
@@ -99,7 +174,7 @@ impl HeaderInfo {
|
||||
ser.write_f32(self.z_size);
|
||||
ser.write_f32(self.layer_thickness);
|
||||
ser.write_f32(self.exposure_time);
|
||||
ser.write_bool(self.exposure_delay_mode);
|
||||
ser.write_u8(self.exposure_delay_mode as u8);
|
||||
ser.write_f32(self.turn_off_time);
|
||||
ser.write_f32(self.bottom_before_lift_time);
|
||||
ser.write_f32(self.bottom_after_lift_time);
|
||||
@@ -125,9 +200,9 @@ impl HeaderInfo {
|
||||
ser.write_f32(self.bottom_second_retract_speed);
|
||||
ser.write_f32(self.second_retract_distance);
|
||||
ser.write_f32(self.second_retract_speed);
|
||||
ser.write_u16(self.bottom_light_pwm);
|
||||
ser.write_u16(self.light_pwm);
|
||||
ser.write_bool(self.advance_mode);
|
||||
ser.write_u16(self.bottom_light_pwm as u16);
|
||||
ser.write_u16(self.light_pwm as u16);
|
||||
ser.write_bool(self.per_layer_settings);
|
||||
ser.write_u32(self.printing_time);
|
||||
ser.write_f32(self.total_volume);
|
||||
ser.write_f32(self.total_weight);
|
||||
@@ -164,7 +239,7 @@ impl HeaderInfo {
|
||||
let z_size = des.read_f32();
|
||||
let layer_thickness = des.read_f32();
|
||||
let exposure_time = des.read_f32();
|
||||
let exposure_delay_mode = des.read_bool();
|
||||
let exposure_delay_mode = ExposureDelayMode::from_bool(des.read_bool());
|
||||
let turn_off_time = des.read_f32();
|
||||
let bottom_before_lift_time = des.read_f32();
|
||||
let bottom_after_lift_time = des.read_f32();
|
||||
@@ -190,8 +265,8 @@ impl HeaderInfo {
|
||||
let bottom_second_retract_speed = des.read_f32();
|
||||
let second_retract_distance = des.read_f32();
|
||||
let second_retract_speed = des.read_f32();
|
||||
let bottom_light_pwm = des.read_u16();
|
||||
let light_pwm = des.read_u16();
|
||||
let bottom_light_pwm = des.read_u16().min(255) as u8;
|
||||
let light_pwm = des.read_u16().min(255) as u8;
|
||||
let advance_mode = des.read_bool();
|
||||
let printing_time = des.read_u32();
|
||||
let total_volume = des.read_f32();
|
||||
@@ -253,7 +328,7 @@ impl HeaderInfo {
|
||||
second_retract_speed,
|
||||
bottom_light_pwm,
|
||||
light_pwm,
|
||||
advance_mode,
|
||||
per_layer_settings: advance_mode,
|
||||
printing_time,
|
||||
total_volume,
|
||||
total_weight,
|
||||
@@ -265,6 +340,15 @@ impl HeaderInfo {
|
||||
}
|
||||
}
|
||||
|
||||
impl ExposureDelayMode {
|
||||
pub fn from_bool(value: bool) -> Self {
|
||||
match value {
|
||||
false => ExposureDelayMode::TurnOffTime,
|
||||
true => ExposureDelayMode::StaticTime,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for HeaderInfo {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("HeaderInfo")
|
||||
@@ -325,7 +409,7 @@ impl Debug for HeaderInfo {
|
||||
.field("second_retract_speed", &self.second_retract_speed)
|
||||
.field("bottom_light_pwm", &self.bottom_light_pwm)
|
||||
.field("light_pwm", &self.light_pwm)
|
||||
.field("advance_mode", &self.advance_mode)
|
||||
.field("advance_mode", &self.per_layer_settings)
|
||||
.field("printing_time", &self.printing_time)
|
||||
.field("total_volume", &self.total_volume)
|
||||
.field("total_weight", &self.total_weight)
|
||||
|
@@ -5,8 +5,8 @@ use common::serde::{Deserializer, Serializer};
|
||||
use crate::DELIMITER;
|
||||
|
||||
pub struct LayerContent {
|
||||
/// 0: Don't pause; 1: Pause on current layer
|
||||
pub pause_flag: u16,
|
||||
/// If printing should be paused on current layer.
|
||||
pub pause: bool,
|
||||
/// The Z position to to if paused, in mm.
|
||||
pub pause_position_z: f32,
|
||||
/// The Z position of the layer, in mm.
|
||||
@@ -39,7 +39,7 @@ pub struct LayerContent {
|
||||
/// Speed to retract the platform a second time, in mm/min.
|
||||
pub second_retract_speed: f32,
|
||||
/// Brightness of the light, 0-255.
|
||||
pub light_pwm: u16,
|
||||
pub light_pwm: u8,
|
||||
/// The actual layer data, run length encoded with [`goo_format::LayerEncoder`].
|
||||
pub data: Vec<u8>,
|
||||
/// Negative wrapping sum of all bytes in `data`.
|
||||
@@ -48,7 +48,7 @@ pub struct LayerContent {
|
||||
|
||||
impl LayerContent {
|
||||
pub fn serialize<T: Serializer>(&self, ser: &mut T) {
|
||||
ser.write_u16(self.pause_flag);
|
||||
ser.write_u16(self.pause as u16);
|
||||
ser.write_f32(self.pause_position_z);
|
||||
ser.write_f32(self.layer_position_z);
|
||||
ser.write_f32(self.layer_exposure_time);
|
||||
@@ -64,7 +64,7 @@ impl LayerContent {
|
||||
ser.write_f32(self.retract_speed);
|
||||
ser.write_f32(self.second_retract_distance);
|
||||
ser.write_f32(self.second_retract_speed);
|
||||
ser.write_u16(self.light_pwm);
|
||||
ser.write_u16(self.light_pwm as u16);
|
||||
ser.write_bytes(DELIMITER);
|
||||
ser.write_u32(self.data.len() as u32 + 2);
|
||||
ser.write_bytes(&[0x55]);
|
||||
@@ -90,7 +90,7 @@ impl LayerContent {
|
||||
let retract_speed = des.read_f32();
|
||||
let second_retract_distance = des.read_f32();
|
||||
let second_retract_speed = des.read_f32();
|
||||
let light_pwm = des.read_u16();
|
||||
let light_pwm = des.read_u16().min(255) as u8;
|
||||
ensure!(des.read_bytes(2) == DELIMITER);
|
||||
let data_len = des.read_u32() as usize - 2;
|
||||
ensure!(des.read_u8() == 0x55);
|
||||
@@ -99,7 +99,7 @@ impl LayerContent {
|
||||
ensure!(des.read_bytes(2) == DELIMITER);
|
||||
|
||||
Ok(Self {
|
||||
pause_flag,
|
||||
pause: pause_flag != 0,
|
||||
pause_position_z,
|
||||
layer_position_z,
|
||||
layer_exposure_time,
|
||||
|
Reference in New Issue
Block a user