Example #1
0
        static void Main()
        {
            IntPtr ptr = GetConsoleWindow();
            //MoveWindow(ptr, -1000, 0, 1000, 400, true);  // Move console window out from under printer windows

            // Start the printer - DO NOT CHANGE THESE LINES
            PrinterThread printer = new PrinterThread();
            Thread        oThread = new Thread(new ThreadStart(printer.Run));

            oThread.Start();
            printer.WaitForInit();

            // Start the firmware thread - DO NOT CHANGE THESE LINES
            FirmwareController firmware = new FirmwareController(printer.GetPrinterSim());

            oThread = new Thread(new ThreadStart(firmware.Start));
            oThread.Start();
            firmware.WaitForInit();

            Command command = new Command(printer.GetPrinterSim());

            Tests testMenu = new Tests(command, printer.GetPrinterSim());

            SetForegroundWindow(ptr);

            bool fDone = false;

            while (!fDone)
            {
                Console.Clear();
                Console.WriteLine("3D Printer Simulation - Control Menu\n");
                Console.WriteLine("P - Print");
                Console.WriteLine("T - Test");
                Console.WriteLine("Q - Quit");

                char ch = Char.ToUpper(Console.ReadKey().KeyChar);
                switch (ch)
                {
                case 'P':     // Print
                    PrintFile("..\\SampleSTLs\\F-35_Corrected.gcode", command, printer.GetPrinterSim());
                    break;

                case 'T':     // Test menu
                    testMenu.TestMenu();
                    break;

                case 'Q':       // Quite
                    printer.Stop();
                    firmware.Stop();
                    fDone = true;
                    break;
                }
            }
        }
Example #2
0
        static void Main()
        {
            IntPtr ptr = GetConsoleWindow();

            MoveWindow(ptr, 0, 0, 1000, 400, true);

            // Start the printer - DO NOT CHANGE THESE LINES
            PrinterThread printer = new PrinterThread();
            Thread        oThread = new Thread(new ThreadStart(printer.Run));

            oThread.Start();
            printer.WaitForInit();

            // Start the firmware thread - DO NOT CHANGE THESE LINES
            FirmwareController firmware = new FirmwareController(printer.GetPrinterSim());

            oThread = new Thread(new ThreadStart(firmware.Start));
            oThread.Start();
            firmware.WaitForInit();

            SetForegroundWindow(ptr);

            bool fDone = false;

            while (!fDone)
            {
                Console.Clear();
                Console.WriteLine("3D Printer Simulation - Control Menu\n");
                Console.WriteLine("P - Print");
                Console.WriteLine("T - Test");
                Console.WriteLine("Q - Quit");

                char ch = Char.ToUpper(Console.ReadKey().KeyChar);
                switch (ch)
                {
                case 'P':     // Print
                    PrintFile(printer.GetPrinterSim());
                    firmware.removeModel();
                    break;

                case 'T':     // Test menu
                    break;

                case 'Q':      // Quite
                    printer.Stop();
                    firmware.Stop();
                    fDone = true;
                    break;
                }
            }
        }
        static void PrintFile(PrinterControl simCtl, PrinterThread printer)
        {
            Stopwatch swTimer = new Stopwatch();

            swTimer.Start();


            swTimer.Stop();
            long elapsedMS = swTimer.ElapsedMilliseconds;

            Console.WriteLine("Total Print Time: {0}", elapsedMS / 1000.0);
            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }
Example #4
0
        static void Main()
        {
            // Start the printer - DO NOT CHANGE THESE LINES
            PrinterThread printer = new PrinterThread();
            Thread        oThread = new Thread(new ThreadStart(printer.Run));

            oThread.Start();
            printer.WaitForInit();

            // Start the firmware thread - DO NOT CHANGE THESE LINES
            FirmwareController firmware = new FirmwareController(printer.GetPrinterSim());

            oThread = new Thread(new ThreadStart(firmware.Start));
            oThread.Start();
            firmware.WaitForInit();

            Command command = new Command(printer.GetPrinterSim());

            int goodCounter = 0;

            for (int i = 0; i < 100; i++)
            {
                string result = command.SendCommandParam1(FWCommands.CMD_SET_LASER, 1);

                if (result == "SUCCESS")
                {
                    goodCounter++;
                }
            }

            if (goodCounter == 100)
            {
                Console.WriteLine("Test passed");
            }
            else
            {
                Console.WriteLine("Test failed");
            }

            printer.Stop();
            firmware.Stop();
        }
 public HostCP(PrinterThread hostControl)
 {
     host = hostControl;
 }
