ENH: refine time estimation in filament change

1.Add sync command. Now gcode and dirrectly add time sync command
2.Add support for ceil and floor in placeholder
3.Update change filament gcode for H2D

jira: NONE

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I6dd97cbd96bae1c2751c08357ff64947876d7471
(cherry picked from commit c99fcd454c2499b0c0e3ed9402a2182c00a9bffa)
This commit is contained in:
xun.zhang
2025-01-04 16:46:59 +08:00
committed by Noisyfox
parent 74cf5b424a
commit 56d40ca24f
4 changed files with 141 additions and 7 deletions

View File

@@ -386,6 +386,36 @@ namespace client
return expr();
}
expr floor(const Iterator start_pos)const
{
switch (this->type()) {
case TYPE_INT:
return expr(this->i(), start_pos, this->it_range.end());
case TYPE_DOUBLE:
return expr(static_cast<int>(std::floor(this->d())), start_pos, this->it_range.end());
default:
this->throw_exception("Cannot floor a non-numeric value.");
}
assert(false);
// Suppress compiler warnings.
return expr();
}
expr ceil(const Iterator start_pos)const
{
switch (this->type()) {
case TYPE_INT:
return expr(this->i(), start_pos, this->it_range.end());
case TYPE_DOUBLE:
return expr(static_cast<int>(std::ceil(this->d())), start_pos, this->it_range.end());
default:
this->throw_exception("Cannot ceil a non-numeric value.");
}
assert(false);
// Suppress compiler warnings.
return expr();
}
expr unary_not(const Iterator start_pos) const
{
switch (this->type()) {
@@ -1926,6 +1956,10 @@ namespace client
{ out = value.unary_integer(out.it_range.begin()); }
static void round(expr &value, expr &out)
{ out = value.round(out.it_range.begin()); }
static void floor(expr &value, expr &out)
{ out = value.floor(out.it_range.begin()); }
static void ceil(expr &value, expr &out)
{ out = value.ceil(out.it_range.begin());}
// For indicating "no optional parameter".
static void noexpr(expr &out) { out.reset(); }
};
@@ -2176,6 +2210,8 @@ namespace client
[ px::bind(&expr::digits<true>, _val, _2, _3) ]
| (kw["int"] > '(' > conditional_expression(_r1) > ')') [ px::bind(&FactorActions::to_int, _1, _val) ]
| (kw["round"] > '(' > conditional_expression(_r1) > ')') [ px::bind(&FactorActions::round, _1, _val) ]
| (kw["ceil"] > '(' > conditional_expression(_r1) > ')') [ px::bind(&FactorActions::ceil, _1, _val) ]
| (kw["floor"] > '(' > conditional_expression(_r1) > ')') [ px::bind(&FactorActions::floor, _1, _val) ]
| (kw["is_nil"] > '(' > variable_reference(_r1) > ')') [px::bind(&MyContext::is_nil_test, _r1, _1, _val)]
| (kw["one_of"] > '(' > one_of(_r1) > ')') [ _val = _1 ]
| (kw["empty"] > '(' > variable_reference(_r1) > ')') [px::bind(&MyContext::is_vector_empty, _r1, _1, _val)]
@@ -2256,6 +2292,8 @@ namespace client
("filament_change")
("repeat")
("round")
("floor")
("ceil")
("not")
("one_of")
("or")