#include "appcontext.h"
#include <QDir>
#include <QDebug>
#include "defs.h"

AppContext::AppContext(QObject *parent)
    : QObject{parent}
{
    connect(&m_httpServer, &HttpServer::netparseConfigureUpdate, this, [this](const QString &filename){
        m_netParseProcess.restart(filename);
        m_calProcess.restart();
    });
    connect(&m_httpServer, &HttpServer::formulaConfigureUpdate, this, [this](const QString &filename){
        m_netParseProcess.restart();
        m_calProcess.restart(filename);
    });
}

AppContext::~AppContext()
{

}

AppContext  &AppContext::instance()
{
    static AppContext instance;
    return instance;
}

PluginManager &AppContext::pluginManager()
{
    return m_pluginMgr;
}

ProjectManager &AppContext::projectManager()
{
    return m_projectMgr;
}

Network &AppContext::network()
{
    return m_network;
}

SerialPort &AppContext::serialPort()
{
    return m_serialPort;
}

HttpServer &AppContext::httpServer()
{
    return m_httpServer;
}

DataFifo &AppContext::dataFifo()
{
    return m_dataFifo;
}

NetParseProcess &AppContext::netParseProcess()
{
    return m_netParseProcess;
}

CalProcess &AppContext::calProcess()
{
    return m_calProcess;
}

DataDict &AppContext::dataDict()
{
    return m_dataDict;
}

SysState &AppContext::sysState()
{
    return m_sysState;
}

MCUModule &AppContext::mcuModule()
{
    return m_mcuModule;
}
