Exemple #1
0
        private void toolPrintJob_Click(object sender, EventArgs e)
        {
            Printjob job = conn.job;

            job.BeginJob();
            job.PushData(textGCodePrepend.Text);
            job.PushData(textGCode.Text);
            job.PushData(textGCodeAppend.Text);
            job.EndJob();
        }
Exemple #2
0
        private void toolPrintJob_Click(object sender, EventArgs e)
        {
            Printjob job = conn.job;

            if (job.dataComplete)
            {
                conn.pause("Press OK to continue.\n\nYou can add pauses in your code with\n@pause Some text like this");
            }
            else
            {
                toolRunJob.Image = imageList.Images[3];
                job.BeginJob();
                job.PushData(editor.getContent(1));
                job.PushData(editor.getContent(0));
                job.PushData(editor.getContent(2));
                job.EndJob();
            }
        }
Exemple #3
0
        private void timer_Tick(object sender, EventArgs e)
        {
            Printjob j = Main.conn.job;

            switch (j.mode)
            {
            case 0:
                labelStatus.Text     = "No job defined";
                labelStartTime.Text  = "-";
                labelFinishTime.Text = "-";
                labelETA.Text        = "-";
                labelLinesSend.Text  = "-";
                labelTotalLines.Text = "-";
                break;

            case 1:     // Running
                labelStatus.Text     = "Running ...";
                labelStartTime.Text  = j.jobStarted.ToLongTimeString();
                labelFinishTime.Text = "-";
                labelETA.Text        = j.ETA;
                labelLinesSend.Text  = j.linesSend.ToString();
                labelTotalLines.Text = j.totalLines.ToString();
                break;

            case 2:
                labelStatus.Text     = "Finished";
                labelStartTime.Text  = j.jobStarted.ToLongTimeString();
                labelFinishTime.Text = j.jobFinished.ToLongTimeString();
                labelETA.Text        = "-";
                labelLinesSend.Text  = j.linesSend.ToString();
                labelTotalLines.Text = j.totalLines.ToString();
                break;

            case 3:
                labelStatus.Text     = "Aborted";
                labelStartTime.Text  = j.jobStarted.ToLongTimeString();
                labelFinishTime.Text = j.jobFinished.ToLongTimeString();
                labelETA.Text        = "-";
                labelLinesSend.Text  = j.linesSend.ToString();
                labelTotalLines.Text = j.totalLines.ToString();
                break;
            }
        }
Exemple #4
0
        private void timer_Tick(object sender, EventArgs e)
        {
            Printjob j = Main.conn.connector.Job;

            switch (j.mode)
            {
            case 0:
                labelStatus.Text     = Trans.T("L_NO_JOB_DEFINED"); // "No job defined";
                labelStartTime.Text  = "-";
                labelFinishTime.Text = "-";
                labelETA.Text        = "-";
                labelLinesSend.Text  = "-";
                labelTotalLines.Text = "-";
                break;

            case 1:                                             // Running
                labelStatus.Text     = Trans.T("L_RUNNING..."); // "Running ...";
                labelStartTime.Text  = j.jobStarted.ToLongTimeString();
                labelFinishTime.Text = "-";
                labelETA.Text        = j.ETA;
                labelLinesSend.Text  = j.linesSend.ToString();
                labelTotalLines.Text = j.totalLines.ToString();
                break;

            case 2:
                labelStatus.Text     = Trans.T("L_FINISHED"); // "Finished";
                labelStartTime.Text  = j.jobStarted.ToLongTimeString();
                labelFinishTime.Text = j.jobFinished.ToLongTimeString();
                labelETA.Text        = "-";
                labelLinesSend.Text  = j.linesSend.ToString();
                labelTotalLines.Text = j.totalLines.ToString();
                break;

            case 3:
                labelStatus.Text     = Trans.T("L_ABORTED"); // "Aborted";
                labelStartTime.Text  = j.jobStarted.ToLongTimeString();
                labelFinishTime.Text = j.jobFinished.ToLongTimeString();
                labelETA.Text        = "-";
                labelLinesSend.Text  = j.linesSend.ToString();
                labelTotalLines.Text = j.totalLines.ToString();
                break;
            }
        }
 public VirtualPrinterConnector()
 {
     virtualPrinter = new VirtualPrinter(this);
     con            = Main.conn;
     job            = new Printjob(Main.conn);
 }
