예제 #1
0
    def test_LayerTrigger_ExtruderTriggerWait(self):
        """Test wait on extruder"""
        position = Position(self.Settings, self.OctoprintPrinterProfile, False)

        trigger = LayerTrigger(self.Settings)
        trigger.RequireZHop = False  # no zhop required
        trigger.HeightIncrement = 0  # Trigger on every layer change

        # home the axis
        position.update("G28")

        # add the current state
        pos = position.get_position(0)
        state = position.Extruder.get_state(0)
        state.IsPrimed = False
        # Use on extruding start for this test.
        trigger.ExtruderTriggers = ExtruderTriggers(True, None, None, None,
                                                    None, None, None, None,
                                                    None, None)
        state.IsExtrudingStart = False
        pos.IsLayerChange = True

        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertTrue(trigger.is_waiting(0))

        # update again with no change
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertTrue(trigger.is_waiting(0))
        # set the trigger and try again
        state.IsExtrudingStart = True
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
예제 #2
0
    def test_LayerTrigger_LayerChange_ZHop(self):
        """Test the layer trigger for layer changes triggers"""
        self.Settings.current_snapshot().layer_trigger_require_zhop = True
        self.Settings.current_printer().z_hop = .5
        position = Position(self.Settings, self.OctoprintPrinterProfile, False)
        trigger = LayerTrigger(self.Settings)
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, None, None,
                                                    None,
                                                    None)  # Ignore extruder
        trigger.HeightIncrement = 0  # Trigger on any height change
        # test initial state
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # send commands that normally would trigger a layer change, but without all axis homed.
        position.update("g0 x0 y0 z.2 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Home all axis and try again, will not trigger or wait, previous axis not homed
        position.update("g28")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Waiting on ZHop
        position.update("g0 x0 y0 z.2 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertTrue(trigger.is_waiting(0))
        # try zhop
        position.update("g0 x0 y0 z.7 ")
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # extrude on current layer, no trigger (wait on zhop)
        position.update("g0 x0 y0 z.7 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertTrue(trigger.is_waiting(0))

        # do not extrude on current layer, still waiting
        position.update("g0 x0 y0 z.7 ")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertTrue(trigger.is_waiting(0))

        # partial hop, but close enough based on our printer measurement tolerance (0.005)
        position.update("g0 x0 y0 z1.1999")
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # creat wait state
        position.update("g0 x0 y0 z1.3 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertTrue(trigger.is_waiting(0))

        # move down (should never happen, should behave properly anyway)
        position.update("g0 x0 y0 z.8")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertTrue(trigger.is_waiting(0))

        # move back up to current layer (should NOT trigger zhop)
        position.update("g0 x0 y0 z1.3")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertTrue(trigger.is_waiting(0))

        # move up a bit, not enough to trigger zhop
        position.update("g0 x0 y0 z1.795")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertTrue(trigger.is_waiting(0))

        # move up a bit, just enough to trigger zhop
        position.update("g0 x0 y0 z1.7951")
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
예제 #3
0
    def test_LayerTrigger_LayerChange(self):
        """Test the layer trigger for layer changes triggers"""

        position = Position(self.Settings, self.OctoprintPrinterProfile, False)
        trigger = LayerTrigger(self.Settings)
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, None, None,
                                                    None,
                                                    None)  # Ignore extruder
        trigger.RequireZHop = False  # no zhop required
        trigger.HeightIncrement = 0  # Trigger on any height change
        # test initial state
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # send commands that normally would trigger a layer change, but without all axis homed.
        position.update("g0 x0 y0 z.2 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Home all axis and try again
        position.update("g28")
        trigger.update(position)
        position.update("g0 x0 y0 z.2 e1")
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # extrude again on the same layer and make sure it does NOT trigger
        position.update("g0 x1 y1 z.2 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # move to higher layer, but do not extrude (no layer change)
        position.update("g0 x1 y1 z.4")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
        position.update("g0 x2 y2 z.4")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # return to previous layer, do not extrude
        position.update("g0 x2 y2 z.2")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
        position.update("g0 x4 y4 z.2")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # extrude again on current layer
        position.update("g0 x2 y2 z.2 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # move up two times, down and extrude (this should trigger after the final command
        position.update("g0 x2 y2 z.4")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
        position.update("g0 x2 y2 z.6")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
        position.update("g0 x2 y2 z.4 e1")
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # This should never happen in a print, but test extruding on previous layers
        # move down to previous layer, extrude,
        position.update("g0 x2 y2 z.2 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
        # move back to current layer (.4), extrude (no trigger)
        position.update("g0 x2 y2 z.4 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
        # move up one more layer and extrude (trigger)
        position.update("g0 x2 y2 z.6 e1")
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
예제 #4
0
    def test_LayerTrigger_ExtruderTriggers(self):
        """Test All Extruder Triggers"""
        position = Position(self.Settings, self.OctoprintPrinterProfile, False)
        # home the axis
        position.update("G28")
        trigger = LayerTrigger(self.Settings)
        trigger.RequireZHop = False  # no zhop required
        trigger.HeightIncrement = 0  # Trigger on every layer change

        # get the current extruder state
        state = position.Extruder.get_state(0)
        # Try on extruding start right after home, should fail since we haven't extruded yet
        trigger.ExtruderTriggers = ExtruderTriggers(True, None, None, None,
                                                    None, None, None, None,
                                                    None, None)
        state.IsExtrudingStart = True
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Try again, should trigger after the extrusion
        position.update("G1 E1")
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Reset the previous extruder state
        state = ExtruderState()
        position.Extruder.StateHistory[0] = state
        state.IsPrimed = False

        # try out on extruding
        state.IsExtruding = True
        trigger.ExtruderTriggers = ExtruderTriggers(None, True, None, None,
                                                    None, None, None, None,
                                                    None, None)

        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Reset the previous extruder state
        state = ExtruderState()
        position.Extruder.StateHistory[0] = state
        state.IsPrimed = False

        # try out on primed
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, True, None,
                                                    None, None, None, None,
                                                    None, None)
        state.IsPrimed = True
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Reset the previous extruder state
        state = ExtruderState()
        position.Extruder.StateHistory[0] = state
        state.IsPrimed = False

        # try out on retracting start
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, True,
                                                    None, None, None, None,
                                                    None, None)
        state.IsRetractingStart = True
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Reset the previous extruder state
        state = ExtruderState()
        position.Extruder.StateHistory[0] = state
        state.IsPrimed = False

        # try out on retracting
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    True, None, None, None,
                                                    None, None)
        state.IsRetracting = True
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Reset the previous extruder state
        state = ExtruderState()
        position.Extruder.StateHistory[0] = state
        state.IsPrimed = False
        # try out on partially retracted
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, True, None, None,
                                                    None, None)
        state.IsPartiallyRetracted = True
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Reset the previous extruder state
        state = ExtruderState()
        position.Extruder.StateHistory[0] = state
        state.IsPrimed = False
        # try out on retracted
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, True, None,
                                                    None, None)
        state.IsRetracted = True
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Reset the previous extruder state
        state = ExtruderState()
        position.Extruder.StateHistory[0] = state
        state.IsPrimed = False
        # try out on detracting Start
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, None, True,
                                                    None, None)
        state.IsDetractingStart = True
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Reset the previous extruder state
        state = ExtruderState()
        position.Extruder.StateHistory[0] = state
        state.IsPrimed = False
        # try out on detracting Start
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, None, None,
                                                    True, None)
        state.IsDetracting = True
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Reset the previous extruder state
        state = ExtruderState()
        position.Extruder.StateHistory[0] = state
        state.IsPrimed = False
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, None, None,
                                                    None, True)
        state.IsDetracted = True
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
예제 #5
0
    def test_LayerTrigger_ExtruderTriggers_NotHomed(self):
        """Make sure nothing triggers when the axis aren't homed"""
        position = Position(self.Settings, self.OctoprintPrinterProfile, False)
        trigger = LayerTrigger(self.Settings)
        trigger.RequireZHop = False  # no zhop required
        trigger.HeightIncrement = 0  # Trigger on every layer change
        position.Extruder.PrinterRetractionLength = 4

        # Try on extruding start
        trigger.ExtruderTriggers = ExtruderTriggers(True, None, None, None,
                                                    None, None, None, None,
                                                    None, None)
        position.update("g0 x0 y0 z.2 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # try out on extruding
        trigger.ExtruderTriggers = ExtruderTriggers(None, True, None, None,
                                                    None, None, None, None,
                                                    None, None)
        position.update("g0 x0 y0 z.3 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # try out on primed
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, True, None,
                                                    None, None, None, None,
                                                    None, None)
        position.update("g0 x0 y0 z.4 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # try out on retracting start
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, True,
                                                    None, None, None, None,
                                                    None, None)
        position.update("g0 x0 y0 z.5 e-1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # try out on retracting
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    True, None, None, None,
                                                    None, None)
        position.update("g0 x0 y0 z.5 e-1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # try out on partially retracted
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, True, None, None,
                                                    None, None)
        position.update("g0 x0 y0 z.5 e-1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # try out on retracted
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, True, None,
                                                    None, None)
        position.update("g0 x0 y0 z.5 e-1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # try out on detracting
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, True, None,
                                                    None, None)
        position.update("g0 x0 y0 z.5 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
예제 #6
0
    def test_LayerTrigger_HeightChange(self):
        """Test the layer trigger height change """

        position = Position(self.Settings, self.OctoprintPrinterProfile, False)
        trigger = LayerTrigger(self.Settings)
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, None, None,
                                                    None,
                                                    None)  # Ignore extruder
        trigger.RequireZHop = False  # no zhop required
        trigger.HeightIncrement = .25  # Trigger every .25

        # test initial state
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # send commands that normally would trigger a layer change, but without all axis homed.
        position.update("g0 x0 y0 z.2 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # cur increment 0.25
        position.update("g28")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # extrude at height 0.2, should trigger
        position.update("g0 x0 y0 z.2 e1")
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # cur increment 0.25
        # move to higher layer, but do not extrude (no layer change)
        position.update("g0 x1 y1 z.4")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
        position.update("g0 x2 y2 z.4")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # cur increment 0.25
        # return to previous layer, do not extrude
        position.update("g0 x2 y2 z.2")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
        position.update("g0 x4 y4 z.2")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # cur increment 0.25
        # extrude again on current layer
        position.update("g0 x2 y2 z.2 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # cur increment 0.25
        # move up two times, down and extrude (this should trigger after the final command
        position.update("g0 x2 y2 z.4")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
        position.update("g0 x2 y2 z.6")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
        position.update("g0 x2 y2 z.4 e1")
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # cur increment 0.5
        # This should never happen in a print, but test extruding on previous layers
        # move down to previous layer, extrude,
        position.update("g0 x2 y2 z.2 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
        # move back to current layer (.4), extrude (no trigger)
        position.update("g0 x2 y2 z.4 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
        # move up one more layer and extrude (trigger)
        position.update("g0 x2 y2 z.6 e1")
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # test very close to height increment (.74)
        # move up one more layer and extrude (trigger)
        position.update("g0 x2 y2 z0.74  e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
        # now it should trigger
        position.update("m114")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Test at the increment (.75)
        position.update("g0 x2 y2 z0.7500 e1")
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))