Example #1
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))
Example #2
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)
Example #3
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))