提交 1da9a28c 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

Add debug method, to display the HEX data

上级 c225ff8f
......@@ -11,8 +11,14 @@ namespace ZPDatabase{
{
bTerm = false;
}
//!Get an database connection belong to current thread.
//!if database does not exist, it will be added using dbtype
/**
* @brief Get an database connection belong to current thread.
* if database does not exist, it will be added using dbtype
* @fn DatabaseResource::databse
* @param strDBName the database name
* @return QSqlDatabase return the database object
*/
QSqlDatabase DatabaseResource::databse(const QString & strDBName)
{
QMutexLocker locker(&m_mutex_reg);
......@@ -58,6 +64,22 @@ namespace ZPDatabase{
m_dbNames.remove(strDBName) ;
}
/**
* @brief add a database connection resource
*
* @fn DatabaseResource::addConnection
* @param connName the user-specified name standing for this connection
* @param type the Qt-Sql database driver name, QPSQL, QMYSQL, etc.
* @param HostAddr the host address will connect to.
* @param port the port will connect to.
* @param dbName the database schema name
* @param User username
* @param Pass password
* @param ExtraOptions some extra options.
* @param testSQL if this para is not empty, confirmConnection will call this SQL to confirm the db is OK,
* for example, select 1+1 , will return 2 if db is ok.
* @return bool succeed : true
*/
bool DatabaseResource::addConnection(
const QString & connName,
const QString & type,
......@@ -114,6 +136,14 @@ namespace ZPDatabase{
m_dbNames.remove(connName) ;
return false;
}
/**
* @brief this method runs in a special guarding thread
* to confirm the connection resource is still OK
* see DatabaseResource::run()
* @fn DatabaseResource::confirmConnection
* @param connName the connection name which to be tested.
* @return bool the check result.
*/
bool DatabaseResource::confirmConnection (const QString & connName)
{
QMutexLocker locker(&m_mutex_reg);
......
......@@ -7,10 +7,14 @@
#include <QString>
#include <QMutex>
#include <QThread>
//!this class provide an database reource,
//!In different thread, workers can get existing db connections
//! immediately without re-creation operations.
namespace ZPDatabase{
/**
* @brief this class provide an database reource pool.In different thread, workers can get existing db connections
* immediately without re-creation operations. The working thread does not maintain db connections, instead of
* maintaining, it just using db resources from DatabaseResource
* @class DatabaseResource databaseresource.h "ZoomPipeline_FuncSvr/database/databaseresource.h"
*/
class DatabaseResource : public QThread
{
Q_OBJECT
......
......@@ -6,6 +6,13 @@ namespace ZPTaskEngine{
m_nExistingThreads = 0;
}
/**
* @brief Add nThreads to the thread pool
*
* @fn zp_pipeline::addThreads
* @param nThreads how many threads you want to add.
* @return int current threads count after add.
*/
int zp_pipeline::addThreads(int nThreads)
{
if (nThreads>=1 && nThreads <=128)
......@@ -31,7 +38,13 @@ namespace ZPTaskEngine{
return m_vec_workingThreads.size();
}
//remove n threads and kill them.nthreads=-1 means kill all.
/**
* @brief remove n threads and kill them.nthreads=-1 means kill all.
*
* @fn zp_pipeline::removeThreads
* @param nThreads how many threads to kill
* @return int the threads count after del
*/
int zp_pipeline::removeThreads(int nThreads)
{
int nsz = m_vec_workingThreads.size();
......@@ -47,8 +60,13 @@ namespace ZPTaskEngine{
return m_vec_workingThreads.size();
}
//Threads call this function to get next task, task will be popped from list.
/**
* @brief Threads call this function to get next task, task will be popped from list.
*
* @fn zp_pipeline::popTask
* @param bValid return whether this task is valid
* @return zp_plTaskBase the top-task in queue
*/
zp_plTaskBase * zp_pipeline::popTask( bool * bValid)
{
*bValid = false;
......@@ -64,7 +82,13 @@ namespace ZPTaskEngine{
return funcres;
}
//Call this function to insert func
/**
* @brief Call this function to insert an task into queue.
* task will be put into the tail of the fifo
* @fn zp_pipeline::pushTask
* @param task the pointer to this task object
* @param bFire if true, will fire an deal-event immediately
*/
void zp_pipeline::pushTask(zp_plTaskBase * task,bool bFire )
{
m_mutex_protect.lock();
......@@ -111,6 +135,13 @@ namespace ZPTaskEngine{
return idle;
}
/**
* @brief this slot will be called when a task is finished,
* in this method, it will check whether the queue is still not empty
* and fire the event to deal with next job.
* @fn zp_pipeline::on_finished_task
* @param task
*/
void zp_pipeline::on_finished_task (zp_plWorkingThread * task)
{
int res = 0;
......
......@@ -9,7 +9,7 @@
#include <QThread>
#include "zp_plworkingthread.h"
#include "zp_pltaskbase.h"
/*!
/**!
The pipe line will process each task item group by group.
quit your task as soon as possible, so that other tasks can get more cpu time.
*/
......@@ -18,6 +18,11 @@ namespace ZPTaskEngine{
class zp_plWorkingThread;
/**
* @brief the task engine class. hold some threads to do fifo-like tasks.
*
* @class zp_pipeline zp_pipeline.h "ZoomPipeline_FuncSvr/pipeline/zp_pipeline.h"
*/
class zp_pipeline : public QObject
{
Q_OBJECT
......
......@@ -11,6 +11,15 @@ namespace ZPTaskEngine{
m_bBusy = false;
}
/**
* @brief This slot mark this zp_plWorkingThread object
* as stopped. when tasks belong to this zp_plWorkingThread has been
* finished, it will quit.
*
* @fn zp_plWorkingThread::setStopMark
* @param obj the zp_plWorkingThread object recieved by signal-slot system.
* this method will omit zp_plWorkingThread objs except for it self.
*/
void zp_plWorkingThread::setStopMark(zp_plWorkingThread * obj)
{
if (obj != this)
......@@ -23,6 +32,13 @@ namespace ZPTaskEngine{
QThread::currentThread()->quit();
}
/**
* @brief Call zp_plTaskBase::popTask to fetch new tasks.
*
* @fn zp_plWorkingThread::FetchNewTask
* @param obj the zp_plWorkingThread object recieved by signal-slot system.
* this method will omit zp_plWorkingThread objs except for it self.
*/
void zp_plWorkingThread::FetchNewTask(zp_plWorkingThread * obj)
{
......
......@@ -6,8 +6,11 @@
namespace ZPTaskEngine{
class zp_pipeline;
//Working thread, reading functions from queue,
//running tasks
/**
* @brief /Working thread, reading functions from queue,
* call the tasks' "run" method, doing actual works.
* @class zp_plWorkingThread zp_plworkingthread.h "ZoomPipeline_FuncSvr/pipeline/zp_plworkingthread.h"
*/
class zp_plWorkingThread : public QObject
{
Q_OBJECT
......
......@@ -135,6 +135,7 @@ namespace SmartLink{
{
//then , Start deal to-server messages
//Server - deal messages
emit evt_Message("Debug:" + m_currentBlock.toHex());
if (m_currentHeader.destin_id==0x00000001)
{
if (this->m_bLoggedIn==false || this->m_bUUIDRecieved==false)
......@@ -229,7 +230,8 @@ namespace SmartLink{
bool st_clientNodeAppLayer::Deal_ToServer_Handshakes()
{
bool res = true;
//qDebug()<<m_currentHeader.data_length<<"\n";
//qDebug()<<this->m_currentBlock.toHex()<<"\n";
if (m_currentHeader.data_length < sizeof (SMARTLINK_MSG_APP::tag_app_layer_header))
return false;
if (m_currentMessageSize < sizeof(SMARTLINK_MSG) - 1 + sizeof (SMARTLINK_MSG_APP::tag_app_layer_header))
......@@ -250,6 +252,7 @@ namespace SmartLink{
return false;
}
//do
qDebug()<<m_current_app_header.header.MsgType<<"\n";
switch (m_current_app_header.header.MsgType)
{
case 0x1000:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册