#include "mainobject.h" MainObject::MainObject(QIODevice* ioDevice, const QString& settingsPathIn, const bool masterIn, QObject *parent) : QObject(parent), master(masterIn), masterIODevice(ioDevice), ioMultiplexer(masterIODevice), micro(ioMultiplexer.getIoDevice()), broadCast(ioMultiplexer.getIoDevice(), masterIn), settingsPath(settingsPathIn), sunSensorSource(49.884450, 8.650536), rgbItem(new RgbItem(µ, 5487422, "Rgb Lights")), auxItem(new AuxItem(µ, 5487421, "Desk Light")) { qDebug()<<"Is master:"<removeAllActors(); auxItem->removeAllActors(); powerItem.removeAllActors(); items.addItem(rgbItem); items.addItem(auxItem); items.load(json, µ); powerItem.load(json["Power"].toObject()); qDebug()<<"aray size: "<= 2) { rgbItem->load(json["Items"].toArray()[0].toObject()); auxItem->load(json["Items"].toArray()[1].toObject()); } micro.requestState(); } void MainObject::recivedJson(const QJsonObject json) { if(master)storeJsonObjectToDisk(json, settingsPath); load(json); } void MainObject::sendJson() { QJsonObject json; store(json); broadCast.sendJson(json); } QJsonObject MainObject::getJsonObjectFromDisk(const QString& filePath, bool* error) { QFile file; #ifndef Q_OS_ANDROID if(filePath.size() > 0) file.setFileName(filePath); else #endif { file.setFileName(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/shinterface.json"); } file.open(QIODevice::ReadOnly); if(!file.isOpen()) std::cerr<<"Can not open config file: "<