コード例 #1
0
        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"));
                }
            }
        }
コード例 #2
0
 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"));
             }
         }
     }
 }
コード例 #3
0
ファイル: GCodeFileWriter.cs プロジェクト: urish/M3D
 public bool Write(GCode code)
 {
     try
     {
         if (m_bIsBinaryMode)
         {
             writeBinary.Write(code.getBinary(2));
         }
         else
         {
             writeAscii.WriteLine(code.getAscii(false, false));
         }
     }
     catch (Exception ex)
     {
         ErrorLogger.LogErrorMsg("Exception in GCodeWriter.Write " + ex.Message, "Exception");
         return(false);
     }
     return(true);
 }