예제 #1
0
        /// <summary>
        /// Расчет обработки
        /// </summary>
        public static List <ProcessingAction> Generate(IEnumerable <ProcessObject> processObjects, List <Curve> sectionCurves)
        {
            try
            {
                IsCalculation = true;
                AutocadUtils.StartTransaction();
                Machine.Start();
                foreach (var processObject in processObjects)
                {
                    if (!IsCalculation)
                    {
                        break;
                    }
                    if (!CheckParams(processObject))
                    {
                        continue;
                    }

                    Machine.SetTool(processObject.Tool);

                    if (processObject.Curve.OutsideSign == 0)
                    {
                        CalcUtils.CalcOutside(processObject.Curve);
                    }

                    var curve = AutocadUtils.GetCurve(processObject.Curve.ObjectId);

                    if (Settings.ProcessMode == ProcessMode.ContinuousDescent)
                    {
                        if (!curve.Closed)
                        {
                            throw new Exception("Расчет в режиме непрерывного опускания возможен только для замкнутой кривой");
                        }
                        CuttingContinuousDescent(processObject, curve);
                    }
                    else if (Settings.ProcessMode == ProcessMode.ProfileDisc)
                    {
                        CuttingProfileDisc(processObject, curve, sectionCurves);
                    }
                    else
                    {
                        Cutting(processObject, curve);
                    }
                }
                Machine.Stop();
                AutocadUtils.CommitTransaction();
            }
            catch (Exception e)
            {
                Machine.Clear();
                var error = String.Format("Ошибка при расчете обработки: {0}", e.Message);
                AutocadUtils.ShowError(error);
            }
            AutocadUtils.DisposeTransaction();
            IsCalculation = false;

            return(Machine.GetProcessingActions());
        }
예제 #2
0
        private static void Retract(Curve toolpathCurve, int direction, int outsideSign, ProcessingParams par)
        {
            if (par.RetractionType == FeedType.None)
            {
                return;
            }
            var feedGroup = CalcUtils.CalcFeedGroup(toolpathCurve, direction == -1, outsideSign, par.RetractionType, par.RetractionRadius, par.RetractionAngle, par.RetractionLength);

            Machine.RetractMove(feedGroup.Arc, par.GreatSpeed);
            if (Settings.WithCompensation)
            {
                Machine.SetCompensation(CompensationSide.None);
            }
            Machine.RetractMove(feedGroup.Line, par.GreatSpeed);
        }
예제 #3
0
        private static void CuttingProfileDisc(ProcessObject processObject, Curve curve, List <Curve> sectionCurves)
        {
            if (sectionCurves.Count == 0)
            {
                AutocadUtils.ShowError("Не указано сечение");
                return;
            }
            var par = processObject.ProcessingParams;
            var z   = Settings.HeightMax;

            do
            {
                if (!IsCalculation)
                {
                    return;
                }
                var    d1 = CalcUtils.GetSectionDepth(sectionCurves, z);
                var    d2 = CalcUtils.GetSectionDepth(sectionCurves, z - processObject.Tool.Thickness.GetValueOrDefault());
                double d;
                if (d1.HasValue && d2.HasValue)
                {
                    d = d1 > d2 ? d1.Value : d2.Value;
                }
                else if (d1.HasValue)
                {
                    d = d1.Value;
                }
                else if (d2.HasValue)
                {
                    d = d2.Value;
                }
                else
                {
                    return;
                }

                var toolpathCurve = AutocadUtils.GetDisplacementCopy(curve, z);

                AlternatingCuttingCurve(processObject, toolpathCurve, d + Settings.Pripusk);

                z -= Settings.VerticalStep;
            }while (z >= Settings.HeightMin);
        }
