Refactoring
This commit is contained in:
parent
2479e01efd
commit
69c8a4b269
2 changed files with 87 additions and 30 deletions
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2018, Lars Brubaker, John Lewin
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
The views and conclusions contained in the software and documentation are those
|
||||||
|
of the authors and should not be interpreted as representing official policies,
|
||||||
|
either expressed or implied, of the FreeBSD Project.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using MatterControl.Printing;
|
||||||
|
using MatterHackers.Agg;
|
||||||
|
using MatterHackers.Agg.Platform;
|
||||||
|
using MatterHackers.Agg.UI;
|
||||||
|
using MatterHackers.Localizations;
|
||||||
|
using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling;
|
||||||
|
using MatterHackers.MatterControl.DataStorage;
|
||||||
|
using MatterHackers.MatterControl.PrinterCommunication.Io;
|
||||||
|
using MatterHackers.MatterControl.PrintQueue;
|
||||||
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
|
using MatterHackers.SerialPortCommunication;
|
||||||
|
using MatterHackers.SerialPortCommunication.FrostedSerial;
|
||||||
|
using MatterHackers.VectorMath;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
|
{
|
||||||
|
|
||||||
|
public class ConnectFailedEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public ConnectionFailure Reason { get; }
|
||||||
|
|
||||||
|
public ConnectFailedEventArgs(ConnectionFailure reason)
|
||||||
|
{
|
||||||
|
this.Reason = reason;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -27,16 +27,6 @@ of the authors and should not be interpreted as representing official policies,
|
||||||
either expressed or implied, of the FreeBSD Project.
|
either expressed or implied, of the FreeBSD Project.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using MatterControl.Printing;
|
using MatterControl.Printing;
|
||||||
using MatterHackers.Agg;
|
using MatterHackers.Agg;
|
||||||
using MatterHackers.Agg.Platform;
|
using MatterHackers.Agg.Platform;
|
||||||
|
|
@ -50,6 +40,16 @@ using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
using MatterHackers.SerialPortCommunication;
|
using MatterHackers.SerialPortCommunication;
|
||||||
using MatterHackers.SerialPortCommunication.FrostedSerial;
|
using MatterHackers.SerialPortCommunication.FrostedSerial;
|
||||||
using MatterHackers.VectorMath;
|
using MatterHackers.VectorMath;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.PrinterCommunication
|
namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
{
|
{
|
||||||
|
|
@ -353,12 +353,15 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
case SettingsKey.temperature:
|
case SettingsKey.temperature:
|
||||||
extruder = 0;
|
extruder = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SettingsKey.temperature1:
|
case SettingsKey.temperature1:
|
||||||
extruder = 1;
|
extruder = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SettingsKey.temperature2:
|
case SettingsKey.temperature2:
|
||||||
extruder = 2;
|
extruder = 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SettingsKey.temperature3:
|
case SettingsKey.temperature3:
|
||||||
extruder = 3;
|
extruder = 3;
|
||||||
break;
|
break;
|
||||||
|
|
@ -429,7 +432,6 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrinterSettings/Options {{
|
// PrinterSettings/Options {{
|
||||||
|
|
||||||
public int BaudRate
|
public int BaudRate
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -1093,7 +1095,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
string message = @"In order for MatterControl to access the serial ports on Linux, you will need to give your user account the appropriate permissions. Run these commands in a terminal to add yourself to the correct group.
|
string message = @"In order for MatterControl to access the serial ports on Linux, you will need to give your user account the appropriate permissions. Run these commands in a terminal to add yourself to the correct group.
|
||||||
|
|
||||||
Ubuntu/Debian
|
Ubuntu/Debian
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
|
@ -1192,7 +1194,7 @@ You will then need to logout and log back in to the computer for the changes to
|
||||||
forceImmediateWrites = false;
|
forceImmediateWrites = false;
|
||||||
|
|
||||||
CommunicationState = CommunicationStates.Disconnecting;
|
CommunicationState = CommunicationStates.Disconnecting;
|
||||||
CurrentReadThreadIndex++;
|
currentReadThreadIndex++;
|
||||||
if (serialPort != null)
|
if (serialPort != null)
|
||||||
{
|
{
|
||||||
serialPort.Close();
|
serialPort.Close();
|
||||||
|
|
@ -1741,7 +1743,7 @@ You will then need to logout and log back in to the computer for the changes to
|
||||||
ClearQueuedGCode();
|
ClearQueuedGCode();
|
||||||
|
|
||||||
CommunicationState = CommunicationStates.Disconnecting;
|
CommunicationState = CommunicationStates.Disconnecting;
|
||||||
CurrentReadThreadIndex++;
|
currentReadThreadIndex++;
|
||||||
ToggleHighLowHigh(serialPort);
|
ToggleHighLowHigh(serialPort);
|
||||||
if (serialPort != null)
|
if (serialPort != null)
|
||||||
{
|
{
|
||||||
|
|
@ -2117,7 +2119,7 @@ You will then need to logout and log back in to the computer for the changes to
|
||||||
// connectThread.Join(JoinThreadTimeoutMs);
|
// connectThread.Join(JoinThreadTimeoutMs);
|
||||||
|
|
||||||
CommunicationState = CommunicationStates.Disconnecting;
|
CommunicationState = CommunicationStates.Disconnecting;
|
||||||
CurrentReadThreadIndex++;
|
currentReadThreadIndex++;
|
||||||
if (serialPort != null)
|
if (serialPort != null)
|
||||||
{
|
{
|
||||||
serialPort.Close();
|
serialPort.Close();
|
||||||
|
|
@ -2669,7 +2671,6 @@ You will then need to logout and log back in to the computer for the changes to
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrintTask ActivePrintTask { get; set; }
|
public PrintTask ActivePrintTask { get; set; }
|
||||||
internal int CurrentReadThreadIndex { get => currentReadThreadIndex; set => currentReadThreadIndex = value; }
|
|
||||||
|
|
||||||
public void TurnOffBedAndExtruders(TurnOff turnOffTime)
|
public void TurnOffBedAndExtruders(TurnOff turnOffTime)
|
||||||
{
|
{
|
||||||
|
|
@ -2933,8 +2934,8 @@ You will then need to logout and log back in to the computer for the changes to
|
||||||
{
|
{
|
||||||
this.printerConnection = printerConnection;
|
this.printerConnection = printerConnection;
|
||||||
numRunning++;
|
numRunning++;
|
||||||
printerConnection.CurrentReadThreadIndex++;
|
printerConnection.currentReadThreadIndex++;
|
||||||
creationIndex = printerConnection.CurrentReadThreadIndex;
|
creationIndex = printerConnection.currentReadThreadIndex;
|
||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
|
@ -2958,7 +2959,7 @@ You will then need to logout and log back in to the computer for the changes to
|
||||||
|
|
||||||
internal bool IsCurrentThread()
|
internal bool IsCurrentThread()
|
||||||
{
|
{
|
||||||
return printerConnection.CurrentReadThreadIndex == creationIndex;
|
return printerConnection.currentReadThreadIndex == creationIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2996,16 +2997,6 @@ You will then need to logout and log back in to the computer for the changes to
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ConnectFailedEventArgs : EventArgs
|
|
||||||
{
|
|
||||||
public ConnectionFailure Reason { get; }
|
|
||||||
|
|
||||||
public ConnectFailedEventArgs(ConnectionFailure reason)
|
|
||||||
{
|
|
||||||
this.Reason = reason;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ConnectionFailure
|
public enum ConnectionFailure
|
||||||
{
|
{
|
||||||
Unknown,
|
Unknown,
|
||||||
|
|
@ -3025,4 +3016,4 @@ You will then need to logout and log back in to the computer for the changes to
|
||||||
UsbDisconnected,
|
UsbDisconnected,
|
||||||
ConnectionTimeout
|
ConnectionTimeout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue