kliment/Printrun — pull request #352 by fsantini (2013-04-08 17:27:53+00:00)
Title: Recovery after pause

Other pull request referring https://github.com/kliment/Printrun/pull/351, based on experimental branch. Summary of changes:
* Implementation of recovery after pause to last print position
* build_dimensions must be made aware of endstop switches
* Implementation of host command ;@pause
* execution of pause.gcode and end.gcode on pause and end

Copy-pasted longer explanation from the previous pull request:

While working on porting Pronterface to a 7" tablet, I also found useful to do some "core" changes to Printrun itself, specifically in the "pause" handling code. I found myself in the situation of wanting to change filament mid-print to a different color and I found it inconvenient with the current implementation.

So I ported from RepetierHost the code to recover after a "pause" command, returning to the last printing position. In order to do so, a new GCode analyzer class was added, which analyzes every command to keep track of the position.

For this to work, the program must be made aware of the position of the home switches and of the bed size; therefore, I added three parameters to the "build dimensions" variable, accepting the same format as the offset, specifying the home positions. By default, they are 0,0,0 which should be ok for common printers.

In addition to this, the possibility of running a "pause script" was added. If a file named "pause.gcode" exists, it is sent to the printer /after/ the position is saved. Similarly, a "end.gcode" script is executed at the end of the job (again, similarly to RepetierHost). This is useful to move the extruder away from the part when done. The scripts execution is triggered from Pronterface, and not from Printcore, to avoid overloading printcore with extra functionalities.

Finally, I added the possibility of adding a "@pause" statement as a "host command" anywhere in the code. This way, a print can be paused for filament change at a specific position.

Unfortunately, this change affects the default functionality of the program, so I am wondering whether it is better to enable it conditionally. On the other hand, I cannot think of a use case when such a functionality would not be desired.

One major drawback of this patch is the introduced redundancy between the GCodeAnalyzer class and the gcoder class. If needed, I can try to merge the two classes into one.

PS I apologize for this double request but I'm kind of new to git/github, I'm trying my best :)