Skip to content

Commit

Permalink
VFD rework (#1324)
Browse files Browse the repository at this point in the history
* Fixed Generate_VCXProj

* Moved VFD spindles to their own namespace and inheritance structure. TODO: Configuration.

* Changed the factory a bit to ensure configurations still work.

* This compiles. TODO: Loader script.

* Changed names and made them consistent. This also removes them from IRAM.

* Split out the VFDProtocol code into a separate file.

* Added comment

---------

Co-authored-by: Stefan de Bruijn <stefan@nubilosoft.com>
  • Loading branch information
atlaste and Stefan de Bruijn authored Oct 27, 2024
1 parent 59f9b17 commit 8e36c50
Show file tree
Hide file tree
Showing 37 changed files with 2,214 additions and 2,085 deletions.
23 changes: 21 additions & 2 deletions FluidNC/src/Configuration/GenericFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Configuration {

GenericFactory() = default;

GenericFactory(const GenericFactory&) = delete;
GenericFactory(const GenericFactory&) = delete;
GenericFactory& operator=(const GenericFactory&) = delete;

class BuilderBase {
Expand All @@ -28,7 +28,7 @@ namespace Configuration {
public:
BuilderBase(const char* name) : name_(name) {}

BuilderBase(const BuilderBase& o) = delete;
BuilderBase(const BuilderBase& o) = delete;
BuilderBase& operator=(const BuilderBase& o) = delete;

virtual BaseType* create(const char* name) const = 0;
Expand Down Expand Up @@ -59,6 +59,24 @@ namespace Configuration {
BaseType* create(const char* name) const override { return new DerivedType(name); }
};

template <typename DerivedType, typename DependencyType>
class DependentInstanceBuilder : public BuilderBase {
public:
explicit DependentInstanceBuilder(const char* name, bool autocreate = false) : BuilderBase(name) {
instance().registerBuilder(this);
if (autocreate) {
auto& objects = instance().objects_;
auto object = create(name);
objects.push_back(object);
}
}

DerivedType* create(const char* name) const override {
auto dependency = new DependencyType();
return new DerivedType(name, dependency);
}
};

// This factory() method is used when there can be only one instance of the type,
// as with a kinematics system. The variable that points to the instance must
// be created externally and passed as an argument.
Expand All @@ -75,6 +93,7 @@ namespace Configuration {
handler.enterSection(inst->name(), inst);
}
}

// This factory() method is used when there can be multiple instances,
// as with spindles and modules. A vector in the GenericFactory<BaseType>
// singleton holds the derived type instances, so there is no need to
Expand Down
1 change: 1 addition & 0 deletions FluidNC/src/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
#else

# define WEAK_LINK
# define IRAM_ATTR

#endif
157 changes: 0 additions & 157 deletions FluidNC/src/Spindles/DanfossSpindle.cpp

This file was deleted.

83 changes: 0 additions & 83 deletions FluidNC/src/Spindles/DanfossSpindle.h

This file was deleted.

Loading

0 comments on commit 8e36c50

Please sign in to comment.