Merge pull request #28167 from tarman3/machinestate
CAM: MachineState - Allow process list of commands
This commit is contained in:
@@ -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"""
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user