Merge branch '1.0.5' of https://github.com/MatterHackers/MatterControl into development

This commit is contained in:
larsbrubaker 2014-03-05 21:04:28 -08:00
commit f52eae0f33
7 changed files with 151 additions and 129 deletions

View file

@ -136,6 +136,7 @@ namespace MatterHackers.MatterControl
TextImageButtonFactory advancedControlsButtonFactory = new TextImageButtonFactory();
RGBA_Bytes unselectedTextColor = ActiveTheme.Instance.TabLabelUnselected;
static MainSlide globalInstance;
public EventHandler AdvancedControlsLoaded;
GuiWidget LeftPanel
{
@ -288,6 +289,14 @@ namespace MatterHackers.MatterControl
//Empty function used as placeholder
}
void OnAdvancedControlsLoaded()
{
if (AdvancedControlsLoaded != null)
{
AdvancedControlsLoaded(this, null);
}
}
SliceSettingsWidget.UiState sliceSettingsUiState;
void DoChangePanel(object state)
{
@ -297,7 +306,9 @@ namespace MatterHackers.MatterControl
// remove the advance control and replace it with new ones build for the selected printer
int advancedControlsWidgetIndex = RightPanel.GetChildIndex(this.advancedControlsTabControl);
RightPanel.RemoveChild(advancedControlsWidgetIndex);
this.advancedControlsTabControl = CreateNewAdvancedControlsTab(sliceSettingsUiState);
this.advancedControlsTabControl = CreateNewAdvancedControlsTab(sliceSettingsUiState);
RightPanel.AddChild(this.advancedControlsTabControl, advancedControlsWidgetIndex);
// set the selected tab back to the one it was before we replace the control
@ -308,6 +319,8 @@ namespace MatterHackers.MatterControl
RectangleDouble localBounds = this.LocalBounds;
this.LocalBounds = new RectangleDouble(0, 0, this.LocalBounds.Width - 1, 10);
this.LocalBounds = localBounds;
OnAdvancedControlsLoaded();
}
TabControl CreateNewAdvancedControlsTab(SliceSettingsWidget.UiState sliceSettingsUiState)
@ -350,6 +363,8 @@ namespace MatterHackers.MatterControl
advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(configurationControls, configurationLabel), 18,
ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
return advancedControls;
}

View file

