Fixed connection issues
Got rid of AnchoredDropDownList Put in BaudRate user edit field
This commit is contained in:
parent
d83ed4edfa
commit
0ba8a78dc5
12 changed files with 119 additions and 72 deletions
|
|
@ -165,7 +165,7 @@ namespace MatterHackers.MatterControl
|
|||
FlowLayoutWidget controlsContainer = new FlowLayoutWidget();
|
||||
controlsContainer.HAnchor |= HAnchor.ParentCenter;
|
||||
|
||||
AnchoredDropDownList releaseOptionsDropList = new AnchoredDropDownList("Development");
|
||||
var releaseOptionsDropList = new StyledDropDownList("Development");
|
||||
releaseOptionsDropList.Margin = new BorderDouble(0, 3);
|
||||
|
||||
MenuItem releaseOptionsDropDownItem = releaseOptionsDropList.AddItem("Release", "release");
|
||||
|
|
@ -203,7 +203,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
private void ReleaseOptionsDropList_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
string releaseCode = ((AnchoredDropDownList)sender).SelectedValue;
|
||||
string releaseCode = ((StyledDropDownList)sender).SelectedValue;
|
||||
if (releaseCode != UserSettings.Instance.get("UpdateFeedType"))
|
||||
{
|
||||
UserSettings.Instance.set("UpdateFeedType", releaseCode);
|
||||
|
|
|
|||
|
|
@ -53,28 +53,4 @@ namespace MatterHackers.MatterControl
|
|||
this.BackgroundColor = new RGBA_Bytes(255, 255, 255, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public class AnchoredDropDownList : DropDownList
|
||||
{
|
||||
private static RGBA_Bytes whiteSemiTransparent = new RGBA_Bytes(255, 255, 255, 100);
|
||||
private static RGBA_Bytes whiteTransparent = new RGBA_Bytes(255, 255, 255, 0);
|
||||
|
||||
public AnchoredDropDownList(string noSelectionString, Direction direction = Direction.Down, double maxHeight = 0)
|
||||
: base(noSelectionString, whiteTransparent, whiteSemiTransparent, direction, maxHeight)
|
||||
{
|
||||
this.HAnchor = HAnchor.ParentLeftRight;
|
||||
this.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
|
||||
this.MenuItemsBorderWidth = 1;
|
||||
this.MenuItemsBackgroundColor = RGBA_Bytes.White;
|
||||
this.MenuItemsBorderColor = ActiveTheme.Instance.SecondaryTextColor;
|
||||
this.MenuItemsPadding = new BorderDouble(10, 4, 10, 6);
|
||||
this.MenuItemsBackgroundHoverColor = ActiveTheme.Instance.PrimaryAccentColor;
|
||||
this.MenuItemsTextHoverColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
this.BorderWidth = 1;
|
||||
this.BorderColor = ActiveTheme.Instance.SecondaryTextColor;
|
||||
this.HoverColor = whiteSemiTransparent;
|
||||
this.BackgroundColor = new RGBA_Bytes(255, 255, 255, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -49,7 +49,6 @@ namespace MatterHackers.MatterControl.DataStorage.ClassicDB
|
|||
{
|
||||
public class ClassicSqlitePrinterProfiles
|
||||
{
|
||||
|
||||
public class ClassicSettingsLayer
|
||||
{
|
||||
//Container class representing a collection of setting along with the meta info for that collection
|
||||
|
|
@ -93,24 +92,32 @@ namespace MatterHackers.MatterControl.DataStorage.ClassicDB
|
|||
|
||||
string fullProfilePath = Path.Combine(profilePath, printer.Id + ".json");
|
||||
|
||||
layeredProfile.UserLayer["MatterControl.Make"] = printer.Make ?? "";
|
||||
layeredProfile.UserLayer["MatterControl.Model"] = printer.Model ?? "";
|
||||
layeredProfile.UserLayer["MatterControl.BaudRate"] = printer.BaudRate ?? "";
|
||||
layeredProfile.UserLayer["MatterControl.ComPort"] = printer.ComPort ?? "";
|
||||
layeredProfile.UserLayer["MatterControl.DefaultMaterialPresets"] = printer.MaterialCollectionIds ?? "";
|
||||
layeredProfile.UserLayer["MatterControl.WindowsDriver"] = printer.DriverType ?? "";
|
||||
layeredProfile.UserLayer["MatterControl.DeviceToken"] = printer.DeviceToken ?? "";
|
||||
layeredProfile.UserLayer["MatterControl.DeviceType"] = printer.DeviceType ?? "";
|
||||
|
||||
// TODO: Where should this be collected from or stored to?
|
||||
//layeredProfile.SetActiveValue("MatterControl.<<<<<LLLLLEVELING>>>>>", printer.PrintLevelingJsonData);
|
||||
|
||||
// TODO: Where can we find CalibrationFiiles in the current model?
|
||||
//layeredProfile.SetActiveValue("MatterControl.CalibrationFiles", printer.Make);
|
||||
|
||||
File.WriteAllText(fullProfilePath, JsonConvert.SerializeObject(layeredProfile, Formatting.Indented));
|
||||
|
||||
//GET LEVELING DATA from DB
|
||||
|
||||
//PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(printer);
|
||||
|
||||
/*
|
||||
PrintLevelingPlane.Instance.SetPrintLevelingEquation(
|
||||
levelingData.SampledPosition0,
|
||||
levelingData.SampledPosition1,
|
||||
levelingData.SampledPosition2,
|
||||
ActiveSliceSettings.Instance.PrintCenter); */
|
||||
|
||||
}
|
||||
|
||||
private static void LoadMaterialSettings(LayeredProfile layeredProfile, Printer printer)
|
||||
{
|
||||
var materialAssignments = printer.MaterialCollectionIds.Split(',');
|
||||
var materialAssignments = printer.MaterialCollectionIds?.Split(',');
|
||||
if(materialAssignments == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var collections = Datastore.Instance.dbSQLite.Table<SliceSettingsCollection>().Where(v => v.PrinterId == printer.Id && v.Tag == "material");
|
||||
foreach (var collection in collections)
|
||||
|
|
@ -176,7 +183,6 @@ namespace MatterHackers.MatterControl.DataStorage.ClassicDB
|
|||
settings.Add(defaultSettingsLayer);
|
||||
}
|
||||
|
||||
|
||||
private static ClassicSettingsLayer LoadConfigurationSettingsFromFile(string pathAndFileName, SliceSettingsCollection collection)
|
||||
{
|
||||
Dictionary<string, SliceSetting> settingsDictionary = new Dictionary<string, SliceSetting>();
|
||||
|
|
|
|||
|
|
@ -396,9 +396,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
{
|
||||
try
|
||||
{
|
||||
if (this.ActivePrinter.BaudRate != null)
|
||||
if (ActiveSliceSettings.Instance.BaudRate != null)
|
||||
{
|
||||
baudRate = Convert.ToInt32(this.ActivePrinter.BaudRate);
|
||||
baudRate = Convert.ToInt32(ActiveSliceSettings.Instance.BaudRate);
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
|
@ -513,18 +513,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
}
|
||||
}
|
||||
|
||||
public string ComPort
|
||||
{
|
||||
get
|
||||
{
|
||||
string comPort = null;
|
||||
if (this.ActivePrinter != null)
|
||||
{
|
||||
comPort = this.ActivePrinter.ComPort;
|
||||
}
|
||||
return comPort;
|
||||
}
|
||||
}
|
||||
public string ComPort => ActiveSliceSettings.Instance?.ComPort;
|
||||
|
||||
public string DriverType => ActiveSliceSettings.Instance?.DriverType;
|
||||
|
||||
public bool AtxPowerEnabled
|
||||
{
|
||||
|
|
@ -1537,7 +1528,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
// current approach results in unpredictable behavior if the caller fails to close the connection
|
||||
if (serialPort == null && this.ActivePrinter != null)
|
||||
{
|
||||
IFrostedSerialPort resetSerialPort = FrostedSerialPortFactory.GetAppropriateFactory(this.ActivePrinter.DriverType).Create(this.ActivePrinter.ComPort);
|
||||
IFrostedSerialPort resetSerialPort = FrostedSerialPortFactory.GetAppropriateFactory(this.DriverType).Create(this.ComPort);
|
||||
resetSerialPort.Open();
|
||||
|
||||
Thread.Sleep(500);
|
||||
|
|
@ -1829,7 +1820,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
{
|
||||
// We reset the board while attempting to connect, so now we don't have a serial port.
|
||||
// Create one and do the DTR to reset
|
||||
var resetSerialPort = FrostedSerialPortFactory.GetAppropriateFactory(this.ActivePrinter.DriverType).Create(this.ActivePrinter.ComPort);
|
||||
var resetSerialPort = FrostedSerialPortFactory.GetAppropriateFactory(this.DriverType).Create(this.ComPort);
|
||||
resetSerialPort.Open();
|
||||
|
||||
Thread.Sleep(500);
|
||||
|
|
@ -2191,7 +2182,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
}
|
||||
|
||||
bool serialPortIsAvailable = SerialPortIsAvailable(serialPortName);
|
||||
bool serialPortIsAlreadyOpen = FrostedSerialPortFactory.GetAppropriateFactory(this.ActivePrinter.DriverType).SerialPortAlreadyOpen(serialPortName);
|
||||
bool serialPortIsAlreadyOpen = FrostedSerialPortFactory.GetAppropriateFactory(this.DriverType).SerialPortAlreadyOpen(serialPortName);
|
||||
|
||||
if (serialPortIsAvailable && !serialPortIsAlreadyOpen)
|
||||
{
|
||||
|
|
@ -2199,7 +2190,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
{
|
||||
try
|
||||
{
|
||||
serialPort = FrostedSerialPortFactory.GetAppropriateFactory(this.ActivePrinter.DriverType).CreateAndOpen(serialPortName, baudRate, true);
|
||||
serialPort = FrostedSerialPortFactory.GetAppropriateFactory(this.DriverType).CreateAndOpen(serialPortName, baudRate, true);
|
||||
#if __ANDROID__
|
||||
ToggleHighLowHeigh(serialPort);
|
||||
#endif
|
||||
|
|
@ -2238,7 +2229,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
// If the serial port isn't available (i.e. the specified port name wasn't found in GetPortNames()) or the serial
|
||||
// port is already opened in another instance or process, then report the connection problem back to the user
|
||||
connectionFailureMessage = (serialPortIsAlreadyOpen ?
|
||||
string.Format("{0} in use", PrinterConnectionAndCommunication.Instance.ActivePrinter.ComPort) :
|
||||
string.Format("{0} in use", this.ComPort) :
|
||||
LocalizedString.Get("Port not found"));
|
||||
|
||||
OnConnectionFailed(null);
|
||||
|
|
@ -2262,8 +2253,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
//Debug.WriteLine("Open ports: {0}".FormatWith(portNames.Length));
|
||||
if (portNames.Length > 0)
|
||||
{
|
||||
//Debug.WriteLine("Connecting to: {0} {1}".FormatWith(this.ActivePrinter.ComPort, this.BaudRate));
|
||||
AttemptToConnect(this.ActivePrinter.ComPort, this.BaudRate);
|
||||
AttemptToConnect(this.ComPort, this.BaudRate);
|
||||
if (CommunicationState == CommunicationStates.FailedToConnect)
|
||||
{
|
||||
OnConnectionFailed(null);
|
||||
|
|
@ -2305,11 +2295,11 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
|
||||
if (!string.IsNullOrEmpty(currentPortName))
|
||||
{
|
||||
this.ActivePrinter.ComPort = currentPortName;
|
||||
this.ComPort = currentPortName;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (SerialPortIsAvailable(this.ActivePrinter.ComPort))
|
||||
if (SerialPortIsAvailable(this.ComPort))
|
||||
{
|
||||
//Create a timed callback to determine whether connection succeeded
|
||||
Timer connectionTimer = new Timer(new TimerCallback(ConnectionCallbackTimer));
|
||||
|
|
@ -2323,11 +2313,11 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine("Connection failed: {0}".FormatWith(this.ActivePrinter.ComPort));
|
||||
Debug.WriteLine("Connection failed: {0}".FormatWith(this.ComPort));
|
||||
|
||||
connectionFailureMessage = string.Format(
|
||||
"{0} is not available".Localize(),
|
||||
this.ActivePrinter.ComPort);
|
||||
this.ComPort);
|
||||
|
||||
OnConnectionFailed(null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ using Newtonsoft.Json;
|
|||
using MatterHackers.MatterControl.SettingsManagement;
|
||||
using MatterHackers.Agg;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
|
||||
namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||
{
|
||||
|
|
@ -195,8 +197,23 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
private static SettingsLayer LoadMatterHackersBaseLayer()
|
||||
{
|
||||
// TODO: Build if missing?
|
||||
string baseConfigPath = Path.Combine(profilesPath, "config.json");
|
||||
if(!File.Exists(baseConfigPath))
|
||||
{
|
||||
string configIniPath = StaticData.Instance.MapPath(Path.Combine("PrinterSettings", "config.ini"));
|
||||
|
||||
SettingsLayer baseLayer;
|
||||
|
||||
using (var sourceStream = StaticData.Instance.OpenSteam(configIniPath))
|
||||
using (var reader = new StreamReader(sourceStream))
|
||||
{
|
||||
baseLayer = SettingsLayer.LoadFromIni(reader);
|
||||
}
|
||||
File.WriteAllText(baseConfigPath, JsonConvert.SerializeObject(baseLayer));
|
||||
|
||||
return baseLayer;
|
||||
}
|
||||
|
||||
return JsonConvert.DeserializeObject<SettingsLayer>(File.ReadAllText(baseConfigPath));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1149,6 +1149,44 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
return foundValue;
|
||||
}
|
||||
|
||||
public static SettingsLayer LoadFromIni(TextReader reader)
|
||||
{
|
||||
var layer = new SettingsLayer();
|
||||
|
||||
string line;
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
var segments = line.Split('=');
|
||||
if (!line.StartsWith("#") && !string.IsNullOrEmpty(line))
|
||||
{
|
||||
string key = segments[0].Trim();
|
||||
layer[key] = segments[1].Trim();
|
||||
}
|
||||
}
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
||||
public static SettingsLayer LoadFromIni(string filePath)
|
||||
{
|
||||
var settings = from line in File.ReadAllLines(filePath)
|
||||
let segments = line.Split('=')
|
||||
where !line.StartsWith("#") && !string.IsNullOrEmpty(line)
|
||||
select new
|
||||
{
|
||||
Key = segments[0].Trim(),
|
||||
Value = segments[1].Trim()
|
||||
};
|
||||
|
||||
var layer = new SettingsLayer();
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
layer[setting.Key] = setting.Value;
|
||||
}
|
||||
|
||||
return layer;
|
||||
}
|
||||
}
|
||||
|
||||
public class ProfileData
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
|
|||
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.ImageProcessing;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.ImageProcessing;
|
||||
|
|
@ -51,7 +52,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
private string filterTag;
|
||||
private string filterLabel;
|
||||
public AnchoredDropDownList DropDownList;
|
||||
public StyledDropDownList DropDownList;
|
||||
private TupleList<string, Func<bool>> DropDownMenuItems = new TupleList<string, Func<bool>>();
|
||||
|
||||
private int extruderIndex; //For multiple materials
|
||||
|
|
@ -221,9 +222,15 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
#endif
|
||||
}
|
||||
|
||||
private AnchoredDropDownList CreateDropdown()
|
||||
private StyledDropDownList CreateDropdown()
|
||||
{
|
||||
AnchoredDropDownList dropDownList = new AnchoredDropDownList("- default -", maxHeight: 300);
|
||||
var dropDownList = new StyledDropDownList("- default -", maxHeight: 300)
|
||||
{
|
||||
UseLeftIcons = true,
|
||||
HAnchor = HAnchor.ParentLeftRight,
|
||||
MenuItemsPadding = new BorderDouble(10, 4, 10, 6),
|
||||
};
|
||||
|
||||
dropDownList.Margin = new BorderDouble(0, 3);
|
||||
dropDownList.MinimumSize = new Vector2(dropDownList.LocalBounds.Width, dropDownList.LocalBounds.Height);
|
||||
|
||||
|
|
@ -237,7 +244,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
menuItem.Selected += onItemSelect;
|
||||
}
|
||||
|
||||
// put in a small bottom region
|
||||
MenuItem addNewPreset = dropDownList.AddItem("Add New Setting...", "new", InvertLightness.DoInvertLightness(StaticData.Instance.LoadIcon("icon_circle_plus.png")));
|
||||
addNewPreset.Selected += onNewItemSelect;
|
||||
|
||||
if (false)
|
||||
{
|
||||
FlowLayoutWidget container = new FlowLayoutWidget();
|
||||
container.HAnchor = HAnchor.ParentLeftRight;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
"has_heated_bed",
|
||||
"has_power_control",
|
||||
"has_sd_card_reader",
|
||||
"MatterControl.BaudRate",
|
||||
"manual_probe_paper_width",
|
||||
"pause_gcode",
|
||||
"print_leveling_method",
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ infill_type = TRIANGLES
|
|||
layer_gcode = ; LAYER:[layer_num]
|
||||
layer_height = 0.4
|
||||
layer_to_pause =
|
||||
MatterControl.BaudRate = 250000
|
||||
max_fan_speed = 100
|
||||
min_extrusion_before_retract = .1
|
||||
min_fan_speed = 35
|
||||
|
|
|
|||
|
|
@ -272,7 +272,9 @@ Advanced
|
|||
extruder_count
|
||||
heat_extruder_before_homing
|
||||
extruders_share_temperature
|
||||
z_homes_to_max
|
||||
Firmware
|
||||
MatterControl.BaudRate
|
||||
z_can_be_negative
|
||||
gcode_flavor
|
||||
use_relative_e_distances
|
||||
|
|
@ -293,7 +295,6 @@ Advanced
|
|||
Speed
|
||||
resume_first_layer_speed
|
||||
Homing
|
||||
z_homes_to_max
|
||||
resume_position_before_z_home
|
||||
Custom G-Code
|
||||
Start G-Code
|
||||
|
|
|
|||
|
|
@ -1216,6 +1216,13 @@
|
|||
"DataEditType": "CHECK_BOX",
|
||||
"ExtraSettings": ""
|
||||
},
|
||||
{
|
||||
"SlicerConfigName": "MatterControl.BaudRate",
|
||||
"PresentationName": "Baud Rate",
|
||||
"HelpText": "The serial port communication speed of the printers firmware.",
|
||||
"DataEditType": "INT",
|
||||
"ExtraSettings": ""
|
||||
},
|
||||
{
|
||||
"SlicerConfigName": "vibration_limit",
|
||||
"PresentationName": "Vibration Limit",
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 686f8389fd1a84dd8ab98bc6cbe1625b91389ed2
|
||||
Subproject commit 798aad7d8f2d9817979383bad80b2fbc368ae234
|
||||
Loading…
Add table
Add a link
Reference in a new issue