Exemplo n.º 1
0
    def test_TimerTrigger_ExtruderTriggerWait(self):
        """Test wait on extruder"""
        position = Position(self.Settings, self.OctoprintPrinterProfile, False)
        # home the axis
        position.update("G28")
        trigger = TimerTrigger(self.Settings)
        trigger.RequireZHop = False  # no zhop required
        trigger.IntervalSeconds = 1

        # Use on extruding start for this test.
        trigger.ExtruderTriggers = ExtruderTriggers(
            True, None, None, None, None, None, None, None, None, None)

        # set the extruder trigger
        position.Extruder.get_state(0).IsExtrudingStart = True
        # will not wait or trigger because not enough time has elapsed
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # add 1 second to the state and try again
        trigger.get_state(0).TriggerStartTime = time.time() - 1.01

        # send another command and try again
        position.update("PreviousPositionIsNowHomed")
        # set the extruder trigger
        position.Extruder.get_state(0).IsExtrudingStart = True
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
Exemplo n.º 2
0
    def StartTimelapse(self, octoprintPrinter, octoprintPrinterProfile,
                       ffmpegPath, g90InfluencesExtruder):
        self.Reset()

        self.OctoprintPrinter = octoprintPrinter
        self.OctoprintPrinterProfile = octoprintPrinterProfile
        self.FfMpegPath = ffmpegPath
        self.PrintStartTime = time.time()
        self.Snapshot = Snapshot(self.Settings.CurrentSnapshot())
        self.Gcode = SnapshotGcodeGenerator(self.Settings,
                                            octoprintPrinterProfile)
        self.Printer = Printer(self.Settings.CurrentPrinter())
        self.Rendering = Rendering(self.Settings.CurrentRendering())
        self.CaptureSnapshot = CaptureSnapshot(
            self.Settings, self.DataFolder, printStartTime=self.PrintStartTime)
        self.Position = Position(self.Settings, octoprintPrinterProfile,
                                 g90InfluencesExtruder)
        self.State = TimelapseState.WaitingForTrigger

        self.IsTestMode = self.Settings.CurrentDebugProfile().is_test_mode
        # create the triggers
        # If the gcode trigger is enabled, add it
        if (self.Snapshot.gcode_trigger_enabled):
            #Add the trigger to the list
            self.Triggers.append(GcodeTrigger(self.Settings))
        # If the layer trigger is enabled, add it
        if (self.Snapshot.layer_trigger_enabled):
            self.Triggers.append(LayerTrigger(self.Settings))
        # If the layer trigger is enabled, add it
        if (self.Snapshot.timer_trigger_enabled):
            self.Triggers.append(TimerTrigger(self.Settings))
Exemplo n.º 3
0
    def test_TimerTrigger(self):
        """Test the timer trigger"""
        # use a short trigger time so that the test doesn't take too long
        self.Settings.profiles.current_snapshot().timer_trigger_seconds = 2
        position = Position(self.Settings, self.OctoprintPrinterProfile, False)
        trigger = TimerTrigger(self.Settings)
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, None, None,
                                                    None,
                                                    None)  # Ignore extruder
        trigger.require_zhop = False  # no zhop required
        trigger.height_increment = 0  # Trigger on any height change
        # test initial state
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # set interval time to 0, send another command and test again (should not trigger, no homed axis)
        trigger.interval_seconds = 0
        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 with interval seconds 1 - should not trigger since the timer will start after
        # the home command
        trigger.interval_seconds = 2
        position.update("g28")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # send another command and try again, should not trigger cause we haven't waited 2 seconds yet
        position.update("g0 x0 y0 z.2 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Set the last trigger time to 1 before the previous LastTrigger time(equal to interval seconds), should not
        # trigger
        trigger.get_state(0).trigger_start_time = time.time() - 1.01
        position.update("g0 x0 y0 z.2 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))

        # Set the last trigger time to 1 before the previous LastTrigger time(equal to interval seconds), should trigger
        trigger.trigger_start_time = time.time() - 2.01
        position.update("g0 x0 y0 z.2 e1")
        trigger.update(position)
        self.assertFalse(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))
Exemplo n.º 4
0
    def test_TimerTrigger(self):
        """Test the timer trigger"""
        # use a short trigger time so that the test doesn't take too long
        self.Settings.CurrentSnapshot().timer_trigger_seconds = 2
        position = Position(self.Settings, self.OctoprintPrinterProfile, False)
        trigger = TimerTrigger(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.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == False)

        # set interval time to 0, send another command and test again (should not trigger, no homed axis)
        trigger.IntervalSeconds = 0
        position.Update("g0 x0 y0 z.2 e1")
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == False)

        # Home all axis and try again with interval seconds 1 - should not trigger since the timer will start after the home command
        trigger.IntervalSeconds = 2
        position.Update("g28")
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == False)

        # send another command and try again, should not trigger cause we haven't waited 2 seconds yet
        position.Update("g0 x0 y0 z.2 e1")
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == False)

        # Set the last trigger time to 1 before the previous LastTrigger time(equal to interval seconds), should not trigger
        trigger.TriggerStartTime = time.time() - 1.01
        position.Update("g0 x0 y0 z.2 e1")
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == False)

        # Set the last trigger time to 1 before the previous LastTrigger time(equal to interval seconds), should trigger
        trigger.TriggerStartTime = time.time() - 2.01
        position.Update("g0 x0 y0 z.2 e1")
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == True)
        self.assertTrue(trigger.IsWaiting == False)
