diff --git a/src/dialogs/connectsettingsdialog.cpp b/src/dialogs/connectsettingsdialog.cpp
index f0d537d..19fcec9 100644
--- a/src/dialogs/connectsettingsdialog.cpp
+++ b/src/dialogs/connectsettingsdialog.cpp
@@ -1,110 +1,111 @@
/* Atelier KDE Printer Host for 3D Printing
Copyright (C) <2016>
Author: Lays Rodrigues - laysrodrigues@gmail.com
Chris Rizzitello - rizzitello@kde.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#include "connectsettingsdialog.h"
#include
#include
#include
#include
#include
ConnectSettingsDialog::ConnectSettingsDialog(QWidget *parent) :
QDialog(parent),
atcore(new AtCore)
{
initDisplay();
initData();
setWindowTitle(i18n("Connect to Printer"));
atcore->setSerialTimerInterval(100);
connect(atcore, &AtCore::portsChanged, this, &ConnectSettingsDialog::updateSerialPort);
connect(buttonBox, &QDialogButtonBox::accepted, this, &ConnectSettingsDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &ConnectSettingsDialog::close);
}
void ConnectSettingsDialog::initDisplay()
{
serialPortCB = new QComboBox;
serialPortCB->setEditable(true);
QLabel *deviceLabel = new QLabel(i18n("Device"));
QHBoxLayout *deviceLayout = new QHBoxLayout;
deviceLayout->addWidget(deviceLabel);
deviceLayout->addWidget(serialPortCB);
deviceProfileCB = new QComboBox;
QHBoxLayout *profileLayout = new QHBoxLayout;
QLabel *profileLabel = new QLabel(i18n("Profile"));
profileLayout->addWidget(profileLabel);
profileLayout->addWidget(deviceProfileCB);
buttonBox = new QDialogButtonBox();
buttonBox->addButton(i18n("Connect"),QDialogButtonBox::AcceptRole);
buttonBox->addButton(QDialogButtonBox::Cancel);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(deviceLayout);
mainLayout->addLayout(profileLayout);
mainLayout->addWidget(buttonBox);
setLayout(mainLayout);
}
void ConnectSettingsDialog::initData()
{
settings.beginGroup("GeneralSettings");
QStringList profiles = settings.childGroups();
settings.endGroup();
deviceProfileCB->addItems(profiles);
}
void ConnectSettingsDialog::updateSerialPort(const QStringList &ports)
{
serialPortCB->clear();
if(!ports.isEmpty()) {
serialPortCB->addItems(ports);
}
}
QMap ConnectSettingsDialog::profileData()
{
QString profile = deviceProfileCB->currentText();
settings.beginGroup("GeneralSettings");
settings.beginGroup(profile);
QMap data;
data["bps"] = settings.value(QStringLiteral("bps"), QStringLiteral("115200"));
data["bedTemp"] = settings.value(QStringLiteral("maximumTemperatureBed"), QStringLiteral("0"));
data["hotendTemp"] = settings.value(QStringLiteral("maximumTemperatureExtruder"), QStringLiteral("0"));
data["firmware"] = settings.value(QStringLiteral("firmware"),QStringLiteral("Auto-Detect"));
+ data["postPause"] = settings.value(QStringLiteral("postPause"),QStringLiteral(""));
data["name"] = profile;
settings.endGroup();
settings.endGroup();
return data;
}
void ConnectSettingsDialog::accept()
{
if (deviceProfileCB->currentText().isEmpty()) {
QMessageBox::critical(this, i18n("Error"), i18n("Please, create a profile to connect on Settings!"));
return;
}
if (serialPortCB->currentText().isEmpty()) {
QMessageBox::critical(this, i18n("Error"), i18n("Please, connect a serial device to continue!"));
return;
}
emit startConnection(serialPortCB->currentText(), profileData());
close();
}
diff --git a/src/dialogs/profilesdialog.cpp b/src/dialogs/profilesdialog.cpp
index 3890fb2..712c803 100644
--- a/src/dialogs/profilesdialog.cpp
+++ b/src/dialogs/profilesdialog.cpp
@@ -1,237 +1,239 @@
/* Atelier KDE Printer Host for 3D Printing
Copyright (C) <2016>
Author: Lays Rodrigues - laysrodrigues@gmail.com
Chris Rizzitello - rizzitello@kde.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#include "profilesdialog.h"
#include "ui_profilesdialog.h"
#include
#include
#include
//Do not include for windows/mac os
#ifndef Q_OS_WIN
#ifndef Q_OS_MAC
#include
#endif
#endif
ProfilesDialog::ProfilesDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ProfilesDialog)
{
ui->setupUi(this);
ui->firmwareCB->addItem(QStringLiteral("Auto-Detect"));
ui->firmwareCB->addItems(detectFWPlugins());
ui->baudCB->addItems(SERIAL::BAUDS);
ui->baudCB->setCurrentText(QLatin1String("115200"));
ui->profileCB->setAutoCompletion(true);
connect(ui->profileCB, static_cast(&QComboBox::currentIndexChanged), [ = ] {
loadSettings();
});
updateCBProfiles();
connect(ui->buttonBox, &QDialogButtonBox::clicked, [ = ](QAbstractButton * btn) {
switch (ui->buttonBox->buttonRole(btn)) {
case QDialogButtonBox::ResetRole:
loadSettings();
break;
case QDialogButtonBox::RejectRole:
close();
break;
default:
break;
}
});
connect(ui->heatedBedCK, &QCheckBox::clicked, [ = ](const bool & status) {
ui->bedTempSB->setEnabled(status);
});
connect(ui->cartesianRB, &QRadioButton::clicked, [ = ]() {
ui->cartesianGB->setHidden(false);
ui->deltaGB->setHidden(true);
});
connect(ui->deltaRB, &QRadioButton::clicked, [ = ]() {
ui->cartesianGB->setHidden(true);
ui->deltaGB->setHidden(false);
});
connect(ui->removeProfilePB, &QPushButton::clicked, this, &ProfilesDialog::removeProfile);
#ifdef Q_OS_LINUX
ui->removeProfilePB->setIcon(QIcon::fromTheme("edit-delete"));
#else
ui->removeProfilePB->setIcon(style()->standardIcon(QStyle::SP_TrashIcon));
#endif
}
ProfilesDialog::~ProfilesDialog()
{
delete ui;
}
void ProfilesDialog::saveSettings()
{
settings.beginGroup(QStringLiteral("GeneralSettings"));
QStringList groups = settings.childGroups();
settings.endGroup();
QString currentProfile = ui->profileCB->currentText();
if (groups.contains(currentProfile)) {
int ret = QMessageBox::information(this, i18n("Save?"),
i18n("A profile with this name already exists. \n Are you sure you want to overwrite it?"),
QMessageBox::Save, QMessageBox::Cancel);
if (ret == QMessageBox::Cancel) {
return;
}
}
//Add indent to better view of the data
settings.beginGroup(QStringLiteral("GeneralSettings"));
settings.beginGroup(currentProfile);
//BED
if (ui->cartesianRB->isChecked()) {
settings.setValue(QStringLiteral("isCartesian"), true);
settings.setValue(QStringLiteral("dimensionX"), ui->x_dimensionSB->value());
settings.setValue(QStringLiteral("dimensionY"), ui->y_dimensionSB->value());
settings.setValue(QStringLiteral("dimensionZ"), ui->z_dimensionSB->value());
}
else {
settings.setValue(QStringLiteral("isCartesian"), false);
settings.setValue(QStringLiteral("radius"), ui->radiusSB->value());
settings.setValue(QStringLiteral("z_delta_dimension"), ui->z_dimensionSB->value());
}
settings.setValue(QStringLiteral("heatedBed"), ui->heatedBedCK->isChecked());
settings.setValue(QStringLiteral("maximumTemperatureBed"), ui->bedTempSB->value());
//HOTEND
settings.setValue(QStringLiteral("maximumTemperatureExtruder"), ui->extruderTempSB->value());
//Baud
settings.setValue(QStringLiteral("bps"), ui->baudCB->currentText());
settings.setValue(QStringLiteral("firmware"),ui->firmwareCB->currentText());
+ settings.setValue(QStringLiteral("postPause"), ui->postPauseLE->text());
settings.endGroup();
settings.endGroup();
//Load new profile
updateCBProfiles();
loadSettings(currentProfile);
emit updateProfiles();
}
void ProfilesDialog::loadSettings(const QString ¤tProfile)
{
settings.beginGroup(QStringLiteral("GeneralSettings"));
const QString profileName = currentProfile.isEmpty() ? ui->profileCB ->currentText() : currentProfile;
ui->profileCB->setCurrentText(profileName);
settings.beginGroup(profileName);
//BED
if (settings.value(QStringLiteral("isCartesian")).toBool()) {
ui->cartesianGB->setHidden(false);
ui->cartesianRB->setChecked(true);
ui->deltaRB->setChecked(false);
ui->deltaGB->setHidden(true);
ui->x_dimensionSB->setValue(settings.value(QStringLiteral("dimensionX"), QStringLiteral("0")).toInt());
ui->y_dimensionSB->setValue(settings.value(QStringLiteral("dimensionY"), QStringLiteral("0")).toInt());
ui->z_dimensionSB->setValue(settings.value(QStringLiteral("dimensionZ"), QStringLiteral("0")).toInt());
} else {
ui->deltaGB->setHidden(false);
ui->deltaRB->setChecked(true);
ui->cartesianRB->setChecked(false);
ui->cartesianGB->setHidden(true);
ui->radiusSB->setValue(settings.value(QStringLiteral("radius"), QStringLiteral("0")).toFloat());
ui->z_delta_dimensionSB->setValue(settings.value(QStringLiteral("z_delta_dimension"), QStringLiteral("0")).toFloat());
}
ui->heatedBedCK->setChecked(settings.value(QStringLiteral("heatedBed"), QStringLiteral("true")).toBool());
ui->bedTempSB->setEnabled(ui->heatedBedCK->isChecked());
ui->bedTempSB->setValue(settings.value(QStringLiteral("maximumTemperatureBed"), QStringLiteral("0")).toInt());
//HOTEND
ui->extruderTempSB->setValue(settings.value(QStringLiteral("maximumTemperatureExtruder"), QStringLiteral("0")).toInt());
//Baud
ui->baudCB->setCurrentText(settings.value(QStringLiteral("bps"), QStringLiteral("115200")).toString());
ui->firmwareCB->setCurrentText(settings.value(QStringLiteral("firmware"), QStringLiteral("Auto-Detect")).toString());
+ ui->postPauseLE->setText(settings.value(QStringLiteral("postPause"),QStringLiteral("")).toString());
settings.endGroup();
settings.endGroup();
}
void ProfilesDialog::updateCBProfiles()
{
settings.beginGroup(QStringLiteral("GeneralSettings"));
QStringList groups = settings.childGroups();
settings.endGroup();
if (groups.isEmpty()) {
ui->deltaGB->setHidden(true);
}
ui->profileCB->clear();
ui->profileCB->addItems(groups);
}
void ProfilesDialog::accept()
{
saveSettings();
}
void ProfilesDialog::removeProfile(){
QString currentProfile = ui->profileCB->currentText();
settings.beginGroup(QStringLiteral("GeneralSettings"));
settings.beginGroup(currentProfile);
settings.remove("");
settings.endGroup();
settings.remove(currentProfile);
settings.endGroup();
updateCBProfiles();
}
QStringList ProfilesDialog::detectFWPlugins() const
{
//Path used if for windows/ mac os only.
QDir pluginDir(qApp->applicationDirPath() + QStringLiteral("/plugins"));
#if defined(Q_OS_WIN)
pluginDir.setNameFilters(QStringList() << "*.dll");
#elif defined(Q_OS_MAC)
pluginDir.setNameFilters(QStringList() << "*.dylib");
#else //Not Windows || Not MAC
QStringList pathList = AtCoreDirectories::pluginDir;
pathList.append(QLibraryInfo::location(QLibraryInfo::PluginsPath) + QStringLiteral("/AtCore"));
for (const auto &path : pathList) {
if (QDir(path).exists()) {
//use path where plugins were detected.
pluginDir = QDir(path);
break;
}
}
pluginDir.setNameFilters(QStringList() << "*.so");
#endif
QStringList firmwares;
QStringList files = pluginDir.entryList(QDir::Files);
foreach (const QString &f, files) {
QString file = f;
file = file.split(QChar::fromLatin1('.')).at(0);
if (file.startsWith(QStringLiteral("lib"))) {
file = file.remove(QStringLiteral("lib"));
}
file = file.toLower().simplified();
firmwares.append(file);
}
return firmwares;
}
diff --git a/src/dialogs/profilesdialog.ui b/src/dialogs/profilesdialog.ui
index 305a937..f3f4524 100644
--- a/src/dialogs/profilesdialog.ui
+++ b/src/dialogs/profilesdialog.ui
@@ -1,358 +1,368 @@
ProfilesDialog
0
0
301
622
Profiles
-
-
Profile
-
&Cartesian
true
-
Printer Type
-
Delta
-
true
-
Remove Profile
2
-
-
Bits per second
-
-
0
0
0
General
-
Dimension
-
Dimension Z
-
Radius
-
mm
999999999
-
mm
999999999
-
Dimension
-
Dimension Z
-
Dimension Y
-
Dimension X
-
mm
999999999
-
mm
999999999
-
mm
999999999
-
Temperatures
-
Heated bed?
-
true
-
Maximum Bed
-
ºC
999
-
Maximum Hotend
-
ºC
999
Advanced
-
- -
+
+
-
Firmware
- -
+
-
- -
+
-
Qt::Vertical
20
40
+ -
+
+
+ PostPause
+
+
+
+ -
+
+
-
Qt::Horizontal
QDialogButtonBox::Close|QDialogButtonBox::Reset|QDialogButtonBox::Save
profileCB
cartesianRB
deltaRB
radiusSB
z_delta_dimensionSB
x_dimensionSB
y_dimensionSB
z_dimensionSB
heatedBedCK
bedTempSB
buttonBox
accepted()
ProfilesDialog
accept()
248
254
157
274
buttonBox
rejected()
ProfilesDialog
reject()
316
260
286
274
diff --git a/src/widgets/atcoreinstancewidget.cpp b/src/widgets/atcoreinstancewidget.cpp
index 0f7d3a8..5df8a1c 100644
--- a/src/widgets/atcoreinstancewidget.cpp
+++ b/src/widgets/atcoreinstancewidget.cpp
@@ -1,285 +1,290 @@
/* Atelier KDE Printer Host for 3D Printing
Copyright (C) <2017>
Author: Lays Rodrigues - laysrodriguessilva@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#include "atcoreinstancewidget.h"
#include "ui_atcoreinstancewidget.h"
#include
#include
#include
#include
AtCoreInstanceWidget::AtCoreInstanceWidget(QWidget *parent):
QWidget(parent)
{
ui = new Ui::AtCoreInstanceWidget;
ui->setupUi(this);
ui->printPB->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
ui->pausePB->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
ui->stopPB->setIcon(style()->standardIcon(QStyle::SP_MediaStop));
ui->disableMotorsPB->setIcon(style()->standardIcon(QStyle::SP_DockWidgetCloseButton));
ui->printProgressWidget->setVisible(false);
setupConnections();
enableControls(false);
}
void AtCoreInstanceWidget::setupConnections(){
connect(ui->pausePB, &QPushButton::clicked, this, &AtCoreInstanceWidget::pausePrint);
connect(ui->stopPB, &QPushButton::clicked, this, &AtCoreInstanceWidget::stopPrint);
connect(ui->disableMotorsPB, &QPushButton::clicked, this, &AtCoreInstanceWidget::disableMotors);
buildToolbar();
connect(ui->disconnectPB, &QPushButton::clicked, [ & ]{
m_core.setState(AtCore::DISCONNECTED);
});
}
AtCoreInstanceWidget::~AtCoreInstanceWidget()
{
delete ui;
}
void AtCoreInstanceWidget::buildToolbar()
{
toolBar = new QToolBar();
auto axis = new QAction("Axis");
axis->setCheckable(true);
axis->setChecked(true);
connect(axis, &QAction::toggled, ui->axisViewWidget, &AxisControl::setVisible);
auto controls = new QAction("Controls");
controls->setCheckable(true);
controls->setChecked(true);
connect(controls, &QAction::toggled, ui->bedExtWidget, &BedExtruderWidget::setVisible);
auto plot = new QAction("Temperature Plot");
plot->setCheckable(true);
plot->setChecked(true);
connect(plot, &QAction::toggled, ui->plotWidget, &PlotWidget::setVisible);
toolBar->addAction(axis);
toolBar->addAction(controls);
toolBar->addAction(plot);
ui->toolBarLayout->addWidget(new QLabel(i18n("Show/Hide: ")));
ui->toolBarLayout->addWidget(toolBar);
ui->toolBarLayout->addStretch();
}
-void AtCoreInstanceWidget::startConnection(const QString& serialPort, const QMap& profiles){
- m_core.initSerial(serialPort, profiles["bps"].toInt());
+void AtCoreInstanceWidget::startConnection(const QString& serialPort, const QMap& profile){
+ m_core.initSerial(serialPort, profile["bps"].toInt());
+ profileData = profile;
initConnectsToAtCore();
}
void AtCoreInstanceWidget::initConnectsToAtCore()
{
// Handle AtCore status change
connect(&m_core, &AtCore::stateChanged, this, &AtCoreInstanceWidget::handlePrinterStatusChanged);
// If the number of extruders from the printer change, we need to update the radiobuttons on the widget
connect(this, &AtCoreInstanceWidget::extruderCountChanged, ui->bedExtWidget, &BedExtruderWidget::setExtruderCount);
// Bed and Extruder temperatures management
connect(ui->bedExtWidget, &BedExtruderWidget::bedTemperatureChanged, &m_core, &AtCore::setBedTemp);
connect(ui->bedExtWidget, &BedExtruderWidget::extTemperatureChanged, &m_core, &AtCore::setExtruderTemp);
// Connect AtCore temperatures changes on Atelier Plot
connect(&m_core.temperature(), &Temperature::bedTemperatureChanged, [ & ](const float& temp) {
checkTemperature(0x00, 0, temp);
ui->plotWidget->appendPoint(i18n("Actual Bed"), temp);
ui->plotWidget->update();
ui->bedExtWidget->updateBedTemp(temp);
});
connect(&m_core.temperature(), &Temperature::bedTargetTemperatureChanged, [ & ](const float& temp) {
checkTemperature(0x01, 0, temp);
ui->plotWidget->appendPoint(i18n("Target Bed"), temp);
ui->plotWidget->update();
ui->bedExtWidget->updateBedTargetTemp(temp);
});
connect(&m_core.temperature(), &Temperature::extruderTemperatureChanged, [ & ](const float& temp) {
checkTemperature(0x02, 0, temp);
ui->plotWidget->appendPoint(i18n("Actual Ext.1"), temp);
ui->plotWidget->update();
ui->bedExtWidget->updateExtTemp(temp);
});
connect(&m_core.temperature(), &Temperature::extruderTargetTemperatureChanged, [ & ](const float& temp) {
checkTemperature(0x03, 0, temp);
ui->plotWidget->appendPoint(i18n("Target Ext.1"), temp);
ui->plotWidget->update();
ui->bedExtWidget->updateExtTargetTemp(temp);
});
connect(ui->pushGCodeWidget, &PushGCodeWidget::push, [ & ](QString command) {
ui->logWidget->addLog("Push " + command);
m_core.pushCommand(command);
});
// Fan, Flow and Speed management
connect(ui->ratesControlWidget, &RatesControlWidget::fanSpeedChanged, &m_core, &AtCore::setFanSpeed);
connect(ui->ratesControlWidget, &RatesControlWidget::flowRateChanged, &m_core, &AtCore::setFlowRate);
connect(ui->ratesControlWidget, &RatesControlWidget::printSpeedChanged, &m_core, &AtCore::setPrinterSpeed);
connect(ui->axisViewWidget, &AxisControl::clicked, this, &AtCoreInstanceWidget::axisControlClicked);
}
void AtCoreInstanceWidget::printFile(const QUrl& fileName)
{
if (!fileName.isEmpty() && (m_core.state() == AtCore::IDLE)) {
m_core.print(fileName.toLocalFile());
}
}
void AtCoreInstanceWidget::pausePrint()
{
- m_core.pause(QString());
+ if(m_core.state() == AtCore::BUSY) {
+ m_core.pause(profileData["postPause"].toString());
+ } else if (m_core.state() == AtCore::PAUSE) {
+ m_core.resume();
+ }
}
void AtCoreInstanceWidget::stopPrint()
{
m_core.stop();
}
void AtCoreInstanceWidget::disableMotors()
{
m_core.setIdleHold(0);
}
void AtCoreInstanceWidget::handlePrinterStatusChanged(AtCore::STATES newState)
{
static QString stateString;
switch (newState) {
case AtCore::CONNECTING: {
stateString = i18n("Connecting...");
connect(&m_core, &AtCore::receivedMessage, this, &AtCoreInstanceWidget::checkReceivedCommand);
connect(m_core.serial(), &SerialLayer::pushedCommand, this, &AtCoreInstanceWidget::checkPushedCommands);
} break;
case AtCore::IDLE: {
stateString = i18n("Connected to ") + m_core.serial()->portName();
emit extruderCountChanged(m_core.extruderCount());
ui->logWidget->addLog(i18n("Serial connected"));
ui->disconnectPB->setEnabled(true);
enableControls(true);
} break;
case AtCore::DISCONNECTED: {
stateString = i18n("Not Connected");
disconnect(&m_core, &AtCore::receivedMessage, this, &AtCoreInstanceWidget::checkReceivedCommand);
disconnect(m_core.serial(), &SerialLayer::pushedCommand, this, &AtCoreInstanceWidget::checkPushedCommands);
ui->logWidget->addLog(i18n("Serial disconnected"));
enableControls(false);
} break;
case AtCore::STARTPRINT: {
stateString = i18n("Starting Print");
ui->printProgressWidget->setVisible(true);
connect(&m_core, &AtCore::printProgressChanged, ui->printProgressWidget, &PrintProgressWidget::updateProgressBar);
} break;
case AtCore::FINISHEDPRINT: {
stateString = i18n("Finished Print");
ui->printProgressWidget->setVisible(false);
disconnect(&m_core, &AtCore::printProgressChanged, ui->printProgressWidget, &PrintProgressWidget::updateProgressBar);
} break;
case AtCore::BUSY: {
stateString = i18n("Printing");
ui->disconnectPB->setDisabled(true);
} break;
case AtCore::PAUSE: {
stateString = i18n("Paused");
} break;
case AtCore::STOP: {
stateString = i18n("Stoping Print");
} break;
case AtCore::ERRORSTATE: {
stateString = i18n("Error");
} break;
default:
qWarning("AtCore State not Recognized.");
break;
}
ui->lblState->setText(stateString);
}
void AtCoreInstanceWidget::checkTemperature(uint sensorType, uint number, uint temp)
{
static QString msg;
switch (sensorType) {
case 0x00: // bed
msg = QString::fromLatin1("Bed Temperature ");
break;
case 0x01: // bed target
msg = QString::fromLatin1("Bed Target Temperature ");
break;
case 0x02: // extruder
msg = QString::fromLatin1("Extruder Temperature ");
break;
case 0x03: // extruder target
msg = QString::fromLatin1("Extruder Target Temperature ");
break;
case 0x04: // enclosure
msg = QString::fromLatin1("Enclosure Temperature ");
break;
case 0x05: // enclosure target
msg = QString::fromLatin1("Enclosure Target Temperature ");
break;
}
msg.append(QString::fromLatin1("[%1] : %2"));
msg = msg.arg(QString::number(number))
.arg(QString::number(temp));
ui->logWidget->addRLog(msg);
}
void AtCoreInstanceWidget::checkReceivedCommand(const QByteArray &message)
{
ui->logWidget->addRLog(QString::fromUtf8(message));
}
void AtCoreInstanceWidget::checkPushedCommands(const QByteArray &bmsg)
{
QString msg = QString::fromUtf8(bmsg);
QRegExp _newLine(QChar::fromLatin1('\n'));
QRegExp _return(QChar::fromLatin1('\r'));
msg.replace(_newLine, QStringLiteral("\\n"));
msg.replace(_return, QStringLiteral("\\r"));
ui->logWidget->addSLog(msg);
}
void AtCoreInstanceWidget::axisControlClicked(QChar axis, int value)
{
m_core.setRelativePosition();
m_core.pushCommand(GCode::toCommand(GCode::G1, QStringLiteral("%1%2").arg(axis, QString::number(value))));
m_core.setAbsolutePosition();
}
void AtCoreInstanceWidget::enableControls(bool b)
{
ui->mainTab->setEnabled(b);
ui->printPB->setEnabled(b);
ui->pausePB->setEnabled(b);
ui->stopPB->setEnabled(b);
ui->disconnectPB->setEnabled(b);
ui->disableMotorsPB->setEnabled(b);
toolBar->setEnabled(b);
}
bool AtCoreInstanceWidget::connected()
{
return (m_core.state() != AtCore::DISCONNECTED);
}
diff --git a/src/widgets/atcoreinstancewidget.h b/src/widgets/atcoreinstancewidget.h
index d19d43e..afd84a9 100644
--- a/src/widgets/atcoreinstancewidget.h
+++ b/src/widgets/atcoreinstancewidget.h
@@ -1,70 +1,71 @@
/* Atelier KDE Printer Host for 3D Printing
Copyright (C) <2017>
Author: Lays Rodrigues - laysrodriguessilva@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#pragma once
#include
#include
#include
#include
namespace Ui
{
class AtCoreInstanceWidget;
}
/**
* @todo write docs
*/
class AtCoreInstanceWidget : public QWidget
{
Q_OBJECT
public:
/**
* Default constructor
*/
AtCoreInstanceWidget(QWidget* parent = nullptr);
/**
* Destructor
*/
~AtCoreInstanceWidget();
- void startConnection(const QString& serialPort, const QMap& profiles);
+ void startConnection(const QString& serialPort, const QMap& profile);
bool connected();
private:
Ui::AtCoreInstanceWidget* ui;
AtCore m_core;
QToolBar *toolBar;
+ QMap profileData;
void initConnectsToAtCore();
void printFile(const QUrl& fileName);
void pausePrint();
void stopPrint();
void disableMotors();
void checkReceivedCommand(const QByteArray &message);
void checkPushedCommands(const QByteArray &bmsg);
void handlePrinterStatusChanged(AtCore::STATES newState);
void checkTemperature(uint sensorType, uint number, uint temp);
void axisControlClicked(QChar axis, int value);
void enableControls(bool b);
void buildToolbar();
void setupConnections();
signals:
void extruderCountChanged(int count);
};