Merge pull request #265 from GreatFruitOmsk/master

Show a warning if computer is not connected to AC power
master
daid 2012-11-20 01:28:06 -08:00
commit 035ccf0325
4 changed files with 35 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "Cura/util/Power"]
path = Cura/util/Power
url = git://github.com/GreatFruitOmsk/Power.git

View File

@ -11,6 +11,7 @@ from gui import taskbar
from util import machineCom
from util import profile
from util import gcodeInterpreter
from util import power
printWindowMonitorHandle = None
@ -116,6 +117,20 @@ class printWindow(wx.Frame):
sb = wx.StaticBox(self.panel, label="Statistics")
boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
self.powerWarningText = wx.StaticText(parent=self.panel,
id=-1,
label="Connect your computer to AC power\nIf it shuts down during printing, the product will be lost.",
style=wx.ALIGN_CENTER)
self.powerWarningText.SetBackgroundColour('red')
self.powerWarningText.SetForegroundColour('white')
boxsizer.AddF(self.powerWarningText, flags=wx.SizerFlags().Expand().Border(wx.BOTTOM, 10))
self.powerManagement = power.PowerManagement()
self.powerWarningTimer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.OnPowerWarningChange, self.powerWarningTimer)
self.OnPowerWarningChange(None)
self.powerWarningTimer.Start(10000)
self.statsText = wx.StaticText(self.panel, -1, "Filament: ####.##m #.##g\nEstimated print time: #####:##\nMachine state:\nDetecting baudrateXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
boxsizer.Add(self.statsText, flag=wx.LEFT, border=5)
@ -476,6 +491,15 @@ class printWindow(wx.Frame):
self.termInput.SetValue(self.termHistory[self.termHistoryIdx])
e.Skip()
def OnPowerWarningChange(self, e):
type = self.powerManagement.get_providing_power_source_type()
if type == power.POWER_TYPE_AC and self.powerWarningText.IsShown():
self.powerWarningText.Hide()
self.Layout()
elif type != power.POWER_TYPE_AC and not self.powerWarningText.IsShown():
self.powerWarningText.Show()
self.Layout()
def LoadGCodeFile(self, filename):
if self.machineCom != None and self.machineCom.isPrinting():
return

1
Cura/util/Power Submodule

@ -0,0 +1 @@
Subproject commit 9630adf08ee2de90cb3a49af53d85693060ccbff

View File

@ -0,0 +1,7 @@
import sys
import os
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Power'))
import power