<UIPath>/ui/index.html</UIPath>
<EnableHTTPServer>no</EnableHTTPServer> <!-- not implemented yet -->
<EnableSerialServer>yes</EnableSerialServer>
+<SerialSpeed>9600</SerialSpeed>
</dennco>
\ No newline at end of file
#include "DNGlobal.h"
#include "DNUtils.h"
#include "TKLog.h"
+#include "DNSettings.h"
#include <stdlib.h>
#include <sstream>
#include <iostream>
DNEngine::DNEngine(const char *contentPath) :
- mContainer(NULL),mPortNumber(9080),mHTTPServer(NULL),mSerialServer(NULL),mValid(false), mDoTickThread(NULL)
+ mContainer(NULL),mPortNumber(9080),mHTTPServer(NULL),mSerialServer(NULL),mSerialServerEnabled(false),mValid(false), mDoTickThread(NULL)
{
mTimeKeeper = new DNTimeKeeper();
mContainer = TKContainer::createContainer();
return;
}
+ if (mSerialServerEnabled)
+ {
+ mSerialServerEnabled = startSerialServer();
+ }
+ else
+ {
+ stopSerialServer();
+ }
+
mValid = true;
}
DNXMLElement *e = element->inner;
while(e)
{
- if (e->name == "TickIntervalSec")
+ std::string pname = upperString(e->name);
+
+ if (pname == "TICKINTERVALSEC")
{
std::istringstream is(e->text);
float t = 0.0;
}
}
}
- else if (e->name == "UIPath")
+ else if (pname == "UIPATH")
{
mUIPath = e->text;
}
- else if (e->name == "EnableHTTPServer")
+ else if (pname == "ENABLEHTTPSERVER")
{
}
- else if (e->name == "EnableSerialServer")
+ else if (pname == "ENABLESERIALSERVER")
{
if ( upperString(e->text) == "YES")
{
- startSerialServer();
+ mSerialServerEnabled = true;
}
else
{
- stopSerialServer();
+ mSerialServerEnabled = false;
}
}
+ else if (pname == "SERIALSPEED")
+ {
+ DNSettings::setValue(DNSettings::SERIAL_RATE, e->text);
+ }
e = e->next;
}
}
int mPortNumber;
DNServerHTTP *mHTTPServer;
DNServerSerialPort *mSerialServer;
+ bool mSerialServerEnabled;
DNTimeKeeper *mTimeKeeper;
bool mValid;
std::string mUIPath;
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on Apr/27/2012.
+//
+#include "DNSettings.h"
+#include "DNSettingsImpl.h"
+
+const char *DNSettings::CONTEXT_PATH = "content_path";
+
+const char *DNSettings::SERIAL_PORTNAME = "serial portName";
+const char *DNSettings::SERIAL_RATE = "serial rate";
+const char *DNSettings::SERIAL_DATABITS = "serial databits";
+const char *DNSettings::SERIAL_PARITY = "serial parity";
+const char *DNSettings::SERIAL_STOPBITS = "serial stopbits";
+const char *DNSettings::SERIAL_FLOWCONTROL = "serial flowControl";
+
+//static
+std::string DNSettings::getValue(const char *key, std::string defaultValue)
+{
+ return DNSettingsImpl::getValue(key, defaultValue);
+}
+
+//static
+void DNSettings::setValue(const char *key, std::string value)
+{
+ DNSettingsImpl::setValue(key, value);
+}
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on Apr/27/2012.
+//
+#ifndef DNSETTINGS_H
+#define DNSETTINGS_H
+
+#include <string>
+
+class DNSettings
+{
+public:
+ static const char *CONTEXT_PATH;
+
+ static const char *SERIAL_PORTNAME;
+ static const char *SERIAL_RATE;
+ static const char *SERIAL_DATABITS;
+ static const char *SERIAL_PARITY;
+ static const char *SERIAL_STOPBITS;
+ static const char *SERIAL_FLOWCONTROL;
+
+ static std::string getValue(const char *key, std::string defaultValue = "");
+ static void setValue(const char *key, std::string value);
+
+
+private:
+ DNSettings() {}
+};
+
+#endif // DNSETTINGS_H
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on Apr/27/2012.
+//
+#ifndef DNSETTINGSIMPL_H
+#define DNSETTINGSIMPL_H
+
+#include <string>
+
+class DNSettingsImpl
+{
+public:
+ static std::string getValue(const char* key, std::string defaultValue);
+ static void setValue(const char* key, std::string value);
+
+private:
+ DNSettingsImpl() {}
+};
+
+#endif // DNSETTINGSIMPL_H
#include <QFileDialog>
#include <QDir>
#include <QDebug>
-#include <QSettings>
#include <QWebFrame>
#include "TKLog.h"
#include "DNEngine.h"
#include "TKConsole.h"
#include "dnwebinterface.h"
+#include "DNSettings.h"
//static
QWidget *MainWindow::instance = NULL;
instance = this;
ui->setupUi(this);
- QSettings settings("dennco project", "dennco engine");
- QVariant defaultPath(QDir::homePath());
- QString contentPath = settings.value("content_path", defaultPath).toString();
+ QString defaultPath(QDir::homePath());
+ QString contentPath = QString::fromStdString(DNSettings::getValue(DNSettings::CONTEXT_PATH, defaultPath.toStdString()));
ui->filePath->setText(contentPath);
{
ui->filePath->setText(dirPath);
- QSettings settings("dennco project", "dennco engine");
- settings.setValue("content_path", QVariant(dirPath));
+ DNSettings::setValue(DNSettings::CONTEXT_PATH, dirPath.toStdString());
}
}
DNServerHTTP.cpp \
DNServerSerialPort.cpp \
DNSerialPort.cpp \
- platform/qt/qtdnserialportimpl.cpp
+ platform/qt/qtdnserialportimpl.cpp \
+ DNSettings.cpp \
+ platform/qt/qtdnsettingsimpl.cpp
HEADERS += QtDennco/mainwindow.h \
DNSerialPort.h \
DNSerialPortImpl.h \
platform/qt/qtdnserialportimpl.h \
- DNServerHTTPImpl.h
+ DNServerHTTPImpl.h \
+ DNSettings.h \
+ DNSettingsImpl.h
FORMS += QtDennco/mainwindow.ui
FORMS += QtDennco/portinfodialog.ui
#include "mainwindow.h"
#include "TKLog.h"
#include "DNUtils.h"
+#include "DNSettings.h"
#include <QThread>
#include <QtCore/QVariant>
connect(ui->portsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(procItemPortChanged(int)));
connect(ui->okPushButton, SIGNAL(clicked()), this, SLOT(procOKButtonClick()));
connect(ui->cancelPushButton, SIGNAL(clicked()), this, SLOT(procCancelButtonClick()));
+
+ //default setting
+ QString defaultPortName = QString::fromStdString(DNSettings::getValue(DNSettings::SERIAL_PORTNAME , ""));
+ for (int i = 0; i < ui->portsComboBox->count(); i++)
+ {
+ if (ui->portsComboBox->itemText(i) == defaultPortName)
+ {
+ ui->portsComboBox->setCurrentIndex(i);
+ break;
+ }
+ }
+
+ QString defaultBaudRate = QString::fromStdString(DNSettings::getValue(DNSettings::SERIAL_RATE, "9600"));
+ for (int i = 0; i < ui->ratesComboBox->count(); i++)
+ {
+ if (ui->ratesComboBox->itemText(i) == defaultBaudRate)
+ {
+ ui->ratesComboBox->setCurrentIndex(i);
+ break;
+ }
+ }
+
+ QString defaultDataBits = QString::fromStdString(DNSettings::getValue(DNSettings::SERIAL_DATABITS, "8"));
+ for (int i = 0; i < ui->dataBitsComboBox->count(); i++)
+ {
+ if (ui->dataBitsComboBox->itemText(i) == defaultDataBits)
+ {
+ ui->dataBitsComboBox->setCurrentIndex(i);
+ break;
+ }
+ }
+
+ QString defaultParity = QString::fromStdString(DNSettings::getValue(DNSettings::SERIAL_PARITY, "No parity"));
+ for (int i = 0; i < ui->parityComboBox->count(); i++)
+ {
+ if (ui->parityComboBox->itemText(i) == defaultParity)
+ {
+ ui->parityComboBox->setCurrentIndex(i);
+ break;
+ }
+ }
+
+ QString defaultStopBits = QString::fromStdString(DNSettings::getValue(DNSettings::SERIAL_STOPBITS, "one stop"));
+ for (int i = 0; i < ui->stopBitsComboBox->count(); i++)
+ {
+ if (ui->stopBitsComboBox->itemText(i) == defaultStopBits)
+ {
+ ui->stopBitsComboBox->setCurrentIndex(i);
+ break;
+ }
+ }
+
+ QString defaultFlowControl = QString::fromStdString(DNSettings::getValue(DNSettings::SERIAL_FLOWCONTROL, "No flow control"));
+ for (int i = 0; i < ui->flowControlComboBox->count(); i++)
+ {
+ if (ui->flowControlComboBox->itemText(i) == defaultFlowControl)
+ {
+ ui->flowControlComboBox->setCurrentIndex(i);
+ break;
+ }
+ }
+
}
QtDNSerialPortSettingDialog::~QtDNSerialPortSettingDialog()
bool QtDNSerialPortSettingDialog::isOK()
{
+ // save selections
+ DNSettings::setValue(DNSettings::SERIAL_PORTNAME, ui->portsComboBox->currentText().toStdString());
+ DNSettings::setValue(DNSettings::SERIAL_RATE, ui->ratesComboBox->currentText().toStdString());
+ DNSettings::setValue(DNSettings::SERIAL_DATABITS, ui->dataBitsComboBox->currentText().toStdString());
+ DNSettings::setValue(DNSettings::SERIAL_PARITY, ui->parityComboBox->currentText().toStdString());
+ DNSettings::setValue(DNSettings::SERIAL_STOPBITS, ui->stopBitsComboBox->currentText().toStdString());
+ DNSettings::setValue(DNSettings::SERIAL_FLOWCONTROL, ui->flowControlComboBox->currentText().toStdString());
+
return mIsOK;
}
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on Apr/27/2012.
+//
+#include "DNSettingsImpl.h"
+
+#include <QString>
+#include <QSettings>
+#include <QVariant>
+
+#include <string>
+
+//static
+std::string DNSettingsImpl::getValue(const char *key, std::string defaultValue)
+{
+ QSettings settings("dennco project", "dennco engine");
+ QString result = settings.value(QString(key), QString::fromStdString(defaultValue)).toString();
+
+ return result.toStdString();
+}
+
+//static
+void DNSettingsImpl::setValue(const char *key, std::string value)
+{
+ QSettings settings("dennco project", "dennco engine");
+ settings.setValue(QString(key), QVariant(QString::fromStdString(value)));
+}
+