コード例 #1
0
        //internal override ProgramPhase GetOperationProgram(Operazione operazione)
        //{
        //    /*
        //     * il richiamo degli utensili magari farlo e delle operazioni comuni magari farlo in astratto più a monte
        //     *
        //     */

        //    var program = new ProgramPhase(SicurezzaZ);

        //    // cambio utensile // se
        //    var toolChange = new ChangeToolAction(program, operazione);

        //    /*
        //     * potrei settare qui punto iniziale.. non vedo altre opzioni. rimane sempre una cosa da ricordarsi in più
        //     * >> more bugs..
        //     */

        //    program.ActiveAsseC(true);

        //    var secureFeed = 1;

        //    var extraCorsa = 1;

        //    var parametro = operazione.GetParametro<ParametroFresaCandela>();

        //    var feed = parametro.GetFeed(FeedType.ASync);

        //    if (feed <= 0)
        //        return null;

        //    var feedDictionary = new Dictionary<MoveType, double>
        //                             {
        //                                 {MoveType.Rapid, 10000},
        //                                 {MoveType.SecureRapidFeed, secureFeed},
        //                                 {MoveType.Work, feed},
        //                                 {MoveType.Cw, feed},
        //                                 {MoveType.Ccw, feed},
        //                             };

        //    program.SetFeedDictionary(feedDictionary);



        //    if (parametro == null)
        //        throw new NullReferenceException();


        //    var moveCollection = new MoveActionCollection();

        //    switch ((LavorazioniEnumOperazioni)operazione.OperationType)
        //    {
        //        case LavorazioniEnumOperazioni.Sgrossatura:
        //            {

        //                var par = operazione.GetParametro<ParametroFresaCandela>();

        //                if (par == null)
        //                    throw new NullReferenceException();

        //                var profPassat = par.GetProfonditaPassata();

        //                var larghPassat = par.GetLarghezzaPassata();


        //                ProcessRoughLineMilling(moveCollection, PuntoInizialeX, PuntoInizialeY, OrientationAngle, Lunghezza, Sovrametallo, ProfonditaLavorazione,
        //                    profPassat, larghPassat, par.DiametroFresa, SicurezzaZ, extraCorsa, InizioLavorazioneZ);

        //            } break;

        //        case LavorazioniEnumOperazioni.Finitura:
        //            {

        //                var par = operazione.GetParametro<ParametroFresaCandela>();

        //                if (par == null)
        //                    throw new NullReferenceException();

        //                var profPassat = par.GetProfonditaPassata();

        //                var larghPassat = par.GetLarghezzaPassata();

        //                /*
        //                 * Per finitura assumo sovrametallo minore della larghezza passata
        //                 */

        //                ProcessRoughLineMilling(moveCollection, PuntoInizialeX, PuntoInizialeY, OrientationAngle, Lunghezza, larghPassat, ProfonditaLavorazione,
        //                    profPassat, larghPassat, par.DiametroFresa, SicurezzaZ, extraCorsa, InizioLavorazioneZ);

        //            } break;

        //        case LavorazioniEnumOperazioni.Smussatura:
        //            {

        //                var par = operazione.GetParametro<ParametroFresaCandela>();

        //                if (par == null)
        //                    throw new NullReferenceException();

        //                /*
        //                 * qui al posto della profondita lavorazione uso valore profondita fresa smussatura.
        //                 */

        //                ProcessChamferSideLineMilling(moveCollection, PuntoInizialeX, PuntoInizialeY, OrientationAngle, Lunghezza, Sovrametallo, ProfonditaFresaSmussatura, par.DiametroFresa, SicurezzaZ, extraCorsa, InizioLavorazioneZ);

        //            } break;

        //        default:
        //            throw new NotImplementedException();
        //    }



        //    var mm = base.GetFinalProgram(moveCollection);

        //    foreach (var variable in mm)
        //    {
        //        program.AddMoveAction(variable);
        //    }

        //    program.ActiveAsseC(false);

        //    return program;
        //}

        private static void ProcessRoughLineMilling(MoveActionCollection moveCollection, double puntoInizialeX, double puntoInizialeY, double orientationAngle,
                                                    double lunghezza, double sovrametallo, double profonditaLavorazione, double profPassat, double larghPassat,
                                                    double diaFresa, double sicurezzaZ, double extraCorsa, double inizioLavorazioneZ, int isCncCompensated = 0)
        {
            if (CheckValueHelper.GreatherThanZero(new[] { profPassat, larghPassat, lunghezza, sovrametallo, profonditaLavorazione, diaFresa }) ||
                CheckValueHelper.GreatherThan(new[]
            {
                new KeyValuePair <double, double>(sicurezzaZ, inizioLavorazioneZ),
            })
                )
            {
                return;
            }

            var currentZ = inizioLavorazioneZ;

            var zFinale = currentZ - profonditaLavorazione;

            var raggioFresa = diaFresa / 2;

            var offset = raggioFresa;

            if (isCncCompensated != 0)
            {
                offset = 0;
            }

            var xIniPoint = puntoInizialeX - extraCorsa - raggioFresa;
            var xEndPoint = puntoInizialeX + extraCorsa + raggioFresa + lunghezza;

            var yIniPoint = puntoInizialeY + sovrametallo + offset;
            var yEndPoint = puntoInizialeY + offset;

            CncCompensationState cncCompensationState = CncCompensationState.NoChange;


            if (isCncCompensated == 1)
            {
                cncCompensationState = CncCompensationState.G41;
            }

            else if (isCncCompensated == 2)
            {
                cncCompensationState = CncCompensationState.G42;
            }

            var rotationMatrix = new Matrix3D();

            rotationMatrix.RotateAt(new Quaternion(new Vector3D(0, 0, 1), orientationAngle), new System.Windows.Media.Media3D.Point3D(puntoInizialeX, puntoInizialeY, 0));

            while (currentZ > zFinale)
            {
                currentZ -= profPassat;

                if (currentZ < zFinale)
                {
                    currentZ = zFinale;
                }

                var currentY = yIniPoint;

                while (currentY > yEndPoint)
                {
                    currentY -= larghPassat;
                    if (currentY < yEndPoint)
                    {
                        currentY = yEndPoint;
                    }

                    moveCollection.AddLinearMove(MoveType.Rapid, AxisAbilited.Xy, xIniPoint, currentY, null, rotationMatrix, null, cncCompensationState);

                    moveCollection.AddLinearMove(MoveType.Rapid, AxisAbilited.Z, null, null, sicurezzaZ);

                    moveCollection.AddLinearMove(MoveType.Rapid, AxisAbilited.Z, null, null, currentZ);

                    moveCollection.AddLinearMove(MoveType.Work, AxisAbilited.Xy, xEndPoint, currentY, null, rotationMatrix);

                    moveCollection.AddLinearMove(MoveType.Rapid, AxisAbilited.Z, null, null, sicurezzaZ);
                }

                if (cncCompensationState == CncCompensationState.G41 || cncCompensationState == CncCompensationState.G42)
                {
                    moveCollection.AddLinearMove(MoveType.Rapid, AxisAbilited.Z, null, null, sicurezzaZ, null, CncCompensationState.G40);
                }
            }
        }