예제 #1
0
        private void SetCompensation(CncCompensationState cncCompensationState, ref string str)
        {
            if (CurrentCncCompensation == cncCompensationState || cncCompensationState == CncCompensationState.NoChange)
            {
                return;
            }

            CurrentCncCompensation = cncCompensationState;

            switch (cncCompensationState)
            {
            case CncCompensationState.G41:
            {
                str += "G41";
            } break;

            case CncCompensationState.G42:
            {
                str += "G42";
            } break;

            case CncCompensationState.G40:
            {
                str += "G40";
            } break;

            default:
                break;
            }
        }
예제 #2
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);
                }
            }
        }
예제 #3
0
        internal void AddLinearMove(MoveType moveType, AxisAbilited axisAbilited, double?x, double?y, double?z, double?feed = null, CncCompensationState cncCompensationState = CncCompensationState.NoChange)
        {
            var moveAction = new LinearMoveAction(axisAbilited, moveType)
            {
                Feed = feed, CncCompensationState = cncCompensationState
            };

            switch (axisAbilited)
            {
            case AxisAbilited.Z:
            {
                moveAction.Z = z;
            } break;

            case AxisAbilited.Xy:
            {
                _x = moveAction.X = x;
                _y = moveAction.Y = y;
            } break;

            default:
            {
                _x           = moveAction.X = x;
                _y           = moveAction.Y = y;
                moveAction.Z = z;
            } break;
            }

            this.Add(moveAction);
        }
예제 #4
0
        internal void AddLinearMove(MoveType moveType, AxisAbilited axisAbilited, double x, double y, double?z, Matrix3D rotationMatrix, double?feed = null, CncCompensationState cncCompensationState = CncCompensationState.NoChange)
        {
            var rotatedPnt = Geometry.GeometryHelper.MultiplyPoint(new Geometry.Point3D(x, y, 0), rotationMatrix);

            var moveAction = new LinearMoveAction(axisAbilited, moveType)
            {
                Feed = feed, CncCompensationState = cncCompensationState
            };

            switch (axisAbilited)
            {
            case AxisAbilited.Z:
            {
                moveAction.Z = z;
            } break;

            case AxisAbilited.Xy:
            {
                _x = moveAction.X = rotatedPnt.X;
                _y = moveAction.Y = rotatedPnt.Y;
            } break;

            default:
            {
                throw new NotImplementedException();
            } break;
            }

            this.Add(moveAction);
        }
예제 #5
0
        public void AddArcMove(AxisAbilited axisAbilited, double?x, double?y, double?z, double radius, bool clockWise, Point2D center, double?feed = null, CncCompensationState cncCompensationState = CncCompensationState.NoChange)
        {
            var moveType = clockWise ? MoveType.Cw : MoveType.Ccw;

            var moveAction = new ArcMoveAction(axisAbilited, moveType)
            {
                Radius = radius, ClockWise = clockWise, Center = center, CncCompensationState = cncCompensationState
            };

            moveAction.Z = z;

            _x = moveAction.X = x;
            _y = moveAction.Y = y;

            this.Add(moveAction);
        }
예제 #6
0
        public void AddArcMove(AxisAbilited axisAbilited, double x, double y, double?z, double radius, bool clockWise, Point2D center, Matrix3D rotationMatrix, double?feed = null, CncCompensationState cncCompensationState = CncCompensationState.NoChange)
        {
            var moveType = clockWise ? MoveType.Cw : MoveType.Ccw;

            var rotatedEndPnt = Geometry.GeometryHelper.MultiplyPoint(new Geometry.Point3D(x, y, 0), rotationMatrix);

            var rotatedCenterArc = Geometry.GeometryHelper.MultiplyPoint(new Geometry.Point3D(center.X, center.Y, 0), rotationMatrix);

            var moveAction = new ArcMoveAction(axisAbilited, moveType)
            {
                Radius = radius, ClockWise = clockWise, Center = new Point2D(rotatedCenterArc.X, rotatedCenterArc.Y), CncCompensationState = cncCompensationState
            };

            moveAction.Z = z;

            _x = moveAction.X = rotatedEndPnt.X;
            _y = moveAction.Y = rotatedEndPnt.Y;

            this.Add(moveAction);
        }