/*! \brief Default constructor This is the default constructor for the main class of the application. It adds the standard actions and create the ATMOSphere's KCM. */ ATMOSphere::ATMOSphere() : KMainWindow( 0, "ATMOSphere" ) { // set the shell's ui resource file setXMLFile("atmosphereui.rc"); KStdAction::keyBindings(this, SLOT( slotConfigureKeys() ), actionCollection() ); KStdAction::configureNotifications(this, SLOT(slotConfigureNotifications()), actionCollection()); KStdAction::configureToolbars(this, SLOT(slotConfigureToolBars()), actionCollection()); KStdAction::quit(this, SLOT(close()), actionCollection()); KStdAction::preferences(this, SLOT(setup()), actionCollection()); createGUI(); kcmDialog = new KCMultiDialog( KCMultiDialog::Plain, "ATMOSphere settings", this, "kcmDialog", true); kcmDialog->addModule("kcmatmosphere"); iv = new KIconView(this); setCentralWidget(iv); loadDevices(); connect(iv, SIGNAL( executed(QIconViewItem*) ), this, SLOT(deviceOpened(QIconViewItem*))); #ifdef HAVE_TFTP tftpServer = new TFTP::Server( QHostAddress() ); connect(tftpServer, SIGNAL( receivedFile(QIODevice*,const QString) ), this, SLOT(tftpFileReceived(QIODevice *, const QString))); connect(tftpServer, SIGNAL( sentFile(QIODevice*, QString) ), this, SLOT(tftpFileSent(QIODevice *, QString))); #endif }
/** * The method to be called to start iLedlif * It calls all the necessary initialization methods and enters a (nearly) * infinite loop * @param configPath The full path and filename to the configuration file */ void iLedlif::run(std::string configPath) { //Declare local variables //Load the devices std::cout << "iLedlif: Starting to load devices" << std::endl; //load device objects from xml config file loadDevices(configPath); //start each device thread #ifdef DSAAV loadDSAAVCom(); #endif startDeviceThreads(); //tell each device to run its initialization method lifMsg initMsg; initMsg.set_source("iLedlif"); initMsg.set_command("Initialize"); iLedlif::sendMsgToAllDevices(initMsg); std::cout << "iLedlif: Entering message wait state (i.e. infinite loop)" << std::endl; while (1) { //Lock the mainMsgMutex pthread_mutex_lock(&mainMsgMutex); //Check if mainMsgQueue is empty // - If it is empty, wait here until you receive a signal that // a message has been pushed onto mainMsgQueue if (mainMsgQueue.empty()) { //std::cout<<"The queue is empty"<<std::endl; pthread_cond_wait(&mainMsgQueuePushed, &mainMsgMutex); } pthread_mutex_unlock(&mainMsgMutex); handleMessage(); } }
void PortAudioHelper::initDevices() { if (!init()) { qDebug() << ("Error: Port audio not initialized.\n"); return; } loadDevices(); }
Config::Config() { QSettings settings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName()); QDir dir = QDir( QFileInfo(settings.fileName()).absolutePath() ); qDebug() << dir.absolutePath(); if (!dir.exists()) { dir.mkpath(dir.absolutePath()); } devices_file_name = dir.absolutePath() + "/devices.txt"; qDebug() << devices_file_name; known_files_file_name = dir.absolutePath() + "/knownFiles.txt"; qDebug() << known_files_file_name; daily_comments_file_name = dir.absolutePath() + "/dailyComments.txt"; qDebug() << daily_comments_file_name; gui_params_file_name = dir.absolutePath() + "/GUIParams.txt"; qDebug() << gui_params_file_name; /* migrate config.txt (< v0.4.1) to devices.txt */ QFile config(dir.absolutePath() + "/config.txt"); if (config.exists()) { qDebug() << "migrating configuration file for version > 0.4.1"; config.rename(devices_file_name); } loadKnownFiles(); loadDevices(); loadDailyComments(); loadGUIParams(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); color_icon = false; loadDevices(); showTrayIcon(); }
bool InsteonNetwork::connect() { utils::Logger::Instance().Trace(FUNCTION_NAME); if (!msg_proc_->connect()) return false; loadDevices(); if (config_["PLM"]["enable_monitor_mode"].as<bool>(false)) if (insteon_controller_->enableMonitorMode()) utils::Logger::Instance().Info("PLM monitor mode enabled " "successfully!"); // start loading the ALDB from PLM if (config_["PLM"]["load_aldb"].as<bool>(false)) { utils::Logger::Instance().Info("%s\n\t - getting aldb from PLM", FUNCTION_NAME_CSTR); insteon_controller_->getDatabaseRecords(0x1F, 0xF8); } // wait here until the database is loaded std::unique_lock<std::mutex> lk(mx_load_db_); cv_load_db_.wait(lk, [this] { return insteon_controller_->is_loading_database_ == false; }); // get aldb from each enabled device in the list if (config_["PLM"]["load_aldb"].as<bool>(false)) { utils::Logger::Instance().Info("%s\n\t - getting aldb from known devices", FUNCTION_NAME_CSTR); for (const auto& it : device_list_) { if (!config_["DEVICES"][utils::int_to_hex(it.second->insteon_address())] ["device_disabled_"].as<bool>(false)) { io_strand_.post(std::bind(&InsteonDevice::command, it.second, InsteonDeviceCommand::ALDBReadWrite, 0x00)); } } } // get status of each enabled device in the list if (config_["PLM"]["sync_device_status"].as<bool>(true)) { utils::Logger::Instance().Info("%s\n\t - syncing device status", FUNCTION_NAME_CSTR); for (const auto& it : device_list_) { if (!config_["DEVICES"][utils::int_to_hex(it.second->insteon_address())] ["device_disabled_"].as<bool>(false)) { io_strand_.post(std::bind(&InsteonDevice::command, it.second, InsteonDeviceCommand::LightStatusRequest, 0x02)); } } } return true; }
void Rig::loadJSON(JSONNode root) { //JSONNode::const_iterator i = root.begin(); JSONNode::iterator i = root.begin(); auto version = root.find("version"); if (version == root.end()) { Logger::log(ERR, "No version specified for input file. Aborting load."); return; } else { stringstream ss; stringstream ss2(version->as_string()); ss << LumiverseCore_VERSION_MAJOR << "." << LumiverseCore_VERSION_MINOR; float libVer; float fileVer; ss >> libVer; ss2 >> fileVer; if (fileVer < libVer) { // Friendly warning if you're loading an old file. Logger::log(WARN, "File created against earlier version of Lumiverse. Check logs for any load problems."); } else if (fileVer > libVer) { // Loading newer file with older library. Logger::log(WARN, "File created against newer version of Lumiverse. Check logs for any load problems."); } } while (i != root.end()){ // get the node name and value as a string std::string nodeName = i->name(); if (nodeName == "devices") { loadDevices(*i); Logger::log(INFO, "Device load complete"); } else if (nodeName == "patches") { i->push_back(*root.find("jsonPath")); loadPatches(*i); Logger::log(INFO, "Patch load complete"); } else if (nodeName == "refreshRate") { setRefreshRate(i->as_int()); } //increment the iterator ++i; } }
bool QSerialPortPrivate::open(QIODevice::OpenMode mode) { Q_Q(QSerialPort); // FIXME: Maybe need added check an ReadWrite open mode? Q_UNUSED(mode) if (!loadDevices()) { q->setError(QSerialPort::UnknownError); return false; } RCommServ server; errnum = server.Connect(); if (errnum != KErrNone) { q->setError(decodeSystemError()); return false; } if (systemLocation.contains("BTCOMM")) errnum = server.LoadCommModule(KBluetoothModuleName); else if (systemLocation.contains("IRCOMM")) errnum = server.LoadCommModule(KInfraRedModuleName); else if (systemLocation.contains("ACM")) errnum = server.LoadCommModule(KACMModuleName); else errnum = server.LoadCommModule(KRS232ModuleName); if (errnum != KErrNone) { q->setError(decodeSystemError()); return false; } // In Symbian OS port opening only in R/W mode? TPtrC portName(static_cast<const TUint16*>(systemLocation.utf16()), systemLocation.length()); errnum = descriptor.Open(server, portName, ECommExclusive); if (errnum != KErrNone) { q->setError(decodeSystemError()); return false; } // Save current port settings. errnum = descriptor.Config(restoredSettings); if (errnum != KErrNone) { q->setError(decodeSystemError()); return false; } detectDefaultSettings(); return true; }
/** * @brief connects ALL devices * @return * void */ void OpenBeaconUSBStrategy::connectDevices () { loadDevices (); QMapIterator<QString, OpenBeaconCommunication *> i(devices); while (i.hasNext()) { i.next(); if (i.value()) { i.value ()->startCommunication (); i.value ()->sendToOB (QString ("FIFO %1").arg (maxPackages)); i.value ()->sendToOB ("D"); qCDebug(OPENBEACON_STRATEGY) << QString("Started device %1").arg (i.key()); } } }
bool SerialPortInfo::isValid() const { if (!loadDevices()) return false; RCommServ server; TInt r = server.Connect(); if (r != KErrNone) return false; RComm port; TPtrC portName(static_cast<const TUint16*>(systemLocation().utf16()), systemLocation().length()); r = port.Open(server, portName, ECommExclusive); if (r == KErrNone) port.Close(); return r == KErrNone || r == KErrLocked; }
QList<SerialPortInfo> SerialPortInfo::availablePorts() { QList<SerialPortInfo> ports; if (!loadDevices()) return ports; RCommServ server; TInt r = server.Connect(); if (r != KErrNone) return ports; //User::LeaveIfError(r); TSerialInfo nativeInfo; // Native Symbian OS port info class. QString s("%1::%2"); // FIXME: Get info about RS232 ports. r = server.LoadCommModule(KRS232ModuleName); //User::LeaveIfError(r); if (r == KErrNone) { r = server.GetPortInfo(KRS232ModuleName, nativeInfo); if (r == KErrNone) { // for (quint32 i = nativeInfo.iLowUnit; i < nativeInfo.iHighUnit + 1; ++i) { SerialPortInfo info; // My (desired) info class. info.d_ptr->device = s .arg(QString::fromUtf16(nativeInfo.iName.Ptr(), nativeInfo.iName.Length())) .arg(i); info.d_ptr->portName = info.d_ptr->device; info.d_ptr->description = QString::fromUtf16(nativeInfo.iDescription.Ptr(), nativeInfo.iDescription.Length()); info.d_ptr->manufacturer = QString(QObject::tr("Unknown.")); ports.append(info); } } } // FIXME: Get info about Bluetooth ports. r = server.LoadCommModule(KBluetoothModuleName); //User::LeaveIfError(r); if (r == KErrNone) { r = server.GetPortInfo(KBluetoothModuleName, nativeInfo); if (r == KErrNone) { // for (quint32 i = nativeInfo.iLowUnit; i < nativeInfo.iHighUnit + 1; ++i) { SerialPortInfo info; // My (desired) info class. info.d_ptr->device = s .arg(QString::fromUtf16(nativeInfo.iName.Ptr(), nativeInfo.iName.Length())) .arg(i); info.d_ptr->portName = info.d_ptr->device; info.d_ptr->description = QString::fromUtf16(nativeInfo.iDescription.Ptr(), nativeInfo.iDescription.Length()); info.d_ptr->manufacturer = QString(QObject::tr("Unknown.")); ports.append(info); } } } // FIXME: Get info about InfraRed ports. r = server.LoadCommModule(KInfraRedModuleName); //User::LeaveIfError(r); if (r == KErrNone) { r = server.GetPortInfo(KInfraRedModuleName, nativeInfo); if (r == KErrNone) { // for (quint32 i = nativeInfo.iLowUnit; i < nativeInfo.iHighUnit + 1; ++i) { SerialPortInfo info; // My (desired) info class. info.d_ptr->device = s .arg(QString::fromUtf16(nativeInfo.iName.Ptr(), nativeInfo.iName.Length())) .arg(i); info.d_ptr->portName = info.d_ptr->device; info.d_ptr->description = QString::fromUtf16(nativeInfo.iDescription.Ptr(), nativeInfo.iDescription.Length()); info.d_ptr->manufacturer = QString(QObject::tr("Unknown.")); ports.append(info); } } } // FIXME: Get info about ACM ports. r = server.LoadCommModule(KACMModuleName); //User::LeaveIfError(r); if (r == KErrNone) { r = server.GetPortInfo(KACMModuleName, nativeInfo); if (r == KErrNone) { // for (quint32 i = nativeInfo.iLowUnit; i < nativeInfo.iHighUnit + 1; ++i) { SerialPortInfo info; // My (desired) info class. info.d_ptr->device = s .arg(QString::fromUtf16(nativeInfo.iName.Ptr(), nativeInfo.iName.Length())) .arg(i); info.d_ptr->portName = SerialPortPrivate::portNameFromSystemLocation(info.d_ptr->device); info.d_ptr->description = QString::fromUtf16(nativeInfo.iDescription.Ptr(), nativeInfo.iDescription.Length()); info.d_ptr->manufacturer = QString(QObject::tr("Unknown.")); ports.append(info); } } } return ports; }
QList<QSerialPortInfo> QSerialPortInfo::availablePorts() { QList<QSerialPortInfo> serialPortInfoList; if (!loadDevices()) return serialPortInfoList; RCommServ server; TInt r = server.Connect(); if (r != KErrNone) return serialPortInfoList; TSerialInfo nativeSerialInfo; QString s("%1::%2"); // FIXME: Get info about RS232 ports. r = server.LoadCommModule(KRS232ModuleName); if (r == KErrNone) { r = server.GetPortInfo(KRS232ModuleName, nativeSerialInfo); if (r == KErrNone) { for (quint32 i = nativeSerialInfo.iLowUnit; i < nativeSerialInfo.iHighUnit + 1; ++i) { QSerialPortInfo serialPortInfo; serialPortInfo.d_ptr->device = s .arg(QString::fromUtf16(nativeSerialInfo.iName.Ptr(), nativeSerialInfo.iName.Length())) .arg(i); serialPortInfo.d_ptr->portName = serialPortInfo.d_ptr->device; serialPortInfo.d_ptr->description = QString::fromUtf16(nativeSerialInfo.iDescription.Ptr(), nativeSerialInfo.iDescription.Length()); serialPortInfo.d_ptr->manufacturer = QString(QObject::tr("Unknown.")); serialPortInfoList.append(serialPortInfo); } } } // FIXME: Get info about Bluetooth ports. r = server.LoadCommModule(KBluetoothModuleName); if (r == KErrNone) { r = server.GetPortInfo(KBluetoothModuleName, nativeSerialInfo); if (r == KErrNone) { for (quint32 i = nativeSerialInfo.iLowUnit; i < nativeSerialInfo.iHighUnit + 1; ++i) { QSerialPortInfo serialPortInfo; serialPortInfo.d_ptr->device = s .arg(QString::fromUtf16(nativeSerialInfo.iName.Ptr(), nativeSerialInfo.iName.Length())) .arg(i); serialPortInfo.d_ptr->portName = serialPortInfo.d_ptr->device; serialPortInfo.d_ptr->description = QString::fromUtf16(nativeSerialInfo.iDescription.Ptr(), nativeSerialInfo.iDescription.Length()); serialPortInfo.d_ptr->manufacturer = QString(QObject::tr("Unknown.")); serialPortInfoList.append(serialPortInfo); } } } // FIXME: Get info about InfraRed ports. r = server.LoadCommModule(KInfraRedModuleName); if (r == KErrNone) { r = server.GetPortInfo(KInfraRedModuleName, nativeSerialInfo); if (r == KErrNone) { for (quint32 i = nativeSerialInfo.iLowUnit; i < nativeSerialInfo.iHighUnit + 1; ++i) { QSerialPortInfo serialPortInfo; serialPortInfo.d_ptr->device = s .arg(QString::fromUtf16(nativeSerialInfo.iName.Ptr(), nativeSerialInfo.iName.Length())) .arg(i); serialPortInfo.d_ptr->portName = serialPortInfo.d_ptr->device; serialPortInfo.d_ptr->description = QString::fromUtf16(nativeSerialInfo.iDescription.Ptr(), nativeSerialInfo.iDescription.Length()); serialPortInfo.d_ptr->manufacturer = QString(QObject::tr("Unknown.")); serialPortInfoList.append(serialPortInfo); } } } // FIXME: Get info about ACM ports. r = server.LoadCommModule(KACMModuleName); if (r == KErrNone) { r = server.GetPortInfo(KACMModuleName, nativeSerialInfo); if (r == KErrNone) { for (quint32 i = nativeSerialInfo.iLowUnit; i < nativeSerialInfo.iHighUnit + 1; ++i) { QSerialPortInfo serialPortInfo; serialPortInfo.d_ptr->device = s .arg(QString::fromUtf16(nativeSerialInfo.iName.Ptr(), nativeSerialInfo.iName.Length())) .arg(i); serialPortInfo.d_ptr->portName = QSerialPortPrivate::portNameFromSystemLocation(serialPortInfo.d_ptr->device); serialPortInfo.d_ptr->description = QString::fromUtf16(nativeSerialInfo.iDescription.Ptr(), nativeSerialInfo.iDescription.Length()); serialPortInfo.d_ptr->manufacturer = QString(QObject::tr("Unknown.")); serialPortInfoList.append(serialPortInfo); } } } return serialPortInfoList; }