Skip to content

Refactor BacklashManager, MotorsManager, CoolantManager, Probe into instance-based classes under CNCMachine#9

Closed
Copilot wants to merge 7 commits intomainfrom
copilot/make-managers-non-static
Closed

Refactor BacklashManager, MotorsManager, CoolantManager, Probe into instance-based classes under CNCMachine#9
Copilot wants to merge 7 commits intomainfrom
copilot/make-managers-non-static

Conversation

Copy link

Copilot AI commented Feb 24, 2026

Four all-static utility classes (BacklashManager, MotorsManager, CoolantManager, Probe) have been converted to regular instantiable classes, with their single instances owned as public static members of a new CNCMachine class. This centralises machine subsystem access and lifecycle management.

Class changes

  • Removed static from all methods and member variables in BacklashManager, MotorsManager, CoolantManager, and Probe
  • Removed static member definitions from their .cpp files

New CNCMachine class (CNCMachine.h / CNCMachine.cpp)

  • Owns the four subsystem instances as public static members
  • Provides static void Initialize() and static void Reset() lifecycle methods
class CNCMachine {
public:
    static BacklashManager fBacklashManager;
    static MotorsManager   fMotorsManager;
    static CoolantManager  fCoolantManager;
    static Probe           fProbe;

    static void Initialize();
    static void Reset();
};

Call-site updates

All direct calls replaced with the new access pattern across Grbl.cpp, MotionControl.cpp, GCode.cpp, Stepper.cpp, ProcessSettings.cpp, Limits.cpp, Report.cpp, Protocol.cpp:

// Before
MotorsManager::Initialize();
CoolantManager::Flood_Coolant.TurnOn();
Probe::setSystemProbeState(true);

// After
CNCMachine::Initialize();
CNCMachine::fCoolantManager.Flood_Coolant.TurnOn();
CNCMachine::fProbe.setSystemProbeState(true);

Include structure

CNCMachine.h deliberately does not re-include the manager headers — doing so created a circular chain (BacklashManager.h → Grbl.h → CNCMachine.h → BacklashManager.h). Grbl.h includes all four manager headers before CNCMachine.h, ensuring types are defined when needed.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…ance-based classes under CNCMachine

Co-authored-by: nsiatras <6023918+nsiatras@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor managers to be public static references in CNCMachine Refactor BacklashManager, MotorsManager, CoolantManager, Probe into CNCMachine singleton Feb 24, 2026
Copilot AI requested a review from nsiatras February 24, 2026 10:42
Copilot AI and others added 2 commits February 24, 2026 10:47
Co-authored-by: nsiatras <6023918+nsiatras@users.noreply.github.com>
Co-authored-by: nsiatras <6023918+nsiatras@users.noreply.github.com>
Copilot AI changed the title Refactor BacklashManager, MotorsManager, CoolantManager, Probe into CNCMachine singleton Fix circular include error in CNCMachine.h Feb 24, 2026
Copilot AI changed the title Fix circular include error in CNCMachine.h Fix circular include between CNCMachine.h and manager headers Feb 24, 2026
Co-authored-by: nsiatras <6023918+nsiatras@users.noreply.github.com>
Copilot AI changed the title Fix circular include between CNCMachine.h and manager headers Add CNCMachine::Initialize() and CNCMachine::Reset() static methods Feb 24, 2026
Copilot AI changed the title Add CNCMachine::Initialize() and CNCMachine::Reset() static methods Refactor BacklashManager, MotorsManager, CoolantManager, Probe into instance-based classes under CNCMachine Feb 24, 2026
@nsiatras nsiatras closed this Feb 24, 2026
@nsiatras nsiatras deleted the copilot/make-managers-non-static branch February 24, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants