コード例 #1
0
    def test_extruderTriggers_NoFilter(self):
        """Test the extruder triggers"""

        # test with no filters - should trigger
        self.Extruder.reset()
        state = ExtruderState()
        self.Extruder.add_state(state)
        state.is_primed = False  # turn this off so we don't have to account for this default state
        triggers = ExtruderTriggers(None, None, None, None, None, None, None,
                                    None, None, None)
        self.assertTrue(self.Extruder.is_triggered(triggers))
コード例 #2
0
    def test_ResetInitialState(self):
        """Test the initial extruder state, change all values, reset and check again"""
        # Check the initial state
        self.assertEquals(len(self.Extruder.StateHistory), 1)

        # add some states
        state1 = ExtruderState()
        self.Extruder.add_state(state1)

        state2 = ExtruderState()
        self.Extruder.add_state(state2)

        state3 = ExtruderState()
        self.Extruder.add_state(state3)

        # check the length of StateHistory
        self.assertEquals(len(self.Extruder.StateHistory), 4)

        # reset the state and check again
        self.Extruder.reset()
        self.assertEquals(len(self.Extruder.StateHistory), 0)
コード例 #3
0
    def test_ExtruderState_InitialValues(self):
        # create a new state
        state = ExtruderState()

        # verify the initial values
        self.assertEquals(state.E, 0)
        self.assertEquals(state.extrusion_length, 0.0)
        self.assertEquals(state.extruder_length_total, 0.0)
        self.assertEquals(state.retraction_length, 0.0)
        self.assertEquals(state.deretraction_length, 0.0)
        self.assertFalse(state.is_extruding_start)
        self.assertFalse(state.is_extruding)
        self.assertFalse(state.is_primed)
        self.assertFalse(state.is_retracting_start)
        self.assertFalse(state.is_retracting)
        self.assertFalse(state.is_partially_retracted)
        self.assertFalse(state.is_retracted)
        self.assertFalse(state.is_deretracting_start)
        self.assertFalse(state.is_deretracting)
        self.assertFalse(state.is_deretracted)
        self.assertFalse(state.has_changed)
コード例 #4
0
ファイル: test_extruder.py プロジェクト: woebbi/Octolapse
    def test_ExtruderState_InitialValues(self):
        # create a new state
        state = ExtruderState()

        # verify the initial values
        self.assertEquals(state.E, 0)
        self.assertEquals(state.ExtrusionLength, 0.0)
        self.assertEquals(state.ExtrusionLengthTotal, 0.0)
        self.assertEquals(state.RetractionLength, 0.0)
        self.assertEquals(state.DetractionLength, 0.0)
        self.assertFalse(state.IsExtrudingStart)
        self.assertFalse(state.IsExtruding)
        self.assertFalse(state.IsPrimed)
        self.assertFalse(state.IsRetractingStart)
        self.assertFalse(state.IsRetracting)
        self.assertFalse(state.IsPartiallyRetracted)
        self.assertFalse(state.IsRetracted)
        self.assertFalse(state.IsDetractingStart)
        self.assertFalse(state.IsDetracting)
        self.assertFalse(state.IsDetracted)
        self.assertFalse(state.HasChanged)
コード例 #5
0
 def test_extruderTriggers_on_deretracted(self):
     # test on_deretracted
     self.Extruder.reset()
     state = ExtruderState()
     self.Extruder.add_state(state)
     triggers = ExtruderTriggers(None, None, None, None, None, None, None,
                                 None, None, True)
     # test True with true filter
     state.is_deretracted = True
     state.is_primed = False  # turn this off so we don't have to account for this default state
     self.assertTrue(self.Extruder.is_triggered(triggers))
     # test False with True filter
     state.is_deretracted = False
     self.assertTrue(not self.Extruder.is_triggered(triggers))
     # test on_deretracted - False Filter
     triggers = ExtruderTriggers(None, None, None, None, None, None, None,
                                 None, None, False)
     # test True with False filter
     state.is_deretracted = True
     self.assertTrue(not self.Extruder.is_triggered(triggers))
     # test False with False filter
     state.is_deretracted = False
     self.assertTrue(not self.Extruder.is_triggered(triggers))
