コード例 #1
0
ファイル: GCodeVisual.cs プロジェクト: lanthan/Repetier-Host
        public void ParseText(string text, bool clear)
        {
            GCode gc = new GCode();

            if (clear)
            {
                Clear();
            }
            foreach (string s in text.Split('\n'))
            {
                gc.Parse(s);
                AddGCode(gc);
            }
        }
コード例 #2
0
ファイル: Printjob.cs プロジェクト: yikuaiyu/Repetier-Host
 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);
         jobList.AddLast(gcode);
         totalLines++;
     }
 }
コード例 #3
0
        /// <summary>
        /// Send a print command, that does not belong to a print job.
        /// </summary>
        /// <param name="command">GCode command</param>
        public void injectManualCommand(string command)
        {
            GCode gc = new GCode();

            gc.Parse(command);
            lock (history)
                injectCommands.AddLast(gc);
            if (job.dataComplete == false)
            {
                if (injectCommands.Count == 0)
                {
                    firePrinterAction("Idle");
                }
                else
                {
                    firePrinterAction(injectCommands.Count.ToString() + " commands waiting");
                }
            }
        }
コード例 #4
0
ファイル: Printjob.cs プロジェクト: cakeller98/Repetier-Host
 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(gcode);
             totalLines++;
         }
         if (line.hasLayer)
         {
             maxLayer = line.layer;
         }
     }
     computedPrintingTime = ana.printingTime;
 }
コード例 #5
0
ファイル: StoreCode.cs プロジェクト: JackTing/Repetier-Host
 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"));
         }
     }
 }
コード例 #6
0
 public void open()
 {
     if (writeThread == null)
     {
         writeThread = new Thread(new ThreadStart(this.WriteLoop));
         writeThread.Start();
     }
     isMarlin = isRepetier = false;
     try
     {
         if (port.ToLower().Equals("virtual printer"))
         {
             isVirtualActive = true;
             virtualPrinter.open();
             GCode gc = new GCode();
             gc.Parse("M105");
             virtualPrinter.receiveLine(gc);
             connected = true;
             if (transferProtocol < 2)
                 binaryVersion = 0;
             else binaryVersion = transferProtocol - 1;
             readyForNextSend = true;
             nackLines.Clear();
             ignoreNextOk = false;
             linesSend = errorsReceived = bytesSend = 0;
             gc.Parse("N0 M110");
             virtualPrinter.receiveLine(gc);
             gc.Parse("M115");
             virtualPrinter.receiveLine(gc);
             gc.Parse("M105");
             virtualPrinter.receiveLine(gc);
             if (eventConnectionChange != null)
                 eventConnectionChange(Trans.T("L_CONNECTED"));
             Main.main.Invoke(Main.main.UpdateJobButtons);
             return;
         }
         isVirtualActive = false;
         if (Main.IsMono)
             serial = new SerialPort();
         else
             serial = new ProtectedSerialPort();
         garbageCleared = false;
         serial.PortName = port;
         serial.BaudRate = baud;
         serial.Parity = parity;
         serial.DataBits = databits;
         serial.StopBits = stopbits;
         if (!Main.IsMono)
             serial.DataReceived += received;
         serial.ErrorReceived += error;
         serial.RtsEnable = false;
         serial.DtrEnable = false;
         serial.Open();
       //  serial.DtrEnable = true;
      //   Thread.Sleep(400);
      //   serial.DtrEnable = false;
         // If we didn't restart the connection we need to eat
         // all unread data on this port.
         serial.DiscardInBuffer();
         /*while(serial.BytesToRead > 0)
         {
             string indata = serial.ReadExisting();
         }*/
         serial.WriteLine("M105");
         connected = true;
         if (transferProtocol < 2)
             binaryVersion = 0;
         else binaryVersion = transferProtocol - 1;
         readyForNextSend = true;
         nackLines.Clear();
         ignoreNextOk = false;
         linesSend = errorsReceived = bytesSend = 0;
         if (readThread == null && Main.IsMono)
         {
             readThread = new Thread(new ThreadStart(this.ReadThread));
             readThread.Start();
         }
         GetInjectLock();
         injectManualCommand("N0 M110"); // Make sure we tal about the same linenumbers
         injectManualCommand("M115"); // Check firmware
         injectManualCommand("M105"); // Read temperature
         ReturnInjectLock();
         if (eventConnectionChange != null)
             eventConnectionChange(Trans.T("L_CONNECTED"));
         Main.main.Invoke(Main.main.UpdateJobButtons);
     }
     catch (IOException ex)
     {
         serial = null;
         log(ex.Message, true, 2);
         if (eventConnectionChange != null)
             eventConnectionChange(Trans.T("L_CONNECTION_ERROR")); // "Conn. error");
         RepetierHost.view.SoundConfig.PlayError(false);
     }
 }
コード例 #7
0
 public void injectManualCommandFirst(string command)
 {
     GCode gc = new GCode();
     gc.Parse(command);
     if (gc.comment) return;
     lock (history)
         injectCommands.AddFirst(gc);
     if (job.dataComplete == false)
     {
         if (injectCommands.Count == 0)
         {
             firePrinterAction(Trans.T("L_IDLE"));
         }
         else
         {
             firePrinterAction(Trans.T1("L_X_COMMANDS_WAITING", injectCommands.Count.ToString()));
         }
     }
 }
コード例 #8
0
ファイル: StoreCode.cs プロジェクト: neo3000/Repetier-Host
 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"));
     }
 }
コード例 #9
0
 /// <summary>
 /// Send a print command, that does not belong to a print job.
 /// </summary>
 /// <param name="command">GCode command</param>
 public void injectManualCommand(string command)
 {
     GCode gc = new GCode();
     gc.Parse(command);
     lock(history)
         injectCommands.AddLast(gc);
     if (job.dataComplete == false)
     {
         if (injectCommands.Count == 0)
         {
             firePrinterAction("Idle");
         }
         else
         {
             firePrinterAction(injectCommands.Count.ToString() + " commands waiting");
         }
     }
 }
コード例 #10
0
ファイル: Printjob.cs プロジェクト: neo3000/Repetier-Host
 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;
 }
コード例 #11
0
ファイル: Printjob.cs プロジェクト: neo3000/Repetier-Host
 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++;
         }
     }
 }
コード例 #12
0
ファイル: GCodeVisual.cs プロジェクト: neo3000/Repetier-Host
 public void ParseText(string text, bool clear)
 {
     GCode gc = new GCode();
     if (clear)
         Clear();
     foreach (string s in text.Split('\n'))
     {
         gc.Parse(s);
         AddGCode(gc);
     }
 }
コード例 #13
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;
 }
コード例 #14
0
ファイル: Printjob.cs プロジェクト: rkoeppl/Repetier-Host
 public void PushGCodeShortArray(List<GCodeShort> codes)
 {
     foreach (GCodeShort line in codes)
     {
         if (line.Length == 0) continue;
         GCode gcode = new GCode();
         gcode.Parse(line.text);
         if (!gcode.comment)
         {
             jobList.AddLast(gcode);
             totalLines++;
         }
         if (line.hasLayer)
             maxLayer = line.layer;
     }
 }