Exemple #6
0
        private void toolAddFile_Click(object sender, EventArgs e)
        {
            Printjob job = Main.connection.job;

            //if (job.mode == 1)
            if (job.mode == Printjob.jobMode.printingJob)
            {
                updateButtons();
                return;
            }
            SDCardUpload f = SDCardUpload.Execute();

            if (f.exit)
            {
                toolStatus.Text = Trans.T("L_UPLOADING_FILE..."); // "Uploading file ...";
                progress.Value  = 0;
                job.BeginJob();
                job.exclusive = true;
                job.PushData("M28 " + (currentDirectory.Length > 0?"/":"") + currentDirectory + f.textFilename.Text);
                if (f.checkAppendPrepend.Checked)
                {
                    job.PushGCodeShortArray(Main.main.editor.getContentArray(1));
                }
                if (f.radioCurrent.Checked)
                {
                    job.PushGCodeShortArray(Main.main.editor.getContentArray(0));
                }
                else
                {
                    try
                    {
                        job.PushData(System.IO.File.ReadAllText(f.extFilename.Text));
                    }
                    catch (Exception ex)
                    {
                        job.exclusive = false;
                        job.BeginJob();
                        job.EndJob();
                        MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                if (f.checkAppendPrepend.Checked)
                {
                    job.PushGCodeShortArray(Main.main.editor.getContentArray(2));
                }
                if (f.checkJobFinished.Checked)
                {
                    PrinterConnection con = Main.connection;
                    if (con.afterJobDisableExtruder)
                    {
                        for (int i = 0; i < Main.connection.numberExtruder; i++)
                        {
                            job.PushData("M104 S0 T" + i.ToString());
                        }
                    }
                    if (con.afterJobDisablePrintbed)
                    {
                        job.PushData("M140 S0");
                    }
                    if (con.afterJobGoDispose)
                    {
                        job.PushData("G90");
                        job.PushData("G1 X" + con.disposeX.ToString(GCode.format) + " Y" + con.disposeY.ToString(GCode.format) + " F" + con.travelFeedRate.ToString(GCode.format));
                    }
                }
                job.PushData("M29");
                job.EndJob();
                uploading = true;
                startTime = DateTime.Now.Ticks;
            }
        }
Exemple #7
0
 private void analyzer(string res)
 {
     if (readFilenames)
     {
         if (res.StartsWith("End file list"))
         {
             readFilenames = false;
             fillFiles(currentDirectory);
             return;
         }
         string[] parts = reduceSpace(res.ToLower()).Trim().Split(' ');
         allFiles.AddLast(new FileEntry(parts));
         //files.Items.Add(new ListViewItem(parts));
         return;
     }
     if (res.StartsWith("Begin file list"))
     {
         readFilenames = true;
         allFiles.Clear();
         allDirs.Clear();
         return;
     }
     // Printing done?
     if (res.IndexOf("Not SD printing") != -1 || res.IndexOf("Done printing file") != -1)
     {
         printing        = false;
         toolStatus.Text = Trans.T("L_PRINT_FINISHED"); // "Print finished";
         progress.Value  = 200;
     }
     else if (res.IndexOf("SD printing byte ") != -1) // Print status update
     {
         string   s  = res.Substring(res.IndexOf("SD printing byte ") + 17);
         string[] s2 = s.Split('/');
         if (s2.Length == 2)
         {
             long a, b;
             long.TryParse(s2[0], out a);
             long.TryParse(s2[1], out b);
             progress.Value = (int)(200 * a / b);
         }
     }
     else if (res.IndexOf("SD init fail") != -1 || res.IndexOf("volume.init failed") != -1 ||
              res.IndexOf("openRoot failed") != -1) // mount failed
     {
         mounted = false;
     }
     else if (uploading && (res.Contains("M999") || res.IndexOf("error writing to file") != -1)) // write error
     {
         Main.connection.job.KillJob();
         Main.connection.analyzer.uploading = false;
         uploading       = false;
         toolStatus.Text = Trans.T("L_UPLOAD_FAILED"); // "Upload failed.";
     }
     else if (res.IndexOf("Done saving file") != -1)   // save finished
     {
         double time = (double)(DateTime.Now.Ticks - startTime) * 0.0000001;
         uploading       = false;
         progress.Value  = 200;
         toolStatus.Text = Trans.T("L_UPLOAD_FINISHED"); // "Upload finished.";
         updateFilenames = true;
         Main.connection.log(Trans.T1("L_UPLOADING_TIME", Printjob.DoubleToTime(time)), false, 3);
     }
     else if (res.Contains("Invalid directory"))
     {
         if (uploading)
         {
             Main.connection.job.KillJob();
             Main.connection.analyzer.uploading = false;
             uploading       = false;
             toolStatus.Text = Trans.T("L_UPLOAD_FAILED"); // "Upload failed.";
         }
     }
     else if (res.IndexOf("File selected") != -1)
     {
         toolStatus.Text = Trans.T("L_SD_PRINTING..."); // "SD printing ...";
         progress.Value  = 0;
         printing        = true;
         printPaused     = false;
         startPrint      = true;
     }
     else if (uploading && res.StartsWith("open failed, File"))
     {
         Main.connection.job.KillJob();
         Main.connection.analyzer.uploading = false;
         toolStatus.Text = Trans.T("L_UPLOAD_FAILED"); // "Upload failed.";
     }
     else if (res.StartsWith("File deleted"))
     {
         waitDelete      = 0;
         toolStatus.Text = Trans.T("L_FILE_DELETED"); // "File deleted";
         updateFilenames = true;
     }
     else if (res.StartsWith("Deletion failed"))
     {
         waitDelete      = 0;
         toolStatus.Text = Trans.T("L_DELETE_FAILED"); // "Delete failed";
     }
 }
Exemple #8
0
        private void toolAddFile_Click(object sender, EventArgs e)
        {
            Printjob job = Main.conn.job;

            if (job.hasData())
            {
                updateButtons();
                return;
            }
            SDCardUpload f = SDCardUpload.Execute();

            if (f.exit)
            {
                toolStatus.Text = "Uploading file ...";
                progress.Value  = 0;
                job.BeginJob();
                job.exclusive = true;
                job.PushData("M28 " + f.textFilename.Text);
                if (f.checkAppendPrepend.Checked)
                {
                    job.PushData(Main.main.editor.getContent(1));
                }
                if (f.radioCurrent.Checked)
                {
                    job.PushData(Main.main.editor.getContent(0));
                }
                else
                {
                    try
                    {
                        job.PushData(System.IO.File.ReadAllText(f.extFilename.Text));
                    }
                    catch (Exception ex)
                    {
                        job.exclusive = false;
                        job.BeginJob();
                        job.EndJob();
                        MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                if (f.checkAppendPrepend.Checked)
                {
                    job.PushData(Main.main.editor.getContent(2));
                }
                if (f.checkJobFinished.Checked)
                {
                    PrinterConnection con = Main.conn;
                    if (con.afterJobDisableExtruder)
                    {
                        job.PushData("M104 S0");
                    }
                    if (con.afterJobDisablePrintbed)
                    {
                        job.PushData("M140 S0");
                    }
                    con.ReturnInjectLock();
                    if (con.afterJobGoDispose)
                    {
                        job.PushData("G90");
                        job.PushData("G1 X" + con.disposeX.ToString(GCode.format) + " Y" + con.disposeY.ToString(GCode.format) + " F" + con.travelFeedRate.ToString(GCode.format));
                    }
                }
                job.PushData("M29");
                job.EndJob();
                uploading = true;
            }
        }