Skip to content

Commit

Permalink
Integrated DLTMultimeter
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmucde committed Jul 9, 2021
1 parent ab192fe commit 22889b8
Show file tree
Hide file tree
Showing 11 changed files with 620 additions and 140 deletions.
2 changes: 2 additions & 0 deletions DLTPower.pro
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CONFIG += c++11
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
dltlultimeter.cpp \
dltminiserver.cpp \
dltrelais.cpp \
main.cpp \
Expand All @@ -18,6 +19,7 @@ SOURCES += \
HEADERS += \
dialog.h \
dltminiserver.h \
dltmultimeter.h \
dltrelais.h \
settingsdialog.h \
version.h
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Github Sponsors:
v0.0.4:

* Rename from DLTRelais to DLTPower
* Integrate DLTMUltimeter

v0.0.3:

Expand Down
59 changes: 55 additions & 4 deletions dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ Dialog::Dialog(bool autostart,QString configuration,QWidget *parent)

// connect status slots
connect(&dltRelais, SIGNAL(status(QString)), this, SLOT(statusRelais(QString)));
connect(&dltMultimeter, SIGNAL(status(QString)), this, SLOT(statusMultimeter(QString)));
connect(&dltMiniServer, SIGNAL(status(QString)), this, SLOT(statusDlt(QString)));

//connect value slots from Multimeter
connect(&dltMultimeter, SIGNAL(valueMultimeter(QString,QString)), this, SLOT(valueMultimeter(QString,QString)));

// load global settings from registry
QSettings settings;
QString filename = settings.value("autoload/filename").toString();
Expand All @@ -54,6 +58,7 @@ Dialog::Dialog(bool autostart,QString configuration,QWidget *parent)
if(autoload)
{
dltRelais.readSettings(filename);
dltMultimeter.readSettings(filename);
dltMiniServer.readSettings(filename);
restoreSettings();
}
Expand All @@ -62,6 +67,7 @@ Dialog::Dialog(bool autostart,QString configuration,QWidget *parent)
if(!configuration.isEmpty())
{
dltRelais.readSettings(configuration);
dltMultimeter.readSettings(configuration);
dltMiniServer.readSettings(configuration);
restoreSettings();
}
Expand All @@ -76,10 +82,13 @@ Dialog::Dialog(bool autostart,QString configuration,QWidget *parent)
Dialog::~Dialog()
{

// disconnect status slots
// disconnect all slots
disconnect(&dltRelais, SIGNAL(status(QString)), this, SLOT(statusRelais(QString)));
disconnect(&dltMiniServer, SIGNAL(status(QString)), this, SLOT(statusDlt(QString)));

disconnect(&dltMultimeter, SIGNAL(status(QString)), this, SLOT(statusMultimeter(QString)));
disconnect(&dltMultimeter, SIGNAL(valueMultimeter(QString,QString)), this, SLOT(valueMultimeter(QString,QString)));

delete ui;
}

Expand All @@ -105,6 +114,7 @@ void Dialog::on_pushButtonStart_clicked()

// start Relais and DLT communication
dltRelais.start();
dltMultimeter.start();
dltMiniServer.start();

// disable settings and start button
Expand All @@ -122,6 +132,7 @@ void Dialog::on_pushButtonStop_clicked()

// stop Relais and DLT communication
dltRelais.stop();
dltMultimeter.stop();
dltMiniServer.stop();

// enable settings and start button
Expand Down Expand Up @@ -224,6 +235,36 @@ void Dialog::statusRelais(QString text)
}
}

void Dialog::statusMultimeter(QString text)
{
ui->lineEditStatusMultimeter->setText(text);

if(text == "" || text == "stopped")
{
QPalette palette;
palette.setColor(QPalette::Base,Qt::white);
ui->lineEditStatusMultimeter->setPalette(palette);
}
if(text == "reconnect")
{
QPalette palette;
palette.setColor(QPalette::Base,Qt::yellow);
ui->lineEditStatusMultimeter->setPalette(palette);
}
if(text == "started")
{
QPalette palette;
palette.setColor(QPalette::Base,Qt::green);
ui->lineEditStatusMultimeter->setPalette(palette);
}
if(text == "error")
{
QPalette palette;
palette.setColor(QPalette::Base,Qt::red);
ui->lineEditStatusMultimeter->setPalette(palette);
}
}

void Dialog::statusDlt(QString text)
{
// status from DLT Mini Server
Expand Down Expand Up @@ -369,6 +410,7 @@ void Dialog::on_pushButtonDefaultSettings_clicked()
// Reset settings to default
dltRelais.clearSettings();
dltMiniServer.clearSettings();
dltMultimeter.clearSettings();

restoreSettings();
}
Expand All @@ -378,7 +420,7 @@ void Dialog::on_pushButtonLoadSettings_clicked()
// Load settings from XML file

QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Settings"), "", tr("DLTRelais Settings (*.xml);;All files (*.*)"));
tr("Open Settings"), "", tr("DLTPower Settings (*.xml);;All files (*.*)"));

if(fileName.isEmpty())
{
Expand All @@ -388,6 +430,7 @@ void Dialog::on_pushButtonLoadSettings_clicked()

// read the settings from XML file
dltRelais.readSettings(fileName);
dltMultimeter.readSettings(fileName);
dltMiniServer.readSettings(fileName);

restoreSettings();
Expand Down Expand Up @@ -425,6 +468,7 @@ void Dialog::on_pushButtonSaveSettings_clicked()

xml.writeStartElement("DLTRelaisSettings");
dltRelais.writeSettings(xml);
dltMultimeter.writeSettings(xml);
dltMiniServer.writeSettings(xml);
xml.writeEndElement(); // DLTRelaisSettings

Expand All @@ -440,10 +484,10 @@ void Dialog::on_pushButtonSettings_clicked()
// Open settings dialog
SettingsDialog dlg(this);

dlg.restoreSettings(&dltRelais, &dltMiniServer);
dlg.restoreSettings(&dltRelais, &dltMultimeter, &dltMiniServer);
if(dlg.exec()==QDialog::Accepted)
{
dlg.backupSettings(&dltRelais, &dltMiniServer);
dlg.backupSettings(&dltRelais, &dltMultimeter, &dltMiniServer);
restoreSettings();
}
}
Expand Down Expand Up @@ -474,3 +518,10 @@ void Dialog::on_pushButtonInfo_clicked()
msgBox.exec();
}

void Dialog::valueMultimeter(QString value,QString unit)
{
ui->lineEditUnit->setText(unit);
ui->lineEditValue->setText(value);

dltMiniServer.sendValue2(value,unit);
}
6 changes: 6 additions & 0 deletions dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "dltrelais.h"
#include "dltminiserver.h"
#include "dltmultimeter.h"

QT_BEGIN_NAMESPACE
namespace Ui { class Dialog; }
Expand Down Expand Up @@ -52,8 +53,12 @@ private slots:

// Status of Relais and DLT connection
void statusRelais(QString text);
void statusMultimeter(QString text);
void statusDlt(QString text);

// value from Multimeter or Power Supply
void valueMultimeter(QString value,QString unit);

// Settings and Info
void on_pushButtonSettings_clicked();
void on_pushButtonDefaultSettings_clicked();
Expand All @@ -69,6 +74,7 @@ private slots:
Ui::Dialog *ui;

DLTRelais dltRelais;
DLTMultimeter dltMultimeter;
DLTMiniServer dltMiniServer;

// Settings
Expand Down
Loading

0 comments on commit 22889b8

Please sign in to comment.