GCodeGenerator / custom G-codes: Added new read/only options providing
the amount of total extruded material and per extruder extruded material up to the point the value is evaluated: "extruded_volume", "extruded_weight", "extruded_volume_total", "extruded_weight_total"
This commit is contained in:
parent
89b9f702d6
commit
2b7cf2d877
@ -438,6 +438,10 @@ void GCode::PlaceholderParserIntegration::reset()
|
||||
this->opt_e_position = nullptr;
|
||||
this->opt_e_retracted = nullptr;
|
||||
this->opt_e_restart_extra = nullptr;
|
||||
this->opt_extruded_volume = nullptr;
|
||||
this->opt_extruded_weight = nullptr;
|
||||
this->opt_extruded_volume_total = nullptr;
|
||||
this->opt_extruded_weight_total = nullptr;
|
||||
this->num_extruders = 0;
|
||||
this->position.clear();
|
||||
this->e_position.clear();
|
||||
@ -463,6 +467,14 @@ void GCode::PlaceholderParserIntegration::init(const GCodeWriter &writer)
|
||||
this->output_config.set_key_value("e_position", opt_e_position);
|
||||
}
|
||||
}
|
||||
this->opt_extruded_volume = new ConfigOptionFloats(this->num_extruders, 0.f);
|
||||
this->opt_extruded_weight = new ConfigOptionFloats(this->num_extruders, 0.f);
|
||||
this->opt_extruded_volume_total = new ConfigOptionFloat(0.f);
|
||||
this->opt_extruded_weight_total = new ConfigOptionFloat(0.f);
|
||||
this->parser.set("extruded_volume", this->opt_extruded_volume);
|
||||
this->parser.set("extruded_weight", this->opt_extruded_weight);
|
||||
this->parser.set("extruded_volume_total", this->opt_extruded_volume_total);
|
||||
this->parser.set("extruded_weight_total", this->opt_extruded_weight_total);
|
||||
|
||||
// Reserve buffer for current position.
|
||||
this->position.assign(3, 0);
|
||||
@ -484,10 +496,22 @@ void GCode::PlaceholderParserIntegration::update_from_gcodewriter(const GCodeWri
|
||||
assert(! extruders.empty() && num_extruders == extruders.back().id() + 1);
|
||||
this->e_retracted.assign(num_extruders, 0);
|
||||
this->e_restart_extra.assign(num_extruders, 0);
|
||||
this->opt_extruded_volume->values.assign(num_extruders, 0);
|
||||
this->opt_extruded_weight->values.assign(num_extruders, 0);
|
||||
double total_volume = 0.;
|
||||
double total_weight = 0.;
|
||||
for (const Extruder &e : extruders) {
|
||||
this->e_retracted[e.id()] = e.retracted();
|
||||
this->e_restart_extra[e.id()] = e.restart_extra();
|
||||
double v = e.extruded_volume();
|
||||
double w = v * e.filament_density() * 0.001;
|
||||
this->opt_extruded_volume->values[e.id()] = v;
|
||||
this->opt_extruded_weight->values[e.id()] = w;
|
||||
total_volume += v;
|
||||
total_weight += w;
|
||||
}
|
||||
opt_extruded_volume_total->value = total_volume;
|
||||
opt_extruded_weight_total->value = total_weight;
|
||||
opt_e_retracted->values = this->e_retracted;
|
||||
opt_e_restart_extra->values = this->e_restart_extra;
|
||||
if (! writer.config.use_relative_e_distances) {
|
||||
|
@ -362,6 +362,10 @@ private:
|
||||
ConfigOptionFloats *opt_e_position { nullptr };
|
||||
ConfigOptionFloats *opt_e_retracted { nullptr };
|
||||
ConfigOptionFloats *opt_e_restart_extra { nullptr };
|
||||
ConfigOptionFloats *opt_extruded_volume { nullptr };
|
||||
ConfigOptionFloats *opt_extruded_weight { nullptr };
|
||||
ConfigOptionFloat *opt_extruded_volume_total { nullptr };
|
||||
ConfigOptionFloat *opt_extruded_weight_total { nullptr };
|
||||
// Caches of the data passed to the script.
|
||||
size_t num_extruders;
|
||||
std::vector<double> position;
|
||||
|
Loading…
Reference in New Issue
Block a user