コード例 #6
0
 def test_extruderTriggers_on_extruding_start(self):
     self.Extruder.reset()
     state = ExtruderState()
     self.Extruder.add_state(state)
     # test on_extruding_start - True Filter
     triggers = ExtruderTriggers(True, None, None, None, None, None, None,
                                 None, None, None)
     # test True with true filter
     state.is_extruding_start = True
     state.is_primed = False  # turn this off so we don't have to account for this default state
     self.assertTrue(self.Extruder.is_triggered(triggers))
     # test False with True filter
     state.is_extruding_start = False
     self.assertTrue(not self.Extruder.is_triggered(triggers))
     # test on_extruding_start - False Filter
     triggers = ExtruderTriggers(False, None, None, None, None, None, None,
                                 None, None, None)
     # test True with False filter
     state.is_extruding_start = True
     self.assertTrue(not self.Extruder.is_triggered(triggers))
     # test False with False filter
     state.is_extruding_start = False
     self.assertTrue(not self.Extruder.is_triggered(triggers))
コード例 #7
0
ファイル: test_extruder.py プロジェクト: woebbi/Octolapse
 def test_extruderTriggers_OnDetracting(self):
     # test OnDetracting
     self.Extruder.reset()
     state = ExtruderState()
     self.Extruder.add_state(state)
     triggers = ExtruderTriggers(None, None, None, None, None, None, None,
                                 None, True, None)
     # test True with true filter
     state.IsDetracting = True
     state.IsPrimed = False  # turn this off so we don't have to account for this default state
     self.assertTrue(self.Extruder.is_triggered(triggers))
     # test False with True filter
     state.IsDetracting = False
     self.assertTrue(not self.Extruder.is_triggered(triggers))
     # test OnDetracting - False Filter
     triggers = ExtruderTriggers(None, None, None, None, None, None, None,
                                 None, False, None)
     # test True with False filter
     state.IsDetracting = True
     self.assertTrue(not self.Extruder.is_triggered(triggers))
     # test False with False filter
     state.IsDetracting = False
     self.assertTrue(not self.Extruder.is_triggered(triggers))
コード例 #8
0
 def test_extruderTriggers_on_primed(self):
     self.Extruder.reset()
     state = ExtruderState()
     self.Extruder.add_state(state)
     triggers = ExtruderTriggers(None, None, True, None, None, None, None,
                                 None, None, None)
     # test True with true filter
     state.is_primed = True
     self.assertTrue(self.Extruder.is_triggered(triggers))
     # test False with True filter
     state.is_primed = False
     self.assertTrue(not self.Extruder.is_triggered(triggers))
     # test on_primed - False Filter
     triggers = ExtruderTriggers(None, None, False, None, None, None, None,
                                 None, None, None)
     # test True with False filter
     state.is_primed = True
     self.assertTrue(not self.Extruder.is_triggered(triggers))
     # test False with False filter
     state.is_primed = False
     self.assertTrue(not self.Extruder.is_triggered(triggers))
コード例 #9
0
    def test_ExtruderStateCopy(self):
        # create a new state
        state = ExtruderState()
        # change all the default values

        state.E = 1
        state.extrusion_length = 100
        state.extruder_length_total = 200
        state.retraction_length = 300
        state.deretraction_length = 400
        state.is_extruding_start = True
        state.is_extruding = True
        state.is_primed = True
        state.is_retracting_start = True
        state.is_retracting = True
        state.is_partially_retracted = True
        state.is_retracted = True
        state.is_deretracting_start = True
        state.is_deretracting = True
        state.is_deretracted = True
        state.has_changed = True

        # copy to a new state
        new_state = ExtruderState(state)
        # verify the state was copied correctly
        self.assertEquals(new_state.E, 1)
        self.assertEquals(new_state.extrusion_length, 100)
        self.assertEquals(new_state.extruder_length_total, 200)
        self.assertEquals(new_state.retraction_length, 300)
        self.assertEquals(new_state.deretraction_length, 400)
        self.assertTrue(new_state.is_extruding_start)
        self.assertTrue(new_state.is_extruding)
        self.assertTrue(new_state.is_primed)
        self.assertTrue(new_state.is_retracting_start)
        self.assertTrue(new_state.is_retracting)
        self.assertTrue(new_state.is_partially_retracted)
        self.assertTrue(new_state.is_retracted)
        self.assertTrue(new_state.is_deretracting_start)
        self.assertTrue(new_state.is_deretracting)
        self.assertTrue(new_state.is_deretracted)
        self.assertTrue(new_state.has_changed)