@ -102,7 +102,10 @@ namespace MatterHackers.MatterControl.PrintQueue
sliceItem.Done -= new EventHandler(sliceItem_Done);
sliceItem.SlicingOutputMessage -= printItemWrapper_SlicingOutputMessage;
savedGCodeFileNames.Add(sliceItem.GCodePathAndFileName);
if (File.Exists(sliceItem.FileLocation))
{
savedGCodeFileNames.Add(sliceItem.GCodePathAndFileName);
}
itemCountBeingWorkedOn++;
if (itemCountBeingWorkedOn < allFilesToExport.Count)
@ -125,15 +128,23 @@ namespace MatterHackers.MatterControl.PrintQueue
if (lines.Length > 0)
{
string filamentAmountLine = lines[lines.Length - 1];
bool foundAmountInGCode = false;
int startPos = filamentAmountLine.IndexOf("(");
int endPos = filamentAmountLine.IndexOf("cm3)");
string value = filamentAmountLine.Substring(startPos + 1, endPos - (startPos + 1));
double amountForThisFile;
if (double.TryParse(value, out amountForThisFile))
if (startPos > 0)
{
total += amountForThisFile;
int endPos = filamentAmountLine.IndexOf("cm3)", startPos);
if (endPos > 0)
{
string value = filamentAmountLine.Substring(startPos + 1, endPos - (startPos + 1));
double amountForThisFile;
if (double.TryParse(value, out amountForThisFile))
{
foundAmountInGCode = true;
total += amountForThisFile;
}
}
}
else
if (!foundAmountInGCode)
{
GCodeFile gcodeFile = new GCodeFile(gcodeFileName);
total += gcodeFile.GetFilamentCubicMm(ActiveSliceSettings.Instance.FillamentDiameter) / 1000;

View file

@ -51,15 +51,23 @@ namespace MatterHackers.MatterControl.PrintQueue
if (doneSlicing)
{
string message = "Slicing Error";
string gcodePathAndFileName = GetGCodePathAndFileName();
if (gcodePathAndFileName != "" && File.Exists(gcodePathAndFileName))
if (File.Exists(FileLocation))
{
FileInfo info = new FileInfo(gcodePathAndFileName);
if (info.Length > 10)
string gcodePathAndFileName = GetGCodePathAndFileName();
if (gcodePathAndFileName != "" && File.Exists(gcodePathAndFileName))
{
message = "Ready to Print";
FileInfo info = new FileInfo(gcodePathAndFileName);
// This is really just to make sure it is bigger than nothing.
if (info.Length > 10)
{
message = "Ready to Print";
}
}
}
else
{
message = string.Format("File Not Found\n'{0}'", FileLocation);
}
OnSlicingOutputMessage(new StringEventArgs(message));

View file

@ -22,9 +22,7 @@ namespace MatterHackers.MatterControl.PrintQueue
public DropDownMenu MenuDropList;
private TupleList<string, Func<bool>> menuItems;
ExportToFolderFeedbackWindow exportingWindow;
bool exportingWindowIsOpen = false;
ExportToFolderFeedbackWindow exportingWindow = null;
public PrintQueueMenu()
{
@ -66,7 +64,6 @@ namespace MatterHackers.MatterControl.PrintQueue
{new LocalizedString(" Export to Zip").Translated, exportQueueToZipMenu_Click},
{"GCode", null},
{new LocalizedString(" Export to Folder").Translated, exportGCodeToFolderButton_Click},
//{" Export to SD Card", exportToSDCardButton_Click},
{new LocalizedString("Extra").Translated, null},
{new LocalizedString(" Create Part Sheet").Translated, createPartsSheetsButton_Click},
};
@ -142,31 +139,11 @@ namespace MatterHackers.MatterControl.PrintQueue
return true;
}
private void OpenExportWindow(List<PrintItem> parts)
{
if (this.exportingWindowIsOpen == false)
{
exportingWindow = new ExportToFolderFeedbackWindow(parts.Count, parts [0].Name, ActiveTheme.Instance.PrimaryBackgroundColor);
this.exportingWindowIsOpen = true;
exportingWindow.Closed += new EventHandler(ExportToFolderFeedbackWindow_Closed);
}
else
{
if (exportingWindow != null)
{
exportingWindow.BringToFront();
}
}
}
void ExportToFolderFeedbackWindow_Closed(object sender, EventArgs e)
{
this.exportingWindowIsOpen = false;
this.exportingWindow = null;
}
private void SelectLocationToExportGCode(object state)
{
SelectFolderDialogParams selectParams = new SelectFolderDialogParams("Select Location To Save Files");
@ -179,8 +156,18 @@ namespace MatterHackers.MatterControl.PrintQueue
List<PrintItem> parts = PrintQueueControl.Instance.CreateReadOnlyPartList();
if (parts.Count > 0)
{
OpenExportWindow (parts);
ExportToFolderProcess exportToFolderProcess = new ExportToFolderProcess(parts, path);
if (exportingWindow == null)
{
exportingWindow = new ExportToFolderFeedbackWindow(parts.Count, parts[0].Name, ActiveTheme.Instance.PrimaryBackgroundColor);
exportingWindow.Closed += new EventHandler(ExportToFolderFeedbackWindow_Closed);
exportingWindow.ShowAsSystemWindow();
}
else
{
exportingWindow.BringToFront();
}
ExportToFolderProcess exportToFolderProcess = new ExportToFolderProcess(parts, path);
exportToFolderProcess.StartingNextPart += exportingWindow.StartingNextPart;
exportToFolderProcess.UpdatePartStatus += exportingWindow.UpdatePartStatus;
exportToFolderProcess.DoneSaving += exportingWindow.DoneSaving;
@ -189,39 +176,6 @@ namespace MatterHackers.MatterControl.PrintQueue
}
}
bool exportToSDCardButton_Click()
{
UiThread.RunOnIdle(ExportToSDCardButtonOnIdle);
return true;
}
void ExportToSDCardButtonOnIdle(object state)
{
if (!PrinterCommunication.Instance.PrinterIsConnected)
{
StyledMessageBox.ShowMessageBox("You must connect to a printer before you can export to the printers SD Card.", "You must connect to a printer");
}
else
{
string message = string.Format("Do you want to save your entire queue to the printers SD Card? This can be a lengthy process");
if (StyledMessageBox.ShowMessageBox(message, "Save to SD Card", StyledMessageBox.MessageType.YES_NO))
{
List<PrintItem> parts = PrintQueueControl.Instance.CreateReadOnlyPartList();
if (parts.Count > 0)
{
ExportToSdCardFeedbackWindow exportingWindow = new ExportToSdCardFeedbackWindow(parts.Count, parts[0].Name, ActiveTheme.Instance.PrimaryBackgroundColor);
exportingWindow.ShowAsSystemWindow();
ExportToSdCardProcess exportToSdCardProcess = new ExportToSdCardProcess(parts);
exportToSdCardProcess.StartingNextPart += exportingWindow.StartingNextPart;
exportToSdCardProcess.UpdatePartStatus += exportingWindow.UpdatePartStatus;
exportToSdCardProcess.DoneSaving += exportingWindow.DoneSaving;
exportToSdCardProcess.Start();
}
}
}
}
bool exportQueueToZipMenu_Click()
{
UiThread.RunOnIdle(ExportQueueToZipOnIdle);

View file

@ -106,6 +106,12 @@ namespace MatterHackers.MatterControl
get { return firmwareType; }
}
string firmwareVersion;
public string FirmwareVersion
{
get { return firmwareVersion; }
}
static PrinterCommunication globalInstance;
string connectionFailureMessage = "Unknown Reason";
@ -124,6 +130,7 @@ namespace MatterHackers.MatterControl
public RootedObjectEventHandler ExtruderTemperatureRead = new RootedObjectEventHandler();
public RootedObjectEventHandler ExtruderTemperatureSet = new RootedObjectEventHandler();
public RootedObjectEventHandler FanSpeedSet = new RootedObjectEventHandler();
public RootedObjectEventHandler FirmwareVersionRead = new RootedObjectEventHandler();
public RootedObjectEventHandler PrintFinished = new RootedObjectEventHandler();
public RootedObjectEventHandler PositionRead = new RootedObjectEventHandler();
public RootedObjectEventHandler ReadLine = new RootedObjectEventHandler();
@ -531,7 +538,7 @@ namespace MatterHackers.MatterControl
{
return CommunicationState == CommunicationStates.Paused;
}
}
}
int NumberOfLinesInCurrentPrint
{
@ -965,6 +972,16 @@ namespace MatterHackers.MatterControl
firmwareType = FirmwareTypes.Sprinter;
}
}
string firmwareVersionReported = "";
if (GCodeFile.GetFirstStringAfter("PROTOCOL_VERSION:", foundStringEventArgs.LineToCheck, " ", ref firmwareVersionReported))
{
//Firmware version was detected and is different
if (firmwareVersionReported != "" && firmwareVersion != firmwareVersionReported)
{
firmwareVersion = firmwareVersionReported;
OnFirmwareVersionRead(null);
}
}
}
public void FoundStart(object sender, EventArgs e)
@ -1076,6 +1093,7 @@ namespace MatterHackers.MatterControl
CommunicationState = CommunicationStates.AttemptingToConnect;
this.stopTryingToConnect = false;
firmwareType = FirmwareTypes.Unknown;
firmwareVersion = null;
if (SerialPortIsAvailable(this.ActivePrinter.ComPort))
{
@ -1244,6 +1262,11 @@ namespace MatterHackers.MatterControl
PrintFinished.CallEvents(this, new PrintItemWrapperEventArgs(this.ActivePrintItem));
}
void OnFirmwareVersionRead(EventArgs e)
{
FirmwareVersionRead.CallEvents(this, e);
}
void OnExtruderTemperatureRead(EventArgs e)
{
ExtruderTemperatureRead.CallEvents(this, e);

View file

@ -150,6 +150,7 @@ namespace MatterHackers.MatterControl
FlowLayoutWidget controlsTopToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom);
controlsTopToBottomLayout.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
controlsTopToBottomLayout.VAnchor = Agg.UI.VAnchor.FitToChildren;
controlsTopToBottomLayout.Name = "ManualPrinterControls.ControlsContainer";
controlsTopToBottomLayout.Padding = new BorderDouble(3, 0);

