protected override void CreateSpecificProgram(ProgramOperation programPhase, Operazione operazione)
        {
            var diametrable = operazione.Utensile as IDiametrable;

            var parametro = operazione.Utensile.ParametroUtensile as ParametroFresaCandela;

            if (diametrable == null)
            {
                return;
            }

            var diaFresa = diametrable.Diametro;


            double profPassata      = 0;
            double larghezzaPassata = 0;

            if (parametro != null)
            {
                profPassata = parametro.GetProfonditaPassata();

                larghezzaPassata = parametro.GetLarghezzaPassata();
            }


            var moveCollection = new MoveActionCollection();


            switch (operazione.OperationType)
            {
            case LavorazioniEnumOperazioni.Sgrossatura:
            {
                MillProgrammingHelper.FresaturaScanalaturaChiusaProgram(moveCollection, GetProfile(), ProfonditaLavorazione, Larghezza, SicurezzaZ, InizioLavorazioneZ, diaFresa, larghezzaPassata, profPassata, ExtraCorsa, SovrametalloFinituraProfilo, FinishWithCompensation);
            } break;

            case LavorazioniEnumOperazioni.Finitura:
            {
                MillProgrammingHelper.FresaturaScanalaturaChiusaProgram(moveCollection, GetProfile(), ProfonditaLavorazione, Larghezza, SicurezzaZ, InizioLavorazioneZ, diaFresa, larghezzaPassata, profPassata, ExtraCorsa, 0, FinishWithCompensation);
            } break;

            case LavorazioniEnumOperazioni.Smussatura:
            {
                FresaturaSmussaturaScanalaturaChiusaProgram(moveCollection, GetProfile(), ProfonditaLavorazione, SicurezzaZ, InizioLavorazioneZ, diaFresa, Larghezza);
            } break;
            }
            var mm = base.GetFinalProgram(moveCollection);

            foreach (var variable in mm)
            {
                programPhase.AggiungiAzioneMovimento(variable);
            }
        }
        /*
         * mi serve
         * 1- metodo che mi restituisca i profili calcolati
         *
         *
         *
         */

        //private static List<Profile2D> CalculateInternOffset(Profile2D origin, double offsetValue, double diameterValue)
        //{
        //    offsetValue = -Math.Abs(offsetValue);

        //    var firstPaths = origin.Offset(-diameterValue, false);

        //    if (firstPaths == null)
        //        return null;

        //    var rslt = new List<Profile2D>();

        //    foreach (var firstPath in firstPaths)
        //    {
        //        rslt.Add(firstPath);

        //        RicorsivaGenerateInternOffset(firstPath, offsetValue, false, ref rslt);
        //    }


        //    return rslt;
        //}

        //private static void RicorsivaGenerateInternOffset(Profile2D profile2D, double offset, bool clockwise, ref List<Profile2D> profile2DsList)
        //{
        //    // Calcola offset , ritorna 1 o più contorni
        //    var offsetRslt = profile2D.Offset(offset, clockwise);


        //    // se non ritorna più niente termina metodo
        //    if (offsetRslt == null)
        //        return;

        //    foreach (var singleContour in offsetRslt)
        //    {
        //        profile2DsList.Add(singleContour);
        //        RicorsivaGenerateInternOffset(singleContour, offset, clockwise, ref profile2DsList);
        //    }
        //}



        private static void FresaturaSmussaturaScanalaturaChiusaProgram(MoveActionCollection moveActionCollection, Profile2D profile2D, double profonditaSmusso, double zSicurezza, double zIniziale, double diaFresa, double larghezzaScanaltura)
        {
            /*
             * teoria.
             * - Prendo profilo
             *  - Se valido faccio offset negativo del raggio della fresa
             * - Poi faccio offset della larghezza di passata fino a che il metodo non mi restituisce più niente. ( ho raggiunto il massimo )
             */

            /*
             * Controllo Valori
             */
            if (CheckValueHelper.GreatherThanZero(new[] { profonditaSmusso, diaFresa, larghezzaScanaltura }) ||
                CheckValueHelper.GreatherThan(new[]
            {
                new KeyValuePair <double, double>(zSicurezza, zIniziale),
            })
                )
            {
                return;
            }

            if (profile2D == null)
            {
                return;
            }

            /*
             * chiamo metodo comune per 2 profili (maggiore e minore della fresatura di scanalatura)
             */
            var offsetValue = larghezzaScanaltura / 2;

            var profileExt = profile2D.Offset(offsetValue, true);
            var profileInt = profile2D.Offset(-offsetValue, true);

            if ((profileExt == null || profileExt.Count == 0) ||
                (profileInt == null || profileInt.Count == 0))
            {
                return;
            }

            MillProgrammingHelper.GetExterChamfer(moveActionCollection, profileInt[0], null, false, profonditaSmusso, diaFresa, 0, false, zIniziale, zSicurezza);

            MillProgrammingHelper.GetInternChamfer(moveActionCollection, profileExt[0], profonditaSmusso, diaFresa, 0, false, zIniziale, zSicurezza);
        }
Example #3
0
        private void ElaborateAllargaturaBareno(ProgramOperation programPhase, Operazione operazione)
        {
            var opBarenatura = operazione.Lavorazione as IBarenoAble;

            if (opBarenatura == null)
            {
                throw new NullReferenceException();
            }

            var pntListBar = GetDrillPointList();

            var moveCollection = new MoveActionCollection();

            var iniZ = InizioZ;

            var endZ = InizioZ - opBarenatura.ProfonditaBareno;

            var fresa = operazione.Utensile as FresaCandela;

            var parametro = operazione.Utensile.ParametroUtensile as ParametroFresaCandela;

            var larghezzaPassata = parametro.GetLarghezzaPassata();

            var profPassata = parametro.GetProfonditaPassata();

            var diaAllargatura = opBarenatura.DiametroBarenatura - opBarenatura.MaterialePerFinitura;

            if (InizioZ <= endZ)
            {
                return;
            }
            if (fresa.Diametro > diaAllargatura)
            {
                return;
            }

            foreach (var point2D in pntListBar)
            {
                // Semplice)
                if (opBarenatura.ModalitaAllargatura == 0)
                {
                    var profile = Profile2D.CreateCircle(diaAllargatura / 2, point2D);

                    moveCollection.AddLinearMove(MoveType.Rapid, AxisAbilited.Xy, point2D.X,
                                                 point2D.Y, null, null);

                    MillProgrammingHelper.GetInternRoughing(moveCollection, profile, opBarenatura.ProfonditaBareno,
                                                            profPassata, larghezzaPassata, fresa.Diametro, 0, InizioZ, SicurezzaZ, 0, 0);

                    moveCollection.AddLinearMove(MoveType.Rapid, AxisAbilited.Xy, point2D.X,
                                                 point2D.Y, null, null);
                }

                // Interpolazione
                else if (opBarenatura.ModalitaAllargatura == 1)
                {
                    MillProgrammingHelper.GetRoughHelicalInterpolation(moveCollection, InizioZ, endZ, SicurezzaZ, point2D,
                                                                       diaAllargatura, fresa.Diametro, profPassata, larghezzaPassata);
                }
            }

            foreach (var a in moveCollection)
            {
                programPhase.AggiungiAzioneMovimento(a);
            }
        }
Example #4
0
        protected override void CreateSpecificProgram(ProgramOperation programPhase, Operazione operazione)
        {
            var diametrable = operazione.Utensile as IDiametrable;

            var parametro = operazione.Utensile.ParametroUtensile as ParametroFresaCandela;

            if (diametrable == null)
            {
                return;
            }

            var diaFresa = diametrable.Diametro;


            double profPassata      = 0;
            double larghezzaPassata = 0;

            if (parametro != null)
            {
                profPassata = parametro.GetProfonditaPassata();

                larghezzaPassata = parametro.GetLarghezzaPassata();
            }

            var moveCollection = new MoveActionCollection();

            var workProfile = GetProfile();

            switch (operazione.OperationType)
            {
            case LavorazioniEnumOperazioni.Sgrossatura:
            {
                var sovraXy = SovrametalloFinituraProfilo;

                if (!Finitura.Abilitata)
                {
                    sovraXy = 0;
                }

                MillProgrammingHelper.GetInternRoughing(moveCollection, workProfile, ProfonditaLavorazione,
                                                        profPassata, larghezzaPassata, diaFresa, ExtraCorsa,
                                                        InizioLavorazioneZ, SicurezzaZ,
                                                        sovraXy, SovrametalloFinituraZ);
            } break;

            case LavorazioniEnumOperazioni.Finitura:
            {
                MillProgrammingHelper.GetInternFinish(moveCollection, workProfile, ProfonditaLavorazione, profPassata, diaFresa, ExtraCorsa, FinishWithCompensation, InizioLavorazioneZ, SicurezzaZ);
            } break;

            case LavorazioniEnumOperazioni.Smussatura:
            {
                MillProgrammingHelper.GetInternChamfer(moveCollection, workProfile, ProfonditaFresaSmussatura,
                                                       diaFresa, ExtraCorsa, ChamferWithCompensation,
                                                       InizioLavorazioneZ, SicurezzaZ);
            } break;

            default:
            {
                Debug.Fail("FresaturaCava.GetOperationProgram");
            } break;
            }
            var mm = base.GetFinalProgram(moveCollection);

            foreach (var variable in mm)
            {
                programPhase.AggiungiAzioneMovimento(variable);
            }
        }
        protected override void CreateSpecificProgram(ProgramOperation programPhase, Operazione operazione)
        {
            /*
             * utensile e parametro lo prendo all'interno del cambio switch..
             */
            var fresa = operazione.Utensile as FresaCandela;

            var parametro = operazione.Utensile.ParametroUtensile as ParametroFresaCandela;

            if (fresa == null || parametro == null)
            {
                throw new NullReferenceException();
            }

            if (PatternDrilling == null)
            {
                return;
            }
            var diameter = DiametroMetricoFinale;

            var pntList = PatternDrilling.GetPointList();

            if (pntList == null || pntList.Count <= 0)
            {
                return;
            }

            var diaFresa = fresa.Diametro;


            var moveCollection = new MoveActionCollection();

            var workUp   = InizioLavorazioneZ;
            var workDown = InizioLavorazioneZ - ProfonditaLavorazione;

            foreach (var point2D in pntList)
            {
                switch (operazione.OperationType)
                {
                case LavorazioniEnumOperazioni.Smussatura:
                {
                    var profile = Profile2D.CreateCircle(DiametroMetricoFinale / 2, point2D);

                    MillProgrammingHelper.GetInternChamfer(moveCollection, profile, ProfonditaSvasatura, diaFresa, 0, false, InizioLavorazioneZ, SicurezzaZ);
                } break;

                case LavorazioniEnumOperazioni.FresaturaFilettare:
                {
                    var helicalRadius = (diameter - diaFresa) / 2;

                    if (FilettaturaSinistra && !FilettaturaEsterna)
                    {
                        //MillProgrammingHelper.GetInternThreadSx(moveCollection, );
                        MillProgrammingHelper.GetInternThreadSx(moveCollection, workUp, workDown, SicurezzaZ, point2D, PassoMetrico, DiametroMetricoFinale / 2, true);
                    }
                    else if (!FilettaturaSinistra && !FilettaturaEsterna)
                    {
                        MillProgrammingHelper.GetInternThreadDx(moveCollection, workUp, workDown, SicurezzaZ, point2D, PassoMetrico, DiametroMetricoFinale / 2, true);
                    }

                    else if (!FilettaturaSinistra && FilettaturaEsterna)
                    {
                        var extracorsa = diaFresa / 2 + ExtraCorsa;

                        MillProgrammingHelper.GetExternThreadDx(moveCollection, workUp, workDown, SicurezzaZ, point2D, PassoMetrico, DiametroMetricoFinale / 2, true, extracorsa);
                    }

                    else if (FilettaturaSinistra && FilettaturaEsterna)
                    {
                        var extracorsa = diaFresa / 2 + ExtraCorsa;

                        MillProgrammingHelper.GetExternThreadSx(moveCollection, workUp, workDown, SicurezzaZ, point2D, PassoMetrico, DiametroMetricoFinale / 2, true, extracorsa);
                    }
                }
                break;

                default:
                    throw  new Exception("FresaturaFilettatura.CreateSpecificProgram");
                    break;
                }
            }
            var mm = base.GetFinalProgram(moveCollection);

            foreach (var variable in mm)
            {
                programPhase.AggiungiAzioneMovimento(variable);
            }
        }