Example #6
0
        static void Main()
        {
            try
            {
                //IntPtr ptr = GetConsoleWindow();
                //MoveWindow(ptr, 0, 0, 1000, 400, true);

                // Start the printer - DO NOT CHANGE THESE LINES
                PrinterThread printer = new PrinterThread();
                Thread        oThread = new Thread(new ThreadStart(printer.Run));
                oThread.Start();
                printer.WaitForInit();

                // Start the firmware thread - DO NOT CHANGE THESE LINES
                FirmwareController firmware = new FirmwareController(printer.GetPrinterSim());
                oThread = new Thread(new ThreadStart(firmware.Start));
                oThread.Start();
                firmware.WaitForInit();
                HostHandler handler = new HostHandler(printer);

                //SetForegroundWindow(ptr);
                // Hide Console
                //ShowWindow(ptr, 0);
                Application app = new Application();
                app.Run(new MainWindow(handler));

                printer.Stop();
                firmware.Stop();
                //bool fDone = false;
                //while (!fDone)
                //{
                //
                //    Console.Clear();
                //    Console.WriteLine("3D Printer Simulation - Control Menu\n");
                //    Console.WriteLine("P - Print");
                //    Console.WriteLine("T - Test");
                //    Console.WriteLine("Q - Quit");
                //
                //    char ch = Char.ToUpper(Console.ReadKey().KeyChar);
                //    switch (ch)
                //    {
                //        case 'P': // Print
                //            PrintFile(printer.GetPrinterSim());
                //            break;
                //
                //        case 'T': // Test menu
                //            break;
                //
                //        case 'Q' :  // Quite
                //            printer.Stop();
                //            firmware.Stop();
                //            fDone = true;
                //            break;
                //    }
                //
                //}
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.StackTrace);
            }
        }