View file

@ -170,73 +170,83 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
if (PrinterCommunication.Instance.ActivePrintItem != null && listOfSlicingItems.Count > 0)
{
PrintItemWrapper itemToSlice = listOfSlicingItems[0];
itemToSlice.CurrentlySlicing = true;
string currentConfigurationFileAndPath = Path.Combine(ApplicationDataStorage.Instance.GCodeOutputPath, "config_" + ActiveSliceSettings.Instance.GetHashCode().ToString() + ".ini");
ActiveSliceSettings.Instance.GenerateConfigFile(currentConfigurationFileAndPath);
string gcodePathAndFileName = itemToSlice.GCodePathAndFileName;
bool gcodeFileIsComplete = itemToSlice.IsGCodeFileComplete(gcodePathAndFileName);
if (!File.Exists(gcodePathAndFileName) || !gcodeFileIsComplete)
// check that the STL file is currently on disk
if (File.Exists(itemToSlice.FileLocation))
{
slicerProcess = new Process();
itemToSlice.CurrentlySlicing = true;
switch (ActivePrinterProfile.Instance.ActiveSliceEngineType)
string currentConfigurationFileAndPath = Path.Combine(ApplicationDataStorage.Instance.GCodeOutputPath, "config_" + ActiveSliceSettings.Instance.GetHashCode().ToString() + ".ini");
ActiveSliceSettings.Instance.GenerateConfigFile(currentConfigurationFileAndPath);
string gcodePathAndFileName = itemToSlice.GCodePathAndFileName;
bool gcodeFileIsComplete = itemToSlice.IsGCodeFileComplete(gcodePathAndFileName);
if (!File.Exists(gcodePathAndFileName) || !gcodeFileIsComplete)
{
case ActivePrinterProfile.SlicingEngineTypes.Slic3r:
slicerProcess.StartInfo.Arguments = "--load \"" + currentConfigurationFileAndPath + "\" --output \"" + gcodePathAndFileName + "\" \"" + itemToSlice.PartToSlicePathAndFileName + "\"";
break;
slicerProcess = new Process();
case ActivePrinterProfile.SlicingEngineTypes.CuraEngine:
slicerProcess.StartInfo.Arguments = "-v -o \"" + gcodePathAndFileName + "\" " + CuraEngineMappings.GetCuraCommandLineSettings() + " \"" + itemToSlice.PartToSlicePathAndFileName + "\"";
//Debug.Write(slicerProcess.StartInfo.Arguments);
break;
case ActivePrinterProfile.SlicingEngineTypes.MatterSlice:
slicerProcess.StartInfo.Arguments = "--load \"" + currentConfigurationFileAndPath + "\" --output \"" + gcodePathAndFileName + "\" \"" + itemToSlice.PartToSlicePathAndFileName + "\"";
break;
}
string slicerFullPath = getSlicerFullPath();
slicerProcess.StartInfo.CreateNoWindow = true;
slicerProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
slicerProcess.StartInfo.RedirectStandardError = true;
slicerProcess.StartInfo.RedirectStandardOutput = true;
slicerProcess.StartInfo.FileName = slicerFullPath;
slicerProcess.StartInfo.UseShellExecute = false;
slicerProcess.OutputDataReceived += (sender, args) =>
{
if (args.Data != null)
switch (ActivePrinterProfile.Instance.ActiveSliceEngineType)
{
string message = args.Data;
message = message.Replace("=>", "").Trim();
if (message.Contains(".gcode"))
{
message = "Saving intermediate file";
}
message += "...";
itemToSlice.OnSlicingOutputMessage(new StringEventArgs(message));
case ActivePrinterProfile.SlicingEngineTypes.Slic3r:
slicerProcess.StartInfo.Arguments = "--load \"" + currentConfigurationFileAndPath + "\" --output \"" + gcodePathAndFileName + "\" \"" + itemToSlice.PartToSlicePathAndFileName + "\"";
break;
case ActivePrinterProfile.SlicingEngineTypes.CuraEngine:
slicerProcess.StartInfo.Arguments = "-v -o \"" + gcodePathAndFileName + "\" " + CuraEngineMappings.GetCuraCommandLineSettings() + " \"" + itemToSlice.PartToSlicePathAndFileName + "\"";
//Debug.Write(slicerProcess.StartInfo.Arguments);
break;
case ActivePrinterProfile.SlicingEngineTypes.MatterSlice:
slicerProcess.StartInfo.Arguments = "--load \"" + currentConfigurationFileAndPath + "\" --output \"" + gcodePathAndFileName + "\" \"" + itemToSlice.PartToSlicePathAndFileName + "\"";
break;
}
};
slicerProcess.Start();
string slicerFullPath = getSlicerFullPath();
slicerProcess.BeginOutputReadLine();
string stdError = slicerProcess.StandardError.ReadToEnd();
slicerProcess.StartInfo.CreateNoWindow = true;
slicerProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
slicerProcess.StartInfo.RedirectStandardError = true;
slicerProcess.StartInfo.RedirectStandardOutput = true;
slicerProcess.WaitForExit();
using (TimedLock.Lock(slicerProcess, "SlicingProcess"))
{
slicerProcess = null;
slicerProcess.StartInfo.FileName = slicerFullPath;
slicerProcess.StartInfo.UseShellExecute = false;
slicerProcess.OutputDataReceived += (sender, args) =>
{
if (args.Data != null)
{
string message = args.Data;
message = message.Replace("=>", "").Trim();
if (message.Contains(".gcode"))
{
message = "Saving intermediate file";
}
message += "...";
UiThread.RunOnIdle((state) =>
{
itemToSlice.OnSlicingOutputMessage(new StringEventArgs(message));
});
}
};
slicerProcess.Start();
slicerProcess.BeginOutputReadLine();
string stdError = slicerProcess.StandardError.ReadToEnd();
slicerProcess.WaitForExit();
using (TimedLock.Lock(slicerProcess, "SlicingProcess"))
{
slicerProcess = null;
}
}
}
itemToSlice.CurrentlySlicing = false;
itemToSlice.DoneSlicing = true;
UiThread.RunOnIdle((state) =>
{
itemToSlice.CurrentlySlicing = false;
itemToSlice.DoneSlicing = true;
});
using (TimedLock.Lock(listOfSlicingItems, "CreateSlicedPartsThread()"))
{