Skip to content

Commit

Permalink
Merge pull request #1279 from bdring/MultiLaser
Browse files Browse the repository at this point in the history
Allow multiple factory sections of the same name, e.g. laser
  • Loading branch information
bdring authored Aug 2, 2024
2 parents 0f9a326 + 223756a commit 9f7c7fc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
14 changes: 7 additions & 7 deletions FluidNC/src/Configuration/GenericFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ namespace Configuration {
auto name = (*it)->name();
auto it2 =
std::find_if(objects.begin(), objects.end(), [&](auto& object) { return strcasecmp(object->name(), name) == 0; });
if (it2 == objects.end()) {
auto object = (*it)->create(name);
objects.push_back(object);
handler.enterFactory(name, *object);
} else {
handler.enterFactory(name, **it2);
}
// If the config file contains multiple factory sections with the same name,
// for example two laser: sections or oled: sections, create a new node
// for each repetition. FluidNC can thus support multiple lasers with
// different tool numbers and output pins, multiple OLED displays, etc
auto object = (*it)->create(name);
objects.push_back(object);
handler.enterFactory(name, *object);
}
} else {
for (auto it : objects) {
Expand Down
6 changes: 6 additions & 0 deletions FluidNC/src/Spindles/Spindle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ namespace Spindles {
_speeds[i].scale = scaler;
}

void Spindle::validate() {
for (auto s : Spindles::SpindleFactory::objects()) {
Assert(s == this || s->_tool != _tool, "Duplicate tool_number %d with /%s", _tool, s->name());
}
}

void Spindle::afterParse() {
if (_speeds.size() && !maxSpeed()) {
log_error("Speed map max speed is 0. Using default");
Expand Down
5 changes: 1 addition & 4 deletions FluidNC/src/Spindles/Spindle.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ namespace Spindles {
const char* name() { return _name; }

// Configuration handlers:
void validate() override {
// TODO: Validate spinup/spindown delay?
}

void validate() override;
void afterParse() override;

void group(Configuration::HandlerBase& handler) override {
Expand Down

0 comments on commit 9f7c7fc

Please sign in to comment.