{
std::string message = std::string("Failed to construct cell: ").append(cellInfo->location).append("#").append(cellInfo->cellName);
message.append("\nCellCode '").append(cellInfo->cellCodeClassOrType).append("' couldn't be found.");
- TKLog::printf("%s", message.c_str());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Initialization failed", message);
}
}
else
if (newCell == NULL)
{
std::string message = std::string("Failed to construct cell: ").append(cellInfo->location).append("#").append(cellInfo->cellName);
- TKLog::printf("%s", message.c_str());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Initialization failed", message);
}
mPendingCellDefinitions.pop();
}
if (!orgCell->connectTo(connInfo->connectionName, tgtCell))
{
std::string message = std::string("Failed to make connection. Receptor name for the target cell may be duplicated. (").append(connInfo->connectionName).append(" cell:").append(connInfo->originCellName).append(" - > ").append(connInfo->targetCellName);
- TKLog::printf("%s", message.c_str());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Initialization failed", message);
}
}
else
{
std::string message = std::string("Failed to make connection (").append(connInfo->connectionName).append(" cell:").append(connInfo->originCellName).append(" - > ").append(connInfo->targetCellName);
- TKLog::printf("%s", message.c_str());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Initialization failed", message);
}
mPendingConnections.pop();
}
if (defineDepth > 0)
{
std::string message = std::string("Syntax error while parsing ").append(path).append(". A defnie element seems to be nested.");
- TKLog::printf("%s", message.c_str());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Initialization failed", message);
}
else
{
else
{
std::string message = std::string("Syntax error while parsing ").append(path).append(". defnie='").append("' isn't correct.");
- TKLog::printf("%s\n", message.c_str());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Initialization failed", message);
}
}
}
{
std::string message = std::string("Syntax error while parsing ").append(path).append(". CellCode:").append(cellName);
message.append("\n'type' can't be defined here if you use CellCode class.");
- TKLog::printf("%s\n", message.c_str());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Initialization failed", message);
}
}
else if (parameter== "connection")
else
{
std::string message = std::string("Syntax error while parsing ").append(path).append(". parameter='").append(parameter).append("' isn't correct.");
- TKLog::printf("%s", message.c_str());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Initialization failed", message);
}
}
mUIPath = "/ui/index.html";
dnGlobal()->updateRunningStatus(DNGlobal::STOPPED);
+ dnGlobal()->resetErrorStatus();
std::string basePath(contentPath);
std::string containerRoot = basePath;
succeeded = parseSettingFile(contentPath);
if (!succeeded || !dnGlobal()->isErrorStatusNormal())
{
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("property.xml parse error");
- dnGlobal()->setMessage2("failed to parse setting file /property.xml");
- }
- else
- {
- dnGlobal()->setMessage1("property.xml parse error");
- }
+ dnNotifyError("property.xml parse error", "failed to parse setting file /property.xml");
return;
}
succeeded = mContainer->setDataStore(dataStorePath.c_str());
if (!succeeded)
{
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2("Failed to the setup data store");
- }
- else
- {
- dnGlobal()->setMessage1("Initialization failed");
- }
+ dnNotifyError("Initialization failed","Failed to the setup data store");
return;
}
succeeded = parseContainerFile(containerRoot.c_str());
if (!succeeded)
{
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2("Failed to parse container file");
- }
- else
- {
- dnGlobal()->setMessage1("Initialization failed");
- }
+ dnNotifyError("Initialization failed", "Failed to parse container file");
return;
}
{
valid = false;
std::string message = "Failed to load property.xml file";
- TKLog::printf("ERROR wile loading property.xml file.\n%s\n",message.c_str());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2(message);
- }
- else
- {
- dnGlobal()->setMessage1("Initialization failed");
- }
+ dnNotifyError("Initialization failed",message);
}
if (valid && element->name != "dennco")
{
valid = false;
std::string message = "First element of property.xml should be <dennco>";
- TKLog::printf("ERROR wile parsing property.xml file.\n%s\n",message.c_str());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2(message);
- }
- else
- {
- dnGlobal()->setMessage1("Initialization failed");
- }
+ dnNotifyError("Initialization failed",message);
}
if (valid)
{
valid = false;
std::string message = "Error in property.xml. TickIntervalSec is not configured properly.";
- TKLog::printf("ERROR wile parsing property.xml file.\n%s\n",message.c_str());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2(message);
- }
- else
- {
- dnGlobal()->setMessage1("Initialization failed");
- }
+ dnNotifyError("Initialization failed",message);
}
}
else if (pname == "UIPATH")
float DNEngine::doClientGetRequest(const char* path)
{
+ if (dnGlobal()->getRunningStatus() != DNGlobal::RUNNIING)
+ return 0;
+
std::string fqn = getFQNString("/",path);
TKUICell *cell = (TKUICell*)mContainer->getInterfaceCell(fqn);
float result = 0;
{
result = cell->getValue();
}
+ else
+ {
+ std::string message = "The requested path ";
+ message += path;
+ message += " doesn't exist.";
+ dnNotifyWarning("Failed to process the client request. (getValue)", message);
+ }
return result;
}
bool DNEngine::doClientSetRequest(const char* path, float value)
{
+ if (dnGlobal()->getRunningStatus() != DNGlobal::RUNNIING)
+ return false;
+
std::string fqn = getFQNString("/",path);
TKUICell *cell = (TKUICell*)mContainer->getInterfaceCell(fqn);
bool result = false;
cell->setValue(value);
result = true;
}
+ else
+ {
+ std::string message = "The requested path ";
+ message += path;
+ message += " doesn't exist.";
+ dnNotifyWarning("Failed to process the client request. (setValue)", message);
+ }
return result;
}
#include "DNUtils.h"
#include "TKLog.h"
#include "TKDebug.h"
+#include "DNGlobal.h"
#ifndef _MSC_VER
#include <string.h>
if (inFunction == -1)
{
//FUNCTION DEF
- std::string fn = "";
funcs.append(jname);
funcs.append(".prototype.");
funcs.append(fff);
return result;
}
+static TKLock NotifyLock;
+
+void dnNotifyError(std::string title, std::string message)
+{
+ NotifyLock.lock();
+
+ std::string::size_type pos = 0;
+ while(pos = message.find("\n", pos), pos != std::string::npos) {
+ message.replace(pos, 1, "\n ");
+ pos += 1;
+ }
+
+ std::string outMessage = "[ERROR!!!]:";
+ outMessage.append(title).append("\n ");
+ outMessage.append(message);
+
+ TKLog::printf(TKLog::ERROR, "%s", outMessage.c_str());
+ if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
+ {
+ dnGlobal()->setMessage1(title);
+ dnGlobal()->setMessage2(message);
+ }
+ else
+ {
+ dnGlobal()->setMessage1(title);
+ }
+ NotifyLock.unlock();
+}
+
+void dnNotifyWarning(std::string title, std::string message)
+{
+ NotifyLock.lock();
+
+ std::string::size_type pos = 0;
+ while(pos = message.find("\n", pos), pos != std::string::npos) {
+ message.replace(pos, 1, "\n ");
+ pos += 1;
+ }
+
+ std::string outMessage = "[WARNING] :";
+ outMessage.append(title).append("\n ");
+ outMessage.append(message);
+
+ TKLog::printf(TKLog::WARNING, "%s", outMessage.c_str());
+ if (dnGlobal()->updateErrorStatus(DNGlobal::WARNING))
+ {
+ dnGlobal()->setMessage1(title);
+ dnGlobal()->setMessage2(message);
+ }
+ else
+ {
+ dnGlobal()->setMessage1(title);
+ }
+ NotifyLock.unlock();
+}
std::string getJSEscapeString(const char *cstring);
std::string parseCellCodeForScriptEngine(std::string jname, std::string cellCode);
+void dnNotifyError(std::string title, std::string message);
+void dnNotifyWarning(std::string title, std::string message);
+
class DNLocker
{
public:
#include "DNSettings.h"
//static
+QColor MainWindow::NORMAL_COLOR(0,0,0);
+//static
+QColor MainWindow::WARN_COLOR(0xff, 0x95, 0x2b);
+//static
+QColor MainWindow::ERROR_COLOR(0xff, 0,0);
+//static
QWidget *MainWindow::instance = NULL;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
- mEngine(NULL), mWebInterface(NULL),
- mHasPendingConsoleMessage(false)
+ mEngine(NULL), mWebInterface(NULL)
{
instance = this;
ui->setupUi(this);
ui->filePath->setText(contentPath);
- ui->console->document()->setMaximumBlockCount(2000);
+ ui->console->document()->setMaximumBlockCount(500);
QFont monofont("Courier");
monofont.setStyleHint(QFont::Monospace);
ui->console->setFont(monofont);
void MainWindow::paintEvent( QPaintEvent * event )
{
mConsoleLock.lock();
- if (mHasPendingConsoleMessage)
+ while (!mPendingConsoleMessages.isEmpty())
{
- ui->console->append(mPendingConsoleMessage);
- mPendingConsoleMessage.clear();
- mHasPendingConsoleMessage = false;
+ PendingConsoleMessage aMessage = mPendingConsoleMessages.dequeue();
+ switch(aMessage.messageType)
+ {
+ case TKLog::NORMAL :
+ ui->console->setTextColor(NORMAL_COLOR);
+ break;
+ case TKLog::WARNING :
+ ui->console->setTextColor(WARN_COLOR);
+ break;
+ case TKLog::ERROR :
+ ui->console->setTextColor(ERROR_COLOR);
+ break;
+ }
+ ui->console->append(aMessage.text);
}
mConsoleLock.unlock();
QMainWindow::paintEvent(event);
}
-void MainWindow::vprintf(const char *fmt, va_list ap)
+
+void MainWindow::vprintf(TKLog::MessageType type, const char *fmt, va_list ap)
{
QString msg = QString().vsprintf(fmt,ap);
#ifdef DEBUG
qDebug() << msg << endl;
#endif
mConsoleLock.lock();
- if (mHasPendingConsoleMessage)
- mPendingConsoleMessage.append("\n");
- mPendingConsoleMessage.append(msg);
- mHasPendingConsoleMessage = true;
+ PendingConsoleMessage newMessage;
+ newMessage.messageType = type;
+ newMessage.text = msg;
+ mPendingConsoleMessages.enqueue(newMessage);
mConsoleLock.unlock();
emit consoleUpdated();
}
#define MAINWINDOW_H
#include <QMainWindow>
+#include <QQueue>
#include "TKConsole.h"
#include "TKLock.h"
TKConsole *mConsole;
DNWebInterface *mWebInterface;
- virtual void vprintf(const char *fmt, va_list arg);
+ class PendingConsoleMessage
+ {
+ public:
+ TKLog::MessageType messageType;
+ QString text;
+ };
+
+ static QColor NORMAL_COLOR;
+ static QColor WARN_COLOR;
+ static QColor ERROR_COLOR;
+
+ virtual void vprintf(TKLog::MessageType type, const char *fmt, va_list arg);
virtual void vDebugPrintf(const char *fmt, va_list arg);
TKLock mConsoleLock;
- QString mPendingConsoleMessage;
- bool mHasPendingConsoleMessage;
+ QQueue<PendingConsoleMessage> mPendingConsoleMessages;
signals:
void consoleUpdated();
#include "TKReceptor.h"
#include "TKAxon.h"
#include "TKCellCodeInstance.h"
+#include "DNUtils.h"
DNQSBasicCell::DNQSBasicCell(DNQSContainer *container, std::string location, std::string name, bool canInterface):
DNQSCellBase(container,location,name,canInterface)
void DNQSBasicCell::handleScriptException(const char *funcName)
{
- TKLog::printf("Script Error! in %s#%s.%s", mLocation.c_str(), mName.c_str(), funcName);
+ std::string message = "Script Error! in ";
+ message += mLocation;
+ message += "#";
+ message += funcName;
if (mEngine->hasUncaughtException())
{
QScriptValue error = mEngine->uncaughtException();
QString errorString = error.toString();
- TKLog::printf(" Error Message: %s", errorString.toLocal8Bit().data());
+ message += "\n";
+ message += errorString.toStdString();
mEngine->clearExceptions();
}
+ dnNotifyWarning("Script error", message);
}
bool DNQSBasicCell::doTick(float time)
{
QScriptValue error = engine->uncaughtException();
QString errorString = error.toString();
- TKLog::printf("Script error at scriptFunction_storage_getXYZVArray. Error Message: %s", errorString.toLocal8Bit().data());
+ TKLog::debugPrintf("Script error at scriptFunction_storage_getXYZVArray. Error Message: %s", errorString.toLocal8Bit().data());
engine->clearExceptions();
}
#endif //DEBUG
#include "dnqscontainer.h"
#include "dnqscellbase.h"
#include "dnqscellcodeinstance.h"
+#include "DNGlobal.h"
DNQSCellCode::DNQSCellCode(std::string name, std::string cellapi, DNQSContainer *container, std::string code):
TKCellCode(name,cellapi), mCellContainer(container)
QScriptEngine *scriptEngine = mCellContainer->getScriptEngine();
QScriptValue scriptGlobalObject = mCellContainer->getScriptGlobalObject();
scriptEngine->evaluate(QScriptProgram(stmt));
+ if (scriptEngine->hasUncaughtException())
+ {
+ QScriptValue error = scriptEngine->uncaughtException();
+ QString errorString = error.toString();
+ scriptEngine->clearExceptions();
+
+ std::string message = "Failed to construct Cell code : ";
+ message.append(getName()).append("\n");
+ message.append("Error Message:").append(errorString.toStdString());
+ dnNotifyError("Initialization failed", message);
+ return;
+ }
+
mCellCodeConstructor = scriptGlobalObject.property(QString::fromStdString(jname), QScriptValue::ResolveLocal);
if (mCellCodeConstructor.isNull() || mCellCodeConstructor.isUndefined() || ! mCellCodeConstructor.isValid())
{
- TKLog::printf("DNQSCellCode ERROR creating:%s", name.c_str());
+ std::string message = "Failed to construct Cell code : ";
+ message.append(getName()).append("\n");
+ message.append("The constructor is invalid.");
+ dnNotifyError("Initialization failed", message);
+ return;
}
}
}
if (mCellCodeConstructor.isNull() || mCellCodeConstructor.isUndefined() || ! mCellCodeConstructor.isValid())
{
- TKLog::printf("DNQSCellCode::createCellCodeInstance ERROR. %s", getName().c_str());
+ std::string message = "Failed to construct Cell code '";
+ message.append(owner->getName());
+ message.append("' cellcode:");
+ message.append(getName()).append("\n");
+ message.append("Cell code invalid");
+ dnNotifyError("Initialization failed", message);
return NULL;
}
TKCellCodeInstance *result = NULL;
+ QScriptEngine *scriptEngine = mCellContainer->getScriptEngine();
QScriptValueList args;
args << ((DNQSCellBase*)owner)->getCellAPI();
QScriptValue instance = mCellCodeConstructor.construct(args);
+ if (scriptEngine->hasUncaughtException())
+ {
+ QScriptValue error = scriptEngine->uncaughtException();
+ QString errorString = error.toString();
+ scriptEngine->clearExceptions();
+
+ std::string message = "Failed to construct Cell code '";
+ message.append(owner->getName()).append("'\n");
+ message.append("cellcode:");
+ message.append(getName()).append("\n");
+ message.append("Error Message:").append(errorString.toStdString());
+ dnNotifyError("Initialization failed", message);
+ return NULL;
+ }
if (instance.isValid())
{
- QScriptEngine *scriptEngine = mCellContainer->getScriptEngine();
-
//
QScriptContext *context = scriptEngine->pushContext();
context->setThisObject(instance);
QString customScriptStr((const char*)data);
QScriptProgram customScript(customScriptStr);
scriptEngine->evaluate(customScript);
+ if (scriptEngine->hasUncaughtException())
+ {
+ QScriptValue error = scriptEngine->uncaughtException();
+ QString errorString = error.toString();
+ scriptEngine->clearExceptions();
+
+ std::string message = "";
+ message.append("Failed to construct Cell code '");
+ message.append(owner->getName()).append("'\n");
+ message.append("cellcode:");
+ message.append(getName()).append("\n");
+ message.append("Error Message:").append(errorString.toStdString());
+ dnNotifyError("Initialization failed", message);
+ }
scriptEngine->popContext();
if (context->argumentCount() >= 1)
{
QString value = context->argument(0).toString();
- TKLog::printf("%s", value.toLocal8Bit().data());
+ TKLog::printf(TKLog::NORMAL, "%s", value.toLocal8Bit().data());
}
return engine->nullValue();
}
{
std::string message = std::string("Failed to construct cell '").append(theLocation).append("#").append(theName);
message.append("'\nThe cellcode requires type '").append(type).append("' but it's not a supported type.");
- TKLog::printf("%s", message.c_str());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Initialization failed", message);
}
if (cell)
{
std::string message = std::string("Failed to construct cell '").append(theLocation).append("#").append(theName);
message.append("'\nThe cellcode is type '").append(type).append("'. This type doesn't support custom script.");
- TKLog::printf("%s", message.c_str());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Initialization failed",message);
}
}
}
else
{
std::string fqnName = getFQNString(theLocation.c_str(),theName.c_str());
- TKLog::printf("Failed to create a cell. %s", fqnName.c_str());
+ std::string message = "Failed to create a cell. ";
+ message += fqnName;
+ message += "\n";
+ message += "Out of memory?";
+ dnNotifyError("Initialization failed", message);
}
return cell;
{
std::string message = std::string("Failed to construct cell '").append(theLocation).append("#").append(theName);
message.append("'\nThe cellcode type '").append(type).append("' doesn't support to have a CellCode class.");
- TKLog::printf("%s", message.c_str());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Initialization failed", message);
}
else if (type == CELLTYPE_IN)
{
std::string message = std::string("Failed to construct cell '").append(theLocation).append("#").append(theName);
message.append("'\nThe cellcode requires type '").append(type).append("' doesn't support to have a CellCode class.");
- TKLog::printf("%s", message.c_str());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Initialization failed", message);
}
else
{
std::string message = std::string("Failed to construct cell '").append(theLocation).append("#").append(theName);
message.append("'\nThe cellcode requires type '").append(type).append("' but it's not a supported type.");
- TKLog::printf("%s", message.c_str());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Initialization failed");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Initialization failed",message);
}
else
{
std::string fqnName = getFQNString(theLocation.c_str(),theName.c_str());
- TKLog::printf("Failed to create a cell. %s", fqnName.c_str());
+ std::string message = "Failed to create a cell. ";
+ message += fqnName;
+ message += "\n";
+ message += "Out of memory?";
+ dnNotifyError("Initialization failed", message);
}
return cell;
#define dennco_TKConsole_h
#include <stdarg.h>
+#include "TKLog.h"
class TKConsole
{
public:
- virtual void vprintf(const char *fmt, va_list arg);
+ virtual void vprintf(TKLog::MessageType type, const char *fmt, va_list arg);
virtual void vDebugPrintf(const char *fmt, va_list arg);
};
TKConsole *TKLog::msConsole = 0;
-void TKLog::printf(const char* fmt,...)
+void TKLog::printf(MessageType type, const char* fmt,...)
{
if (TKLog::msConsole)
{
va_list ap;
va_start(ap, fmt);
- msConsole->vprintf(fmt, ap);
+ msConsole->vprintf(type, fmt, ap);
va_end(ap);
}
}
class TKLog
{
public:
- static void printf(const char* fmt,...);
- static void debugPrintf(const char* fmt,...);
+ enum MessageType {NORMAL, WARNING, ERROR};
+
+ static void printf(MessageType type, const char* fmt,...);
+ static void debugPrintf(const char* fmt,...);
static void setDestination(TKConsole *console);
private:
static TKConsole *msConsole;
};
-#endif
\ No newline at end of file
+#endif
float TKReceptor::getValue()
{
#ifdef DEBUG_CONNECTION
- TKLog::printf("TKReceptor::getValue called: owner:%s tarminal owner:%s value:%f\n",
+ TKLog::debugPrintf("TKReceptor::getValue called: owner:%s tarminal owner:%s value:%f\n",
mOwner->getName().c_str(),
mTerminal->getOwner()->getOwner()->getName().c_str(),
mTerminal->getValue());
#include <QDebug>
-void TKConsole::vprintf(const char *fmt, va_list ap)
+void TKConsole::vprintf(TKLog::MessageType type, const char *fmt, va_list ap)
{
+ (type);
QString msg = QString().vsprintf(fmt,ap);
qDebug() << msg << endl;
}
port = NULL;
}
retry--;
- TKLog::printf("Failed to open the serial port. retrying...");
+ dnNotifyWarning("SerialPort initialization", "Failed to open the serial port. retrying...");
}
} while (!r && retry >= 0);
impl->mStartStopLock.lock();
impl->mStopping = true;
impl->mStartStopLock.unlock();
- TKLog::printf("Failed to open the serial port. giving up!");
+ dnNotifyWarning("SerialPort initialization", "Failed to open the serial port. giving up!");
return;
}
if (cmd == "M")
{
//message
- TKLog::printf("(SERIALl):%s", par.toLocal8Bit().constData());
+ TKLog::printf(TKLog::NORMAL, "(SERIALl):%s", par.toLocal8Bit().constData());
}
else if (cmd == "S")
{
#include "DNStorage.h"
#include "DNStorageImpl.h"
#include "TKLog.h"
+#include "DNUtils.h"
#include <QtSql>
#include <DNGlobal.h>
message.append(key);
message.append("\n");
message.append(mQueries->propertiesCountQuery.lastError().text().toStdString());
- TKLog::printf("%s", message.c_str());
+ dnNotifyWarning("SQL ERROR", message);
return false;
}
mQueries->propertiesCountQuery.next();
message.append(key);
message.append("\n");
message.append(mQueries->propertiesCountQuery.lastError().text().toStdString());
- TKLog::printf("%s", message.c_str());
+ dnNotifyWarning("SQL ERROR", message);
return false;
}
}
message.append(key);
message.append("\n");
message.append(mQueries->propertiesCountQuery.lastError().text().toStdString());
- TKLog::printf("%s", message.c_str());
+ dnNotifyWarning("SQL ERROR", message);
return false;
}
}
message.append(key);
message.append("\n");
message.append(mQueries->propertiesCountQuery.lastError().text().toStdString());
- TKLog::printf("%s", message.c_str());
+ dnNotifyWarning("SQL ERROR", message);
return false;
}
mQueries->propertiesGetQuery.next();
message.append(key);
message.append("\n");
message.append(mQueries->propertiesCountQuery.lastError().text().toStdString());
- TKLog::printf("%s", message.c_str());
+ dnNotifyWarning("SQL ERROR", message);
return 0;
}
message.append(key);
message.append("\n");
message.append(mQueries->xyzvDataCountQuery.lastError().text().toStdString());
- TKLog::printf("%s", message.c_str());
+ dnNotifyWarning("SQL ERROR", message);
return 0;
}
message.append(key);
message.append("\n");
message.append(mQueries->xyzvDataInsetQuery.lastError().text().toStdString());
- TKLog::printf("%s", message.c_str());
+ dnNotifyWarning("SQL ERROR", message);
return false;
}
message.append(key);
message.append("\n");
message.append(mQueries->xyzvDataCountQuery.lastError().text().toStdString());
- TKLog::printf("%s", message.c_str());
+ dnNotifyWarning("SQL ERROR", message);
return 0;
}
mQueries->xyzvDataCountQuery.next();
message.append(key);
message.append("\n");
message.append(mQueries->xyzvDataGetQuery.lastError().text().toStdString());
- TKLog::printf("%s", message.c_str());
+ dnNotifyWarning("SQL ERROR", message);
if (records)
delete records;
return 0;
message.append(key);
message.append("\n");
message.append(mQueries->xyzvDataRemoveQuery.lastError().text().toStdString());
- TKLog::printf("%s", message.c_str());
+ dnNotifyWarning("SQL ERROR", message);
return false;
}
return true;
message.append(mStoragePath.toStdString());
message.append("\n");
message.append(mDatabase->database.lastError().text().toStdString());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Persistent storage initialization error.");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Persistent storage initialization error.", message);
return false;
}
message.append(mStoragePath.toStdString());
message.append("\n");
message.append(mDatabase->database.lastError().text().toStdString());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Persistent storage initialization error.");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Persistent storage initialization error.", message);
return false;
}
}
message.append(mStoragePath.toStdString());
message.append("\n");
message.append(mDatabase->database.lastError().text().toStdString());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Persistent storage initialization error.");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Persistent storage initialization error.", message);
return false;
}
}
message.append(mStoragePath.toStdString());
message.append("\n");
message.append(mDatabase->database.lastError().text().toStdString());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Persistent storage initialization error.");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Persistent storage initialization error.", message);
return false;
}
{
if (!wait(5000))
{
- TKLog::printf("!WARNING! DNThread %p hasn't finished in 5sec. execute terminate to quit forcedly ", this);
+ TKLog::printf(TKLog::WARNING, "!WARNING! DNThread %p hasn't finished in 5sec. execute terminate to quit forcedly ", this);
setTerminationEnabled(true);
terminate();
}
#include "DNXMLElement.h"
#include "TKLog.h"
#include "DNGlobal.h"
+#include "DNUtils.h"
DNXMLImpl *DNXMLImpl::createXMLFromFileImpl(const char *docRoot, const char *docPath)
{
if (!mValid)
{
- TKLog::printf("ERROR failed to load file.%s", filePath.toLocal8Bit().data());
std::string message = "failed to load file:";
message.append(filePath.toStdString());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Error at loading XML file");
- dnGlobal()->setMessage2(message);
- }
+ dnNotifyError("Error at loading XML file", message);
}
}
bool QtXMLHandler::error (const QXmlParseException & exception )
{
std::string message = exception.message().toStdString();
- TKLog::printf("Error while reading XML file!! \n%s", message.c_str());
+ TKLog::printf(TKLog::WARNING, "Error while reading XML file!! \n%s", message.c_str());
return true;
}
{
QString message = QString().sprintf("ERROR while reading XML file!! file.%s (line:%d) \nReason:%s",
mFilePath.toLocal8Bit().data(), exception.lineNumber(), exception.message().toLocal8Bit().data());
- TKLog::printf("%s", message.toLocal8Bit().data());
- if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
- {
- dnGlobal()->setMessage1("Error at loading XML file");
- dnGlobal()->setMessage2(message.toStdString());
- }
+ dnNotifyError("Error at loading XML file", message.toStdString());
return true;
}