Exemplo n.º 5
0
    def test_TimerTrigger_ExtruderTriggerWait(self):
        """Test wait on extruder"""
        position = Position(self.Settings, self.OctoprintPrinterProfile, False)
        # home the axis
        position.Update("G28")
        trigger = TimerTrigger(self.Settings)
        trigger.RequireZHop = False  # no zhop required
        trigger.IntervalSeconds = 1

        #Reset the extruder

        position.Extruder.Reset()
        position.Extruder.IsPrimed = False
        trigger.IsWaiting = False
        # Use on extruding start for this test.
        trigger.ExtruderTriggers = ExtruderTriggers(True, None, None, None,
                                                    None, None, None, None,
                                                    None, None)
        position.Extruder.IsExtrudingStart = False
        trigger.TriggerStartTime = time.time() - 1.01
        # will not wait or trigger because the previous position state was not homed
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == False)

        # send another command and try again
        position.Update("PreviousPositionIsNowHomed")
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == True)

        # update again with no change
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == True)
        # set the trigger and try again
        position.Extruder.IsExtrudingStart = True
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == True)
        self.assertTrue(trigger.IsWaiting == False)
Exemplo n.º 6
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

        position.Extruder.Reset()
        position.Extruder.IsPrimed = False
        trigger.IsWaiting = True
        # Try on extruding start - previous position not homed, do not trigger
        trigger.ExtruderTriggers = ExtruderTriggers(True, None, None, None,
                                                    None, None, None, None,
                                                    None, None)
        position.Extruder.IsExtrudingStart = True
        trigger.TriggerStartTime = time.time() - 1.01
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == True)

        # send another command, now the previous state has been homed, should trigger
        position.Update("AnotherCommandNowPreviousHomed")
        position.Extruder.IsExtrudingStart = True  # set is extruding start, wont be set by the above command!
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == True)
        self.assertTrue(trigger.IsWaiting == False)
        #Reset the extruder
        position.Extruder.Reset()
        position.Extruder.IsPrimed = False
        trigger.IsWaiting = True
        # try out on extruding
        trigger.ExtruderTriggers = ExtruderTriggers(None, True, None, None,
                                                    None, None, None, None,
                                                    None, None)
        position.Extruder.IsExtruding = True
        trigger.TriggerStartTime = time.time() - 1.01
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == True)
        self.assertTrue(trigger.IsWaiting == False)

        #Reset the extruder
        position.Extruder.Reset()
        position.Extruder.IsPrimed = False
        trigger.IsWaiting = True
        # try out on primed
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, True, None,
                                                    None, None, None, None,
                                                    None, None)
        position.Extruder.IsPrimed = True
        trigger.TriggerStartTime = time.time() - 1.01
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == True)
        self.assertTrue(trigger.IsWaiting == False)

        #Reset the extruder
        position.Extruder.Reset()
        position.Extruder.IsPrimed = False
        trigger.IsWaiting = True
        # try out on retracting start
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, True,
                                                    None, None, None, None,
                                                    None, None)
        position.Extruder.IsRetractingStart = True
        trigger.TriggerStartTime = time.time() - 1.01
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == True)
        self.assertTrue(trigger.IsWaiting == False)

        #Reset the extruder
        position.Extruder.Reset()
        position.Extruder.IsPrimed = False
        trigger.IsWaiting = True
        # try out on retracting
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    True, None, None, None,
                                                    None, None)
        position.Extruder.IsRetracting = True
        trigger.TriggerStartTime = time.time() - 1.01
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == True)
        self.assertTrue(trigger.IsWaiting == False)

        #Reset the extruder
        position.Extruder.Reset()
        position.Extruder.IsPrimed = False
        trigger.IsWaiting = True
        # try out on partially retracted
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, True, None, None,
                                                    None, None)
        position.Extruder.IsPartiallyRetracted = True
        trigger.TriggerStartTime = time.time() - 1.01
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == True)
        self.assertTrue(trigger.IsWaiting == False)

        #Reset the extruder
        position.Extruder.Reset()
        position.Extruder.IsPrimed = False
        trigger.IsWaiting = True
        # try out on retracted
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, True, None,
                                                    None, None)
        position.Extruder.IsRetracted = True
        trigger.TriggerStartTime = time.time() - 1.01
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == True)
        self.assertTrue(trigger.IsWaiting == False)

        #Reset the extruder
        position.Extruder.Reset()
        position.Extruder.IsPrimed = False
        trigger.IsWaiting = True
        # try out on detracting Start
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, None, True,
                                                    None, None)
        position.Extruder.IsDetractingStart = True
        trigger.TriggerStartTime = time.time() - 1.01
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == True)
        self.assertTrue(trigger.IsWaiting == False)

        #Reset the extruder
        position.Extruder.Reset()
        position.Extruder.IsPrimed = False
        trigger.IsWaiting = True
        # try out on detracting Start
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, None, None,
                                                    True, None)
        position.Extruder.IsDetracting = True
        trigger.TriggerStartTime = time.time() - 1.01
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == True)
        self.assertTrue(trigger.IsWaiting == False)

        #Reset the extruder
        position.Extruder.Reset()
        position.Extruder.IsPrimed = False
        trigger.IsWaiting = True
        # try out on detracting Start
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, None, None,
                                                    None, True)
        position.Extruder.IsDetracted = True
        trigger.TriggerStartTime = time.time() - 1.01
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == True)
        self.assertTrue(trigger.IsWaiting == False)
