init branch
This commit is contained in:
52
main.cpp
52
main.cpp
@ -17,7 +17,8 @@
|
||||
#include "mainwindow.h"
|
||||
#include "relaydialog.h"
|
||||
#include "ampmanager.h"
|
||||
#include "power.h"
|
||||
#include "alarmactions.h"
|
||||
#include "alarmsettingsdialog.h"
|
||||
|
||||
#define BAUD QSerialPort::Baud38400
|
||||
|
||||
@ -29,7 +30,7 @@ int main(int argc, char *argv[])
|
||||
QCoreApplication::setOrganizationName("UVOS");
|
||||
QCoreApplication::setOrganizationDomain("uvos.xyz");
|
||||
QCoreApplication::setApplicationName("SHinterface");
|
||||
QCoreApplication::setApplicationVersion("0.2");
|
||||
QCoreApplication::setApplicationVersion("0.5");
|
||||
|
||||
QDir::setCurrent(a.applicationDirPath());
|
||||
|
||||
@ -54,8 +55,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
QSettings settings;
|
||||
|
||||
|
||||
|
||||
//connect to microcontoler
|
||||
Microcontroller micro;
|
||||
if(parser.isSet(tcpOption))
|
||||
@ -89,41 +88,38 @@ int main(int argc, char *argv[])
|
||||
else micro.setIODevice(microPort);
|
||||
}
|
||||
|
||||
Power power(&settings, µ);
|
||||
|
||||
|
||||
|
||||
AlarmActions alarmActions(&settings, µ);
|
||||
|
||||
AmpManager amp(µ, 0);
|
||||
|
||||
MainWindow w(&settings, µ, parser.isSet(secondaryOption));
|
||||
QObject::connect(µ, SIGNAL(textRecived(QString)), &w, SLOT(changeHeaderLableText(QString)));
|
||||
QObject::connect(µ, SIGNAL(relayStateChanged(std::vector<bool>)), &w, SLOT(relayStateChanged(std::vector<bool>)));
|
||||
|
||||
RelayDialog relayDialog(µ);
|
||||
QObject::connect(µ, SIGNAL(relayStateChanged(std::vector<bool>)), &relayDialog, SLOT(relayStateChanged(std::vector<bool>)));
|
||||
|
||||
//Alarms
|
||||
AlarmTime almNight(settings.value("nightTime").toTime());
|
||||
AlarmTime almAlarm(settings.value("alarmTime").toTime());
|
||||
|
||||
AlarmTime *almAlarm = new AlarmTime(settings.value("alarmTime").toTime());
|
||||
QSignalMapper signalMapper;
|
||||
//mainwindow
|
||||
MainWindow w(µ, parser.isSet(secondaryOption));
|
||||
QObject::connect(µ, SIGNAL(textRecived(QString)), &w, SLOT(changeHeaderLableText(QString)));
|
||||
QObject::connect(µ, SIGNAL(relayStateChanged(std::vector<bool>)), &w, SLOT(relayStateChanged(std::vector<bool>)));
|
||||
QObject::connect(µ, SIGNAL(auxStateChanged(int)), &w, SLOT(auxStateChanged(int)));
|
||||
|
||||
//dialogs
|
||||
AlarmSettingsDialog alarmDialog(&almNight, &almAlarm, &settings, &w);
|
||||
|
||||
RelayDialog relayDialog(µ, &w);
|
||||
QObject::connect(µ, SIGNAL(relayStateChanged(std::vector<bool>)), &relayDialog, SLOT(relayStateChanged(std::vector<bool>)));
|
||||
|
||||
if(!parser.isSet(secondaryOption))
|
||||
{
|
||||
|
||||
QObject::connect(&almNight, SIGNAL(trigger()), &power, SLOT(syncoff()));
|
||||
QObject::connect(&almNight, SIGNAL(trigger()), &alarmActions, SLOT(syncoff()));
|
||||
QObject::connect(&w, SIGNAL(signalAlmNightChanged(QTime)), &almNight, SLOT(changeTime(QTime)));
|
||||
QObject::connect(&w, SIGNAL(signalAlmNightStateChanged(int)), &almNight, SLOT(runOrAbort(int)));
|
||||
//QMetaObject::invokeMethod(&almNight, "run", Qt::QueuedConnection );
|
||||
almNight.run();
|
||||
|
||||
|
||||
QObject::connect(almAlarm, SIGNAL(trigger()), &signalMapper, SLOT(map()));
|
||||
signalMapper.setMapping(almAlarm, 4);
|
||||
QObject::connect(&signalMapper, SIGNAL(mapped(int)), µ, SLOT(setPattern(int)));
|
||||
QObject::connect(&w, SIGNAL(signalAlmAlarmChanged(QTime)), almAlarm, SLOT(changeTime(QTime)));
|
||||
QObject::connect(&w, SIGNAL(signalAlmAlarmStateChanged(int)), almAlarm, SLOT(runOrAbort(int)));
|
||||
//QMetaObject::invokeMethod(almAlarm, "run", Qt::QueuedConnection );
|
||||
QObject::connect(&almAlarm, &AlarmTime::trigger, µ, &Microcontroller::startSunrise);
|
||||
QObject::connect(&w, SIGNAL(signalAlmAlarmChanged(QTime)), &almAlarm, SLOT(changeTime(QTime)));
|
||||
QObject::connect(&w, SIGNAL(signalAlmAlarmStateChanged(int)), &almAlarm, SLOT(runOrAbort(int)));
|
||||
almAlarm.run();
|
||||
|
||||
//Amplifyer
|
||||
QObject::connect(&w, SIGNAL(signalAmpOn()), &, SLOT(run()));
|
||||
@ -131,12 +127,12 @@ int main(int argc, char *argv[])
|
||||
QMetaObject::invokeMethod(&, "run", Qt::QueuedConnection );
|
||||
}
|
||||
|
||||
//Advanced Relays
|
||||
//show dialogs
|
||||
QObject::connect(&w, SIGNAL(showAdvRelayDialog()), &relayDialog, SLOT(show()));
|
||||
QObject::connect(&w, &MainWindow::showAlmSettingsDialog, &alarmDialog, &AlarmSettingsDialog::show);
|
||||
|
||||
QMetaObject::invokeMethod(µ, "run", Qt::QueuedConnection );
|
||||
|
||||
QMetaObject::invokeMethod(&w, "postActivate", Qt::QueuedConnection );
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
|
Reference in New Issue
Block a user