Click here to Skip to main content
15,881,424 members
Articles / Desktop Programming / MFC
Article

CAM simulator

Rate me:
Please Sign up or sign in to vote.
4.95/5 (14 votes)
19 Feb 2002 177.4K   8K   55   18
This program shows how a CN machine works

Sample Image - CAM_simulator.gif

Introduction

After 6 months of work, here is finally my first MFC program release. This program is a CAM simulator. I am not a software engineer, so please forgive me for errors. If you have questions please let me know. I am sure that you will find them. The lecture of data files was a big problem to me at the beginning, so here is the implementation. I needed to read *.txt files, what the CNC machine generate. Here is an example M X25 Y23 Z25 SPEED1500. This is a block of data, needed to setup the machines. This is a kind of language that the machine use to move on the coordinates over the work space. So in this implementation you can read a full document, splitting the block in the necessary X Y Z and SPEED values. This is my first upload, I have more things to say about this program I will try to improve soon, this short commentary.

void CProgramaDoc::OnFileOpen() 
{
    CString fichero="archivo de Código G",temp;

    CFileDialog archivos(true,NULL,fichero,OFN_ALLOWMULTISELECT,
        "Codigo G (*.tap)|*.tap|Codigo G (*.act)|*.act||",NULL);

    if (archivos.DoModal() == FALSE) return;
    fichero=archivos.GetPathName();

    CFile cfFile (fichero, CFile::modeNoTruncate | CFile::modeRead);
    CArchive ar (&cfFile, CArchive::load); 

    if(!ar.ReadString(temp))  return;

    nl=0;
    do
    {
        if(temp.GetLength() == 0) continue;
        strcpy(linea[nl],temp);
        nl++;

    }while(ar.ReadString(temp));    

    
    // SEPARANDO COORDENADAS

    int i,j,k,d,sp;
    char aux[30];

    for ( i=0; i<5000; i++)
    {
        x[i] = y[i] = z[i] = 0;
    }    

    kn=0;
    for (i=0;i<nl;i++)
    {
        
        if (linea[i][0]=='S');
        {
            Inicio=1;
        }
        
        if (linea[i][0]=='M');
        {
        sp = 0;
        k = 0;
        d = strlen(linea[i]);

        for (j=0;j<d;j++)
        {
            if ((linea[i][j]=='-')|(isdigit(linea[i][j]))|
                                        (linea[i][j]=='.'))
            {
                aux[k] = linea[i][j];
                k++;
                continue;
            }

            if (linea[i][j]==' ')
            {
                sp++;
                if (sp==1) continue;

                aux[k]=0;

                if (sp==2)
                    if ((aux[0]=='-')|(isdigit(aux[0]))|(aux[0]=='.'))
                        x[kn] = atof(aux);
                    else
                        x[kn] = x[kn-1];

                if (sp==3) 
                    if ((aux[0]=='-')|(isdigit(aux[0]))|(aux[0]=='.')) 
                        y[kn] = atof(aux);
                    else
                        y[kn] = y[kn-1];

                if (sp==4)
                    if ((aux[0]=='-')|(isdigit(aux[0]))|(aux[0]=='.')) 
                        z[kn] = atof(aux);
                    else
                        z[kn] = z[kn-1];

                k = 0;
                continue;
            }            
        }

        kn++;
        j = d;
        }
    }
    
    presentar = 1;

    //    VERIFICANDO TORNO O FRESA

    sumz = 0;
    for (i=0; i<nl; i++)
    {
        sumz += abs(z[i]);
    }

    if (sumz == 0)
        torno = 1;
    else
        fresa = 1;

    UpdateAllViews(NULL);
    
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Engineer
United States United States
May 2001 – January 2002 MERCK SHARP & DOHME QUITO, ECUADOR
Project Assistant in the area of Engineering. I am in charge of project 02: Remodeling of the area of Liquids and Laundry: where the syrups Hemocyton and Aurimel are synthesized. I have received courses in Industrial Security and GMP (good manufacturing practices). I designed the systems for vapor, cold, and hot soft water for these areas.

2000 - 2001 GENCO DRAWING SERVICES QUITO, ECUADOR
I created this company that is devoted to the service of drawing of plans in AutoCAD through the Internet. I designed the web page and the promotion systems and publicity. I elaborated the operation procedures. Another part of this company is MiCotizador.com, a database of products and services for contractors and projects, in Quito.
August 1996 – November 2001 Escuela Politécnica del Ejército (ESPE), School of Mechanical Engineering (FIME) , QUITO, ECUADOR
• First prize in a competition of Structures
• Third prize in a Heat Transfer challenge (Adiabatic Processes)
• Attended a seminar on normalized procedures for the assembly of oil facilities
• I have complied with all courses and credits required by the ESPE for the termination of my degree. Upon defending my thesis in November, I was awarded my diploma. My thesis topic was: "Development of a Simulator for Milling and Lathe Machines by means of Numeric Control" for the laboratory of CAD/CAM of the Faculty of Mechanical Engineering.

August 2000 Occidental Petroleum Corporation

• One month internship with OXY, Block 15, Sucumbios (in the Ecuadorian Amazon); completed 337 hours of work.
• I spent time in the areas of mechanical maintenance, plant area and finally in automation and control.


1990 -1996 SAN GABRIEL HIGH SCHOOL
• I was on the basketball team.
• I actively participated in the competitions a

Comments and Discussions

 
Question"Unable to open this internet site" is the message I receive upon attempting to download project. Pin
RedDk16-Apr-14 7:16
RedDk16-Apr-14 7:16 
AnswerRe: "Unable to open this internet site" is the message I receive upon attempting to download project. Pin
RedDk21-Apr-14 10:42
RedDk21-Apr-14 10:42 
Generala GCode interpreter written in C/C++ Pin
mushigang200623-Aug-08 5:55
mushigang200623-Aug-08 5:55 
GeneralMfc42d.dll Pin
Member 280963729-May-08 23:57
Member 280963729-May-08 23:57 
GeneralAsk fo open source G code interpreter Pin
Flower30311-Jul-04 23:41
Flower30311-Jul-04 23:41 
GeneralNot IEC or ISO Language Pin
LFC6-Oct-03 6:18
LFC6-Oct-03 6:18 
QuestionCAM? CN? Pin
Philippe Lhoste27-Feb-02 1:49
Philippe Lhoste27-Feb-02 1:49 
AnswerRe: CAM? CN? Pin
Anonymous9-Feb-03 18:39
Anonymous9-Feb-03 18:39 
GeneralRe: CAM? CN? Pin
Philippe Lhoste10-Feb-03 22:48
Philippe Lhoste10-Feb-03 22:48 
GeneralNEW VERSION + OpenGL Pin
Diego Andrade21-Feb-02 13:03
Diego Andrade21-Feb-02 13:03 
GeneralRe: NEW VERSION + OpenGL Pin
jiang.j.q16-Feb-05 22:13
jiang.j.q16-Feb-05 22:13 
GeneralInteresting work Pin
Jamie Hale21-Feb-02 10:38
Jamie Hale21-Feb-02 10:38 
QuestionEnglish? Pin
Matt Newman20-Feb-02 16:40
Matt Newman20-Feb-02 16:40 
AnswerRe: English? Pin
Mazdak20-Feb-02 20:01
Mazdak20-Feb-02 20:01 
AnswerRe: English? Pin
Jamie Hale21-Feb-02 10:36
Jamie Hale21-Feb-02 10:36 
GeneralRe: English? Pin
Matt Newman21-Feb-02 11:31
Matt Newman21-Feb-02 11:31 
GeneralRe: English? Pin
Diego Andrade21-Feb-02 13:00
Diego Andrade21-Feb-02 13:00 
GeneralRe: English? Pin
Cathy28-Feb-02 12:34
Cathy28-Feb-02 12:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.