Exemplo n.º 7
0
    def test_TimerTrigger_LayerChange_ZHop(self):
        """Test the layer trigger for layer changes triggers"""
        self.Settings.CurrentSnapshot().timer_trigger_require_zhop = True
        self.Settings.CurrentPrinter().z_hop = .5
        position = Position(self.Settings, self.OctoprintPrinterProfile, False)
        trigger = TimerTrigger(self.Settings)
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, None, None,
                                                    None,
                                                    None)  #Ignore extruder
        trigger.IntervalSeconds = 1
        # test initial state
        self.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == False)

        # 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.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == False)

        # Home all axis and try again, wait on zhop
        position.Update("g28")
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == False)
        position.Update("g0 x0 y0 z.2 e1")
        trigger.TriggerStartTime = time.time() - 1.01
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == True)

        # try zhop
        position.Update("g0 x0 y0 z.7 ")

        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == True)
        self.assertTrue(trigger.IsWaiting == False)

        # extrude on current layer, no trigger (wait on zhop)
        position.Update("g0 x0 y0 z.7 e1")
        trigger.TriggerStartTime = time.time() - 1.01
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == True)

        # do not extrude on current layer, still waiting
        position.Update("g0 x0 y0 z.7 ")
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == True)

        # 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.IsTriggered == True)
        self.assertTrue(trigger.IsWaiting == False)

        # creat wait state
        position.Update("g0 x0 y0 z1.3 e1")
        trigger.TriggerStartTime = time.time() - 1.01
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == True)

        # move down (should never happen, should behave properly anyway)
        position.Update("g0 x0 y0 z.8")
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == True)

        # move back up to current layer (should NOT trigger zhop)
        position.Update("g0 x0 y0 z1.3")
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == True)

        # move up a bit, not enough to trigger zhop
        position.Update("g0 x0 y0 z1.79749")
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == False)
        self.assertTrue(trigger.IsWaiting == True)

        # move up a bit, just enough to trigger zhop
        position.Update("g0 x0 y0 z1.79751")
        trigger.Update(position)
        self.assertTrue(trigger.IsTriggered == True)
        self.assertTrue(trigger.IsWaiting == False)
Exemplo n.º 8
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.interval_seconds = 1
        trigger.require_zhop = 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).trigger_start_time = 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].is_extruding_start = 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.is_extruding = True
        trigger.get_state(0).trigger_start_time = 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.is_primed = True
        trigger.get_state(0).trigger_start_time = 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.is_retracting_start = True
        trigger.get_state(0).trigger_start_time = 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.is_retracting = True
        trigger.get_state(0).trigger_start_time = 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.is_partially_retracted = True
        trigger.get_state(0).trigger_start_time = 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.is_retracted = True
        trigger.get_state(0).trigger_start_time = 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 deretracting Start
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, None, True,
                                                    None, None)
        state.is_deretracting_start = True
        trigger.get_state(0).trigger_start_time = 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 deretracting Start
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, None, None,
                                                    True, None)
        state.is_deretracting = True
        trigger.get_state(0).trigger_start_time = 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 deretracting Start
        trigger.ExtruderTriggers = ExtruderTriggers(None, None, None, None,
                                                    None, None, None, None,
                                                    None, True)
        state.is_deretracted = True
        trigger.get_state(0).trigger_start_time = time.time() - 1.01
        trigger.update(position)
        self.assertTrue(trigger.is_triggered(0))
        self.assertFalse(trigger.is_waiting(0))