コード例 #10
0
    def test_extruderTriggers_Mixed(self):
        # Test mixed nones, trues and falses
        self.Extruder.reset()
        state = ExtruderState()
        self.Extruder.add_state(state)
        triggers = ExtruderTriggers(None, True, False, None, True, False, None,
                                    True, False, None)
        # Forbidden Due to is_primed
        state.is_extruding_start = True
        state.is_extruding = True
        state.is_primed = True
        state.is_retracting_start = True
        state.is_retracting = True
        state.is_partially_retracted = False
        state.is_retracted = True
        state.is_deretracting_start = True
        state.is_deretracting = False
        state.is_deretracted = True
        self.assertTrue(not self.Extruder.is_triggered(triggers))
        # True - is extruding
        state.is_extruding_start = False
        state.is_extruding = True
        state.is_primed = False
        state.is_retracting_start = True
        state.is_retracting = False
        state.is_partially_retracted = False
        state.is_retracted = True
        state.is_deretracting_start = False
        state.is_deretracting = False
        state.is_deretracted = True
        self.assertTrue(self.Extruder.is_triggered(triggers))

        # Test all false states and all Nones
        state.is_extruding_start = True
        state.is_extruding = True
        state.is_primed = True
        state.is_retracting_start = True
        state.is_retracting = True
        state.is_partially_retracted = True
        state.is_retracted = True
        state.is_deretracting_start = True
        state.is_deretracting = True
        state.is_deretracted = True
        triggers = ExtruderTriggers(None, None, None, None, None, None, None,
                                    None, None, None)
        self.assertTrue(self.Extruder.is_triggered(triggers))
        triggers = ExtruderTriggers(False, True, True, True, True, True, True,
                                    True, True, True)
        self.assertFalse(self.Extruder.is_triggered(triggers))
        triggers = ExtruderTriggers(True, False, True, True, True, True, True,
                                    True, True, True)
        self.assertFalse(self.Extruder.is_triggered(triggers))
        triggers = ExtruderTriggers(True, True, False, True, True, True, True,
                                    True, True, True)
        self.assertFalse(self.Extruder.is_triggered(triggers))
        triggers = ExtruderTriggers(True, True, True, False, True, True, True,
                                    True, True, True)
        self.assertFalse(self.Extruder.is_triggered(triggers))
        triggers = ExtruderTriggers(True, True, True, True, False, True, True,
                                    True, True, True)
        self.assertFalse(self.Extruder.is_triggered(triggers))
        triggers = ExtruderTriggers(True, True, True, True, True, False, True,
                                    True, True, True)
        self.assertFalse(self.Extruder.is_triggered(triggers))
        triggers = ExtruderTriggers(True, True, True, True, True, True, False,
                                    True, True, True)
        self.assertFalse(self.Extruder.is_triggered(triggers))
        triggers = ExtruderTriggers(True, True, True, True, True, True, True,
                                    False, True, True)
        self.assertFalse(self.Extruder.is_triggered(triggers))
        triggers = ExtruderTriggers(True, True, True, True, True, True, True,
                                    True, False, True)
        self.assertFalse(self.Extruder.is_triggered(triggers))
        triggers = ExtruderTriggers(True, True, True, True, True, True, True,
                                    True, True, False)
        self.assertFalse(self.Extruder.is_triggered(triggers))
