예제 #1
0
        public GCodeProcessor(FileStream stream, SettingsContainer preferences, IList <OverrideRule> ruleSet, Duet.MachineInfo machine,
                              IProgress <int> setProgress, IProgress <int> setMaxProgress)
        {
            input       = stream;
            settings    = preferences;
            rules       = ruleSet;
            machineInfo = machine;
            progress    = setProgress;
            maxProgress = setMaxProgress;

            layers     = new List <GCodeLayer>();
            toolPrimed = new List <bool>();
            for (int i = 0; i < preferences.Tools.Length; i++)
            {
                toolPrimed.Add(false);
            }
            lastPoint = new Coordinate();
            // TODO: Make configurable?
            homingPosition = new Coordinate()
            {
                X = -210, Y = -90, Z = 200
            };
            afterProbingPosition = new Coordinate()
            {
                X = 180, Y = 80, Z = 0
            };
        }
예제 #2
0
        private void AddItem(MachineInfo info)
        {
            if (!list.Enabled)
            {
                list.Items.Clear();
                list.Enabled = !manualConfig.Checked;
            }

            list.Items.Add(info.Name);
            boardList.Add(info);

            if (list.SelectedIndex == -1 && !manualConfig.Checked)
            {
                list.SelectedIndex = 0;
            }
        }
예제 #3
0
        public void OnNext(IZeroconfHost value)
        {
            if (!String.IsNullOrEmpty(value.IPAddress))
            {
                foreach (var property in value.Services[HttpService].Properties)
                {
                    if (property.TryGetValue("product", out var product) && product.StartsWith("Duet"))
                    {
                        Task.Run(async() =>
                        {
#if !DEBUG
                            // Request oem.json from the Duet
                            OemInfo info = await OemInfo.Get(value.IPAddress);
                            if (info.Vendor == "diabase")
#endif
                            {
                                // This is a Diabase machine. Check the tool configuration
                                ExtendedStatusResponse statusResponse = await ExtendedStatusResponse.Get(value.IPAddress);
                                ConfigResponse configResponse         = await ConfigResponse.Get(value.IPAddress);

                                MachineInfo boardInfo = new MachineInfo
                                {
                                    IPAddress     = value.IPAddress,
                                    Name          = statusResponse.Name,
                                    Axes          = statusResponse.Axes,
                                    Accelerations = configResponse.Accelerations,
                                    MinFeedrates  = configResponse.MinFeedrates,
                                    MaxFeedrates  = configResponse.MaxFeedrates
                                };
                                foreach (var tool in statusResponse.Tools)
                                {
                                    boardInfo.Tools.Add(new MachineInfo.Tool
                                    {
                                        Number     = tool.Number,
                                        NumDrives  = tool.Drives.Count,
                                        NumHeaters = tool.Heaters.Count,
                                        HasSpindle = statusResponse.Spindles.Any(spindle => spindle.Tool == tool.Number)
                                    });
                                }

                                list.BeginInvoke(new ItemAddDelegate(AddItem), boardInfo);
                            }
                        });
                    }
                }
            }
        }
예제 #4
0
        private void AddItem(MachineInfo info)
        {
            if (!list.Enabled)
            {
                list.Items.Clear();
                list.Enabled = searchNetwork.Checked;
            }

            if (list.Items.Count > 0)
            {
                list.Items.Insert(list.Items.Count - 1, info.Name);
            }
            else
            {
                list.Items.Add(info.Name);
            }
            boardList.Add(info);

            if (list.SelectedIndex == -1 && searchNetwork.Checked)
            {
                list.SelectedIndex = 0;
            }
        }
