diff options
author | volconst <20997907+volconst@users.noreply.github.com> | 2022-01-18 20:59:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-18 20:59:44 +0300 |
commit | 86d212682ba78b5b472b550a57a8188492c4ff88 (patch) | |
tree | 8cf49055f6eb73f6179b07f153f23ec461666d3f | |
parent | faade5b9f33779a9b08286498a15eefd0abd13e0 (diff) | |
parent | 0c40c1a0656dd7a5ddce5db41d74e4a44579cb80 (diff) |
Merge pull request #1237 from volconst/empty-temp-graph
Fix Empty temp graph #1234
-rw-r--r-- | printrun/pronsole.py | 2 | ||||
-rw-r--r-- | printrun/pronterface.py | 55 | ||||
-rwxr-xr-x | testtools/mock-printer.py | 13 |
3 files changed, 32 insertions, 38 deletions
diff --git a/printrun/pronsole.py b/printrun/pronsole.py index 6708db9..c8c1ef0 100644 --- a/printrun/pronsole.py +++ b/printrun/pronsole.py @@ -59,7 +59,7 @@ try: except: READLINE = False # neither readline module is available -tempreading_exp = re.compile("(^T:| T:)") +tempreading_exp = re.compile('\\bT\d*:') REPORT_NONE = 0 REPORT_POS = 1 diff --git a/printrun/pronterface.py b/printrun/pronterface.py index f0e5a37..fda7025 100644 --- a/printrun/pronterface.py +++ b/printrun/pronterface.py @@ -1865,36 +1865,31 @@ Printrun. If not, see <http://www.gnu.org/licenses/>.""" def update_tempdisplay(self): try: temps = parse_temperature_report(self.tempreadings) - if "T0" in temps and temps["T0"][0]: - hotend_temp = float(temps["T0"][0]) - elif "T" in temps and temps["T"][0]: - hotend_temp = float(temps["T"][0]) - else: - hotend_temp = None - if hotend_temp is not None: - if self.display_graph: wx.CallAfter(self.graph.SetExtruder0Temperature, hotend_temp) - if self.display_gauges: wx.CallAfter(self.hottgauge.SetValue, hotend_temp) - setpoint = None - if "T0" in temps and temps["T0"][1]: setpoint = float(temps["T0"][1]) - elif temps["T"][1]: setpoint = float(temps["T"][1]) - if setpoint is not None: - if self.display_graph: wx.CallAfter(self.graph.SetExtruder0TargetTemperature, setpoint) - if self.display_gauges: wx.CallAfter(self.hottgauge.SetTarget, setpoint) - if "T1" in temps: - hotend_temp = float(temps["T1"][0]) - if self.display_graph: wx.CallAfter(self.graph.SetExtruder1Temperature, hotend_temp) - setpoint = temps["T1"][1] - if setpoint and self.display_graph: - wx.CallAfter(self.graph.SetExtruder1TargetTemperature, float(setpoint)) - bed_temp = float(temps["B"][0]) if "B" in temps and temps["B"][0] else None - if bed_temp is not None: - if self.display_graph: wx.CallAfter(self.graph.SetBedTemperature, bed_temp) - if self.display_gauges: wx.CallAfter(self.bedtgauge.SetValue, bed_temp) - setpoint = temps["B"][1] - if setpoint: - setpoint = float(setpoint) - if self.display_graph: wx.CallAfter(self.graph.SetBedTargetTemperature, setpoint) - if self.display_gauges: wx.CallAfter(self.bedtgauge.SetTarget, setpoint) + + for name in 'T', 'T0', 'T1', 'B': + if name not in temps: + continue + current = float(temps[name][0]) + target = float(temps[name][1]) if temps[name][1] else None + if name == 'T': + name = 'T0' + if self.display_graph: + prefix = 'Set' + name.replace('T', 'Extruder').replace('B', 'Bed') + wx.CallAfter(getattr(self.graph, prefix + 'Temperature'), current) + if target is not None: + wx.CallAfter(getattr(self.graph, prefix + 'TargetTemperature'), target) + if self.display_gauges: + if name[0] == 'T': + if name[1] == str(self.current_tool): + def update(c, t): + self.hottgauge.SetValue(c) + self.hottgauge.SetTarget(t or 0) + self.hottgauge.title = _('Heater%s:') % (str(self.current_tool) if self.settings.extruders > 1 else '') + wx.CallAfter(update, current, target) + else: + wx.CallAfter(self.bedtgauge.SetValue, current) + if target is not None: + wx.CallAfter(self.bedtgauge.SetTarget, target) except: self.logError(traceback.format_exc()) diff --git a/testtools/mock-printer.py b/testtools/mock-printer.py index b1b72c2..a28b695 100755 --- a/testtools/mock-printer.py +++ b/testtools/mock-printer.py @@ -1,12 +1,9 @@ #!/usr/bin/env python3 # Test network communication without networked 3d printer # Usage: -# bash1$ ./mock-printer.py -# bash2$ ./pronsole -# pronsole> connect localhost:8080 -# ...> load sliced.gcode -# ...> print -# ...> etc... +# bash1$ ./testtools/mock-printer.py +# bash2$ ./pronterface.py +# Enter localhost:8080 in Port, press Connect, Load file, Print import socket with socket.socket() as s: s.bind(('127.0.0.1', 8080)) @@ -22,7 +19,9 @@ with socket.socket() as s: break print(msg) if msg == b'M105\n': - c.sendall(('ok T:%d\n'%(20 + temp)).encode('ascii')) + # c.sendall(('ok T:%d\n'%(20 + temp)).encode('ascii')) + # test multiple extruders, see #1234 + c.sendall('ok T0:24.06 /34.00 B:23.45 /0.00 T1:44.28 /54 @:0 B@:0 @0:0 @1:0\n'.encode('ascii')) temp = (temp + 1)%30 else: c.sendall(b'ok\n') |