Пример #1
0
        internal static void AcquireNewProfile(string make, string model, string printerName)
        {
            string guid = Guid.NewGuid().ToString();

            OemProfile    printerProfile = LoadHttpOemProfile(make, model);
            SettingsLayer baseConfig     = SliceSettingsOrganizer.Instance.GetDefaultSettings();

            var layeredProfile = new LayeredProfile(printerProfile, baseConfig)
            {
                ID           = guid,
                DocumentPath = Path.Combine(profilesPath, guid + ".json")
            };

            layeredProfile.UserLayer["MatterControl.PrinterName"] = printerName;

            // Import named macros as defined in the following printers: (Airwolf Axiom, HD, HD-R, HD2x, HDL, HDx, Me3D Me2, Robo R1[+])
            var classicDefaultMacros = layeredProfile.GetValue("default_macros");

            if (!string.IsNullOrEmpty(classicDefaultMacros))
            {
                var namedMacros = new Dictionary <string, string>();
                namedMacros["Lights On"]  = "M42 P6 S255";
                namedMacros["Lights Off"] = "M42 P6 S0";
                namedMacros["Offset 0.8"] = "M565 Z0.8;\nM500";
                namedMacros["Offset 0.9"] = "M565 Z0.9;\nM500";
                namedMacros["Offset 1"]   = "M565 Z1;\nM500";
                namedMacros["Offset 1.1"] = "M565 Z1.1;\nM500";
                namedMacros["Offset 1.2"] = "M565 Z1.2;\nM500";
                namedMacros["Z Offset"]   = "G1 Z10;\nG28;\nG29;\nG1 Z10;\nG1 X5 Y5 F4000;\nM117;";

                foreach (string namedMacro in classicDefaultMacros.Split(','))
                {
                    string gcode;
                    if (namedMacros.TryGetValue(namedMacro.Trim(), out gcode))
                    {
                        layeredProfile.Macros.Add(new GCodeMacro()
                        {
                            Name  = namedMacro.Trim(),
                            GCode = gcode
                        });
                    }
                }
            }

            // Copy OemProfile presets into user layers
            layeredProfile.MaterialLayers.AddRange(layeredProfile.OemProfile.MaterialLayers);
            layeredProfile.QualityLayers.AddRange(layeredProfile.OemProfile.QualityLayers);

            layeredProfile.OemProfile.MaterialLayers.Clear();
            layeredProfile.OemProfile.QualityLayers.Clear();

            layeredProfile.Save();

            ProfileData.Profiles.Add(new PrinterInfo
            {
                Name = printerName,
                Id   = guid
            });

            UserSettings.Instance.set("ActiveProfileID", guid);

            Instance = new SettingsProfile(layeredProfile);
        }
Пример #2
0
        public string ExtruderTemperature(int extruderIndex)
        {
            if (extruderIndex >= layeredProfile.MaterialSettingsKeys.Count)
            {
                // MaterialSettingsKeys is empty or lacks a value for the given extruder index
                //
                // If extruder index zero was requested, return the layer cascade temperature value, otherwise null
                return((extruderIndex == 0) ? layeredProfile.GetValue("temperature") : null);
            }

            string materialKey = layeredProfile.MaterialSettingsKeys[extruderIndex];

            if (extruderIndex == 0 && (string.IsNullOrEmpty(materialKey) || layeredProfile.UserLayer.ContainsKey("temperature")))
            {
                // In the case where a user override exists or MaterialSettingsKeys is populated with multiple extruder
                // positions but position 0 is empty and thus unassigned, use layer cascade to resolve temp
                return(layeredProfile.GetValue("temperature"));
            }

            // Otherwise, use the SettingsLayers that is bound to this extruder
            SettingsLayer layer = layeredProfile.GetMaterialLayer(materialKey);

            string result = "0";

            layer?.TryGetValue("temperature", out result);
            return(result);
        }