예제 #5
0
        public static async Task CheckMachine(string address, Action <MachineInfo> callback)
        {
#if !DEBUG
            // Request oem.json from the Duet
            OemInfo info = await OemInfo.Get(address);

            if (info.Vendor == "diabase")
#endif
            {
                // This is a Diabase machine. Check the tool configuration
                ExtendedStatusResponse statusResponse = await ExtendedStatusResponse.Get(address);

                ConfigResponse configResponse = await ConfigResponse.Get(address);

                MachineInfo boardInfo = new MachineInfo
                {
                    IPAddress     = address,
                    Name          = statusResponse.Name,
                    Axes          = statusResponse.Axes,
                    Accelerations = configResponse.Accelerations,
                    MinFeedrates  = configResponse.MinFeedrates,
                    MaxFeedrates  = configResponse.MaxFeedrates
                };
                foreach (var tool in statusResponse.Tools)
                {
                    boardInfo.Tools.Add(new MachineInfo.Tool
                    {
                        Number     = tool.Number,
                        NumDrives  = tool.Drives.Count,
                        NumHeaters = tool.Heaters.Count,
                        HasSpindle = statusResponse.Spindles.Any(spindle => spindle.Tool == tool.Number)
                    });
                }

                callback(boardInfo);
            }
        }
예제 #6
0
        public static async Task CreateTask(FileStream topAdditiveFile, FileStream topSubstractiveFile,
                                            FileStream bottomAdditiveFile, FileStream bottomSubstractiveFile,
                                            FileStream outFile, SettingsContainer settings, IList <OverrideRule> rules, Duet.MachineInfo machine,
                                            IProgress <string> textProgress, IProgress <int> progress, IProgress <int> maxProgress, IProgress <int> totalProgress, bool debug)
        {
            Exception ex = null;

            try
            {
                totalProgressValue = 0;

                // Additive Top
                GCodeProcessor topAdditiveGCode = new GCodeProcessor(topAdditiveFile, settings, rules, machine, progress, maxProgress);
                textProgress.Report("Preprocessing file for additive manufacturing on the top side...");
                await topAdditiveGCode.PreProcess();

                IncreaseTotalProgress(totalProgress);

                textProgress.Report("Postprocessing file for additive manufacturing on the top side...");
                topAdditiveGCode.PostProcess();
                IncreaseTotalProgress(totalProgress);

                // Hybrid Top is not processed

                // Additive Bottom
                GCodeProcessor bottomAdditiveGCode = null;
                if (bottomAdditiveFile != null)
                {
                    bottomAdditiveGCode = new GCodeProcessor(bottomAdditiveFile, settings, rules, machine, progress, maxProgress);
                    textProgress.Report("Preprocessing file for additive manufacturing on the bottom side...");
                    await bottomAdditiveGCode.PreProcess();

                    IncreaseTotalProgress(totalProgress);

                    textProgress.Report("Postprocessing file for additive manufacturing on the bottom side...");
                    bottomAdditiveGCode.PostProcess();
                    IncreaseTotalProgress(totalProgress);
                }

                // Hybrid Bottom is not processed

                // Join files together
                textProgress.Report("Combining results...");
                WriteFileInfo(outFile, "Additive manufacturing on the top side", topAdditiveFile);
                await topAdditiveGCode.WriteToFile(outFile, debug);

                IncreaseTotalProgress(totalProgress);
                if (topSubstractiveFile != null)
                {
                    WriteFileInfo(outFile, "Substractive manufacturing on the top side", topSubstractiveFile);
                    await topSubstractiveFile.CopyToAsync(outFile);

                    IncreaseTotalProgress(totalProgress);
                }
                if (bottomAdditiveFile != null)
                {
                    // TODO: Add code to turn around A-axis for two-sided prints?
                    WriteFileInfo(outFile, "Additive manufacturing on the bottom side", bottomAdditiveFile);
                    await bottomAdditiveGCode.WriteToFile(outFile, debug);

                    IncreaseTotalProgress(totalProgress);
                }
                if (bottomSubstractiveFile != null)
                {
                    WriteFileInfo(outFile, "Substractive manufacturing on the bottom side", bottomSubstractiveFile);
                    await bottomSubstractiveFile.CopyToAsync(outFile);

                    IncreaseTotalProgress(totalProgress);
                }
                textProgress.Report("Done!");
            }
            catch (Exception e)
            {
                ex = e;
            }

            topAdditiveFile.Close();
            topSubstractiveFile?.Close();
            bottomAdditiveFile?.Close();
            bottomSubstractiveFile?.Close();
            outFile.Close();

            if (ex != null)
            {
                throw new AggregateException(ex);
            }
        }