diff --git a/fix/header.go b/fix/header.go index 92111c3..92fbe0e 100644 --- a/fix/header.go +++ b/fix/header.go @@ -20,19 +20,19 @@ func headerV0() [][]byte { h = append(h, H(";header_type: 3dp")) h = append(h, H(";tool_head: %s", Params.ToolHead)) h = append(h, H(";machine: %s", Params.Model)) - h = append(h, H(";file_total_lines: %d", Params.TotalLines)) + h = append(h, H(";file_total_lines: %d", Params.TotalLines+34)) h = append(h, H(";estimated_time(s): %.0f", float64(Params.EstimatedTimeSec)*1.07)) h = append(h, H(";nozzle_temperature(°C): %.0f", Params.EffectiveNozzleTemperature())) h = append(h, H(";nozzle_0_temperature(°C): %.0f", Params.NozzleTemperatures[0])) h = append(h, H(";nozzle_0_diameter(mm): %.1f", Params.NozzleDiameters[0])) h = append(h, H(";nozzle_0_material: %s", Params.FilamentTypes[0])) h = append(h, H(";Extruder 0 Retraction Distance: %.2f", Params.Retractions[0])) - h = append(h, H(";Extruder 0 Switch Retraction Distance: %.2f", Params.SwitchRetraction)) + h = append(h, H(";Extruder 0 Switch Retraction Distance: %.2f", Params.SwitchRetraction[0])) h = append(h, H(";nozzle_1_temperature(°C): %.0f", Params.NozzleTemperatures[1])) h = append(h, H(";nozzle_1_diameter(mm): %.1f", Params.NozzleDiameters[1])) h = append(h, H(";nozzle_1_material: %s", Params.FilamentTypes[1])) h = append(h, H(";Extruder 1 Retraction Distance: %.2f", Params.Retractions[1])) - h = append(h, H(";Extruder 1 Switch Retraction Distance: %.2f", Params.SwitchRetraction)) + h = append(h, H(";Extruder 1 Switch Retraction Distance: %.2f", Params.SwitchRetraction[1])) h = append(h, H(";build_plate_temperature(°C): %.0f", Params.EffectiveBedTemperature())) h = append(h, H(";work_speed(mm/minute): %.0f", Params.PrintSpeedSec*60)) h = append(h, H(";max_x(mm): %.4f", Params.MaxX)) @@ -59,18 +59,18 @@ func headerV1() [][]byte { h = append(h, H(";Version:1")) h = append(h, H(";Printer:%s", Params.Model)) h = append(h, H(";Estimated Print Time:%d", Params.EstimatedTimeSec)) - h = append(h, H(";Lines:%d", Params.TotalLines)) + h = append(h, H(";Lines:%d", Params.TotalLines+27)) h = append(h, H(";Extruder Mode:%s", Params.PrintMode)) h = append(h, H(";Extruder 0 Nozzle Size:%.1f", Params.NozzleDiameters[0])) h = append(h, H(";Extruder 0 Material:%s", Params.FilamentTypes[0])) h = append(h, H(";Extruder 0 Print Temperature:%.0f", Params.NozzleTemperatures[0])) h = append(h, H(";Extruder 0 Retraction Distance:%.2f", Params.Retractions[0])) - h = append(h, H(";Extruder 0 Switch Retraction Distance:%.2f", Params.SwitchRetraction)) + h = append(h, H(";Extruder 0 Switch Retraction Distance:%.2f", Params.SwitchRetraction[0])) h = append(h, H(";Extruder 1 Nozzle Size:%.1f", Params.NozzleDiameters[1])) h = append(h, H(";Extruder 1 Material:%s", Params.FilamentTypes[1])) h = append(h, H(";Extruder 1 Print Temperature:%.0f", Params.NozzleTemperatures[1])) h = append(h, H(";Extruder 1 Retraction Distance:%.2f", Params.Retractions[1])) - h = append(h, H(";Extruder 1 Switch Retraction Distance:%.2f", Params.SwitchRetraction)) + h = append(h, H(";Extruder 1 Switch Retraction Distance:%.2f", Params.SwitchRetraction[1])) h = append(h, H(";Bed Temperature:%.0f", Params.EffectiveBedTemperature())) h = append(h, H(";Work Range - Min X:%.4f", Params.MinX)) h = append(h, H(";Work Range - Min Y:%.4f", Params.MinY)) diff --git a/fix/params.go b/fix/params.go index 19a4976..c25e8b5 100644 --- a/fix/params.go +++ b/fix/params.go @@ -27,7 +27,7 @@ type slicerParams struct { NozzleTemperatures []float64 NozzleDiameters []float64 Retractions []float64 - SwitchRetraction float64 + SwitchRetraction []float64 BedTemperatures []float64 FilamentTypes []string FilamentUsed []float64 // mm @@ -42,36 +42,6 @@ type slicerParams struct { Thumbnail []byte } -var Params = slicerParams{ - Version: 0, - Model: "", - ToolHead: ToolheadSingle, - PrintMode: PrintModeDefault, - LeftExtruderUsed: false, - RightExtruderUsed: false, - PrinterNotes: "", - LayerHeight: 0, - TotalLayers: 0, - TotalLines: 0, - EstimatedTimeSec: 0, - NozzleTemperatures: []float64{-1, -1}, - NozzleDiameters: []float64{-1, -1}, - Retractions: []float64{-1, -1}, - SwitchRetraction: 0, - BedTemperatures: []float64{-1, -1}, - FilamentTypes: []string{"", ""}, - FilamentUsed: []float64{-1, -1}, - FilamentUsedWeight: []float64{-1, -1}, - PrintSpeedSec: 0, - MinX: 0, - MinY: 0, - MinZ: 0, - MaxX: 0, - MaxY: 0, - MaxZ: 0, - Thumbnail: []byte{}, -} - func (p *slicerParams) EffectiveNozzleTemperature() float64 { return p.effective(p.NozzleTemperatures[0], p.NozzleTemperatures[1]) } @@ -95,6 +65,41 @@ func (p *slicerParams) effective(x, y float64) float64 { return x } +func NewParams() *slicerParams { + return &slicerParams{ + Version: 0, + Model: "", + ToolHead: ToolheadSingle, + PrintMode: PrintModeDefault, + LeftExtruderUsed: false, + RightExtruderUsed: false, + PrinterNotes: "", + LayerHeight: 0, + TotalLayers: 0, + TotalLines: 0, + EstimatedTimeSec: 0, + NozzleTemperatures: []float64{-1, -1}, + NozzleDiameters: []float64{-1, -1}, + Retractions: []float64{-1, -1}, + SwitchRetraction: []float64{-1, -1}, + BedTemperatures: []float64{-1, -1}, + FilamentTypes: []string{"", ""}, + FilamentUsed: []float64{-1, -1}, + FilamentUsedWeight: []float64{-1, -1}, + PrintSpeedSec: 0, + MinX: 0, + MinY: 0, + MinZ: 0, + MaxX: 0, + MaxY: 0, + MaxZ: 0, + Thumbnail: []byte{}, + } + +} + +var Params = NewParams() + func ParseParams(f io.Reader) error { defer func(f io.Reader) { if h, ok := f.(io.ReadSeeker); ok { @@ -117,6 +122,7 @@ func ParseParams(f io.Reader) error { ) //////// scan + Params = NewParams() for sc.Scan() { Params.TotalLines++ @@ -155,7 +161,7 @@ func ParseParams(f io.Reader) error { } else if v, ok := getSetting(line, "retract_length", "retraction_length" /*bbs*/); ok { retract_len = splitFloat(v) } else if v, ok := getSetting(line, "retract_length_toolchange"); ok { - Params.SwitchRetraction = parseFloat(v) + Params.SwitchRetraction = splitFloat(v) } else if v, ok := getSetting(line, "nozzle_diameter"); ok { Params.NozzleDiameters = splitFloat(v) } else if v, ok := getSetting(line, "layer_height", "first_layer_height"); ok && Params.LayerHeight == 0 {