#ifndef BPCORE_H
#define BPCORE_H

#include <QObject>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QVariant>
#include <QTimer>
#include <QUuid>
#include <Msg.h>
#include <QUdpSocket>
#include <QHostAddress>
#include <json-c/json.h>
#include <stdlib.h>
#include <unistd.h>

//#include "ycapi.h"

#include "dbthread.h"
#include "logthread.h"
#include "dncommthread.h"
#include "userverthread.h"
#include "alarmchannel.h"

class BpCore : public QObject
{
    Q_OBJECT
public:
    explicit BpCore(QObject *parent = 0);
    void db_init();
    void shm_init();
    bool shm_load();
    bool chk_table(QString tbname, QStringList tables);
    void run();
    void checkRemoteCmd(QByteArray data, QDateTime time, QHostAddress remote);
    int mk_ReportCmd(int cno,int pno, unsigned char *cmd);

signals:

public slots:
    void time_out();
    void dbg_log(QString txt);
    void log(QString txt);
    void recsql(QString sql);
    void confsql(QString sql);

private:
    QSqlDatabase db, recdb;
    QTimer *timer;
    DBThread *dbThread;
    LogThread *logThread;
    DNCommThread *dnThread[8];
    UServerThread *uServerThread;
    QString UskyID, UskyIP;
    QString LocIP,GateWay,NetMask,MacAddr;
    quint16 UskyPort;
    int CHour, CMin, TMin;
    int aghour;
    bool timeoutworking;
};

#endif // BPCORE_H
