Example #1
0
void Worker::commandReceived(const QByteArray command)
{
    if (m_currentState == StoppedState)
    {
        return;
    }

    if (command == "ok")
    {
        m_waitingCount--;
        emit currentLineChanged(m_currentLine - m_waitingCount + 1);

        if (m_waitingCount < m_bufferSize)
        {
            if ((m_currentLine < m_commandList.size())
                    && (m_currentState == RunningState)) // a new command needs to be sent
            {
                sendLine();
            }
        }

        if ((m_waitingCount == 0)
                && (m_currentLine == m_commandList.size())) // we have finished
        {
            stopQueue();
            m_currentState = StoppedState;
            emit currentStateChanged(m_currentState);
            emit finished();
        }
    }
}
Example #2
0
void Worker::sendLine()
{
    QString line;
    bool running = true;

    while (running)
    {
        if (m_currentLine == m_commandList.size())
        {
            return;
        }

        line = m_commandList.at(m_currentLine);

        if ((line.indexOf("G00") == 0) || (line.indexOf("G01") == 0)) // only G00 and G01 allowed
        {
            running = false;
        }

        if (running == false)
        {
            sendCommand(line.toLocal8Bit() + "\n");
        }

        m_currentLine++;
        emit currentLineChanged(m_currentLine - m_waitingCount + 1);

        qDebug() << line;
    }
}
Example #3
0
void Worker::usbDisconnected()
{
    m_currentLine = -1;
    m_currentState = StoppedState;
    m_ready = false;
    emit readyChanged(m_ready);
    emit currentLineChanged(m_currentLine);
    emit currentStateChanged(m_currentState);
}
Example #4
0
/**
 * Emit the line change signal for the give line no
 * @param lineNo The line number to flag
 * @param error True if it is an error
 */
void PythonScript::sendLineChangeSignal(int lineNo, bool error) {
  emit currentLineChanged(lineNo, error);
}