コード例 #11
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))
コード例 #12
0
ファイル: test_extruder.py プロジェクト: woebbi/Octolapse
    def test_ExtruderStateCopy(self):
        # create a new state
        state = ExtruderState()
        # change all the default values

        state.E = 1
        state.ExtrusionLength = 100
        state.ExtrusionLengthTotal = 200
        state.RetractionLength = 300
        state.DetractionLength = 400
        state.IsExtrudingStart = True
        state.IsExtruding = True
        state.IsPrimed = True
        state.IsRetractingStart = True
        state.IsRetracting = True
        state.IsPartiallyRetracted = True
        state.IsRetracted = True
        state.IsDetractingStart = True
        state.IsDetracting = True
        state.IsDetracted = True
        state.HasChanged = True

        # copy to a new state
        new_state = ExtruderState(state)
        # verify the state was copied correctly
        self.assertEquals(new_state.E, 1)
        self.assertEquals(new_state.ExtrusionLength, 100)
        self.assertEquals(new_state.ExtrusionLengthTotal, 200)
        self.assertEquals(new_state.RetractionLength, 300)
        self.assertEquals(new_state.DetractionLength, 400)
        self.assertTrue(new_state.IsExtrudingStart)
        self.assertTrue(new_state.IsExtruding)
        self.assertTrue(new_state.IsPrimed)
        self.assertTrue(new_state.IsRetractingStart)
        self.assertTrue(new_state.IsRetracting)
        self.assertTrue(new_state.IsPartiallyRetracted)
        self.assertTrue(new_state.IsRetracted)
        self.assertTrue(new_state.IsDetractingStart)
        self.assertTrue(new_state.IsDetracting)
        self.assertTrue(new_state.IsDetracted)
        self.assertTrue(new_state.HasChanged)
コード例 #13
0
    def test_TimerTrigger_ExtruderTriggers(self):
        """Test All Extruder Triggers"""
        position = Position(self.Settings, self.OctoprintPrinterProfile, False)
        # home the axis
        position.update("G28")
        trigger = TimerTrigger(self.Settings)
        trigger.IntervalSeconds = 1
        trigger.RequireZHop = False  # no zhop required

        # Reset the extruder
        state = ExtruderState()
        position.Extruder.StateHistory[0] = state
        # Try on extruding start - previous position not homed, do not trigger
        trigger.ExtruderTriggers = ExtruderTriggers(
            True, None, None, None, None, None, None, None, None, None)
        trigger.get_state(0).TriggerStartTime = time.time() - 1.01
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertTrue(trigger.is_waiting(0))

        # Reset the extruder
        state = ExtruderState()
        position.Extruder.StateHistory[0] = state
        # send another command, now the previous state has been homed, should trigger
        position.update("AnotherCommandNowPreviousHomed")
        # set is extruding start, wont be set by the above command!
        position.Extruder.StateHistory[0].IsExtrudingStart = True
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Reset the extruder
        state = ExtruderState()
        position.Extruder.StateHistory[0] = state
        # try out on extruding
        trigger.ExtruderTriggers = ExtruderTriggers(
            None, True, None, None, None, None, None, None, None, None)
        state.IsExtruding = True
        trigger.get_state(0).TriggerStartTime = time.time() - 1.01
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Reset the extruder
        state = ExtruderState()
        position.Extruder.StateHistory[0] = state
        # try out on primed
        trigger.ExtruderTriggers = ExtruderTriggers(
            None, None, True, None, None, None, None, None, None, None)
        state.IsPrimed = True
        trigger.get_state(0).TriggerStartTime = time.time() - 1.01
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Reset the extruder
        state = ExtruderState()
        position.Extruder.StateHistory[0] = state
        # try out on retracting start
        trigger.ExtruderTriggers = ExtruderTriggers(
            None, None, None, True, None, None, None, None, None, None)
        state.IsRetractingStart = True
        trigger.get_state(0).TriggerStartTime = time.time() - 1.01
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Reset the extruder
        state = ExtruderState()
        position.Extruder.StateHistory[0] = state
        # try out on retracting
        trigger.ExtruderTriggers = ExtruderTriggers(
            None, None, None, None, True, None, None, None, None, None)
        state.IsRetracting = True
        trigger.get_state(0).TriggerStartTime = time.time() - 1.01
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

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

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

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

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

        # Reset the extruder
        state = ExtruderState()
        position.Extruder.StateHistory[0] = state
        # try out on detracting Start
        trigger.ExtruderTriggers = ExtruderTriggers(
            None, None, None, None, None, None, None, None, None, True)
        state.IsDetracted = True
        trigger.get_state(0).TriggerStartTime = time.time() - 1.01
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))