Example #7
0
        static void Main()
        {
            IntPtr ptr = GetConsoleWindow();

            MoveWindow(ptr, 0, 0, 1000, 400, true);

            // Start the printer - DO NOT CHANGE THESE LINES
            PrinterThread printer = new PrinterThread();
            Thread        oThread = new Thread(new ThreadStart(printer.Run));

            oThread.Start();
            printer.WaitForInit();

            // Start the firmware thread - DO NOT CHANGE THESE LINES
            FirmwareController firmware = new FirmwareController(printer.GetPrinterSim());

            oThread = new Thread(new ThreadStart(firmware.Start));
            oThread.Start();
            firmware.WaitForInit();

            SetForegroundWindow(ptr);

            bool fDone = false;

            while (!fDone)
            {
                Console.Clear();
                Console.WriteLine("3D Printer Simulation {0} - Control Menu\n", (object)firmware.GetVer());
                Console.WriteLine("P - Print");
                Console.WriteLine("T - Test");
                Console.WriteLine("Q - Quit");

                char ch = Char.ToUpper(Console.ReadKey().KeyChar);
                switch (ch)
                {
                case 'P':     // Print
                    Packet setPlateHome = Packet.Reset();
                    CommunicationsProtocol.SendPacket(printer.GetPrinterSim(), setPlateHome);
                    PrintFile(printer.GetPrinterSim());
                    break;

                case 'T':     // Test menu
                    Console.Clear();
                    Console.WriteLine("3D Printer Simulation {0} - Test Menu\n", (object)firmware.GetVer());
                    Console.WriteLine("B - Test build plate movement from top to bottom");
                    Console.WriteLine("G - Test galvo");
                    Console.WriteLine("L - Test laser on/off");
                    Console.WriteLine("Z - Test build plate movement to specific point");
                    Console.WriteLine("Q - Back");

                    ch = Char.ToUpper(Console.ReadKey().KeyChar);
                    switch (ch)
                    {
                    case 'B':         // Test build plate movement from top to bottom
                        Packet reset = Packet.Reset();
                        CommunicationsProtocol.SendPacket(printer.GetPrinterSim(), reset);
                        break;

                    case 'G':         // Test galvo
                        Console.WriteLine("Insert the X and Y coordinate separated by a space: ");

                        string[] tokens = Console.ReadLine().Split();

                        //Parse element 0
                        double xVoltage = double.Parse(tokens[0]);

                        //Parse element 1
                        double yVoltage = double.Parse(tokens[1]);

                        Packet galv = Packet.MoveGalvos(xVoltage, yVoltage);
                        CommunicationsProtocol.SendPacket(printer.GetPrinterSim(), galv);
                        Packet galv2 = Packet.MoveGalvos(xVoltage + 10, yVoltage + 10);
                        CommunicationsProtocol.SendPacket(printer.GetPrinterSim(), galv2);

                        break;

                    case 'L':         // Test laser on/off
                        Console.WriteLine("1 - On");
                        Console.WriteLine("0 - Off");

                        string x = Console.ReadLine();
                        switch (x)
                        {
                        case "1":             // Test Laser On
                            Packet laserOn = Packet.LaserOn(true);
                            CommunicationsProtocol.SendPacket(printer.GetPrinterSim(), laserOn);

                            break;

                        case "0":             // Test Laser Off
                            Packet laserOff = Packet.LaserOn(false);
                            CommunicationsProtocol.SendPacket(printer.GetPrinterSim(), laserOff);
                            break;
                        }
                        break;

                    case 'Z':         // Test build plate movement to specific point
                        Console.WriteLine("What position on the Z-rail would you like to move the build plate? (0-100): ");
                        int    pos       = Convert.ToInt32(Console.ReadLine());
                        int    steps     = 400 * pos;
                        Packet testZrail = Packet.Reset();
                        CommunicationsProtocol.SendPacket(printer.GetPrinterSim(), testZrail);
                        firmware.StepStepperUp(steps);
                        break;

                    case 'Q':         //back to main menu
                        break;
                    }
                    break;

                case 'Q':       // Quit
                    printer.Stop();
                    firmware.Stop();
                    fDone = true;
                    break;
                }
            }
        }
 public HostHandler(PrinterThread thread)
 {
     this.printer = thread.GetPrinterSim();
 }
        static void Main()
        {
            IntPtr ptr = GetConsoleWindow();

            MoveWindow(ptr, 0, 0, 1000, 400, true);

            // Start the printer - DO NOT CHANGE THESE LINES
            PrinterThread printer = new PrinterThread();
            Thread        oThread = new Thread(new ThreadStart(printer.Run));

            oThread.Start();
            printer.WaitForInit();

            // Start the firmware thread - DO NOT CHANGE THESE LINES
            FirmwareController firmware = new FirmwareController(printer.GetPrinterSim());

            oThread = new Thread(new ThreadStart(firmware.Start));
            oThread.Start();
            firmware.WaitForInit();

            SetForegroundWindow(ptr);

            bool fDone = false;

            while (!fDone)
            {
                Console.Clear();
                Console.WriteLine("3D Printer Simulation - Control Menu\n");
                Console.WriteLine("P - Print");
                Console.WriteLine("T - Test GCODE");
                Console.WriteLine("Q - Quit");

                char ch = Char.ToUpper(Console.ReadKey().KeyChar);
                switch (ch)
                {
                case 'P':     // Print
                    PrintFile(printer.GetPrinterSim(), printer);
                    break;

                case 'T':     // Test GCODE
                    PrinterParser.OpenFile("C:\\Users\\User\\Documents\\GitKraken\\SLAPrintingProject\\SLA-3D-Printer-Project\\SampleSTLs\\F-35_Corrected.gcode");
                    List <PrinterCommand> FileContents = PrinterParser.ParseContents();
                    double max_x_coordinate            = 0.0;
                    double max_y_coordinate            = 0.0;
                    double max_z_layer = 0.0;
                    for (int i = 0; i < FileContents.Count(); i++)
                    {
                        //Console.WriteLine(FileContents[i].x_coordinate);
                        //Console.WriteLine(FileContents[i].y_coordinate);
                        //Console.WriteLine("Line:" + i);



                        if (FileContents[i].g_command != double.MaxValue)
                        {
                            Console.WriteLine("Command: " + FileContents[i].g_command);
                        }
                        if (FileContents[i].x_coordinate != double.MaxValue)
                        {
                            if (FileContents[i].x_coordinate > max_x_coordinate)
                            {
                                max_x_coordinate = FileContents[i].x_coordinate;
                            }
                            Console.WriteLine("X: " + FileContents[i].x_coordinate);
                        }
                        if (FileContents[i].y_coordinate != double.MaxValue)
                        {
                            if (FileContents[i].y_coordinate > max_y_coordinate)
                            {
                                max_y_coordinate = FileContents[i].y_coordinate;
                            }
                            Console.WriteLine("Y: " + FileContents[i].y_coordinate);
                        }
                        if (FileContents[i].z_layer != double.MaxValue)
                        {
                            if (FileContents[i].z_layer > max_z_layer)
                            {
                                max_z_layer = FileContents[i].z_layer;
                            }
                            Console.WriteLine("Z: " + FileContents[i].z_layer);
                        }
                        //if (FileContents[i].isLaserOn == true)
                        //{ Console.WriteLine("Is Laser On? " + FileContents[i].isLaserOn); }
                        Console.WriteLine("Is Laser On? " + FileContents[i].isLaserOn);
                        Console.WriteLine("");
                    }
                    Console.WriteLine("Max x coordinate: " + max_x_coordinate);
                    Console.WriteLine("");
                    Console.WriteLine("Max y coordinate: " + max_y_coordinate);
                    Console.WriteLine("");
                    Console.WriteLine("Max z layer: " + max_z_layer);
                    Console.WriteLine("");
                    Console.ReadLine();
                    break;

                case 'Q':       // Quit
                    printer.Stop();
                    firmware.Stop();
                    fDone = true;
                    break;
                }
            }
        }