Echo on/off

Protocol perfomance tweaks
This commit is contained in:
NeoTheFox 2015-03-03 22:33:44 +03:00
parent caf9a47fb9
commit 983aed1916
4 changed files with 50 additions and 38 deletions

View File

@ -34,15 +34,18 @@ MainWindow::MainWindow(QWidget *parent) :
checkingTemperature = settings.value("core/checktemperature").toBool(); checkingTemperature = settings.value("core/checktemperature").toBool();
ui->checktemp->setChecked(checkingTemperature); ui->checktemp->setChecked(checkingTemperature);
if(!firstrun) echo = settings.value("core/echo").toBool();
else echo = false;
sending = false; sending = false;
paused = false; paused = false;
commandDone = false;
injectingCommand = false; injectingCommand = false;
readingFiles = false; readingFiles = false;
sdprinting = false; sdprinting = false;
sdBytes = 0; sdBytes = 0;
userCommand = ""; userCommand = "";
currentLine = 0; currentLine = 0;
readyRecieve = 0;
serialupdate(); serialupdate();
@ -143,13 +146,10 @@ bool MainWindow::sendLine(QString line)
{ {
if(printer.write(line.toUtf8()+'\n')) if(printer.write(line.toUtf8()+'\n'))
{ {
printMsg(line + '\n'); if(echo) printMsg(line + '\n');
return true; return true;
} }
else else return false;
{
return false;
}
} }
else return false; else return false;
@ -208,7 +208,6 @@ void MainWindow::serialconnect()
ui->progressBar->setValue(0); ui->progressBar->setValue(0);
ui->controlBox->setDisabled(false); ui->controlBox->setDisabled(false);
ui->consoleGroup->setDisabled(false); ui->consoleGroup->setDisabled(false);
commandDone = true;
if(checkingTemperature) injectCommand("M105"); if(checkingTemperature) injectCommand("M105");
} }
} }
@ -380,7 +379,8 @@ void MainWindow::readSerial()
} }
} }
if(data.startsWith("ok") || data.startsWith("wait")) commandDone = true; //Can send next command if(data.startsWith("ok")) readyRecieve++;
else if(data.startsWith("wait")) readyRecieve = 1;
else if(checkingTemperature && data.startsWith("T:")) else if(checkingTemperature && data.startsWith("T:"))
{ {
QFuture<TemperatureReadings> parseThread = QtConcurrent::run(this, &MainWindow::parseStatus, data); QFuture<TemperatureReadings> parseThread = QtConcurrent::run(this, &MainWindow::parseStatus, data);
@ -393,7 +393,7 @@ void MainWindow::readSerial()
if(currentLine < 0) currentLine = 0; if(currentLine < 0) currentLine = 0;
} }
else if(data.startsWith("Done")) sdprinting = false; else if(data.startsWith("Done")) sdprinting = false;
else if(data.startsWith("SD printing byte")) else if(data.startsWith("SD printing byte") && sdWatcher.isFinished())
{ {
QFuture<double> parseSDThread = QtConcurrent::run(this, &MainWindow::parseSDStatus, data); QFuture<double> parseSDThread = QtConcurrent::run(this, &MainWindow::parseSDStatus, data);
sdWatcher.setFuture(parseSDThread); sdWatcher.setFuture(parseSDThread);
@ -465,14 +465,14 @@ void MainWindow::on_sendBtn_clicked()
void MainWindow::sendNext() void MainWindow::sendNext()
{ {
if(injectingCommand && printer.isWritable() && commandDone) if(injectingCommand && printer.isWritable() && readyRecieve > 0)
{ {
sendLine(userCommand); sendLine(userCommand);
commandDone=false; readyRecieve--;
injectingCommand=false; injectingCommand=false;
return; return;
} }
else if(sending && !paused && commandDone && !sdprinting && printer.isWritable()) else if(sending && !paused && readyRecieve > 0 && !sdprinting && printer.isWritable())
{ {
if(currentLine >= gcode.size()) //check if we are at the end of array if(currentLine >= gcode.size()) //check if we are at the end of array
{ {
@ -485,7 +485,7 @@ void MainWindow::sendNext()
} }
sendLine(gcode.at(currentLine)); sendLine(gcode.at(currentLine));
currentLine++; currentLine++;
commandDone = false; readyRecieve--;
ui->filelines->setText(QString::number(gcode.size()) + QString("/") + QString::number(currentLine) + QString(" Lines")); ui->filelines->setText(QString::number(gcode.size()) + QString("/") + QString::number(currentLine) + QString(" Lines"));
ui->progressBar->setValue(((float)currentLine/gcode.size()) * 100); ui->progressBar->setValue(((float)currentLine/gcode.size()) * 100);

View File

@ -58,12 +58,13 @@ private:
bool firstrun; bool firstrun;
bool sending; bool sending;
bool paused; bool paused;
bool commandDone;
bool checkingTemperature; bool checkingTemperature;
bool injectingCommand; bool injectingCommand;
bool readingFiles; bool readingFiles;
bool sdprinting; bool sdprinting;
bool echo;
int currentLine; int currentLine;
int readyRecieve;
double sdBytes; double sdBytes;
QString userCommand; QString userCommand;

View File

@ -10,6 +10,9 @@ SettingsWindow::SettingsWindow(QWidget *parent) :
if(!settings.value("core/firstrun").toBool()) ui->senderbox->setValue(4); if(!settings.value("core/firstrun").toBool()) ui->senderbox->setValue(4);
else ui->senderbox->setValue(settings.value("core/senderinterval").toFloat()); else ui->senderbox->setValue(settings.value("core/senderinterval").toFloat());
if(!settings.value("core/firstrun").toBool()) ui->echobox->setChecked(false);
else ui->echobox->setChecked(settings.value("core/echo").toBool());
if(settings.value("core/statusinterval").toInt()) ui->statusbox->setValue(settings.value("core/statusinterval").toInt()); if(settings.value("core/statusinterval").toInt()) ui->statusbox->setValue(settings.value("core/statusinterval").toInt());
else ui->statusbox->setValue(1500); else ui->statusbox->setValue(1500);
@ -32,4 +35,5 @@ void SettingsWindow::on_buttonBox_accepted()
settings.setValue("core/statusinterval", ui->statusbox->value()); settings.setValue("core/statusinterval", ui->statusbox->value());
settings.setValue("printer/bedy", ui->bedybox->value()); settings.setValue("printer/bedy", ui->bedybox->value());
settings.setValue("printer/bedx", ui->bedxbox->value()); settings.setValue("printer/bedx", ui->bedxbox->value());
settings.setValue("core/echo", ui->echobox->isChecked());
} }

View File

@ -29,17 +29,17 @@
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property> </property>
</widget> </widget>
<widget class="QGroupBox" name="intervalsGroup"> <widget class="QGroupBox" name="internalGroup">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>10</y> <y>10</y>
<width>201</width> <width>171</width>
<height>96</height> <height>123</height>
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
<string>Intervals</string> <string>Internal</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">
@ -49,6 +49,28 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="senderbox">
<property name="toolTip">
<string>A good default is 2, lower = fater, higher = less CPU load. 0 would execute as soon as possible.</string>
</property>
<property name="toolTipDuration">
<number>-1</number>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>999.990000000000009</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
@ -86,25 +108,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="2" column="0" colspan="3">
<widget class="QDoubleSpinBox" name="senderbox"> <widget class="QCheckBox" name="echobox">
<property name="toolTip"> <property name="text">
<string>A good default is 2, lower = fater, higher = less CPU load. 0 would execute as soon as possible.</string> <string>Echo commands</string>
</property>
<property name="toolTipDuration">
<number>-1</number>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>999.990000000000009</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
@ -114,7 +121,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>110</y> <y>130</y>
<width>201</width> <width>201</width>
<height>66</height> <height>66</height>
</rect> </rect>