Ejemplo n.º 1
0
        public override bool Connect()
        {
            con.isMarlin = con.isRepetier = con.isSprinter = false;
            connected    = true;
            virtualPrinter.open(int.Parse(baudRate));
            GCode gc = new GCode();

            gc.Parse("M105");
            virtualPrinter.receiveLine(gc);
            connected = true;
            if (transferProtocol < 2)
            {
                binaryVersion = 0;
            }
            else
            {
                binaryVersion = transferProtocol - 1;
            }
            con.binaryVersion = binaryVersion;
            readyForNextSend  = true;
            lock (nackLines)
            {
                nackLines.Clear();
            }
            linesSend = errorsReceived = bytesSend = 0;
            gc.Parse("N0 M110");
            virtualPrinter.receiveLine(gc);
            gc.Parse("M115");
            virtualPrinter.receiveLine(gc);
            gc.Parse("M105");
            virtualPrinter.receiveLine(gc);
            con.FireConnectionChange(Trans.T("L_CONNECTED") + ":" + con.printerName);
            Main.main.Invoke(Main.main.UpdateJobButtons);
            return(true);
        }
Ejemplo n.º 2
0
        public override void InjectManualCommand(string command)
        {
            if (!connected)
            {
                return;
            }
            GCode gc = new GCode();

            gc.Parse(command);
            if (gc.comment)
            {
                return;
            }
            lock (history)
                injectCommands.AddLast(gc);
            if (job.dataComplete == false)
            {
                if (injectCommands.Count == 0)
                {
                    con.firePrinterAction(Trans.T("L_IDLE"));
                }
                else
                {
                    con.firePrinterAction(Trans.T1("L_X_COMMANDS_WAITING", injectCommands.Count.ToString()));
                }
            }
        }
 private void writeArray(BinaryWriter file, List <GCodeShort> list, bool binary)
 {
     foreach (GCodeShort code in list)
     {
         GCode gc = new GCode();
         gc.Parse(code.text);
         if (gc.hostCommand)
         {
             continue;
         }
         if (binary)
         {
             if (gc.hasCode)
             {
                 byte[] data = gc.getBinary(1);
                 file.Write(data);
             }
         }
         else
         {
             System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
             string cmd = gc.getAscii(false, false);
             if (cmd.Length > 0)
             {
                 file.Write(enc.GetBytes(cmd + "\n"));
             }
         }
     }
 }
        private void writeString(BinaryWriter file, string code, bool binary)
        {
            GCode gc = new GCode();

            gc.Parse(code);
            if (gc.hostCommand)
            {
                return;
            }
            if (binary)
            {
                if (gc.hasCode)
                {
                    byte[] data = gc.getBinary(1);
                    file.Write(data);
                }
            }
            else
            {
                System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
                string cmd = gc.getAscii(false, false);
                if (cmd.Length > 0)
                {
                    file.Write(enc.GetBytes(cmd + "\n"));
                }
            }
        }
Ejemplo n.º 5
0
        private GCode ReadGCodeLineAscii(StreamReader readascii, bool excludeComments)
        {
            var gcode = new GCode();

            do
            {
                string line;
                try
                {
                    line = readascii.ReadLine();
                }
                catch (Exception ex)
                {
                    ErrorLogger.LogErrorMsg("Exception in GCodeReader.StartReading 1 " + ex.Message, "Exception");
                    return(null);
                }
                if (line == null)
                {
                    return(null);
                }

                gcode.Parse(line);
            }while (gcode.comment & excludeComments);
            return(gcode);
        }
Ejemplo n.º 6
0
        private void button5_Click(object sender, EventArgs e)
        {
            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "Drill Files (*.nc)|*.nc";
            if (DialogResult.OK == d.ShowDialog())
            {
                string[] lines = System.IO.File.ReadAllLines(d.FileName);
                g_code = new GCode();
                g_code.Parse(lines);
                Rout [] routs = g_code.GetRouts();
                foreach (Rout r in routs)
                {
                    userControl11.AddObject(r);
                }
            }
        }
Ejemplo n.º 7
0
 public void PushData(string code)
 {
     code = code.Replace('\r', '\n');
     string[] lines = code.Split('\n');
     foreach (string line in lines)
     {
         if (line.Length == 0)
         {
             continue;
         }
         GCode gcode = new GCode();
         gcode.Parse(line);
         if (!gcode.comment)
         {
             jobList.AddLast(new GCodeCompressed(gcode));
             totalLines++;
         }
     }
 }
Ejemplo n.º 8
0
 public void PushGCodeShortArray(List <GCodeShort> codes)
 {
     foreach (GCodeShort line in codes)
     {
         if (line.Length == 0)
         {
             continue;
         }
         ana.analyzeShort(line);
         GCode gcode = new GCode();
         gcode.Parse(line.text);
         if (!gcode.comment)
         {
             jobList.AddLast(new GCodeCompressed(gcode));
             totalLines++;
         }
         if (line.hasLayer)
         {
             maxLayer = line.layer;
         }
     }
     computedPrintingTime = ana.printingTime;
 }