예제 #4
0
        private static void Feed(Curve toolpathCurve, int direction, int outsideSign, ProcessingParams par, bool isFirstPass)
        {
            var feedGroup = CalcUtils.CalcFeedGroup(toolpathCurve, direction == 1, outsideSign, par.FeedType, par.FeedRadius, par.FeedAngle, par.FeedLength);

            if (isFirstPass)
            {
                Machine.SetPosition(feedGroup.Point, par.GreatSpeed);
            }
            else
            {
                Machine.Move(feedGroup.Point, par.GreatSpeed);
            }

            if (Settings.WithCompensation)
            {
                Machine.SetCompensation(direction * outsideSign == 1 ? CompensationSide.Left : CompensationSide.Right);
            }

            Machine.EngageMove(feedGroup.Line, par.SmallSpeed);
            Machine.EngageMove(feedGroup.Arc, par.SmallSpeed);

            Machine.SetSpeed(par.GreatSpeed);
        }
예제 #5
0
        public void Initialize()
        {
            AutocadUtils.WriteMessage("Инициализация плагина ProcessingProgram. Версия с режимом обработки."); // + DateTime.Today.ToShortDateString()); TODO Assemlly.DateTime()

            ObjectForm.DeleteAll        += (sender, args) => DeleteAll();
            ObjectForm.DeleteProcessing += (sender, args) => DeleteProcessing();
            ObjectForm.Calculate        += (sender, args) => Calculate();
            ObjectForm.Quit             += (sender, args) => AutocadUtils.Close();
            ObjectForm.AddObjects       += (sender, args) => AddObjects();
            ObjectForm.ShowTools        += (sender, args) => AutocadUtils.ShowModalDialog(ToolStoreForm);
            ObjectForm.CurrentChanged   += (sender, args) => AutocadUtils.SelectObject(args.Data.Curve.ObjectId);
            ObjectForm.ChangeOutside    += (sender, args) =>
            {
                CalcUtils.ChangeOutside(args.Data.Curve.ObjectId);
                Calculate();
            };
            ObjectForm.ReverseProcess += (sender, args) =>
            {
                args.Data.Direction *= -1;
                Calculate();
            };
            ObjectForm.DeleteObject += (sender, args) =>
            {
                ProcessObjects.Remove(args.Data);
                if (ProcessObjects.All(p => p.Curve != args.Data.Curve))
                {
                    ProcessCurves.Remove(args.Data.Curve);
                }
                Calculate();
            };
            SettingForm.AddSectionObjects += (sender, args) =>
            {
                AddSectionObjects();
                SettingForm.SetSectionDesc(SectionCurves.Any() ? String.Format("Сечение установлено. {0} элемента", SectionCurves.Count) : "");
            };

            AutocadUtils.AddPaletteSet("Объекты", ObjectForm);

            ProcessingForm.CurrentChanged   += (sender, args) => AutocadUtils.SelectObjects(args.Data.ObjectId, args.Data.ToolObjectId);
            ProcessingForm.DeleteProcessing += (sender, args) => DeleteProcessing();
            ProcessingForm.Calculate        += (sender, args) => Calculate();
            AutocadUtils.AddPaletteSet("Обработка", ProcessingForm);

            AutocadUtils.AddPaletteSet("Программа", ProgramForm);
            AutocadUtils.AddPaletteSet("Настройки", SettingForm);

            AutocadUtils.Selected += (sender, args) => ProcessingForm.SelectObjects(args.Data);
            AutocadUtils.Focused  += (sender, args) => ProcessingForm.SetFocus(args.Data);
            AutocadUtils.Focused  += (sender, args) => ObjectForm.SetFocus(args.Data);

            CalcUtils.Init(ProcessObjects, ProcessCurves);
            ProcessObjectFactory.Init(ProcessObjects, ProcessCurves);

            var machine = new Machine();

            machine.ChangeActionsCount += (sender, args) => ObjectForm.ShowProgress(String.Format("Генерация обработки... {0} строк", args.Data));
            ActionGenerator.SetMachine(machine);

            //AutocadUtils.CreateTest();
            //RunTest();
        }