Merge pull request #28167 from tarman3/machinestate

CAM: MachineState - Allow process list of commands
This commit is contained in:
sliptonic
2026-03-13 11:57:49 -05:00
committed by GitHub
3 changed files with 22 additions and 4 deletions
+9
View File
@@ -124,6 +124,15 @@ class TestPathHelpers(PathTestBase):
self.assertTrue(state["Y"] == 50)
self.assertTrue(state["Z"] == 5)
# Test process list of commands
machine = PathMachineState.MachineState()
machine.addCommands(self.commandlist[0])
machine.addCommands(self.commandlist[1:])
state = machine.getState()
self.assertEqual(state["X"], 20)
self.assertEqual(state["Y"], 20)
self.assertEqual(state["Z"], 5)
def test02(self):
"""Test PathUtils filterarcs"""
+12 -2
View File
@@ -28,7 +28,6 @@ __contributors__ = ""
import Path
import FreeCAD
import Path
if False:
Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule())
@@ -72,7 +71,8 @@ class MachineState:
self.T = None #: int = field(default=None)
def addCommand(self, command):
"""Processes a command and updates the internal state of the machine. Returns true if the command has alterned the machine state"""
"""Processes a command and updates the internal state of the machine.
Returns true if the command has alterned the machine state"""
oldstate = self.getState()
if command.Name == "M6":
self.T = int(command.Parameters["T"])
@@ -104,6 +104,16 @@ class MachineState:
return not oldstate == self.getState()
def addCommands(self, commands):
"""Processes a command or list of commands and updates the internal state of the machine"""
if isinstance(commands, (list, tuple)):
for command in commands:
self.addCommand(command)
else:
return self.addCommand(commands)
return False
def getState(self):
"""
Returns a dictionary of the current machine state
+1 -2
View File
@@ -359,8 +359,7 @@ class ObjectDrilling(PathCircularHoleBase.ObjectOp):
solids=solids,
)
self.commandlist.extend(linking_moves)
for move in linking_moves:
machinestate.addCommand(move)
machinestate.addCommands(linking_moves)
# else: no collision - G99 cycle continues, tool stays at retract plane
# Perform drilling