コード例 #1
0
        //return true si doit continer
        bool m_usiner(c_InfoCode v_info)
        {
            c_usiner.AxeX.Next = v_info.v_nextX;
            c_usiner.AxeY.Next = v_info.v_nextY;
            c_usiner.vs_pourCentCodeEnCours = 0;
            c_usiner.m_appelerDelegate(c_usiner.c_eventArgUsiner.enumEventsUsinage.mettreAJourCoordNext);

            while (c_usiner.vs_PauseUsinage)
            { Application.DoEvents(); }
            if (c_usiner.vs_ArreterUsinage) { return false; }

            Controlleur.m_initialise_X_Y();

            double v_deltaX = v_info.v_nbrPasX * c_usiner.AxeX.AvanceParPas,
                    v_deltaY = v_info.v_nbrPasY * c_usiner.AxeY.AvanceParPas,
                    v_avanceMini = 0;

            v_paramDecel = (formMain.v_paramPortParallele.v_acceleration * (c_usiner.vs_vitesseAvance - formMain.v_paramPortParallele.v_vitesseMini)) / 5;
            if (v_info.v_acceleration) //|| (v_info.v_deceleration) || (v_finBlocCirculaire))
            { v_accel = c_usiner.vs_vitesseAvance - formMain.v_paramPortParallele.v_vitesseMini; }

            if (v_info.v_liste == null)
            #region 1 seul AXE
            {
                if (v_info.v_nbrPasX > 0)
                {
                    for (int i = 0; i < v_info.v_nbrPasX; i++)
                    {
                        while (c_usiner.vs_PauseUsinage)
                        { Application.DoEvents(); }
                        if (c_usiner.vs_ArreterUsinage) { return false; }

                        v_accel = m_accel_decel(ref v_info, v_info.v_nbrPasX, v_accel, i);

                        m_envoieCommande("X", v_accel);
                        c_usiner.AxeX.Actuel += c_usiner.AxeX.AvanceParPas * v_sensX;
                        c_usiner.vs_distanceUsinee += c_usiner.DISTANCE_X;
                        //v_nbrInstructions++;
                        v_deltaX -= c_usiner.AxeX.AvanceParPas;
                        c_usiner.vs_ResteAUsiner = new System.Drawing.Point((c_usiner.AxeX.Next - c_usiner.AxeX.Actuel) / 1000, (c_usiner.AxeY.Next - c_usiner.AxeY.Actuel) / 1000);
                        try { c_usiner.vs_pourCentCodeEnCours = ((int)(c_usiner.vs_distanceUsinee - v_lastDistUsinee) * 100) / v_distBloc; }
                        catch { }
                        //Application.DoEvents();
                    }
                }
                else
                {
                    for (int i = 0; i < v_info.v_nbrPasY; i++)
                    {
                        while (c_usiner.vs_PauseUsinage)
                        { Application.DoEvents(); }
                        if (c_usiner.vs_ArreterUsinage) { return false; }

                        v_accel = m_accel_decel(ref v_info, v_info.v_nbrPasY, v_accel, i);

                        m_envoieCommande("Y", v_accel);
                        c_usiner.AxeY.Actuel += c_usiner.AxeY.AvanceParPas * v_sensY;
                        c_usiner.vs_distanceUsinee += c_usiner.DISTANCE_X;
                        //v_nbrInstructions++;
                        v_deltaY -= c_usiner.AxeY.AvanceParPas;
                        c_usiner.vs_ResteAUsiner = new System.Drawing.Point((c_usiner.AxeX.Next - c_usiner.AxeX.Actuel) / 1000, (c_usiner.AxeY.Next - c_usiner.AxeY.Actuel) / 1000);
                        try { c_usiner.vs_pourCentCodeEnCours = ((int)(c_usiner.vs_distanceUsinee - v_lastDistUsinee) * 100) / v_distBloc; }
                        catch { }
                        //Application.DoEvents();
                    }
                }
                m_testerPas(v_info.v_nbrPasX, v_info.v_nbrPasY);
            }
            #endregion
            else
            #region 2 AXES
            {
                string v_axe = "";
                int v_index = 0;
                foreach (byte v_byte in v_info.v_liste)
                {
                    while (v_index < 4)
                    {
                        while (c_usiner.vs_PauseUsinage)
                        { Application.DoEvents(); }
                        if (c_usiner.vs_ArreterUsinage) { return false; }

                        v_axe = v_byte.m_trouverXY(v_index);
                        //usiner v_axe
                        v_accel = m_accel_decel(ref v_info, v_info.v_liste.Count * 4, v_accel, i);
                        m_envoieCommande(v_axe, v_accel);
                        //MAJ coordonnées
                        if (v_axe.Contains('X')) { c_usiner.AxeX.Actuel += (c_usiner.AxeX.AvanceParPas * v_sensX); }
                        if (v_axe.Contains('Y')) { c_usiner.AxeY.Actuel += (c_usiner.AxeY.AvanceParPas * v_sensY); }
                        if (v_axe == "XY") { c_usiner.vs_distanceUsinee += c_usiner.DISTANCE_XY; } else { c_usiner.vs_distanceUsinee += c_usiner.DISTANCE_X; }
                        c_usiner.vs_ResteAUsiner = new System.Drawing.Point((c_usiner.AxeX.Next - c_usiner.AxeX.Actuel) / 1000, (c_usiner.AxeY.Next - c_usiner.AxeY.Actuel) / 1000);
                        c_usiner.vs_pourCentCodeEnCours = ((int)(c_usiner.vs_distanceUsinee - v_lastDistUsinee) * 100) / v_distBloc;
                        Application.DoEvents();

                        v_index++;
                        i++;
                    }
                    v_index = 0;
                }

                /*       double v_delta = 0;
                       int i = 0;
                       if (v_info.v_nbrPasX > v_info.v_nbrPasY)
                       {
                           #region deltaX>deltaY
                           v_delta = (double)c_usiner.AxeX.AvanceParPas * v_info.v_rapportXY;
                           while (v_deltaX > 0)
                           {
                               while (c_usiner.vs_PauseUsinage)
                               { Application.DoEvents(); }
                               if (c_usiner.vs_ArreterUsinage) { return false; }

                               v_accel = m_accel_decel(ref v_info, v_info.v_nbrPasX, v_accel, i);
                               if (v_avanceMini < c_usiner.AxeY.AvanceParPas)
                               {
                                   //avancer X seul
                                   m_envoieCommande("X", v_accel);
                                   v_avanceMini += v_delta;
                                   c_usiner.vs_distanceUsinee += c_usiner.DISTANCE_X;
                               }
                               else
                               {
                                   //avance X et Y
                                   m_envoieCommande("XY", v_accel);
                                   v_deltaY -= c_usiner.AxeY.AvanceParPas;
                                   v_avanceMini += v_delta - (double)c_usiner.AxeX.AvanceParPas;
                                   c_usiner.AxeY.Actuel += (c_usiner.AxeY.AvanceParPas * v_sensY);
                                   c_usiner.vs_distanceUsinee += c_usiner.DISTANCE_XY;
                               }
                               v_deltaX -= c_usiner.AxeX.AvanceParPas;
                               c_usiner.AxeX.Actuel += (c_usiner.AxeX.AvanceParPas * v_sensX);
                               c_usiner.vs_ResteAUsiner = new System.Drawing.Point((c_usiner.AxeX.Next - c_usiner.AxeX.Actuel) / 1000, (c_usiner.AxeY.Next - c_usiner.AxeY.Actuel) / 1000);
                               c_usiner.vs_pourCentCodeEnCours = ((int)(c_usiner.vs_distanceUsinee - v_lastDistUsinee) * 100) / v_distBloc;
                               Application.DoEvents();
                               i++;
                           }
                           while (v_deltaY > 0)
                           {
                               m_envoieCommande("Y", v_accel);
                               v_deltaY -= c_usiner.AxeY.AvanceParPas;
                               c_usiner.AxeY.Actuel += (c_usiner.AxeY.AvanceParPas * v_sensY);
                           }
                           c_usiner.vs_ResteAUsiner = new System.Drawing.Point((c_usiner.AxeX.Next - c_usiner.AxeX.Actuel) / 1000, (c_usiner.AxeY.Next - c_usiner.AxeY.Actuel) / 1000);
                           c_usiner.vs_pourCentCodeEnCours = ((int)(c_usiner.vs_distanceUsinee - v_lastDistUsinee) * 100) / v_distBloc;
                           Application.DoEvents();
                           #endregion
                       }
                       else
                       {
                           #region deltaX<deltaY
                           v_delta = (double)c_usiner.AxeY.AvanceParPas * v_info.v_rapportXY;
                           while (v_deltaY > 0)
                           {
                               while (c_usiner.vs_PauseUsinage)
                               { Application.DoEvents(); }
                               if (c_usiner.vs_ArreterUsinage) { return false; }

                               v_accel = m_accel_decel(ref v_info, v_info.v_nbrPasY, v_accel, i);

                               if (v_avanceMini < c_usiner.AxeY.AvanceParPas)
                               {
                                   //avancer X seul
                                   m_envoieCommande("Y", v_accel);
                                   v_avanceMini += v_delta;
                                   c_usiner.vs_distanceUsinee += c_usiner.DISTANCE_X;
                               }
                               else
                               {
                                   //avance X et Y
                                   m_envoieCommande("XY", v_accel);
                                   v_deltaX -= c_usiner.AxeY.AvanceParPas;
                                   v_avanceMini += v_delta - (double)c_usiner.AxeY.AvanceParPas;
                                   c_usiner.AxeX.Actuel += (c_usiner.AxeX.AvanceParPas * v_sensX);
                                   c_usiner.vs_distanceUsinee += c_usiner.DISTANCE_XY;
                               }
                               v_deltaY -= c_usiner.AxeY.AvanceParPas;
                               c_usiner.AxeY.Actuel += (c_usiner.AxeY.AvanceParPas * v_sensY);
                               c_usiner.vs_ResteAUsiner = new System.Drawing.Point((c_usiner.AxeX.Next - c_usiner.AxeX.Actuel) / 1000, (c_usiner.AxeY.Next - c_usiner.AxeY.Actuel) / 1000);
                               //v_nbrInstructions++;
                               c_usiner.vs_pourCentCodeEnCours = ((int)(c_usiner.vs_distanceUsinee - v_lastDistUsinee) * 100) / v_distBloc;
                               //Application.DoEvents();
                               i++;
                           }
                           while (v_deltaX > 0)
                           {
                               m_envoieCommande("X", v_accel);
                               v_deltaX -= c_usiner.AxeX.AvanceParPas;
                               c_usiner.AxeX.Actuel += (c_usiner.AxeX.AvanceParPas * v_sensX);
                           }
                           c_usiner.vs_ResteAUsiner = new System.Drawing.Point((c_usiner.AxeX.Next - c_usiner.AxeX.Actuel) / 1000, (c_usiner.AxeY.Next - c_usiner.AxeY.Actuel) / 1000);
                           c_usiner.vs_pourCentCodeEnCours = ((int)(c_usiner.vs_distanceUsinee - v_lastDistUsinee) * 100) / v_distBloc;
                           Application.DoEvents();
                           #endregion
                       }
                       m_testerPas(v_info.v_nbrPasX, v_info.v_nbrPasY);
                 * */
            }
            #endregion
            if (v_info.v_deceleration) // pour cumul dans usinage circulaire
            {
                v_lastDistUsinee = (int)c_usiner.vs_distanceUsinee;
                v_finBlocCirculaire = false;
                i = 0;
            }
            else
            { v_finBlocCirculaire = ((v_distBloc - (c_usiner.vs_distanceUsinee - v_lastDistUsinee)) < v_paramDecel * c_usiner.DISTANCE_XY); }
            return true;
        }
