#ifndef COREOBJECT_H
#define COREOBJECT_H

#include <QObject>
#include <QTimer>
#include <QList>
#include <QDateTime>
#include "HCEHomeCMS.h"
#include "HCEHomeAlarm.h"
#include "HCEHomeStream.h"
#include <QUuid>
#include <QRegExp>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <QFile>
#include <QProcess>
#include "../include/YT_EHOME_shm.h"
#include <QXmlStreamReader>
#include <QStringList>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QVariant>
#include <QDebug>
#include "ttsthreads.h"
#include "wechartthreads.h"

class AlarmEvent {
public:
    explicit AlarmEvent(QString id, QString etime, int sta){
        Device_Code = id;
        Event_Time = etime;
        Event_Status = sta;
    }

    QString Device_Code;
    QString Event_Time;
    int Event_Status;
};

class Alarm_Report {
public:
    explicit Alarm_Report(QString addr, QString time, QString type, QString sql){
        Device_Code = addr;
        Event_Time = time;
        Event_Name = type;
        Sql = sql;
    }
    QString Device_Code;
    QString Event_Time;
    QString Event_Name;
    QString Sql;
};

class Company_Phone {
public:
    explicit Company_Phone(QString companycode, QString phone){
        CompanyCode=companycode;
        Phone=phone;
    }
    QString CompanyCode;
    QString Phone;
};

class CoreObject : public QObject
{
    Q_OBJECT
public:
    explicit CoreObject(QObject *parent = 0);
    ~CoreObject();
    void start();
    bool shm_load();
    void shm_init();
    void AlarmReport(QString addr, QString type, QString time, QString companyCode, quint64 insertid);
    void chkPhoneList();
    QString getCompanyCode(QString addr);

    QStringList sqlList;
    QList<AlarmEvent> alarmList;
    QList<Alarm_Report> reportList;
    QList<Company_Phone> companyphoneList;

signals:
    
public slots:
    void time_out();
    void process_stop();
    void chartlog(quint16 idx, QDateTime t, QString data, bool dirflag);
private:
    QTimer *timer;
    bool isWorking;
    QList<QProcess *> processList;
    QSqlDatabase db;
    ttsThreads *wssThread[8];
//    ttsThreads *spThread[8];
    WechartThreads *wxThreads[8];
    int repcur,wxcur;
    int synchour;
};

#endif // COREOBJECT_H
