mirror of
https://github.com/workinghard/mmuGcodeParser.git
synced 2025-12-13 22:32:08 +00:00
Same filament printing is allowed now
This commit is contained in:
81
mmuGcodeParser.py
Normal file → Executable file
81
mmuGcodeParser.py
Normal file → Executable file
@@ -203,28 +203,29 @@ def none_handler(p_tool_change, p_line_number):
|
|||||||
# Just in case we need to do something at the end
|
# Just in case we need to do something at the end
|
||||||
lv_output = ""
|
lv_output = ""
|
||||||
lv_insert = 0 # 0 = don't insert, +1 = after the line, -1 before the line, -9 = comment out
|
lv_insert = 0 # 0 = don't insert, +1 = after the line, -1 before the line, -9 = comment out
|
||||||
if p_tool_change[p_line_number] == UNLOAD_START_LINE:
|
if CURR_TEMP in p_tool_change:
|
||||||
if ram_temp_diff > 0: # Only if set
|
if p_tool_change[p_line_number] == UNLOAD_START_LINE:
|
||||||
# Add temp drop for better tip
|
if ram_temp_diff > 0: # Only if set
|
||||||
lv_lower_temp = int(p_tool_change[CURR_TEMP]) - ram_temp_diff
|
# Add temp drop for better tip
|
||||||
lv_output = "M104 S" + str(lv_lower_temp)
|
lv_lower_temp = int(p_tool_change[CURR_TEMP]) - ram_temp_diff
|
||||||
lv_insert = 1 # after the line
|
lv_output = "M104 S" + str(lv_lower_temp)
|
||||||
|
lv_insert = 1 # after the line
|
||||||
|
|
||||||
if p_tool_change[p_line_number] == DEST_TEMP_LINE:
|
if p_tool_change[p_line_number] == DEST_TEMP_LINE:
|
||||||
# nothing to do
|
# nothing to do
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if p_tool_change[p_line_number] == UNLOAD_LINE:
|
if p_tool_change[p_line_number] == UNLOAD_LINE:
|
||||||
# nothing to do
|
# nothing to do
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if p_tool_change[p_line_number] == PURGE_LINE:
|
if p_tool_change[p_line_number] == PURGE_LINE:
|
||||||
# nothing to do
|
# nothing to do
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if p_tool_change[p_line_number] == PRINT_LINE:
|
if p_tool_change[p_line_number] == PRINT_LINE:
|
||||||
# nothing to do
|
# nothing to do
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# print(toolChange["id"])
|
# print(toolChange["id"])
|
||||||
return lv_output, lv_insert
|
return lv_output, lv_insert
|
||||||
@@ -271,6 +272,8 @@ for line in infile:
|
|||||||
targetTemp_match = target_temp_detect.search(line)
|
targetTemp_match = target_temp_detect.search(line)
|
||||||
if targetTemp_match is not None:
|
if targetTemp_match is not None:
|
||||||
if len(myToolChanges) > 0: # we found at least the start tool change
|
if len(myToolChanges) > 0: # we found at least the start tool change
|
||||||
|
# print(myToolChanges[toolChangeID])
|
||||||
|
|
||||||
if DEST_TEMP_LINE not in myToolChanges[toolChangeID]:
|
if DEST_TEMP_LINE not in myToolChanges[toolChangeID]:
|
||||||
# determine the temperature value
|
# determine the temperature value
|
||||||
tempMatch = re.search(r"S[0-9]*", line)
|
tempMatch = re.search(r"S[0-9]*", line)
|
||||||
@@ -312,6 +315,15 @@ for line in infile:
|
|||||||
# increment the line number
|
# increment the line number
|
||||||
line_number = line_number + 1
|
line_number = line_number + 1
|
||||||
|
|
||||||
|
"""
|
||||||
|
for toolChange in myToolChanges:
|
||||||
|
if DEST_TEMP in myToolChanges[toolChange]:
|
||||||
|
print(myToolChanges[toolChange])
|
||||||
|
else:
|
||||||
|
print("Key is missing")
|
||||||
|
print(myToolChanges[toolChange])
|
||||||
|
"""
|
||||||
|
|
||||||
""" -------------------------
|
""" -------------------------
|
||||||
### Determine the transitions
|
### Determine the transitions
|
||||||
"""
|
"""
|
||||||
@@ -321,24 +333,27 @@ lastTemp = initTemp
|
|||||||
for toolChange in myToolChanges:
|
for toolChange in myToolChanges:
|
||||||
# Last tool change is unloading only
|
# Last tool change is unloading only
|
||||||
# Special handler required in case we need to do something there
|
# Special handler required in case we need to do something there
|
||||||
if myToolChanges[toolChange][DEST_TEMP] == "0":
|
if DEST_TEMP in myToolChanges[toolChange]:
|
||||||
myToolChanges[toolChange][TRANSITION] = NOTRANSITION
|
if myToolChanges[toolChange][DEST_TEMP] == "0":
|
||||||
else:
|
myToolChanges[toolChange][TRANSITION] = NOTRANSITION
|
||||||
if lastTemp > myToolChanges[toolChange][DEST_TEMP]:
|
|
||||||
# Transition from higher value to lower value
|
|
||||||
myToolChanges[toolChange][TRANSITION] = HIGH2LOW
|
|
||||||
else:
|
else:
|
||||||
if lastTemp == myToolChanges[toolChange][DEST_TEMP]:
|
if lastTemp > myToolChanges[toolChange][DEST_TEMP]:
|
||||||
# If there is no difference in temperature, no transition is required
|
# Transition from higher value to lower value
|
||||||
myToolChanges[toolChange][TRANSITION] = NOTRANSITION
|
myToolChanges[toolChange][TRANSITION] = HIGH2LOW
|
||||||
else:
|
else:
|
||||||
# Transition from lower to higher value
|
if lastTemp == myToolChanges[toolChange][DEST_TEMP]:
|
||||||
myToolChanges[toolChange][TRANSITION] = LOW2HIGH
|
# If there is no difference in temperature, no transition is required
|
||||||
|
myToolChanges[toolChange][TRANSITION] = NOTRANSITION
|
||||||
|
else:
|
||||||
|
# Transition from lower to higher value
|
||||||
|
myToolChanges[toolChange][TRANSITION] = LOW2HIGH
|
||||||
|
|
||||||
# Save current temperature. Needed for first tool change
|
# Save current temperature. Needed for first tool change
|
||||||
myToolChanges[toolChange][CURR_TEMP] = lastTemp
|
myToolChanges[toolChange][CURR_TEMP] = lastTemp
|
||||||
# Remember the last temperature
|
# Remember the last temperature
|
||||||
lastTemp = myToolChanges[toolChange][DEST_TEMP]
|
lastTemp = myToolChanges[toolChange][DEST_TEMP]
|
||||||
|
else:
|
||||||
|
myToolChanges[toolChange][TRANSITION] = NOTRANSITION
|
||||||
|
|
||||||
""" ----------------------
|
""" ----------------------
|
||||||
### Update the gcode file
|
### Update the gcode file
|
||||||
|
|||||||
Reference in New Issue
Block a user