Package com.willwinder.universalgcodesender.types

Examples of com.willwinder.universalgcodesender.types.GcodeCommand


    /**
     * Creates a gcode command and queues it for send immediately.
     * Note: this is the only place where a string is sent to the comm.
     */
    public void queueStringForComm(String str) throws Exception {
        GcodeCommand command = this.commandCreator.createCommand(str);
        this.outgoingQueue.add(command);

        this.commandQueued(command);
        this.sendStringToComm(command.getCommandString());
    }
View Full Code Here


       
        // TODO: Expand this to handle canned cycles (Issue#49)
        List<String> processed = gcp.preprocessCommand(commandString);

        for (String s : processed) {
            GcodeCommand command = this.commandCreator.createCommand(s);
            this.prepQueue.add(command);
        }       
    }
View Full Code Here

        }       
    }

    public void appendGcodeCommands(Iterable<String> commandStrings) throws Exception{
        for (String s : commandStrings) {
            GcodeCommand command = this.commandCreator.createCommand(s);
            this.prepQueue.add(command);
        }
    }
View Full Code Here

        this.numCommandsSkipped = 0;
        this.numCommandsCompleted = 0;

        try {
            // Send all queued commands and wait for a response.
            GcodeCommand command;
            while (this.prepQueue.size() > 0) {
                numCommandsStreamed++;
                command = this.prepQueue.remove();
                if (this.saveToFileMode) {
                    this.outputFileWriter.println(command.getCommandString());
                } else {
                    queueCommandForComm(command);
                }
            }
           
View Full Code Here

    public void commandSent(String command) {
        if (this.isStreamingFile()) {
            this.numCommandsSent++;
        }

        GcodeCommand c = this.outgoingQueue.remove();
        c.setSent(true);
       
        if (!c.getCommandString().equals(command)) {
            this.errorMessageForConsole("Command <"+c.getCommandString()+
                    "> does not equal expected command <"+command+">");
        }

        this.awaitingResponseQueue.add(c);
       
View Full Code Here

   
    /**
     * Notify controller that the next command has completed with response.
     */
    public void commandComplete(String response) throws Exception {
        GcodeCommand command = this.awaitingResponseQueue.peek();
        if (command == null) {
            command = new GcodeCommand("");
        }
        command.setResponse(response);
        this.commandComplete(command);
    }
View Full Code Here

   
    /**
     * Internal command complete has extra handling for skipped command case.
     */
    private void commandComplete(GcodeCommand command) throws Exception {
        GcodeCommand c = command;

        // If the command wasn't sent, it was skipped and should be ignored
        // from the remaining queues.
        if (!command.isSkipped()) {
            if (this.awaitingResponseQueue.size() == 0) {
                throw new Exception("Attempting to complete a command that "
                        + "doesn't exist: <" + command.toString() + ">");
            }
           
            c = this.awaitingResponseQueue.remove();
            c.setResponse(command.getResponse());
            this.completedCommandList.add(c);
           
            if (this.isStreamingFile()) {
                // Peek to see if the currently processing command has a comment.
                GcodeCommand next = this.awaitingResponseQueue.peek();
                if (next != null && next.hasComment()) {
                    dispatchCommandCommment(next.getComment());
                }
                this.numCommandsCompleted++;
            }
        } else {
            if (this.isStreamingFile()) {
View Full Code Here

    public int nextCommandNum() {
        return this.numCommands;
    }
   
    public GcodeCommand createCommand(String commandString) throws Exception {
        GcodeCommand gc = new GcodeCommand(commandString, this.numCommands++);
       
        if (gc.getCommandString().length() > this.maxCommandLength) {
            throw new Exception(
                    String.format("Command #%d too long: (%d > %d) '%s'",
                            this.numCommands, commandString.length(), maxCommandLength, commandString));
        }
       
View Full Code Here

       
        return this.currentCommand();
    }
   
    public GcodeCommand appendCommandString(String commandString) {
        GcodeCommand command = new GcodeCommand(commandString);
        command.setCommandNumber(this.numCommands++);
        this.commandQueue.add(command);
       
        // Preload first command, or next command if the first batch finished.
        if (this.currentCommand == null || this.currentCommand.isSent()) {
            this.nextCommand();
View Full Code Here

     * Synchronized because this list is frequently modified through events,
     * especially at the beginning of a file transfer.
     */
    static synchronized protected int getSizeOfBuffer(List<GcodeCommand> list) {
        int characters = 0;
        GcodeCommand command;
        // Number of characters in list.
        Iterator<GcodeCommand> iter = list.iterator();
        while (iter.hasNext()) {
            command = iter.next();
            String next = command.getCommandString();
            // TODO: Carefully trace the newlines in commands and make sure
            //       the GRBL_RX_BUFFER_SIZE is honored.
            //       For now add a safety character to each command.
            characters += next.length() + 1;
        }
View Full Code Here

TOP

Related Classes of com.willwinder.universalgcodesender.types.GcodeCommand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.