コード例 #2
0
 int m_accel_decel(ref c_InfoCode v_info, int nbrPas, int v_accel, int i)
 {
     //gere accel et decel
     if ((v_info.v_acceleration) | (!v_info.v_acceleration & !v_info.v_deceleration & !v_finBlocCirculaire & v_accel != 0))
     {
         if (i % formMain.v_paramPortParallele.v_acceleration == formMain.v_paramPortParallele.v_acceleration - 1)
         { v_accel -= 5; }
         v_info.v_acceleration = (v_accel > 0);
     }
     if (((v_info.v_deceleration) && (nbrPas - i < v_paramDecel)) || (v_finBlocCirculaire))
     {
         if (i % formMain.v_paramPortParallele.v_acceleration == formMain.v_paramPortParallele.v_acceleration - 1)
         {
             v_accel += 5;
             if (v_accel > c_usiner.vs_vitesseAvance - formMain.v_paramPortParallele.v_vitesseMini)
             { v_accel = c_usiner.vs_vitesseAvance - formMain.v_paramPortParallele.v_vitesseMini; }
         }
     }
     return v_accel;
 }
コード例 #3
0
 void m_traiteLigne(c_InfoCode v_Info)
 {
     switch (v_Info.v_ident)
     {
         case Ident.STOP:
             m_lArretSurZ("STOP");
             c_usiner.vs_indexLigne++;
             break;
         case Ident.NOP:
             c_usiner.vs_indexLigne++;
             break;
         case Ident.PasAPas://debut de bloc
             if (c_usiner.vs_PasAPas)
             { m_lArretSurZ("Pas à Pas"); };
             v_distBloc = v_Info.v_distanceBloc;
             break;
         case Ident.arretSurZ:
             if (c_usiner.vs_ArretSurZ)
             { m_lArretSurZ("Arret sur Z"); };
             c_usiner.AxeZ.Actuel = v_Info.v_posZ;
             if (v_Info.v_avancerLigneTraduite)
             { c_usiner.vs_indexLigneCodeTraduit++; }
             break;
         case Ident.changeSens:
             m_setSens(v_Info.v_Axe, v_Info.v_nbrPas, v_Info.v_sensX, v_Info.v_sensY);
             //pour eviter decalage
             c_usiner.vs_indexLigneCodeTraduit--;
             break;
         case Ident.FinBloc:
             c_usiner.vs_indexLigne++;
             break;
         case Ident.DiamOutil:
             c_usiner.vs_diametreOutil = v_Info.v_diamOutil;
             c_usiner.m_appelerDelegate(c_usiner.c_eventArgUsiner.enumEventsUsinage.modifDiamOutil);
             c_usiner.vs_indexLigne++;
             break;
         case Ident.ModifVitesse:
             formMain.vs_infoUsinage.v_vitesseAvancePercent = v_Info.v_modifVitesse;
             c_usiner.m_appelerDelegate(c_usiner.c_eventArgUsiner.enumEventsUsinage.vitesseAvanceModifie);
             c_usiner.vs_indexLigne++;
             break;
         case Ident.usiner:
             m_usiner(v_Info);
             break;
         case Ident.SansAvanceLigneTraduite:
             break;
     }
     if (v_Info.v_ident != Ident.arretSurZ)
     { c_usiner.vs_indexLigneCodeTraduit++; }
     c_usiner.m_appelerDelegate(c_usiner.c_eventArgUsiner.enumEventsUsinage.gBarBuffer);
     c_usiner.m_appelerDelegate(c_usiner.c_eventArgUsiner.enumEventsUsinage.incrementerLBoxFichier);
     //Application.DoEvents();
 }