Example #1
0
        private void generateMachineCodeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string Code = PromptBox.ShowDialog("Enter GCode", "Enter GCode to convert to machine code");

            switch (GCode.GetCode(Code))
            {
            case "G00":
                G00 g0 = new G00(Code);
                break;

            case "G01":
                G01 g1 = new G01(Code);
                MessageBox.Show(g1.MachineCodeFromLocation(0, 0, 0));
                break;

            default:
                throw new NotSupportedException("OpCode " + GCode.GetCode(Code) + " not supported");
            }
        }
Example #2
0
        void MillTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                switch (GCode.GetCode(gCode[GlobalCounter]))
                {
                case "G00":    //Rapid Move
                    Log("Rapid Move");
                    G00 g = new G00(gCode[GlobalCounter++]);
                    MillString = g.MachineCodeFromLocation(Drill_X, Drill_Y, Drill_Z);
                    CutString(MillString);
                    break;

                case "G01":    //Liner Interpolation INCOMPLETE

                    G01 g1 = new G01(gCode[GlobalCounter++]);
                    MillString = g1.MachineCodeFromLocation(Drill_X, Drill_Y, Drill_Z);
                    CutString(MillString);
                    break;

                case "G04":     //Dwell - implement a wait. NOT CORRECTLY WORKING DISABLED FOR NOW
                    //G04 g4 = new G04(gCode[GlobalCounter++]);
                    //Log("Wait for " + g4.Wait.ToString() + " milliseconds");
                    //System.Threading.Thread.Sleep(g4.Wait);
                    GlobalCounter++;
                    break;

                case "G21":     //Programming in Millimeters
                    Log("Programming In Millimeters");
                    GlobalCounter++;
                    break;

                case "G90":     //Absoulte Programming
                    Log("Absolute Programming");
                    GlobalCounter++;
                    break;

                case "M03":     //Spindle On, Clockwise
                    //UserRequest.ShowDialog("Please turn the spindle on.");
                    //Need to implement a wait for okay button pressed style effect
                    GlobalCounter++;
                    break;

                case "M05":     //Spindle Off
                    //UserRequest.ShowDialog("Please turn the spindle off.");
                    GlobalCounter++;
                    break;

                default:
                    Log("OpCode " + GCode.GetCode(gCode[GlobalCounter]) + " not supported");
                    throw new NotSupportedException("OpCode " + GCode.GetCode(gCode[GlobalCounter]) + " not supported");
                }
            }
            catch (Exception ex)
            {
                MillTimer.Dispose();
                Log(ex.Message);
            }


            if ((GlobalCounter == GlobalMaximum) && StringMillComplete)//if we're on the last command and we've cut it out, finish
            {
                MessageBox.Show("Milling Complete");
                MillTimer.Stop();
                MillTimer.Enabled = false;
                MillTimer.Dispose();
            }
        }