Serial communication functionality is under development.
#include "TKContainer.h"
#include "TKUICell.h"
#include "DNTimeKeeper.h"
-#include "DNHTTPServer.h"
+#include "DNServerHTTP.h"
+#include "DNServerSerialPort.h"
#include "TKContainer.h"
#include "DNContainerBuilder.h"
#include "DNEngine.h"
#include <iostream>
DNEngine::DNEngine(const char *contentPath) :
- mContainer(NULL),mPortNumber(9080),mHTTPServer(NULL),mValid(false), mDoTickThread(NULL)
+ mContainer(NULL),mPortNumber(9080),mHTTPServer(NULL),mSerialServer(NULL),mValid(false), mDoTickThread(NULL)
{
mTimeKeeper = new DNTimeKeeper();
mContainer = TKContainer::createContainer();
delete mHTTPServer;
mHTTPServer = NULL;
}
- mHTTPServer = new DNHTTPServer(this);
+ mHTTPServer = new DNServerHTTP(this);
if (mHTTPServer)
{
mHTTPServer->setPortNumber(portNumber);
return true;
}
-void DNEngine::stopServer()
+void DNEngine::stopHTTPServer()
{
if (mHTTPServer && mHTTPServer->isRunning())
{
}
}
+bool DNEngine::startSerialServer()
+{
+ if (mSerialServer && mSerialServer->isRunning())
+ {
+ mSerialServer->stop();
+ delete mSerialServer;
+ mSerialServer = NULL;
+ }
+ mSerialServer = new DNServerSerialPort(this);
+ if (mSerialServer)
+ {
+ if (mSerialServer->setup())
+ {
+ mSerialServer->start();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ return false;
+}
+
+void DNEngine::stopSerialServer()
+{
+ if (mSerialServer && mSerialServer->isRunning())
+ {
+ mSerialServer->stop();
+ delete mSerialServer;
+ mSerialServer = NULL;
+ }
+}
+
void DNEngine::setTickIntervalSec(float interval)
{
if (mTimeKeeper)
class TKContainer;
class DNTimeKeeper;
-class DNHTTPServer;
+class DNServerHTTP;
+class DNServerSerialPort;
#include "TKLock.h"
#include "DNThread.h"
bool stopEngine();
bool startHTTPServer(int portNumber);
- void stopServer();
-
+ void stopHTTPServer();
+
+ bool startSerialServer();
+ void stopSerialServer();
+
void setTickIntervalSec(float interval);
static void doTickThread(void *self);
TKContainer *mContainer;
int mPortNumber;
- DNHTTPServer *mHTTPServer;
+ DNServerHTTP *mHTTPServer;
+ DNServerSerialPort *mSerialServer;
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/15/2012.
+//
+#include "DNSerialPort.h"
+#include "DNSerialPortImpl.h"
+
+DNSerialPort::DNSerialPort(DNServerSerialPort *server)
+{
+ impl = DNSerialPortImpl::create(server);
+}
+
+DNSerialPort::~DNSerialPort()
+{
+ if (impl)
+ {
+ delete impl;
+ impl = 0;
+ }
+}
+
+bool DNSerialPort::setup()
+{
+ if (impl)
+ {
+ return impl->setup();
+ }
+ return false;
+}
+
+bool DNSerialPort::isRunning()
+{
+ if (impl)
+ {
+ return impl->isRunning();
+ }
+ return false;
+}
+
+void DNSerialPort::start()
+{
+ if (impl)
+ {
+ impl->start();
+ }
+}
+
+void DNSerialPort::stop()
+{
+ if (impl)
+ {
+ impl->stop();
+ }
+}
--- /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/15/2012.
+//
+#ifndef DNSERIALPORT_H
+#define DNSERIALPORT_H
+
+class DNServerSerialPort;
+class DNSerialPortImpl;
+
+class DNSerialPort
+{
+public:
+ DNSerialPort(DNServerSerialPort *server);
+ ~DNSerialPort();
+
+ bool setup();
+
+ bool isRunning();
+ void start();
+ void stop();
+
+private:
+ DNSerialPortImpl *impl;
+
+};
+
+#endif // DNSERIALPORT_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/15/2012.
+//
+#ifndef DNSERIALPORTIMPL_H
+#define DNSERIALPORTIMPL_H
+
+class DNServerSerialPort;
+
+class DNSerialPortImpl
+{
+public:
+ static DNSerialPortImpl *create(DNServerSerialPort *server);
+
+ DNSerialPortImpl(DNServerSerialPort *server) : mServer(server) {}
+ virtual ~DNSerialPortImpl() {}
+
+ virtual bool setup() = 0;
+
+ virtual bool isRunning() = 0;
+ virtual void start() = 0;
+ virtual void stop() = 0;
+
+protected:
+ DNServerSerialPort *mServer;
+
+};
+
+#endif // DNSERIALPORTIMPL_H
// Created by tkawata on 1/24/2012.
//
-#ifndef dennco_DNServer_h
-#define dennco_DNServer_h
+#ifndef DNSERVERBASE_H
+#define DNSERVERBASE_H
#include "TKLock.h"
#include <string>
class DNEngine;
-class DNServerImpl;
-class DNServer;
-
-
-class DNServer
+class DNServerBase
{
public:
- DNServer(DNEngine *engine) : mEngine(engine){};
+ DNServerBase(DNEngine *engine) : mEngine(engine){}
+
+ virtual ~DNServerBase(){}
virtual bool isRunning() = 0;
virtual void start() = 0;
virtual void stop() = 0;
+
+ virtual void doQueryRequest(std::string requestBody) = 0;
+ virtual void doSetRequest(std::string requestBody) = 0;
+
protected:
DNEngine *mEngine;
};
-#endif
+#endif //DNSERVERBASE_H
// Created by tkawata on 1/28/2012.
//
-#include "DNHTTPServerImpl.h"
-#include "DNHTTPServer.h"
+#include "DNServerHTTPImpl.h"
+#include "DNServerHTTP.h"
+#include "DNServerBase.h"
#include "DNEngine.h"
#include "DNUtils.h"
#endif
#include <stdio.h>
-const unsigned int DNHTTPServer::HTTPDEFAULTPORT = 50000;
+const unsigned int DNServerHTTP::HTTPDEFAULTPORT = 50000;
-DNHTTPServer::DNHTTPServer(DNEngine* engine) : DNServer(engine)
+DNServerHTTP::DNServerHTTP(DNEngine* engine) : DNServerBase(engine)
{
- impl = DNHTTPServerImpl::create(this, DNHTTPServer::clientRequestHandler);
+ impl = DNServerHTTPImpl::create(this, DNServerHTTP::clientRequestHandler);
}
-DNHTTPServer::~DNHTTPServer()
+DNServerHTTP::~DNServerHTTP()
{
if (impl)
delete impl;
}
-bool DNHTTPServer::isRunning()
+bool DNServerHTTP::isRunning()
{
return impl->isRunning();
}
-void DNHTTPServer::start()
+void DNServerHTTP::start()
{
impl->start();
}
-void DNHTTPServer::stop()
+void DNServerHTTP::stop()
{
impl->stop();
}
-void DNHTTPServer::setPortNumber(unsigned int portNumber)
+void DNServerHTTP::setPortNumber(unsigned int portNumber)
{
impl->setPortNumber(portNumber);
}
-void DNHTTPServer::replyWithStatusCode(int code, const char* message)
+void DNServerHTTP::replyWithStatusCode(int code, const char* message)
{
impl->replyWithStatusCode(code, message);
}
-void DNHTTPServer::replyWithFile(const char* filePath)
+void DNServerHTTP::replyWithFile(const char* filePath)
{
impl->replyWithFile(filePath);
}
//static
-void DNHTTPServer::clientRequestHandler(DNHTTPServer *server, const char *path, const char *body)
+void DNServerHTTP::clientRequestHandler(DNServerHTTP *server, const char *path, const char *body)
{
bool valid = true;
std::string errorMsg;
}
-void DNHTTPServer::doQueryRequest(std::string requestBody)
+void DNServerHTTP::doQueryRequest(std::string requestBody)
{
const char *oc = requestBody.c_str();
size_t oclen = strlen(oc);
replyWithStatusCode(200, resultString.c_str());
}
-void DNHTTPServer::doSetRequest(std::string requestBody)
+void DNServerHTTP::doSetRequest(std::string requestBody)
{
const char *oc = requestBody.c_str();
size_t oclen = strlen(oc);
replyWithStatusCode(200, rs);
}
-void DNHTTPServer::doUIRequest(const char *path)
+void DNServerHTTP::doUIRequest(const char *path)
{
std::string filepath = getContentPath();
trimString(filepath);
}
-void DNHTTPServer::doBadRequest(std::string errorMsg)
+void DNServerHTTP::doBadRequest(std::string errorMsg)
{
replyWithStatusCode(400, errorMsg.c_str());
}
-std::string DNHTTPServer::getContentPath()
+std::string DNServerHTTP::getContentPath()
{
return mEngine->getContentPath();
}
/*
//static
-DNHTTPRequest* DNHTTPServer::parseHttpRequest(const char *message)
+DNHTTPRequest* DNServerHTTP::parseHttpRequest(const char *message)
{
size_t len = strlen(message);
// Created by tkawata on 1/28/2012.
//
-#ifndef dennco_DNSimpleHTTPServer_h
-#define dennco_DNSimpleHTTPServer_h
+#ifndef DNSERVERHTTP_H
+#define DNSERVERHTTP_H
-#include "DNServer.h"
+#include "DNServerBase.h"
-class DNHTTPServerImpl;
+class DNServerHTTPImpl;
/*
class DNHTTPRequest
*/
-class DNHTTPServer : public DNServer
+class DNServerHTTP : public DNServerBase
{
public:
- DNHTTPServer(DNEngine *engine);
- ~DNHTTPServer();
+ DNServerHTTP(DNEngine *engine);
+ virtual ~DNServerHTTP();
virtual bool isRunning();
virtual void start();
virtual void stop();
-
+
+ virtual void doQueryRequest(std::string requestBody);
+ virtual void doSetRequest(std::string requestBody);
+
void setPortNumber(unsigned int portNumber);
void replyWithStatusCode(int code, const char* message);
void replyWithFile(const char* filePath);
static const unsigned int HTTPDEFAULTPORT;
private:
- DNHTTPServerImpl *impl;
+ DNServerHTTPImpl *impl;
- static void clientRequestHandler(DNHTTPServer *server, const char *path, const char *body);
- void doQueryRequest(std::string requestBody);
- void doSetRequest(std::string requestBody);
+ static void clientRequestHandler(DNServerHTTP *server, const char *path, const char *body);
void doUIRequest(const char *path);
void doBadRequest(std::string errorMsg);
// static DNHTTPRequest* parseHttpRequest(const char *message);
};
-typedef void (*DNClientRequestHandler)(DNHTTPServer *server, const char *path, const char *body);
+typedef void (*DNClientRequestHandler)(DNServerHTTP *server, const char *path, const char *body);
-#endif
+#endif // DNSERVERHTTP_H
// Created by tkawata on 1/28/2012.
//
-#ifndef dennco_DNHTTPServerImpl_h
-#define dennco_DNHTTPServerImpl_h
+#ifndef DNSERVERHTTPIMPL_H
+#define DNSERVERHTTPIMPL_H
-#include "DNServer.h"
-#include "DNHTTPServer.h"
+#include "DNServerBase.h"
+#include "DNServerHTTP.h"
class DNEngine;
-class DNHTTPServer;
+class DNServerHTTP;
-class DNHTTPServerImpl
+class DNServerHTTPImpl
{
public:
- static DNHTTPServerImpl* create(DNHTTPServer *owner, DNClientRequestHandler handler);
+ static DNServerHTTPImpl* create(DNServerHTTP *owner, DNClientRequestHandler handler);
virtual bool isRunning() = 0;
virtual void start() = 0;
virtual void stop() = 0;
virtual void replyWithStatusCode(int code, const char* message) = 0;
virtual void replyWithFile(const char* filePath) = 0;
- virtual ~DNHTTPServerImpl() {}
+ virtual ~DNServerHTTPImpl() {}
};
-#endif
+#endif //DNSERVERHTTPIMPL_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/15/2012.
+//
+#include "DNServerSerialPort.h"
+
+#include "DNEngine.h"
+
+DNServerSerialPort::DNServerSerialPort(DNEngine *engine) : DNServerBase(engine)
+{
+ m_serialPort = new DNSerialPort(this);
+}
+
+DNServerSerialPort::~DNServerSerialPort()
+{
+ if (m_serialPort)
+ {
+ m_serialPort->stop();
+ delete m_serialPort;
+ m_serialPort = NULL;
+ }
+}
+
+bool DNServerSerialPort::isRunning()
+{
+ if (m_serialPort)
+ {
+ return m_serialPort->isRunning();
+ }
+ return false;
+}
+
+bool DNServerSerialPort::setup()
+{
+ if (m_serialPort)
+ {
+ return m_serialPort->setup();
+ }
+ return false;
+}
+
+void DNServerSerialPort::start()
+{
+ if (m_serialPort)
+ {
+ m_serialPort->start();
+ }
+}
+
+void DNServerSerialPort::stop()
+{
+ if (m_serialPort)
+ {
+ m_serialPort->stop();
+ }
+}
+
+void DNServerSerialPort::doQueryRequest(std::string requestBody)
+{
+
+}
+
+void DNServerSerialPort::doSetRequest(std::string requestBody)
+{
+}
--- /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/15/2012.
+//
+#ifndef DNSERVERSERIALPORT_H
+#define DNSERVERSERIALPORT_H
+
+#include "DNServerBase.h"
+#include "DNSerialPort.h"
+
+#include <string>
+
+class DNEngine;
+
+class DNServerSerialPort : public DNServerBase
+{
+public:
+ DNServerSerialPort(DNEngine *engine);
+ virtual ~DNServerSerialPort();
+
+ bool setup();
+
+ virtual bool isRunning();
+ virtual void start();
+ virtual void stop();
+
+ virtual void doQueryRequest(std::string requestBody);
+ virtual void doSetRequest(std::string requestBody);
+private:
+ DNSerialPort *m_serialPort;
+
+};
+
+#endif // DNSERVERSERIALPORT_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Dialog</class>
+ <widget class="QDialog" name="Dialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>293</width>
+ <height>255</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Simple port info application</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="portsGroupBox">
+ <property name="title">
+ <string>Available ports:</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="portNameLabel">
+ <property name="text">
+ <string>Current port name:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="portsComboBox"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="updateButton">
+ <property name="text">
+ <string>Update</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>0</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="infoGroupBox">
+ <property name="title">
+ <string>Current port info:</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="locationNameLabel">
+ <property name="text">
+ <string>Location:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="locationValueLabel">
+ <property name="text">
+ <string>***</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="descriptionNameLabel">
+ <property name="text">
+ <string>Description:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="descriptionValueLabel">
+ <property name="text">
+ <string>***</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="manufacturerNameLabel">
+ <property name="text">
+ <string>Manufacturer:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="manufacturerValueLabel">
+ <property name="text">
+ <string>***</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QPushButton" name="validButton">
+ <property name="text">
+ <string>Check valid</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="validLabel">
+ <property name="text">
+ <string>***</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QPushButton" name="busyButton">
+ <property name="text">
+ <string>Check busy</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="busyLabel">
+ <property name="text">
+ <string>***</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QPushButton" name="ratesButton">
+ <property name="text">
+ <string>Get rates</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QComboBox" name="ratesComboBox"/>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null
+#-------------------------------------------------
+#
+# Project created by QtCreator 2012-02-21T22:44:17
+#
+#-------------------------------------------------
+
+QT += core gui webkit script xml sql
+
+TARGET = QtDennco
+TEMPLATE = app
+
+
+INCLUDEPATH += QtScript platform/qt ../Thirdparty/serialport/include
+
+SOURCES += QtDennco/mainwindow.cpp \
+ QtDennco/main.cpp \
+ TKUICell.cpp \
+ TKReceptor.cpp \
+ TKLog.cpp \
+ TKLock.cpp \
+ TKDebug.cpp \
+ TKContainer.cpp \
+ TKCellCodeInstance.cpp \
+ TKCellCode.cpp \
+ TKCell.cpp \
+ TKAxonTerminal.cpp \
+ TKAxon.cpp \
+ DNXMLElement.cpp \
+ DNXML.cpp \
+ DNUtils.cpp \
+ DNTimeKeeper.cpp \
+ DNFileList.cpp \
+ DNEngine.cpp \
+ DNDirectory.cpp \
+ DNContainerBuilder.cpp \
+ DNAlert.cpp \
+ QtScript/dnqscellbase.cpp \
+ QtScript/dnqsbasiccell.cpp \
+ QtScript/dnqscellcode.cpp \
+ QtScript/dnqscellcodeinstance.cpp \
+ QtScript/dnqscontainer.cpp \
+ platform/qt/qttklockimpl.cpp \
+ platform/qt/qtdndirectoryimpl.cpp \
+ platform/qt/qtdnalertimpl.cpp \
+ platform/qt/qtsimplehttpserverimpl.cpp \
+ platform/qt/qtdntimekeeperimpl.cpp \
+ platform/qt/qtdnxmlimpl.cpp \
+ platform/qt/QtTKConsole.cpp \
+ DNGlobal.cpp \
+ DNThread.cpp \
+ platform/qt/qtdnthreadimpl.cpp \
+ QtDennco/dnwebinterface.cpp \
+ QtScript/dnqsinputcell.cpp \
+ QtScript/dnqsoutputcell.cpp \
+ platform/qt/qtdnstorageimpl.cpp \
+ DNStorage.cpp \
+ QtScript/dnqsbasicstoragecell.cpp \
+ DNServerHTTP.cpp \
+ DNServerSerialPort.cpp \
+ DNSerialPort.cpp \
+ platform/qt/qtdnserialportimpl.cpp
+
+
+HEADERS += QtDennco/mainwindow.h \
+ TKUICell.h \
+ TKReceptor.h \
+ TKLog.h \
+ TKLockImpl.h \
+ TKLock.h \
+ TKDebug.h \
+ TKContainer.h \
+ TKConsole.h \
+ TKCellCodeInstance.h \
+ TKCellCode.h \
+ TKCell.h \
+ TKAxonTerminal.h \
+ TKAxon.h \
+ DNXMLImpl.h \
+ DNXMLElement.h \
+ DNXML.h \
+ DNUtils.h \
+ DNTimeKeeperImpl.h \
+ DNTimeKeeper.h \
+ DNFileList.h \
+ DNEngine.h \
+ DNDirectoryImpl.h \
+ DNDirectory.h \
+ DNContainerBuilder.h \
+ DNAlertImpl.h \
+ DNAlert.h \
+ dennco.h \
+ QtScript/dnqscellbase.h \
+ QtScript/dnqsbasiccell.h \
+ QtScript/dnqscellcode.h \
+ QtScript/dnqscellcodeinstance.h \
+ QtScript/dnqscontainer.h \
+ versioninfo.h \
+ platform/qt/qttklockimpl.h \
+ platform/qt/qtdndirectoryimpl.h \
+ platform/qt/qtdnalertimpl.h \
+ platform/qt/qtsimplehttpserverimpl.h \
+ platform/qt/qtdntimekeeperimpl.h \
+ platform/qt/qtdnxmlimpl.h \
+ DNGlobal.h \
+ DNThread.h \
+ DNThreadImpl.h \
+ platform/qt/qtdnthreadimpl.h \
+ QtDennco/dnwebinterface.h \
+ QtScript/dnqsinputcell.h \
+ QtScript/dnqsoutputcell.h \
+ DNStorageImpl.h \
+ DNStorage.h \
+ platform/qt/qtdnstorageimpl.h \
+ QtScript/dnqsbasicstoragecell.h \
+ DNServerHTTP.h \
+ DNServerSerialPort.h \
+ DNServerBase.h \
+ DNSerialPort.h \
+ DNSerialPortImpl.h \
+ platform/qt/qtdnserialportimpl.h \
+ DNServerHTTPImpl.h
+
+FORMS += QtDennco/mainwindow.ui
+FORMS += QtDennco/portinfodialog.ui
+
+Debug:DEFINES+=DEBUG
--- /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/15/2012.
+//
+#include "qtdnserialportimpl.h"
+
+#include "DNServerSerialPort.h"
+#include "DNThread.h"
+#include "DNUtils.h"
+#include <QThread>
+
+class SleeperThread : public QThread
+{
+public:
+ static void msleep(unsigned long msecs)
+ {
+ QThread::msleep(msecs);
+ }
+};
+
+DNSerialPortImpl * DNSerialPortImpl::create(DNServerSerialPort *server)
+{
+ return new QtDNSerialPortImpl(server);
+}
+
+
+QtDNSerialPortImpl::QtDNSerialPortImpl(DNServerSerialPort *server) :
+ DNSerialPortImpl(server), mListnerThread(NULL), mHandlerThread(NULL), mPort(NULL), mStopping(false)
+{
+
+}
+
+QtDNSerialPortImpl::~QtDNSerialPortImpl()
+{
+ stop();
+ if (mListnerThread)
+ {
+ delete mListnerThread;
+ mListnerThread = NULL;
+ }
+ if (mHandlerThread)
+ {
+ delete mHandlerThread;
+ mHandlerThread = NULL;
+ }
+ if (mPort)
+ {
+ delete mPort;
+ mPort = NULL;
+ }
+}
+
+bool QtDNSerialPortImpl::setup()
+{
+ //TODO
+ return false;
+}
+
+bool QtDNSerialPortImpl::isRunning()
+{
+ //TODO
+ return false;
+}
+
+void QtDNSerialPortImpl::start()
+{
+ stop();
+ if (!mListnerThread)
+ mListnerThread = DNThread::createThread(QtDNSerialPortImpl::requestListenerThreadBody, this);
+
+ if (!mHandlerThread)
+ mHandlerThread = DNThread::createThread(QtDNSerialPortImpl::requestHandelrThreadBody, this);
+
+ mListnerThread->start();
+ mHandlerThread->start();
+}
+
+void QtDNSerialPortImpl::stop()
+{
+
+}
+
+//static
+void QtDNSerialPortImpl::requestListenerThreadBody(void *_impl)
+{
+ if (!_impl)
+ return;
+
+ QtDNSerialPortImpl *impl = (QtDNSerialPortImpl*)_impl;
+ char buffer[1024];
+ while(!impl->mStopping)
+ {
+ if ((impl->mPort->bytesAvailable() > 0) || impl->mPort->waitForReadyRead(100))
+ {
+ int len = impl->mPort->readLine(buffer, sizeof(buffer));
+ if (len != -1)
+ {
+ impl->mLock.lock();
+ impl->mRequestQueue.push_back(QString::fromLocal8Bit(buffer));
+ if (impl->mQueueSemaphore.available()==0)
+ {
+ impl->mQueueSemaphore.release(1);
+ }
+ impl->mLock.unlock();
+ }
+ }
+ if (!impl->mPort->isOpen())
+ {
+ SleeperThread::msleep(300);
+ }
+ }
+}
+
+//static
+void QtDNSerialPortImpl::requestHandelrThreadBody(void *_impl)
+{
+ if (!_impl)
+ return;
+
+ QtDNSerialPortImpl *impl = (QtDNSerialPortImpl*)_impl;
+ while(!impl->mStopping)
+ {
+ impl->mQueueSemaphore.tryAcquire(1,100);
+ impl->mLock.lock();
+ if (!impl->mRequestQueue.isEmpty())
+ {
+ QString line = impl->mRequestQueue.dequeue();
+ impl->mLock.unlock();
+
+ //TODO
+
+ }
+ else
+ {
+ impl->mLock.unlock();
+ }
+
+ }
+
+
+}
+
--- /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/15/2012.
+//
+#ifndef QTDNSERIALPORTIMPL_H
+#define QTDNSERIALPORTIMPL_H
+
+#include "DNSerialPortImpl.h"
+
+#include "TKLock.h"
+
+#include <serialport.h>
+#include <QString>
+#include <QQueue>
+#include <QSemaphore>
+
+class DNServerSerialPort;
+class DNThread;
+
+class QtDNSerialPortImpl : public DNSerialPortImpl
+{
+public:
+ QtDNSerialPortImpl(DNServerSerialPort *server);
+ virtual ~QtDNSerialPortImpl();
+
+ virtual bool setup();
+
+ virtual bool isRunning();
+ virtual void start();
+ virtual void stop();
+
+ static void requestListenerThreadBody(void *impl);
+ static void requestHandelrThreadBody(void *impl);
+
+private:
+ DNThread *mListnerThread;
+ DNThread *mHandlerThread;
+ SerialPort *mPort;
+ bool mStopping;
+
+ QQueue<QString> mRequestQueue;
+ TKLock mLock;
+ QSemaphore mQueueSemaphore;
+};
+
+#endif // QTDNSERIALPORTIMPL_H
//
#include "qtsimplehttpserverimpl.h"
-DNHTTPServerImpl *DNHTTPServerImpl::create(DNHTTPServer *owner, DNClientRequestHandler handler)
+DNServerHTTPImpl *DNServerHTTPImpl::create(DNServerHTTP *owner, DNClientRequestHandler handler)
{
//TODO
return NULL;
#ifndef QTSIMPLEHTTPSERVERIMPL_H
#define QTSIMPLEHTTPSERVERIMPL_H
-#include "DNHTTPServerImpl.h"
+#include "DNServerHTTPImpl.h"
-class QtSimpleHTTPServerImpl : public DNHTTPServerImpl
+class QtSimpleHTTPServerImpl : public DNServerHTTPImpl
{
public:
QtSimpleHTTPServerImpl();
--- /dev/null
+This is the directory for storing thirdparty files.
+
+Please get following thirdparty files and put here.
+
+- QSerialDevice 2.0
+ Download QSerialDevice 2.0 from http://gitorious.org/qserialdevice/qserialdevice/trees/2.0 and deploy under this directory.
+ Rename the top directory of the thirdparty file to serialport.
+ The top directory for this thirdparty file will be "Thirdparty/serialport".
+
+ MEMO:
+ If you develop on windows and use QtSDK with default configuration, you may encounter a build error
+ "qwineventnotifier_p.h: No such file or directory." when you compile this thirdparty file.
+
+ The easiest workaround for the issue is to install the source code of the Qt framework to QtSDK.
+ You can do this by "Package Manager" which you can launch through QtCreator menu Help -> Update.
+ The source seems to be copied under <QtSDK installDIR>/QtSource.
+ Copy the directory "src" under QtSource into the build package which you are using, they will be
+ under <QtSDK installDIR>/Desktop/Qt/4.8.0/mingw (or may be msv2010 or msv2008).
+
+
+
#
#-------------------------------------------------
-QT += core gui webkit script xml sql
+TEMPLATE = subdirs
+CONFIG += ordered
-TARGET = QtDennco
-TEMPLATE = app
-
-
-INCLUDEPATH += Source Source/QtScript Source/platform/qt
-
-SOURCES += Source/QtDennco/mainwindow.cpp \
- Source/QtDennco/main.cpp \
- Source/TKUICell.cpp \
- Source/TKReceptor.cpp \
- Source/TKLog.cpp \
- Source/TKLock.cpp \
- Source/TKDebug.cpp \
- Source/TKContainer.cpp \
- Source/TKCellCodeInstance.cpp \
- Source/TKCellCode.cpp \
- Source/TKCell.cpp \
- Source/TKAxonTerminal.cpp \
- Source/TKAxon.cpp \
- Source/DNXMLElement.cpp \
- Source/DNXML.cpp \
- Source/DNUtils.cpp \
- Source/DNTimeKeeper.cpp \
- Source/DNHTTPServer.cpp \
- Source/DNFileList.cpp \
- Source/DNEngine.cpp \
- Source/DNDirectory.cpp \
- Source/DNContainerBuilder.cpp \
- Source/DNAlert.cpp \
- Source/QtScript/dnqscellbase.cpp \
- Source/QtScript/dnqsbasiccell.cpp \
- Source/QtScript/dnqscellcode.cpp \
- Source/QtScript/dnqscellcodeinstance.cpp \
- Source/QtScript/dnqscontainer.cpp \
- Source/platform/qt/qttklockimpl.cpp \
- Source/platform/qt/qtdndirectoryimpl.cpp \
- Source/platform/qt/qtdnalertimpl.cpp \
- Source/platform/qt/qtsimplehttpserverimpl.cpp \
- Source/platform/qt/qtdntimekeeperimpl.cpp \
- Source/platform/qt/qtdnxmlimpl.cpp \
- Source/platform/qt/QtTKConsole.cpp \
- Source/DNGlobal.cpp \
- Source/DNThread.cpp \
- Source/platform/qt/qtdnthreadimpl.cpp \
- Source/QtDennco/dnwebinterface.cpp \
- Source/QtScript/dnqsinputcell.cpp \
- Source/QtScript/dnqsoutputcell.cpp \
- Source/platform/qt/qtdnstorageimpl.cpp \
- Source/DNStorage.cpp \
- Source/QtScript/dnqsbasicstoragecell.cpp
-
-HEADERS += Source/QtDennco/mainwindow.h \
- Source/TKUICell.h \
- Source/TKReceptor.h \
- Source/TKLog.h \
- Source/TKLockImpl.h \
- Source/TKLock.h \
- Source/TKDebug.h \
- Source/TKContainer.h \
- Source/TKConsole.h \
- Source/TKCellCodeInstance.h \
- Source/TKCellCode.h \
- Source/TKCell.h \
- Source/TKAxonTerminal.h \
- Source/TKAxon.h \
- Source/DNXMLImpl.h \
- Source/DNXMLElement.h \
- Source/DNXML.h \
- Source/DNUtils.h \
- Source/DNTimeKeeperImpl.h \
- Source/DNTimeKeeper.h \
- Source/DNServer.h \
- Source/DNHTTPServerImpl.h \
- Source/DNHTTPServer.h \
- Source/DNFileList.h \
- Source/DNEngine.h \
- Source/DNDirectoryImpl.h \
- Source/DNDirectory.h \
- Source/DNContainerBuilder.h \
- Source/DNAlertImpl.h \
- Source/DNAlert.h \
- Source/dennco.h \
- Source/QtScript/dnqscellbase.h \
- Source/QtScript/dnqsbasiccell.h \
- Source/QtScript/dnqscellcode.h \
- Source/QtScript/dnqscellcodeinstance.h \
- Source/QtScript/dnqscontainer.h \
- Source/versioninfo.h \
- Source/platform/qt/qttklockimpl.h \
- Source/platform/qt/qtdndirectoryimpl.h \
- Source/platform/qt/qtdnalertimpl.h \
- Source/platform/qt/qtsimplehttpserverimpl.h \
- Source/platform/qt/qtdntimekeeperimpl.h \
- Source/platform/qt/qtdnxmlimpl.h \
- Source/DNGlobal.h \
- Source/DNThread.h \
- Source/DNThreadImpl.h \
- Source/platform/qt/qtdnthreadimpl.h \
- Source/QtDennco/dnwebinterface.h \
- Source/QtScript/dnqsinputcell.h \
- Source/QtScript/dnqsoutputcell.h \
- Source/DNStorageImpl.h \
- Source/DNStorage.h \
- Source/platform/qt/qtdnstorageimpl.h \
- Source/QtScript/dnqsbasicstoragecell.h
-
-FORMS += Source/QtDennco/mainwindow.ui
-Debug:DEFINES+=DEBUG
+SUBDIRS+=Thirdparty/serialport Source