示例#1
0
    public void ReadCommandList()
    {
        foreach (string commandLine in commandList)
        {
            String[] cmds = commandLine.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
            if (cmds.Length == 0)
            {
                continue;
            }
            foreach (string cmd in cmds)
            {
                ReadCommand(cmd);
            }

            if (modalGroupQueue.Count == 0)
            {
                SendCNCInstruction(CNCInstruction.GCode2ModalGroup(gCode));
            }
            while (modalGroupQueue.Count != 0)
            {
                SendCNCInstruction(modalGroupQueue.Dequeue());
            }
            ResetNonModal();
        }
    }
示例#2
0
    private void ReadCommand(string cmd)
    {
        if (cmd.Length == 0)
        {
            return;
        }
        switch (cmd[0])
        {
        case 'N':
            if (isFirstCommand)
            {
                line++;
                isFirstCommand = false;
                break;
            }
            int num = int.Parse(cmd.Substring(1));
            if (++line != num)
            {
                print("Expected line number (N" + line + ") mismatched with the input line number (" + cmd + "), changed line number to " + cmd);
                line = num;
            }
            break;

        case 'G':
            gCode = int.Parse(cmd.Substring(1));
            int group = CNCInstruction.GCode2ModalGroup(gCode);
            modalGroupQueue.Enqueue(group);
            gCodeForEachGroup[group] = gCode;
            break;

        case 'F':
            feedRate = float.Parse(cmd.Substring(1));
            break;

        case 'S':
            spindleSpeed = float.Parse(cmd.Substring(1));
            break;

        case 'T':
            tool = int.Parse(cmd.Substring(1));
            break;

        case 'M':
            miscFunc = int.Parse(cmd.Substring(1));
            break;

        case 'X':
            posX = float.Parse(cmd.Substring(1));
            break;

        case 'Y':
            posY = float.Parse(cmd.Substring(1));
            break;

        case 'Z':
            posZ = float.Parse(cmd.Substring(1));
            break;

        case 'I':
            posI = float.Parse(cmd.Substring(1));
            break;

        case 'J':
            posJ = float.Parse(cmd.Substring(1));
            break;

        case 'K':
            posK = float.Parse(cmd.Substring(1));
            break;

        default:
            print("Unknown '" + cmd + "' command at line " + line + ", skipped this command.");
            if (DebugVR != null)
            {
                DebugVR.Println("Unknown '" + cmd + "' command at line " + line + ", skipped this command.");
            }
            break;
        }
    }